diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-05-13 16:16:45 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-05-13 16:16:45 +0200 |
| commit | 110b99563e127abe1439fffb0084400b47eea5b3 (patch) | |
| tree | ded22ce24e5d0545b287817661267de34e9810fd /Makefile | |
| download | libstrvec-c-110b99563e127abe1439fffb0084400b47eea5b3.tar.gz libstrvec-c-110b99563e127abe1439fffb0084400b47eea5b3.zip | |
Prelim push
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0c32d75 --- /dev/null +++ b/Makefile @@ -0,0 +1,59 @@ +PREFIX ?= /usr/local +LIBDIR ?= /lib +INCLDIR ?= /include + +CFLAGS = -I include -I lib/liballoc/include -I lib/libdvec/include +CFLAGS += -Wunused-function -Wunused-variable -Wno-prototype +CFLAGS += -Wconversion -Wsign-compare -Werror + +ifeq "$(DEBUG)" "1" +CFLAGS += -Og -g +else +CFLAGS += -O2 +endif + +ifeq "$(ASSERT_ARGS)" "1" +CFLAGS += -Dlibstrvec_ASSERT_ARGS=1 +endif + +ifeq "$(ASSERT_ALLOC)" "1" +CFLAGS += -Dlibstrvec_ASSERT_ALLOC=1 +endif + +all: build/libstrvec.so build/libstrvec.a build/test + +clean: + rm -rf build + +build: + mkdir build + +lib/liballoc/build/liballoc.a: + make -C lib/liballoc build/liballoc.a + +lib/libdvec/build/libdvec.a: + make -C lib/libdvec build/libdvec.a + +build/libstrvec.a: src/strvec.c include/strvec.h libstrvec.api | build + $(CC) -o build/tmp.o src/strvec.c $(CFLAGS) -r + objcopy --keep-global-symbols=libstrvec.api build/tmp.o build/fixed.o + ar rcs $@ build/fixed.o + +build/libstrvec.so: src/strvec.c include/strvec.h libstrvec.lds | build + $(CC) -o $@ src/strvec.c -fPIC $(CFLAGS) \ + -shared -Wl,-version-script libstrvec.lds + +build/test: src/test.c build/libstrvec.a lib/liballoc/build/liballoc.a + $(CC) -o $@ $^ $(CFLAGS) + +install: + install -m644 include/strvec.h -t "$(DESTDIR)$(PREFIX)$(INCLDIR)" + install -m755 build/libstrvec.so -t "$(DESTDIR)$(PREFIX)$(LIBDIR)" + install -m755 build/libstrvec.a -t "$(DESTDIR)$(PREFIX)$(LIBDIR)" + +uninstall: + rm -f "$(DESTDIR)$(PREFIX)$(INCLDIR)/strvec.h" + rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/libstrvec.so" + rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/libstrvec.a" + +.PHONY: all clean install uninstall |
