From 691898d1298d25a55310145aedf06221edf6a339 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Mon, 19 Aug 2019 08:11:13 -0700 Subject: [PATCH] mdbx-make: fix so/dll-suffix for MacOS. --- Makefile | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index dc41049c..f471a016 100644 --- a/Makefile +++ b/Makefile @@ -45,12 +45,6 @@ NN ?= 25000000 ######################################################################## -HEADERS := mdbx.h -LIBRARIES := libmdbx.a libmdbx.so -TOOLS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk -MANPAGES := mdbx_stat.1 mdbx_copy.1 mdbx_dump.1 mdbx_load.1 -SHELL := /bin/bash - ifdef MSVC UNAME := Windows LCK_IMPL := windows @@ -77,11 +71,25 @@ else *) echo 42;; esac endef + define uname2suffix + case "$(UNAME)" in + Darwin*|Mach*) echo dylib;; + CYGWIN*|MINGW32*|MSYS*|Windows*) echo dll;; + *) echo so;; + esac + endef LCK_IMPL := $(shell $(uname2lck)) TEST_OSAL := $(shell $(uname2osal)) TEST_ITER := $(shell $(uname2titer)) + SO_SUFFIX := $(shell $(uname2suffix)) endif +HEADERS := mdbx.h +LIBRARIES := libmdbx.a libmdbx.$(SO_SUFFIX) +TOOLS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk +MANPAGES := mdbx_stat.1 mdbx_copy.1 mdbx_dump.1 mdbx_load.1 +SHELL := /bin/bash + CORE_SRC := src/lck-$(LCK_IMPL).c $(filter-out $(wildcard src/lck-*.c), $(wildcard src/*.c)) CORE_INC := $(wildcard src/*.h) CORE_OBJ := $(patsubst %.c,%.o,$(CORE_SRC)) @@ -93,10 +101,10 @@ TEST_OBJ := $(patsubst %.cc,%.o,$(TEST_SRC)) all: $(LIBRARIES) $(TOOLS) mdbx_test example -mdbx: libmdbx.a libmdbx.so +mdbx: libmdbx.a libmdbx.$(SO_SUFFIX) -example: mdbx.h tutorial/sample-mdbx.c libmdbx.so - $(CC) $(CFLAGS) -I. tutorial/sample-mdbx.c ./libmdbx.so -o example +example: mdbx.h tutorial/sample-mdbx.c libmdbx.$(SO_SUFFIX) + $(CC) $(CFLAGS) -I. tutorial/sample-mdbx.c ./libmdbx.$(SO_SUFFIX) -o example tools: $(TOOLS) @@ -145,13 +153,13 @@ $(foreach file,$(TEST_SRC),$(eval $(call test-rule,$(file)))) libmdbx.a: $(CORE_OBJ) $(AR) rs $@ $? -libmdbx.so: $(CORE_OBJ) +libmdbx.$(SO_SUFFIX): $(CORE_OBJ) $(CC) $(CFLAGS) -save-temps $^ -pthread -shared $(LDFLAGS) -o $@ mdbx_%: src/tools/mdbx_%.c libmdbx.a $(CC) $(CFLAGS) $^ $(EXE_LDFLAGS) -o $@ -mdbx_test: $(TEST_OBJ) libmdbx.so +mdbx_test: $(TEST_OBJ) libmdbx.$(SO_SUFFIX) $(CXX) $(CXXFLAGS) $(TEST_OBJ) -Wl,-rpath . -L . -l mdbx $(EXE_LDFLAGS) -o $@ ############################################################################### @@ -177,7 +185,7 @@ bench-$(1)_$(2).txt: $(3) $(IOARENA) Makefile endef -$(eval $(call bench-rule,mdbx,$(NN),libmdbx.so)) +$(eval $(call bench-rule,mdbx,$(NN),libmdbx.$(SO_SUFFIX))) $(eval $(call bench-rule,sophia,$(NN))) $(eval $(call bench-rule,leveldb,$(NN)))