From b924fc2f66d46ee10aa3b800a6521d3940919f9f Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Fri, 17 Apr 2020 21:02:35 -0400 Subject: nserver/ -> ./ --- Makefile | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Makefile (limited to 'Makefile') diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..238cbd5 --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +CFLAGS=-g -O2 -Wall -Wextra -Isrc -I/usr/local/include -DNDEBUG $(OPTFLAGS) +LIBS=-ldl $(OPTLIBS) +PREFIX?=/usr/local +CTAGS=`which ectags` + +SOURCES=$(wildcard src/**/*.c src/*.c) +OBJECTS=$(patsubst %.c,%.o,$(SOURCES)) + +TEST_SRC=$(wildcard tests/*_tests.c) +TESTS=$(patsubst %.c,%,$(TEST_SRC)) + +PROGRAMS_SRC=$(wildcard bin/*.c) +PROGRAMS=$(patsubst %.c,%,$(PROGRAMS_SRC)) + +TARGET=build/libnserve.a +SO_TARGET=$(patsubst %.a,%.so,$(TARGET)) + +# The Target Build +all: $(TARGET) $(SO_TARGET) $(PROGRAMS) TAGS tests + +dev: CFLAGS=-g -Wall -Isrc -I/usr/local/include -Wall -Wextra $(OPTFLAGS) +dev: all + +$(TARGET): CFLAGS += -fPIC +$(TARGET): build $(OBJECTS) + ar rcs $@ $(OBJECTS) + ranlib $@ +$(SO_TARGET): $(TARGET) $(OBJECTS) + $(CC) -shared -o $@ $(OBJECTS) + +$(PROGRAMS): LDLIBS += $(TARGET) -lm -L/usr/local/lib -lgdbm + +build: + @mkdir -p build + @mkdir -p bin + +# The Unit Tests +.PHONY: tests +tests: LDLIBS += $(TARGET) -lm -L/usr/local/lib -lgdbm +tests: $(TESTS) + sh ./tests/runtests.sh + +# The Cleaner +clean: + rm -rf TAGS build $(OBJECTS) $(TESTS) $(PROGRAMS) + rm -f tests/tests.log + find . -name "*.gc" -exec rm {} \; + rm -rf `find . -name "*.dSYM" -print` + rm -rf nserver.db + +# The Install +install: all + install -d $(DESTDIR)/$(PREFIX)/lib/ + install $(TARGET) $(DESTDIR)/$(PREFIX)/lib/ + +# Generate TAGS file +TAGS: $(SOURCES) $(TEST_SRC) + find ./ -type f -name '*.h' -or -name '*.c' | $(CTAGS) -e -L - + +# The Checker +check: + @echo Files with potentially dangerous functions. + @egrep '[^_.>a-zA-Z0-9](str(n?cpy|n?cat|xfrm|n?dup|str|pbrk|tok|_)\ + |stpn?cpy|a?sn?printf|byte_)' $(SOURCES) || true -- cgit v1.2.3