mdbx-make: fix so/dll-suffix for MacOS.

This commit is contained in:
Leonid Yuriev 2019-08-19 08:11:13 -07:00
parent 351939dd5d
commit 691898d129

View File

@ -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 ifdef MSVC
UNAME := Windows UNAME := Windows
LCK_IMPL := windows LCK_IMPL := windows
@ -77,11 +71,25 @@ else
*) echo 42;; *) echo 42;;
esac esac
endef endef
define uname2suffix
case "$(UNAME)" in
Darwin*|Mach*) echo dylib;;
CYGWIN*|MINGW32*|MSYS*|Windows*) echo dll;;
*) echo so;;
esac
endef
LCK_IMPL := $(shell $(uname2lck)) LCK_IMPL := $(shell $(uname2lck))
TEST_OSAL := $(shell $(uname2osal)) TEST_OSAL := $(shell $(uname2osal))
TEST_ITER := $(shell $(uname2titer)) TEST_ITER := $(shell $(uname2titer))
SO_SUFFIX := $(shell $(uname2suffix))
endif 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_SRC := src/lck-$(LCK_IMPL).c $(filter-out $(wildcard src/lck-*.c), $(wildcard src/*.c))
CORE_INC := $(wildcard src/*.h) CORE_INC := $(wildcard src/*.h)
CORE_OBJ := $(patsubst %.c,%.o,$(CORE_SRC)) CORE_OBJ := $(patsubst %.c,%.o,$(CORE_SRC))
@ -93,10 +101,10 @@ TEST_OBJ := $(patsubst %.cc,%.o,$(TEST_SRC))
all: $(LIBRARIES) $(TOOLS) mdbx_test example 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 example: mdbx.h tutorial/sample-mdbx.c libmdbx.$(SO_SUFFIX)
$(CC) $(CFLAGS) -I. tutorial/sample-mdbx.c ./libmdbx.so -o example $(CC) $(CFLAGS) -I. tutorial/sample-mdbx.c ./libmdbx.$(SO_SUFFIX) -o example
tools: $(TOOLS) tools: $(TOOLS)
@ -145,13 +153,13 @@ $(foreach file,$(TEST_SRC),$(eval $(call test-rule,$(file))))
libmdbx.a: $(CORE_OBJ) libmdbx.a: $(CORE_OBJ)
$(AR) rs $@ $? $(AR) rs $@ $?
libmdbx.so: $(CORE_OBJ) libmdbx.$(SO_SUFFIX): $(CORE_OBJ)
$(CC) $(CFLAGS) -save-temps $^ -pthread -shared $(LDFLAGS) -o $@ $(CC) $(CFLAGS) -save-temps $^ -pthread -shared $(LDFLAGS) -o $@
mdbx_%: src/tools/mdbx_%.c libmdbx.a mdbx_%: src/tools/mdbx_%.c libmdbx.a
$(CC) $(CFLAGS) $^ $(EXE_LDFLAGS) -o $@ $(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 $@ $(CXX) $(CXXFLAGS) $(TEST_OBJ) -Wl,-rpath . -L . -l mdbx $(EXE_LDFLAGS) -o $@
############################################################################### ###############################################################################
@ -177,7 +185,7 @@ bench-$(1)_$(2).txt: $(3) $(IOARENA) Makefile
endef 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,sophia,$(NN)))
$(eval $(call bench-rule,leveldb,$(NN))) $(eval $(call bench-rule,leveldb,$(NN)))