From 5d1049297515c1a6182100a921dca23065f2bd6e Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Tue, 11 Jul 2023 12:10:58 +0200 Subject: [PATCH] support Linux, Darwin and Windows (as rest) also put the shared lib into build --- Makefile | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 5caed60..992d00c 100644 --- a/Makefile +++ b/Makefile @@ -24,12 +24,25 @@ TEST_MURMUR_SRCS := test/test_murmur.c TEST_MURMUR_OBJS := $(TEST_MURMUR_SRCS:%=$(BUILD_DIR)/%.o) TEST_MURMUR_DEPS := $(TEST_MURMUR_OBJS:.o=.d) -CPPFLAGS ?= $(INC_FLAGS) -MMD -MP -g -O0 - -lib: $(BUILD_DIR)/src/libhamt.dylib - -$(BUILD_DIR)/src/libhamt.dylib: $(LIB_OBJS) +CPPFLAGS ?= $(INC_FLAGS) -MMD -MP -g -O3 -fPIC + +TGT := $(shell uname) +ifeq ($(TGT),Linux) +lib: $(BUILD_DIR)/libhamt.so +else +ifeq ($(TGT),Darwin) +lib: $(BUILD_DIR)/libhamt.dylib +else +lib: $(BUILD_DIR)/libhamt.dll +endif +endif + +$(BUILD_DIR)/libhamt.dylib: $(LIB_OBJS) $(CC) $(LIB_OBJS) -dynamiclib -o $@ +$(BUILD_DIR)/libhamt.so: $(LIB_OBJS) + $(CC) $(LIB_OBJS) -shared -o $@ +$(BUILD_DIR)/libhamt.dll: $(LIB_OBJS) + $(CC) $(LIB_OBJS) -shared -o $@ test: $(BUILD_DIR)/test/test_hamt $(BUILD_DIR)/test/test_murmur $(BUILD_DIR)/test/test_murmur