Makefile (1476B)
1PREFIX ?= /usr/local 2LIBDIR ?= /lib 3INCLDIR ?= /include 4 5CFLAGS = -I include -I lib/liballoc/include 6CFLAGS += -Wunused-function -Wunused-variable -Wno-prototype 7CFLAGS += -Wconversion -Wsign-compare -Werror 8 9ifeq "$(DEBUG)" "1" 10CFLAGS += -Og -g 11else 12CFLAGS += -O2 13endif 14 15ifeq "$(ASSERT_ARGS)" "1" 16CFLAGS += -DLIBDVEC_ASSERT_ARGS=1 17endif 18 19ifeq "$(ASSERT_ALLOC)" "1" 20CFLAGS += -DLIBDVEC_ASSERT_ALLOC=1 21endif 22 23all: build/libdvec.so build/libdvec.a build/test 24 25clean: 26 rm -rf build 27 28cleanall: clean 29 make -C lib/liballoc cleanall 30 31build: 32 mkdir build 33 34lib/liballoc/build/liballoc.a: 35 make -C lib/liballoc build/liballoc.a 36 37build/libdvec.a: src/dvec.c include/dvec.h libdvec.api | build 38 $(CC) -o build/tmp.o src/dvec.c $(CFLAGS) -r 39 objcopy --keep-global-symbols=libdvec.api build/tmp.o build/fixed.o 40 ar rcs $@ build/fixed.o 41 42build/libdvec.so: src/dvec.c include/dvec.h libdvec.lds | build 43 $(CC) -o $@ src/dvec.c -fPIC $(CFLAGS) \ 44 -shared -Wl,-version-script libdvec.lds 45 46build/test: src/test.c build/libdvec.a lib/liballoc/build/liballoc.a 47 $(CC) -o $@ $^ $(CFLAGS) 48 49install: 50 install -m644 include/dvec.h -t "$(DESTDIR)$(PREFIX)$(INCLDIR)" 51 install -m755 build/libdvec.so -t "$(DESTDIR)$(PREFIX)$(LIBDIR)" 52 install -m755 build/libdvec.a -t "$(DESTDIR)$(PREFIX)$(LIBDIR)" 53 54uninstall: 55 rm -f "$(DESTDIR)$(PREFIX)$(INCLDIR)/dvec.h" 56 rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/libdvec.so" 57 rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/libdvec.a" 58 59.PHONY: all clean cleanall install uninstall