diff --git a/config.mk b/config.mk index db4d098..f16d87e 100644 --- a/config.mk +++ b/config.mk @@ -23,8 +23,13 @@ endif endif endif -ifneq ($(firstword $(filter %-mingw32 %-cygwin,$(DUMPMACHINE))),) +ifeq ($(firstword $(filter %-mingw32 %-cygwin,$(DUMPMACHINE))),) + DLL_LDFLAGS = -fPIC -shared + DLL_SUFFIX := .so +else + DLL_LDFLAGS = -shared -Wl,--out-implib,$@.a EXE_SUFFIX := .exe + DLL_SUFFIX := .dll ifneq ($(firstword $(filter i686-%,$(DUMPMACHINE))),) XLDFLAGS += -Wl,--large-address-aware endif diff --git a/libhashset/Makefile b/libhashset/Makefile index 48f56d4..6106539 100644 --- a/libhashset/Makefile +++ b/libhashset/Makefile @@ -10,6 +10,7 @@ ALL_PATH := $(SRC_PATH) $(OBJ_PATH) $(LIB_PATH) SRC_FILE := $(wildcard $(SRC_PATH)/*.c) OBJ_FILE := $(addprefix $(OBJ_PATH)/,$(patsubst %.c,%.o,$(notdir $(SRC_FILE)))) LIB_FILE := $(LIB_PATH)/libhashset-1.a +DLL_FILE := $(LIB_PATH)/libhashset-1$(DLL_SUFFIX) .PHONY: all build clean test @@ -17,10 +18,13 @@ all: clean build test: build -build: $(ALL_PATH) $(LIB_FILE) +build: $(ALL_PATH) $(LIB_FILE) $(DLL_FILE) $(LIB_FILE): $(OBJ_FILE) - $(AR) rcs $@ $(OBJ_FILE) + $(AR) rcs $@ $^ + +$(DLL_FILE): $(SRC_FILE) + $(CC) $(CFLAGS) $(DLL_LDFLAGS) -o $@ $^ $(OBJ_FILE): $(CC) $(CFLAGS) -c $(SRC_PATH)/$(patsubst %.o,%.c,$(notdir $@)) -o $@ @@ -29,4 +33,4 @@ $(ALL_PATH): mkdir -p $@ clean: - rm -vf $(LIB_FILE) $(OBJ_PATH)/*.o + rm -vf $(LIB_FILE) $(DLL_FILE) $(DLL_FILE).a $(OBJ_PATH)/*.o