mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-29 08:58:48 +08:00
mdbx-build: add 'make dist' target.
Change-Id: I72c2ff2f90e9da4664bf542761fe445bb713a67a
This commit is contained in:
parent
e7095e9ada
commit
3ec081c187
2
.gitignore
vendored
2
.gitignore
vendored
@ -31,3 +31,5 @@ tmp.db-lck
|
|||||||
valgrind.*
|
valgrind.*
|
||||||
src/elements/version.c
|
src/elements/version.c
|
||||||
src/elements/config.h
|
src/elements/config.h
|
||||||
|
dist/
|
||||||
|
*.tar*
|
||||||
|
346
GNUmakefile
346
GNUmakefile
@ -8,90 +8,55 @@
|
|||||||
# in README and source code if you do. There may be other macros of interest.
|
# in README and source code if you do. There may be other macros of interest.
|
||||||
|
|
||||||
# install sandbox
|
# install sandbox
|
||||||
SANDBOX ?=
|
SANDBOX ?=
|
||||||
|
|
||||||
# install prefixes (inside sandbox)
|
# install prefixes (inside sandbox)
|
||||||
prefix ?= /usr/local
|
prefix ?= /usr/local
|
||||||
mandir ?= $(prefix)/man
|
mandir ?= $(prefix)/man
|
||||||
|
|
||||||
# lib/bin suffix for multiarch/biarch, e.g. '.x86_64'
|
# lib/bin suffix for multiarch/biarch, e.g. '.x86_64'
|
||||||
suffix ?=
|
suffix ?=
|
||||||
|
|
||||||
CC ?= gcc
|
|
||||||
CXX ?= g++
|
|
||||||
LD ?= ld
|
|
||||||
MDBX_OPTIONS ?= -D_GNU_SOURCE=1 -DNDEBUG=1 -DLIBMDBX_EXPORTS=1
|
|
||||||
CFLAGS ?= -O2 -g3 -Wall -Werror -Wextra -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread
|
|
||||||
|
|
||||||
|
CC ?= gcc
|
||||||
|
CXX ?= g++
|
||||||
|
LD ?= ld
|
||||||
|
MDBX_OPTIONS ?= -D_GNU_SOURCE=1 -DNDEBUG=1
|
||||||
|
CFLAGS ?= -O2 -g3 -Wall -Werror -Wextra -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread
|
||||||
CXXFLAGS = -std=c++11 $(filter-out -std=gnu11,$(CFLAGS))
|
CXXFLAGS = -std=c++11 $(filter-out -std=gnu11,$(CFLAGS))
|
||||||
TESTDB ?= $(shell [ -d /dev/shm ] && echo /dev/shm || echo /tmp)/mdbx-test.db
|
|
||||||
TESTLOG ?= $(shell [ -d /dev/shm ] && echo /dev/shm || echo /tmp)/mdbx-test.log
|
|
||||||
|
|
||||||
# LY: '--no-as-needed,-lrt' for ability to built with modern glibc, but then run with the old
|
# LY: '--no-as-needed,-lrt' for ability to built with modern glibc, but then run with the old
|
||||||
LDFLAGS ?= $(shell $(LD) --help 2>/dev/null | grep -q -- --gc-sections && echo '-Wl,--gc-sections,-z,relro,-O1')$(shell $(LD) --help 2>/dev/null | grep -q -- -dead_strip && echo '-Wl,-dead_strip')
|
LDFLAGS ?= $(shell $(LD) --help 2>/dev/null | grep -q -- --gc-sections && echo '-Wl,--gc-sections,-z,relro,-O1')$(shell $(LD) --help 2>/dev/null | grep -q -- -dead_strip && echo '-Wl,-dead_strip')
|
||||||
EXE_LDFLAGS ?= -pthread
|
EXE_LDFLAGS ?= -pthread
|
||||||
|
|
||||||
# LY: just for benchmarking
|
################################################################################
|
||||||
IOARENA ?= $(shell \
|
|
||||||
(test -x ../ioarena/@BUILD/src/ioarena && echo ../ioarena/@BUILD/src/ioarena) || \
|
|
||||||
(test -x ../../@BUILD/src/ioarena && echo ../../@BUILD/src/ioarena) || \
|
|
||||||
(test -x ../../src/ioarena && echo ../../src/ioarena) || which ioarena)
|
|
||||||
NN ?= 25000000
|
|
||||||
|
|
||||||
########################################################################
|
UNAME := $(shell uname -s 2>/dev/null || echo Unknown)
|
||||||
|
define uname2sosuffix
|
||||||
|
case "$(UNAME)" in
|
||||||
|
Darwin*|Mach*) echo dylib;;
|
||||||
|
CYGWIN*|MINGW*|MSYS*|Windows*) echo dll;;
|
||||||
|
*) echo so;;
|
||||||
|
esac
|
||||||
|
endef
|
||||||
|
SO_SUFFIX := $(shell $(uname2sosuffix))
|
||||||
|
|
||||||
ifdef MSVC
|
HEADERS := mdbx.h
|
||||||
UNAME := Windows
|
LIBRARIES := libmdbx.a libmdbx.$(SO_SUFFIX)
|
||||||
TEST_OSAL := windows
|
TOOLS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk
|
||||||
TEST_ITER := 42
|
MANPAGES := mdbx_stat.1 mdbx_copy.1 mdbx_dump.1 mdbx_load.1
|
||||||
else
|
SHELL := /bin/bash
|
||||||
UNAME := $(shell uname -s 2>/dev/null || echo Unknown)
|
|
||||||
define uname2osal
|
|
||||||
case "$(UNAME)" in
|
|
||||||
CYGWIN*|MINGW*|MSYS*|Windows*) echo windows;;
|
|
||||||
*) echo unix;;
|
|
||||||
esac
|
|
||||||
endef
|
|
||||||
define uname2titer
|
|
||||||
case "$(UNAME)" in
|
|
||||||
Darwin*|Mach*) echo 3;;
|
|
||||||
*) echo 42;;
|
|
||||||
esac
|
|
||||||
endef
|
|
||||||
define uname2suffix
|
|
||||||
case "$(UNAME)" in
|
|
||||||
Darwin*|Mach*) echo dylib;;
|
|
||||||
CYGWIN*|MINGW*|MSYS*|Windows*) echo dll;;
|
|
||||||
*) echo so;;
|
|
||||||
esac
|
|
||||||
endef
|
|
||||||
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
|
|
||||||
|
|
||||||
ALLOY_DEPS := $(wildcard src/elements/*)
|
|
||||||
TEST_SRC := test/osal-$(TEST_OSAL).cc $(filter-out $(wildcard test/osal-*.cc), $(wildcard test/*.cc))
|
|
||||||
TEST_INC := $(wildcard test/*.h)
|
|
||||||
TEST_OBJ := $(patsubst %.cc,%.o,$(TEST_SRC))
|
|
||||||
|
|
||||||
.PHONY: mdbx all install clean check coverage
|
.PHONY: mdbx all install clean check coverage
|
||||||
|
|
||||||
all: $(LIBRARIES) $(TOOLS) mdbx_test example
|
all: $(LIBRARIES) $(TOOLS)
|
||||||
|
|
||||||
mdbx: libmdbx.a libmdbx.$(SO_SUFFIX)
|
mdbx: libmdbx.a libmdbx.$(SO_SUFFIX)
|
||||||
|
|
||||||
example: mdbx.h tutorial/sample-mdbx.c libmdbx.$(SO_SUFFIX)
|
|
||||||
$(CC) $(CFLAGS) -I. tutorial/sample-mdbx.c ./libmdbx.$(SO_SUFFIX) -o example
|
|
||||||
|
|
||||||
tools: $(TOOLS)
|
tools: $(TOOLS)
|
||||||
|
|
||||||
|
strip: all
|
||||||
|
strip libmdbx.$(SO_SUFFIX) $(TOOLS)
|
||||||
|
|
||||||
install: $(LIBRARIES) $(TOOLS) $(HEADERS)
|
install: $(LIBRARIES) $(TOOLS) $(HEADERS)
|
||||||
mkdir -p $(SANDBOX)$(prefix)/bin$(suffix) \
|
mkdir -p $(SANDBOX)$(prefix)/bin$(suffix) \
|
||||||
&& cp -t $(SANDBOX)$(prefix)/bin$(suffix) $(TOOLS) && \
|
&& cp -t $(SANDBOX)$(prefix)/bin$(suffix) $(TOOLS) && \
|
||||||
@ -105,22 +70,97 @@ install: $(LIBRARIES) $(TOOLS) $(HEADERS)
|
|||||||
clean:
|
clean:
|
||||||
rm -rf $(TOOLS) mdbx_test @* *.[ao] *.[ls]o *~ tmp.db/* *.gcov *.log *.err src/*.o test/*.o
|
rm -rf $(TOOLS) mdbx_test @* *.[ao] *.[ls]o *~ tmp.db/* *.gcov *.log *.err src/*.o test/*.o
|
||||||
|
|
||||||
check: all
|
libmdbx.a: mdbx-static.o
|
||||||
|
$(AR) rs $@ $?
|
||||||
|
|
||||||
|
libmdbx.$(SO_SUFFIX): mdbx-dylib.o
|
||||||
|
$(CC) $(CFLAGS) $^ -pthread -shared $(LDFLAGS) -o $@
|
||||||
|
|
||||||
|
#> dist-cutoff-begin
|
||||||
|
ifeq ($(wildcard mdbx.c),mdbx.c)
|
||||||
|
#< dist-cutoff-end
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Amalgamated source code, i.e. distributed after `make dists`
|
||||||
|
|
||||||
|
mdbx-config.h: mdbx-config.h.in mdbx.c $(lastword $(MAKEFILE_LIST))
|
||||||
|
(echo '#define MDBX_BUILD_TIMESTAMP "$(shell date +%Y-%m-%dT%H:%M:%S%z)"' \
|
||||||
|
&& echo '#define MDBX_BUILD_OPTIONS_STRING "$(MDBX_OPTIONS)"' \
|
||||||
|
&& echo '#define MDBX_BUILD_FLAGS "$(CFLAGS) $(LDFLAGS)"' \
|
||||||
|
&& echo '#define MDBX_BUILD_COMPILER "$(shell set -o pipefail; $(CC) --version | head -1 || echo 'Please use GCC or CLANG compatible compiler')"' \
|
||||||
|
&& echo '#define MDBX_BUILD_TARGET "$(shell set -o pipefail; LC_ALL=C $(CC) -v 2>&1 | grep -i '^Target:' | cut -d ' ' -f 2- || echo 'Please use GCC or CLANG compatible compiler')"' \
|
||||||
|
) > $@ || rm -f $@
|
||||||
|
|
||||||
|
mdbx-dylib.o: mdbx-config.h mdbx.c $(lastword $(MAKEFILE_LIST))
|
||||||
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) -DLIBMDBX_EXPORTS=1 -c mdbx.c -o $@
|
||||||
|
|
||||||
|
mdbx-static.o: mdbx-config.h mdbx.c $(lastword $(MAKEFILE_LIST))
|
||||||
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) -ULIBMDBX_EXPORTS -c mdbx.c -o $@
|
||||||
|
|
||||||
|
mdbx_%: mdbx_%.c libmdbx.a
|
||||||
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) $^ $(EXE_LDFLAGS) -o $@
|
||||||
|
|
||||||
|
#> dist-cutoff-begin
|
||||||
|
else
|
||||||
|
################################################################################
|
||||||
|
# Plain (non-amalgamated) sources
|
||||||
|
|
||||||
|
define uname2osal
|
||||||
|
case "$(UNAME)" in
|
||||||
|
CYGWIN*|MINGW*|MSYS*|Windows*) echo windows;;
|
||||||
|
*) echo unix;;
|
||||||
|
esac
|
||||||
|
endef
|
||||||
|
define uname2titer
|
||||||
|
case "$(UNAME)" in
|
||||||
|
Darwin*|Mach*) echo 3;;
|
||||||
|
*) echo 12;;
|
||||||
|
esac
|
||||||
|
endef
|
||||||
|
TEST_OSAL := $(shell $(uname2osal))
|
||||||
|
TEST_ITER := $(shell $(uname2titer))
|
||||||
|
TESTDB ?= $(shell [ -d /dev/shm ] && echo /dev/shm || echo /tmp)/mdbx-test.db
|
||||||
|
TESTLOG ?= $(shell [ -d /dev/shm ] && echo /dev/shm || echo /tmp)/mdbx-test.log
|
||||||
|
TEST_SRC := test/osal-$(TEST_OSAL).cc $(filter-out $(wildcard test/osal-*.cc), $(wildcard test/*.cc))
|
||||||
|
TEST_INC := $(wildcard test/*.h)
|
||||||
|
TEST_OBJ := $(patsubst %.cc,%.o,$(TEST_SRC))
|
||||||
|
|
||||||
|
check: all example mdbx_test
|
||||||
rm -f $(TESTDB) $(TESTLOG) && (set -o pipefail; ./mdbx_test --repeat=$(TEST_ITER) --pathname=$(TESTDB) --dont-cleanup-after basic | tee -a $(TESTLOG) | tail -n 42) \
|
rm -f $(TESTDB) $(TESTLOG) && (set -o pipefail; ./mdbx_test --repeat=$(TEST_ITER) --pathname=$(TESTDB) --dont-cleanup-after basic | tee -a $(TESTLOG) | tail -n 42) \
|
||||||
&& ./mdbx_chk -vvn $(TESTDB) && ./mdbx_chk -vvn $(TESTDB)-copy
|
&& ./mdbx_chk -vvn $(TESTDB) && ./mdbx_chk -vvn $(TESTDB)-copy
|
||||||
|
|
||||||
check-singleprocess: all
|
example: mdbx.h tutorial/sample-mdbx.c libmdbx.$(SO_SUFFIX)
|
||||||
|
$(CC) $(CFLAGS) -I. tutorial/sample-mdbx.c ./libmdbx.$(SO_SUFFIX) -o example
|
||||||
|
|
||||||
|
check-singleprocess: all
|
||||||
rm -f $(TESTDB) $(TESTLOG) && (set -o pipefail; \
|
rm -f $(TESTDB) $(TESTLOG) && (set -o pipefail; \
|
||||||
./mdbx_test --repeat=4 --pathname=$(TESTDB) --dont-cleanup-after --hill && \
|
./mdbx_test --repeat=4 --pathname=$(TESTDB) --dont-cleanup-after --hill && \
|
||||||
./mdbx_test --repeat=2 --pathname=$(TESTDB) --dont-cleanup-before --dont-cleanup-after --copy \
|
./mdbx_test --repeat=2 --pathname=$(TESTDB) --dont-cleanup-before --dont-cleanup-after --copy \
|
||||||
| tee -a $(TESTLOG) | tail -n 42) \
|
| tee -a $(TESTLOG) | tail -n 42) \
|
||||||
&& ./mdbx_chk -vvn $(TESTDB) && ./mdbx_chk -vvn $(TESTDB)-copy
|
&& ./mdbx_chk -vvn $(TESTDB) && ./mdbx_chk -vvn $(TESTDB)-copy
|
||||||
|
|
||||||
check-fault: all
|
check-fault: all
|
||||||
rm -f $(TESTDB) $(TESTLOG) && (set -o pipefail; ./mdbx_test --pathname=$(TESTDB) --inject-writefault=42 --dump-config --dont-cleanup-after basic | tee -a $(TESTLOG) | tail -n 42) \
|
rm -f $(TESTDB) $(TESTLOG) && (set -o pipefail; ./mdbx_test --pathname=$(TESTDB) --inject-writefault=42 --dump-config --dont-cleanup-after basic | tee -a $(TESTLOG) | tail -n 42) \
|
||||||
; ./mdbx_chk -vvnw $(TESTDB) && ([ ! -e $(TESTDB)-copy ] || ./mdbx_chk -vvn $(TESTDB)-copy)
|
; ./mdbx_chk -vvnw $(TESTDB) && ([ ! -e $(TESTDB)-copy ] || ./mdbx_chk -vvn $(TESTDB)-copy)
|
||||||
|
|
||||||
|
define test-rule
|
||||||
|
$(patsubst %.cc,%.o,$(1)): $(1) $(TEST_INC) mdbx.h $(lastword $(MAKEFILE_LIST))
|
||||||
|
$(CXX) $(CXXFLAGS) $(MDBX_OPTIONS) -c $(1) -o $$@
|
||||||
|
|
||||||
|
endef
|
||||||
|
$(foreach file,$(TEST_SRC),$(eval $(call test-rule,$(file))))
|
||||||
|
|
||||||
|
mdbx_%: src/tools/mdbx_%.c libmdbx.a
|
||||||
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) $^ $(EXE_LDFLAGS) -o $@
|
||||||
|
|
||||||
|
mdbx_test: $(TEST_OBJ) libmdbx.$(SO_SUFFIX)
|
||||||
|
$(CXX) $(CXXFLAGS) $(TEST_OBJ) -Wl,-rpath . -L . -l mdbx $(EXE_LDFLAGS) -o $@
|
||||||
|
|
||||||
|
ALLOY_DEPS = $(wildcard src/elements/*)
|
||||||
MDBX_VERSION_GIT = ${shell set -o pipefail; git describe --tags | sed -n 's|^v*\([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\)\(.*\)|\1|p' || echo 'Please fetch tags and/or install latest git version'}
|
MDBX_VERSION_GIT = ${shell set -o pipefail; git describe --tags | sed -n 's|^v*\([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\)\(.*\)|\1|p' || echo 'Please fetch tags and/or install latest git version'}
|
||||||
|
MDBX_VERSION_SUFFIX = $(shell set -o pipefail; git describe --tags --long --dirty=-dirty | tr -c -s '[a-zA-Z0-9]\n' _ || echo 'Please fetch tags and/or install latest git version')
|
||||||
|
MDBX_BUILD_SOURCERY = $(shell set -o pipefail; $(MAKE) -s src/elements/version.c && (openssl dgst -r -sha256 src/elements/version.c || sha256sum src/elements/version.c || shasum -a 256 src/elements/version.c) 2>/dev/null | cut -d ' ' -f 1 || echo 'Please install openssl or sha256sum or shasum')_$(MDBX_VERSION_SUFFIX)
|
||||||
|
|
||||||
src/elements/version.c: src/elements/version.c.in $(lastword $(MAKEFILE_LIST)) .git/HEAD .git/index .git/refs/tags
|
src/elements/version.c: src/elements/version.c.in $(lastword $(MAKEFILE_LIST)) .git/HEAD .git/index .git/refs/tags
|
||||||
sed \
|
sed \
|
||||||
-e "s|@MDBX_GIT_TIMESTAMP@|$(shell git show --no-patch --format=%cI HEAD || echo 'Please install latest get version')|" \
|
-e "s|@MDBX_GIT_TIMESTAMP@|$(shell git show --no-patch --format=%cI HEAD || echo 'Please install latest get version')|" \
|
||||||
@ -139,32 +179,114 @@ src/elements/config.h: src/elements/version.c $(lastword $(MAKEFILE_LIST))
|
|||||||
&& echo '#define MDBX_BUILD_FLAGS "$(CFLAGS) $(LDFLAGS)"' \
|
&& echo '#define MDBX_BUILD_FLAGS "$(CFLAGS) $(LDFLAGS)"' \
|
||||||
&& echo '#define MDBX_BUILD_COMPILER "$(shell set -o pipefail; $(CC) --version | head -1 || echo 'Please use GCC or CLANG compatible compiler')"' \
|
&& echo '#define MDBX_BUILD_COMPILER "$(shell set -o pipefail; $(CC) --version | head -1 || echo 'Please use GCC or CLANG compatible compiler')"' \
|
||||||
&& echo '#define MDBX_BUILD_TARGET "$(shell set -o pipefail; LC_ALL=C $(CC) -v 2>&1 | grep -i '^Target:' | cut -d ' ' -f 2- || echo 'Please use GCC or CLANG compatible compiler')"' \
|
&& echo '#define MDBX_BUILD_TARGET "$(shell set -o pipefail; LC_ALL=C $(CC) -v 2>&1 | grep -i '^Target:' | cut -d ' ' -f 2- || echo 'Please use GCC or CLANG compatible compiler')"' \
|
||||||
&& echo '#define MDBX_BUILD_SOURCERY $(shell set -o pipefail; ((openssl dgst -r -sha256 src/elements/version.c.in || sha256sum src/elements/version.c || shasum -a 256 src/elements/version.c) 2>/dev/null | cut -d ' ' -f 1 && echo -n `git describe --tags --long --dirty=-dirty`) | tr -c -s '[a-zA-Z0-9]' _ || echo 'Please install openssl or sha256sum or shasum')' \
|
&& echo '#define MDBX_BUILD_SOURCERY $(MDBX_BUILD_SOURCERY)' \
|
||||||
) > $@ || rm -f $@
|
) > $@ || rm -f $@
|
||||||
|
|
||||||
libmdbx.o: src/elements/config.h src/elements/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST))
|
mdbx-dylib.o: src/elements/config.h src/elements/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST))
|
||||||
$(CC) $(CFLAGS) $(MDBX_OPTIONS) -c src/alloy.c -o $@
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) -DLIBMDBX_EXPORTS=1 -c src/alloy.c -o $@
|
||||||
|
|
||||||
define test-rule
|
mdbx-static.o: src/elements/config.h src/elements/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST))
|
||||||
$(patsubst %.cc,%.o,$(1)): $(1) $(TEST_INC) mdbx.h $(lastword $(MAKEFILE_LIST))
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) -ULIBMDBX_EXPORTS -c src/alloy.c -o $@
|
||||||
$(CXX) $(CXXFLAGS) $(MDBX_OPTIONS) -c $(1) -o $$@
|
|
||||||
|
.PHONY: dist
|
||||||
|
dist: lidmbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz $(lastword $(MAKEFILE_LIST))
|
||||||
|
|
||||||
|
lidmbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz: dist/mdbx.c dist/mdbx-config.h.in dist/mdbx.h \
|
||||||
|
dist/mdbx_chk.c dist/mdbx_copy.c dist/mdbx_dump.c dist/mdbx_load.c dist/mdbx_stat.c \
|
||||||
|
dist/GNUmakefile $(lastword $(MAKEFILE_LIST))
|
||||||
|
tar -c -a -f $@ --owner=0 --group=0 -C dist mdbx.c mdbx-config.h.in mdbx.h \
|
||||||
|
mdbx_chk.c mdbx_copy.c mdbx_dump.c mdbx_load.c mdbx_stat.c GNUmakefile \
|
||||||
|
&& rm dist/@tmp-shared_internals.inc
|
||||||
|
|
||||||
|
dist/mdbx.h: mdbx.h src/elements/version.c $(lastword $(MAKEFILE_LIST))
|
||||||
|
mkdir -p dist && cp $< $@
|
||||||
|
|
||||||
|
dist/GNUmakefile: GNUmakefile
|
||||||
|
mkdir -p dist && sed -e '/^#> dist-cutoff-begin/,/^#< dist-cutoff-end/d' $< > $@
|
||||||
|
|
||||||
|
dist/@tmp-shared_internals.inc: src/elements/version.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST))
|
||||||
|
mkdir -p dist && sed \
|
||||||
|
-e 's|#include "config.h"|@INCLUDE "mdbx-config.h"\n#define MDBX_ALLOY 1\n#define MDBX_BUILD_SOURCERY $(MDBX_BUILD_SOURCERY)|' \
|
||||||
|
-e 's|#include "../../mdbx.h"|@INCLUDE "mdbx.h"|' \
|
||||||
|
-e '/#include "defs.h"/r src/elements/defs.h' \
|
||||||
|
-e '/#include "osal.h"/r src/elements/osal.h' \
|
||||||
|
src/elements/internals.h > $@
|
||||||
|
|
||||||
|
dist/mdbx.c: dist/@tmp-shared_internals.inc $(lastword $(MAKEFILE_LIST))
|
||||||
|
mkdir -p dist && (cat dist/@tmp-shared_internals.inc \
|
||||||
|
&& cat src/elements/core.c src/elements/osal.c src/elements/version.c \
|
||||||
|
&& echo '#if defined(_WIN32) || defined(_WIN64)' \
|
||||||
|
&& cat src/elements/lck-windows.c && echo '#else /* LCK-implementation */' \
|
||||||
|
&& cat src/elements/lck-posix.c && echo '#endif /* LCK-implementation */' \
|
||||||
|
) | grep -v -e '#include "' -e '#pragma once' | sed 's|@INCLUDE|#include|' > $@
|
||||||
|
|
||||||
|
define dist-tool-rule
|
||||||
|
dist/mdbx_$(1).c: src/tools/mdbx_$(1).c src/tools/wingetopt.h src/tools/wingetopt.c dist/mdbx.c $(lastword $(MAKEFILE_LIST))
|
||||||
|
mkdir -p dist && sed \
|
||||||
|
-e '/#include "..\/elements\/internals.h"/r dist/@tmp-shared_internals.inc' \
|
||||||
|
-e '/#include "wingetopt.h"/r r/src/tools/wingetopt.c' \
|
||||||
|
-e '/#include "wingetopt.h"/r r/src/tools/wingetopt.h' \
|
||||||
|
src/tools/mdbx_$(1).c \
|
||||||
|
| grep -v -e '#include "' -e '#pragma once' -e '#define MDBX_ALLOY' \
|
||||||
|
| sed 's|@INCLUDE|#include|' > $$@
|
||||||
|
|
||||||
endef
|
endef
|
||||||
$(foreach file,$(TEST_SRC),$(eval $(call test-rule,$(file))))
|
$(foreach file,chk copy dump load stat,$(eval $(call dist-tool-rule,$(file))))
|
||||||
|
|
||||||
libmdbx.a: libmdbx.o
|
dist/mdbx-config.h.in: src/elements/config.h.in $(lastword $(MAKEFILE_LIST))
|
||||||
$(AR) rs $@ $?
|
mkdir -p dist && grep -v MDBX_BUILD_SOURCERY $< > $@
|
||||||
|
|
||||||
libmdbx.$(SO_SUFFIX): libmdbx.o
|
endif
|
||||||
$(CC) $(CFLAGS) $^ -pthread -shared $(LDFLAGS) -o $@
|
|
||||||
|
|
||||||
mdbx_%: src/tools/mdbx_%.c libmdbx.a
|
################################################################################
|
||||||
$(CC) $(CFLAGS) $(MDBX_OPTIONS) $^ $(EXE_LDFLAGS) -o $@
|
# Cross-compilation simple test
|
||||||
|
|
||||||
mdbx_test: $(TEST_OBJ) libmdbx.$(SO_SUFFIX)
|
CROSS_LIST = mips-linux-gnu-gcc \
|
||||||
$(CXX) $(CXXFLAGS) $(TEST_OBJ) -Wl,-rpath . -L . -l mdbx $(EXE_LDFLAGS) -o $@
|
powerpc64-linux-gnu-gcc powerpc-linux-gnu-gcc \
|
||||||
|
arm-linux-gnueabihf-gcc aarch64-linux-gnu-gcc
|
||||||
|
|
||||||
###############################################################################
|
# hppa-linux-gnu-gcc - don't supported by current qemu release
|
||||||
|
# s390x-linux-gnu-gcc - qemu troubles (hang/abort)
|
||||||
|
# sh4-linux-gnu-gcc - qemu troubles (pread syscall, etc)
|
||||||
|
# mips64-linux-gnuabi64-gcc - qemu troubles (pread syscall, etc)
|
||||||
|
# sparc64-linux-gnu-gcc - qemu troubles (fcntl for F_SETLK/F_GETLK)
|
||||||
|
# alpha-linux-gnu-gcc - qemu (or gcc) troubles (coredump)
|
||||||
|
|
||||||
|
CROSS_LIST_NOQEMU = hppa-linux-gnu-gcc s390x-linux-gnu-gcc \
|
||||||
|
sh4-linux-gnu-gcc mips64-linux-gnuabi64-gcc \
|
||||||
|
sparc64-linux-gnu-gcc alpha-linux-gnu-gcc
|
||||||
|
|
||||||
|
cross-gcc:
|
||||||
|
@echo "CORRESPONDING CROSS-COMPILERs ARE REQUIRED."
|
||||||
|
@echo "FOR INSTANCE: apt install g++-aarch64-linux-gnu g++-alpha-linux-gnu g++-arm-linux-gnueabihf g++-hppa-linux-gnu g++-mips-linux-gnu g++-mips64-linux-gnuabi64 g++-powerpc-linux-gnu g++-powerpc64-linux-gnu g++-s390x-linux-gnu g++-sh4-linux-gnu g++-sparc64-linux-gnu"
|
||||||
|
@for CC in $(CROSS_LIST_NOQEMU) $(CROSS_LIST); do \
|
||||||
|
echo "===================== $$CC"; \
|
||||||
|
$(MAKE) clean && CC=$$CC CXX=$$(echo $$CC | sed 's/-gcc/-g++/') EXE_LDFLAGS=-static $(MAKE) all || exit $$?; \
|
||||||
|
done
|
||||||
|
|
||||||
|
# Unfortunately qemu don't provide robust support for futexes.
|
||||||
|
# Therefore it is impossible to run full multi-process tests.
|
||||||
|
cross-qemu:
|
||||||
|
@echo "CORRESPONDING CROSS-COMPILERs AND QEMUs ARE REQUIRED."
|
||||||
|
@echo "FOR INSTANCE: "
|
||||||
|
@echo " 1) apt install g++-aarch64-linux-gnu g++-alpha-linux-gnu g++-arm-linux-gnueabihf g++-hppa-linux-gnu g++-mips-linux-gnu g++-mips64-linux-gnuabi64 g++-powerpc-linux-gnu g++-powerpc64-linux-gnu g++-s390x-linux-gnu g++-sh4-linux-gnu g++-sparc64-linux-gnu"
|
||||||
|
@echo " 2) apt install binfmt-support qemu-user-static qemu-user qemu-system-arm qemu-system-mips qemu-system-misc qemu-system-ppc qemu-system-sparc"
|
||||||
|
@for CC in $(CROSS_LIST); do \
|
||||||
|
echo "===================== $$CC + qemu"; \
|
||||||
|
$(MAKE) clean && \
|
||||||
|
CC=$$CC CXX=$$(echo $$CC | sed 's/-gcc/-g++/') EXE_LDFLAGS=-static XCFLAGS="-DMDBX_SAFE4QEMU $(XCFLAGS)" \
|
||||||
|
$(MAKE) check-singleprocess || exit $$?; \
|
||||||
|
done
|
||||||
|
|
||||||
|
#< dist-cutoff-end
|
||||||
|
################################################################################
|
||||||
|
# Benchmarking by ioarena
|
||||||
|
|
||||||
|
IOARENA ?= $(shell \
|
||||||
|
(test -x ../ioarena/@BUILD/src/ioarena && echo ../ioarena/@BUILD/src/ioarena) || \
|
||||||
|
(test -x ../../@BUILD/src/ioarena && echo ../../@BUILD/src/ioarena) || \
|
||||||
|
(test -x ../../src/ioarena && echo ../../src/ioarena) || which ioarena)
|
||||||
|
NN ?= 25000000
|
||||||
|
|
||||||
ifneq ($(wildcard $(IOARENA)),)
|
ifneq ($(wildcard $(IOARENA)),)
|
||||||
|
|
||||||
@ -212,61 +334,3 @@ bench-debug: bench-debug_10.txt
|
|||||||
bench-quartet: bench-mdbx_$(NN).txt bench-lmdb_$(NN).txt bench-rocksdb_$(NN).txt bench-wiredtiger_$(NN).txt
|
bench-quartet: bench-mdbx_$(NN).txt bench-lmdb_$(NN).txt bench-rocksdb_$(NN).txt bench-wiredtiger_$(NN).txt
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
ci-rule = ( CC=$$(which $1); if [ -n "$$CC" ]; then \
|
|
||||||
echo -n "probe by $2 ($$(readlink -f $$(which $$CC))): " && \
|
|
||||||
$(MAKE) clean >$1.log 2>$1.err && \
|
|
||||||
$(MAKE) CC=$$(readlink -f $$CC) XCFLAGS="-UNDEBUG -DMDBX_DEBUG=2 -DLIBMDBX_EXPORTS=1" check 1>$1.log 2>$1.err && echo "OK" \
|
|
||||||
|| ( echo "FAILED"; cat $1.err >&2; exit 1 ); \
|
|
||||||
else echo "no $2 ($1) for probe"; fi; )
|
|
||||||
ci:
|
|
||||||
@if [ "$$(readlink -f $$(which $(CC)))" != "$$(readlink -f $$(which gcc || echo /bin/false))" -a \
|
|
||||||
"$$(readlink -f $$(which $(CC)))" != "$$(readlink -f $$(which clang || echo /bin/false))" -a \
|
|
||||||
"$$(readlink -f $$(which $(CC)))" != "$$(readlink -f $$(which icc || echo /bin/false))" ]; then \
|
|
||||||
$(call ci-rule,$(CC),default C compiler); \
|
|
||||||
fi
|
|
||||||
@$(call ci-rule,gcc,GCC)
|
|
||||||
@$(call ci-rule,clang,clang LLVM)
|
|
||||||
@$(call ci-rule,icc,Intel C)
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
|
|
||||||
CROSS_LIST = mips-linux-gnu-gcc \
|
|
||||||
powerpc64-linux-gnu-gcc powerpc-linux-gnu-gcc \
|
|
||||||
arm-linux-gnueabihf-gcc aarch64-linux-gnu-gcc
|
|
||||||
|
|
||||||
# hppa-linux-gnu-gcc - don't supported by current qemu release
|
|
||||||
# s390x-linux-gnu-gcc - qemu troubles (hang/abort)
|
|
||||||
# sh4-linux-gnu-gcc - qemu troubles (pread syscall, etc)
|
|
||||||
# mips64-linux-gnuabi64-gcc - qemu troubles (pread syscall, etc)
|
|
||||||
# sparc64-linux-gnu-gcc - qemu troubles (fcntl for F_SETLK/F_GETLK)
|
|
||||||
# alpha-linux-gnu-gcc - qemu (or gcc) troubles (coredump)
|
|
||||||
|
|
||||||
CROSS_LIST_NOQEMU = hppa-linux-gnu-gcc s390x-linux-gnu-gcc \
|
|
||||||
sh4-linux-gnu-gcc mips64-linux-gnuabi64-gcc \
|
|
||||||
sparc64-linux-gnu-gcc alpha-linux-gnu-gcc
|
|
||||||
|
|
||||||
cross-gcc:
|
|
||||||
@echo "CORRESPONDING CROSS-COMPILERs ARE REQUIRED."
|
|
||||||
@echo "FOR INSTANCE: apt install g++-aarch64-linux-gnu g++-alpha-linux-gnu g++-arm-linux-gnueabihf g++-hppa-linux-gnu g++-mips-linux-gnu g++-mips64-linux-gnuabi64 g++-powerpc-linux-gnu g++-powerpc64-linux-gnu g++-s390x-linux-gnu g++-sh4-linux-gnu g++-sparc64-linux-gnu"
|
|
||||||
@for CC in $(CROSS_LIST_NOQEMU) $(CROSS_LIST); do \
|
|
||||||
echo "===================== $$CC"; \
|
|
||||||
$(MAKE) clean && CC=$$CC CXX=$$(echo $$CC | sed 's/-gcc/-g++/') EXE_LDFLAGS=-static $(MAKE) all || exit $$?; \
|
|
||||||
done
|
|
||||||
|
|
||||||
#
|
|
||||||
# Unfortunately qemu don't provide robust support for futexes.
|
|
||||||
# Therefore it is impossible to run full multi-process tests.
|
|
||||||
cross-qemu:
|
|
||||||
@echo "CORRESPONDING CROSS-COMPILERs AND QEMUs ARE REQUIRED."
|
|
||||||
@echo "FOR INSTANCE: "
|
|
||||||
@echo " 1) apt install g++-aarch64-linux-gnu g++-alpha-linux-gnu g++-arm-linux-gnueabihf g++-hppa-linux-gnu g++-mips-linux-gnu g++-mips64-linux-gnuabi64 g++-powerpc-linux-gnu g++-powerpc64-linux-gnu g++-s390x-linux-gnu g++-sh4-linux-gnu g++-sparc64-linux-gnu"
|
|
||||||
@echo " 2) apt install binfmt-support qemu-user-static qemu-user qemu-system-arm qemu-system-mips qemu-system-misc qemu-system-ppc qemu-system-sparc"
|
|
||||||
@for CC in $(CROSS_LIST); do \
|
|
||||||
echo "===================== $$CC + qemu"; \
|
|
||||||
$(MAKE) clean && \
|
|
||||||
CC=$$CC CXX=$$(echo $$CC | sed 's/-gcc/-g++/') EXE_LDFLAGS=-static XCFLAGS="-DMDBX_SAFE4QEMU $(XCFLAGS)" \
|
|
||||||
$(MAKE) check-singleprocess || exit $$?; \
|
|
||||||
done
|
|
||||||
|
2
mdbx.h
2
mdbx.h
@ -187,12 +187,14 @@ typedef pthread_t mdbx_tid_t;
|
|||||||
#define MDBX_VERSION_MAJOR 0
|
#define MDBX_VERSION_MAJOR 0
|
||||||
#define MDBX_VERSION_MINOR 3
|
#define MDBX_VERSION_MINOR 3
|
||||||
|
|
||||||
|
#ifndef LIBMDBX_API
|
||||||
#if defined(LIBMDBX_EXPORTS)
|
#if defined(LIBMDBX_EXPORTS)
|
||||||
#define LIBMDBX_API __dll_export
|
#define LIBMDBX_API __dll_export
|
||||||
#elif defined(LIBMDBX_IMPORTS)
|
#elif defined(LIBMDBX_IMPORTS)
|
||||||
#define LIBMDBX_API __dll_import
|
#define LIBMDBX_API __dll_import
|
||||||
#else
|
#else
|
||||||
#define LIBMDBX_API
|
#define LIBMDBX_API
|
||||||
|
#endif
|
||||||
#endif /* LIBMDBX_API */
|
#endif /* LIBMDBX_API */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
|
||||||
|
|
||||||
#include "./internals.h"
|
#include "internals.h"
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Internal inlines */
|
/* Internal inlines */
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
#endif /* _MSC_VER (warnings) */
|
#endif /* _MSC_VER (warnings) */
|
||||||
|
|
||||||
#include "../../mdbx.h"
|
#include "../../mdbx.h"
|
||||||
#include "./defs.h"
|
#include "defs.h"
|
||||||
|
|
||||||
#if defined(__GNUC__) && !__GNUC_PREREQ(4,2)
|
#if defined(__GNUC__) && !__GNUC_PREREQ(4,2)
|
||||||
/* Actualy libmdbx was not tested with compilers older than GCC from RHEL6.
|
/* Actualy libmdbx was not tested with compilers older than GCC from RHEL6.
|
||||||
@ -140,7 +140,7 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif /* -Walignment-reduction-ignored */
|
#endif /* -Walignment-reduction-ignored */
|
||||||
|
|
||||||
#include "./osal.h"
|
#include "osal.h"
|
||||||
|
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* <http://www.OpenLDAP.org/license.html>.
|
* <http://www.OpenLDAP.org/license.html>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "./internals.h"
|
#include "internals.h"
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* global constructor/destructor */
|
/* global constructor/destructor */
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* <http://www.OpenLDAP.org/license.html>.
|
* <http://www.OpenLDAP.org/license.html>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "./internals.h"
|
#include "internals.h"
|
||||||
|
|
||||||
/* PREAMBLE FOR WINDOWS:
|
/* PREAMBLE FOR WINDOWS:
|
||||||
*
|
*
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* <http://www.OpenLDAP.org/license.html>.
|
* <http://www.OpenLDAP.org/license.html>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "./internals.h"
|
#include "internals.h"
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user