summaryrefslogtreecommitdiffstats
path: root/lib/libhmap/Makefile
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2024-10-02 03:59:21 +0200
committerLouis Burda <quent.burda@gmail.com>2024-10-02 03:59:21 +0200
commit36c8d24c07ef3c6658f397fd156396f83b35ac27 (patch)
tree1b3293264dca677a8d8e1ca44061aa7af191f839 /lib/libhmap/Makefile
parenteff49100e4fca394a23973abd5001a4fde15d6e8 (diff)
downloadtabular-master.tar.gz
tabular-master.zip
Vendor subgit modulesHEADmaster
Diffstat (limited to 'lib/libhmap/Makefile')
-rw-r--r--lib/libhmap/Makefile59
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/libhmap/Makefile b/lib/libhmap/Makefile
new file mode 100644
index 0000000..3adad36
--- /dev/null
+++ b/lib/libhmap/Makefile
@@ -0,0 +1,59 @@
+PREFIX ?= /usr/local
+INCLDIR ?= /include
+LIBDIR ?= /lib
+
+CFLAGS += -I include -I lib/liballoc/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 += -DLIBHMAP_ASSERT_ARGS=1
+endif
+
+ifeq "$(ASSERT_ALLOC)" "1"
+CFLAGS += -DLIBHMAP_ASSERT_ALLLOC=1
+endif
+
+all: build/libhmap.so build/libhmap.a build/test
+
+clean:
+ rm -rf build
+
+cleanall: clean
+ make -C lib/liballoc cleanall
+
+build:
+ mkdir build
+
+lib/liballoc/build/liballoc.a:
+ make -C lib/liballoc build/liballoc.a
+
+build/libhmap.a: src/hmap.c include/hmap.h libhmap.api | build
+ $(CC) -o build/tmp.o src/hmap.c $(CFLAGS) -r
+ objcopy --keep-global-symbols=libhmap.api build/tmp.o build/fixed.o
+ $(AR) rcs $@ build/fixed.o
+
+build/libhmap.so: src/hmap.c include/hmap.h libhmap.lds | build
+ $(CC) -o $@ src/hmap.c -fPIC $(CFLAGS) -shared \
+ -Wl,-version-script libhmap.lds
+
+build/test: src/test.c build/libhmap.a lib/liballoc/build/liballoc.a | build
+ $(CC) -o $@ $^ -I include -I lib/liballoc/include -g
+
+install:
+ install -m 644 include/hmap.h -t "$(DESTDIR)$(PREFIX)$(INCLDIR)"
+ install -m 755 build/libhmap.a -t "$(DESTDIR)$(PREFIX)$(LIBDIR)"
+ install -m 755 build/libhmap.so -t "$(DESTDIR)$(PREFIX)$(LIBDIR)"
+
+uninstall:
+ rm -f "$(DESTDIR)$(PREFIX)$(INCLDIR)/hmap.h"
+ rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/libhmap.a"
+ rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/libhmap.so"
+
+.PHONY: all clean cleanall install uninstall