2020-09-20 23:07:33 +08:00
|
|
|
# This makefile is for GNU Make 3.80 or above, and nowadays provided
|
2019-08-31 22:13:02 +08:00
|
|
|
# just for compatibility and preservation of traditions.
|
2015-01-07 22:55:19 +08:00
|
|
|
#
|
2020-09-20 23:07:33 +08:00
|
|
|
# Please use CMake in case of any difficulties or
|
|
|
|
# problems with this old-school's magic.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# Preprocessor macros (for MDBX_OPTIONS) of interest.
|
|
|
|
#
|
2019-08-31 22:13:02 +08:00
|
|
|
# Note that the defaults should already be correct for most platforms;
|
|
|
|
# you should not need to change any of these. Read their descriptions
|
2020-09-20 23:07:33 +08:00
|
|
|
# in README and source code (see src/options.h) if you do.
|
|
|
|
# There may be other macros of interest.
|
|
|
|
#
|
|
|
|
|
2019-11-05 09:43:44 +08:00
|
|
|
SHELL := env bash
|
2016-06-01 06:58:23 +08:00
|
|
|
|
|
|
|
# install sandbox
|
2020-04-06 07:24:16 +08:00
|
|
|
DESTDIR ?=
|
2016-06-01 06:58:23 +08:00
|
|
|
|
|
|
|
# install prefixes (inside sandbox)
|
2019-09-10 07:19:35 +08:00
|
|
|
prefix ?= /usr/local
|
|
|
|
mandir ?= $(prefix)/man
|
2015-12-01 23:45:18 +08:00
|
|
|
|
2016-06-01 06:58:23 +08:00
|
|
|
# lib/bin suffix for multiarch/biarch, e.g. '.x86_64'
|
2019-09-10 07:19:35 +08:00
|
|
|
suffix ?=
|
2018-03-14 20:04:07 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
CC ?= gcc
|
2020-04-11 07:37:50 +08:00
|
|
|
CFLAGS_EXTRA ?=
|
2019-09-10 07:19:35 +08:00
|
|
|
LD ?= ld
|
2019-10-06 19:59:53 +08:00
|
|
|
MDBX_OPTIONS ?= -DNDEBUG=1
|
2020-04-11 07:37:50 +08:00
|
|
|
CFLAGS ?= -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread -Wno-error=attributes $(CFLAGS_EXTRA)
|
2019-11-05 09:43:44 +08:00
|
|
|
# -Wno-tautological-compare
|
2020-09-13 23:06:14 +08:00
|
|
|
CXX ?= g++
|
2020-09-20 23:07:33 +08:00
|
|
|
# choicing C++ standard with deferred simple variable expansion trick
|
|
|
|
CXXSTD ?= $(eval CXXSTD := $$(shell PROBE=$$$$([ -f mdbx.c++ ] && echo mdbx.c++ || echo src/mdbx.c++); for std in gnu++20 c++20 gnu++2a c++2a gnu++17 c++17 gnu++14 c++14 gnu+11 c++11; do $(CXX) -std=$$$${std} -c $$$${PROBE} -o /dev/null 2>/dev/null >/dev/null && echo "-std=$$$${std}" && exit; done))$(CXXSTD)
|
|
|
|
CXXFLAGS = $(CXXSTD) $(filter-out -std=gnu11,$(CFLAGS))
|
2015-01-07 22:55:19 +08:00
|
|
|
|
2019-11-12 16:47:23 +08:00
|
|
|
# HINT: Try append '--no-as-needed,-lrt' for ability to built with modern glibc, but then run with the old.
|
2020-05-11 05:21:45 +08:00
|
|
|
LIBS ?= $(shell uname | grep -qi SunOS && echo "-lkstat") $(shell uname | grep -qi -e Darwin -e OpenBSD || echo "-lrt") $(shell uname | grep -qi Windows && echo "-lntdll")
|
2019-11-09 20:15:25 +08:00
|
|
|
|
2019-11-12 16:47:23 +08:00
|
|
|
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')
|
2019-08-13 07:07:10 +08:00
|
|
|
EXE_LDFLAGS ?= -pthread
|
2016-06-01 06:58:23 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
################################################################################
|
2015-01-07 22:55:19 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
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))
|
2019-08-19 23:11:13 +08:00
|
|
|
|
2020-08-23 01:19:46 +08:00
|
|
|
HEADERS := mdbx.h mdbx.h++
|
2019-09-10 07:19:35 +08:00
|
|
|
LIBRARIES := libmdbx.a libmdbx.$(SO_SUFFIX)
|
|
|
|
TOOLS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk
|
2019-09-10 21:08:21 +08:00
|
|
|
MANPAGES := mdbx_stat.1 mdbx_copy.1 mdbx_dump.1 mdbx_load.1 mdbx_chk.1
|
2017-05-24 18:59:50 +08:00
|
|
|
|
2020-07-12 03:27:29 +08:00
|
|
|
.PHONY: mdbx all install clean
|
2015-10-13 20:46:59 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
all: $(LIBRARIES) $(TOOLS)
|
2015-10-13 20:46:59 +08:00
|
|
|
|
2019-08-19 23:11:13 +08:00
|
|
|
mdbx: libmdbx.a libmdbx.$(SO_SUFFIX)
|
2015-10-13 20:46:59 +08:00
|
|
|
|
2016-06-01 06:58:23 +08:00
|
|
|
tools: $(TOOLS)
|
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
strip: all
|
|
|
|
strip libmdbx.$(SO_SUFFIX) $(TOOLS)
|
|
|
|
|
2015-01-07 22:55:19 +08:00
|
|
|
clean:
|
2019-09-10 19:32:17 +08:00
|
|
|
rm -rf $(TOOLS) mdbx_test @* *.[ao] *.[ls]o *~ tmp.db/* \
|
2019-09-18 09:00:16 +08:00
|
|
|
*.gcov *.log *.err src/*.o test/*.o mdbx_example dist \
|
2020-04-15 22:09:37 +08:00
|
|
|
config.h src/config.h src/version.c *.tar*
|
2015-10-21 05:04:35 +08:00
|
|
|
|
2020-08-23 01:19:46 +08:00
|
|
|
libmdbx.a: mdbx-static.o mdbx++-static.o
|
2019-09-10 07:19:35 +08:00
|
|
|
$(AR) rs $@ $?
|
|
|
|
|
2020-08-23 01:19:46 +08:00
|
|
|
libmdbx.$(SO_SUFFIX): mdbx-dylib.o mdbx++-dylib.o
|
|
|
|
$(CXX) $(CXXFLAGS) $^ -pthread -shared $(LDFLAGS) $(LIBS) -o $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
|
|
|
#> dist-cutoff-begin
|
|
|
|
ifeq ($(wildcard mdbx.c),mdbx.c)
|
|
|
|
#< dist-cutoff-end
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Amalgamated source code, i.e. distributed after `make dists`
|
2019-09-11 01:00:54 +08:00
|
|
|
MAN_SRCDIR := man1/
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2019-09-10 19:32:17 +08:00
|
|
|
config.h: mdbx.c $(lastword $(MAKEFILE_LIST))
|
2019-09-10 07:19:35 +08:00
|
|
|
(echo '#define MDBX_BUILD_TIMESTAMP "$(shell date +%Y-%m-%dT%H:%M:%S%z)"' \
|
2020-09-20 20:47:03 +08:00
|
|
|
&& echo '#define MDBX_BUILD_FLAGS "$(CXXSTD) $(CFLAGS) $(LDFLAGS) $(LIBS)"' \
|
2020-06-18 00:17:38 +08:00
|
|
|
&& echo '#define MDBX_BUILD_COMPILER "$(shell (LC_ALL=C $(CC) --version || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \
|
|
|
|
&& echo '#define MDBX_BUILD_TARGET "$(shell set -o pipefail; (LC_ALL=C $(CC) -v 2>&1 | grep -i '^Target:' | cut -d ' ' -f 2- || (LC_ALL=C $(CC) --version | grep -qi e2k && echo E2K) || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \
|
2019-09-10 19:32:17 +08:00
|
|
|
) > $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2020-08-23 01:19:46 +08:00
|
|
|
mdbx-dylib.o: config.h mdbx.c mdbx.h $(lastword $(MAKEFILE_LIST))
|
2019-09-10 19:32:17 +08:00
|
|
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -DLIBMDBX_EXPORTS=1 -c mdbx.c -o $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2020-08-23 01:19:46 +08:00
|
|
|
mdbx-static.o: config.h mdbx.c mdbx.h $(lastword $(MAKEFILE_LIST))
|
2019-09-10 19:32:17 +08:00
|
|
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c mdbx.c -o $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2020-08-23 01:19:46 +08:00
|
|
|
mdbx++-dylib.o: config.h mdbx.c++ mdbx.h mdbx.h++ $(lastword $(MAKEFILE_LIST))
|
|
|
|
$(CXX) $(CXXFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -DLIBMDBX_EXPORTS=1 -c mdbx.c++ -o $@
|
|
|
|
|
|
|
|
mdbx++-static.o: config.h mdbx.c++ mdbx.h mdbx.h++ $(lastword $(MAKEFILE_LIST))
|
|
|
|
$(CXX) $(CXXFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c mdbx.c++ -o $@
|
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
mdbx_%: mdbx_%.c libmdbx.a
|
2019-11-12 16:47:23 +08:00
|
|
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $(EXE_LDFLAGS) $(LIBS) -o $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
|
|
|
#> dist-cutoff-begin
|
|
|
|
else
|
|
|
|
################################################################################
|
2019-09-10 19:32:17 +08:00
|
|
|
# Plain (non-amalgamated) sources with test
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2020-07-12 03:27:29 +08:00
|
|
|
.PHONY: test dist check doxygen reformat
|
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
define uname2osal
|
|
|
|
case "$(UNAME)" in
|
|
|
|
CYGWIN*|MINGW*|MSYS*|Windows*) echo windows;;
|
|
|
|
*) echo unix;;
|
|
|
|
esac
|
|
|
|
endef
|
2019-09-10 19:32:17 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
define uname2titer
|
|
|
|
case "$(UNAME)" in
|
2019-10-11 06:00:40 +08:00
|
|
|
Darwin*|Mach*) echo 2;;
|
2019-09-10 07:19:35 +08:00
|
|
|
*) echo 12;;
|
|
|
|
esac
|
|
|
|
endef
|
2019-09-10 19:32:17 +08:00
|
|
|
|
2020-06-13 08:07:15 +08:00
|
|
|
DIST_EXTRA := LICENSE README.md CMakeLists.txt GNUmakefile Makefile ChangeLog.md VERSION config.h.in ntdll.def \
|
2020-04-15 22:09:37 +08:00
|
|
|
$(addprefix man1/, $(MANPAGES)) cmake/compiler.cmake cmake/profile.cmake cmake/utils.cmake
|
2020-08-23 01:19:46 +08:00
|
|
|
DIST_SRC := mdbx.h mdbx.h++ mdbx.c mdbx.c++ $(addsuffix .c, $(TOOLS))
|
2019-09-11 01:00:54 +08:00
|
|
|
|
2019-09-10 19:32:17 +08:00
|
|
|
TEST_DB ?= $(shell [ -d /dev/shm ] && echo /dev/shm || echo /tmp)/mdbx-test.db
|
2020-05-01 05:52:56 +08:00
|
|
|
TEST_LOG ?= $(shell [ -d /dev/shm ] && echo /dev/shm || echo /tmp)/mdbx-test.log.gz
|
2019-09-10 07:19:35 +08:00
|
|
|
TEST_OSAL := $(shell $(uname2osal))
|
|
|
|
TEST_ITER := $(shell $(uname2titer))
|
|
|
|
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))
|
2020-04-04 22:39:06 +08:00
|
|
|
TAR ?= $(shell which gnu-tar || echo tar)
|
2020-06-04 22:13:42 +08:00
|
|
|
ZIP ?= $(shell which zip || echo "echo 'Please install zip'")
|
2020-05-05 23:52:32 +08:00
|
|
|
CLANG_FORMAT ?= $(shell (which clang-format-12 || which clang-format-11 || which clang-format-10 || which clang-format) 2>/dev/null)
|
2020-05-02 02:20:17 +08:00
|
|
|
|
|
|
|
reformat:
|
|
|
|
@if [ -n "$(CLANG_FORMAT)" ]; then \
|
|
|
|
git ls-files | grep -E '\.(c|cxx|cc|cpp|h|hxx|hpp)(\.in)?$$' | xargs -r $(CLANG_FORMAT) -i --style=file; \
|
|
|
|
else \
|
|
|
|
echo "clang-format version 8..12 not found for 'reformat'"; \
|
|
|
|
fi
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2019-09-11 03:41:53 +08:00
|
|
|
MAN_SRCDIR := src/man1/
|
2020-04-15 22:09:37 +08:00
|
|
|
ALLOY_DEPS := $(wildcard src/*)
|
2020-09-20 20:47:47 +08:00
|
|
|
MDBX_GIT_VERSION = $(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')
|
2020-06-13 02:01:41 +08:00
|
|
|
MDBX_GIT_REVISION = $(shell git rev-list --count HEAD ^`git tag --sort=-version:refname | sed -n '/^\(v[0-9]\+\.[0-9]\+\.[0-9]\+\)*/p;q'`)
|
2019-09-10 19:32:17 +08:00
|
|
|
MDBX_GIT_TIMESTAMP = $(shell git show --no-patch --format=%cI HEAD || echo 'Please install latest get version')
|
|
|
|
MDBX_GIT_DESCRIBE = $(shell git describe --tags --long --dirty=-dirty || echo 'Please fetch tags and/or install latest git version')
|
|
|
|
MDBX_VERSION_SUFFIX = $(shell set -o pipefail; echo -n '$(MDBX_GIT_DESCRIBE)' | tr -c -s '[a-zA-Z0-9]' _)
|
2020-09-20 20:47:47 +08:00
|
|
|
MDBX_BUILD_SOURCERY = $(shell set -o pipefail; $(MAKE) CXXSTD= -s src/version.c && (openssl dgst -r -sha256 src/version.c || sha256sum src/version.c || shasum -a 256 src/version.c) 2>/dev/null | cut -d ' ' -f 1 || echo 'Please install openssl or sha256sum or shasum')_$(MDBX_VERSION_SUFFIX)
|
2020-06-04 22:13:42 +08:00
|
|
|
MDBX_DIST_DIR = libmdbx-$(MDBX_VERSION_SUFFIX)
|
2019-09-10 19:32:17 +08:00
|
|
|
|
2020-09-22 05:16:26 +08:00
|
|
|
# Extra options mdbx_test utility
|
|
|
|
MDBX_TEST_EXTRA ?=
|
|
|
|
|
2020-05-02 02:15:04 +08:00
|
|
|
check: test dist
|
2019-11-13 20:22:02 +08:00
|
|
|
|
2020-05-02 02:15:04 +08:00
|
|
|
test: build-test
|
2019-10-11 06:00:40 +08:00
|
|
|
rm -f $(TEST_DB) $(TEST_LOG) && (set -o pipefail; \
|
2020-09-22 05:16:26 +08:00
|
|
|
(./mdbx_test --table=+data.integer --keygen.split=29 --datalen.min=min --datalen.max=max --progress --console=no --repeat=$(TEST_ITER) --pathname=$(TEST_DB) --dont-cleanup-after $(MDBX_TEST_EXTRA) basic && \
|
|
|
|
./mdbx_test --mode=-writemap,-nosync-safe,-lifo --progress --console=no --repeat=12 --pathname=$(TEST_DB) --dont-cleanup-after $(MDBX_TEST_EXTRA) basic) \
|
2020-05-01 05:52:56 +08:00
|
|
|
| tee >(gzip --stdout > $(TEST_LOG)) | tail -n 42) \
|
2019-09-10 19:32:17 +08:00
|
|
|
&& ./mdbx_chk -vvn $(TEST_DB) && ./mdbx_chk -vvn $(TEST_DB)-copy
|
2015-01-07 22:55:19 +08:00
|
|
|
|
2019-11-13 20:22:02 +08:00
|
|
|
test-singleprocess: all mdbx_test
|
2019-09-10 19:32:17 +08:00
|
|
|
rm -f $(TEST_DB) $(TEST_LOG) && (set -o pipefail; \
|
2020-09-22 05:16:26 +08:00
|
|
|
(./mdbx_test --table=+data.integer --keygen.split=29 --datalen.min=min --datalen.max=max --progress --console=no --repeat=42 --pathname=$(TEST_DB) --dont-cleanup-after $(MDBX_TEST_EXTRA) --hill && \
|
2019-10-11 06:00:40 +08:00
|
|
|
./mdbx_test --progress --console=no --repeat=2 --pathname=$(TEST_DB) --dont-cleanup-before --dont-cleanup-after --copy && \
|
2020-09-22 05:16:26 +08:00
|
|
|
./mdbx_test --mode=-writemap,-nosync-safe,-lifo --progress --console=no --repeat=42 --pathname=$(TEST_DB) --dont-cleanup-after $(MDBX_TEST_EXTRA) --nested) \
|
2020-05-01 05:52:56 +08:00
|
|
|
| tee >(gzip --stdout > $(TEST_LOG)) | tail -n 42) \
|
2019-09-10 19:32:17 +08:00
|
|
|
&& ./mdbx_chk -vvn $(TEST_DB) && ./mdbx_chk -vvn $(TEST_DB)-copy
|
2018-03-22 03:25:46 +08:00
|
|
|
|
2019-11-13 20:22:02 +08:00
|
|
|
test-fault: all mdbx_test
|
2020-09-22 05:16:26 +08:00
|
|
|
rm -f $(TEST_DB) $(TEST_LOG) && (set -o pipefail; ./mdbx_test --progress --console=no --pathname=$(TEST_DB) --inject-writefault=42 --dump-config --dont-cleanup-after $(MDBX_TEST_EXTRA) basic \
|
2020-05-01 05:52:56 +08:00
|
|
|
| tee >(gzip --stdout > $(TEST_LOG)) | tail -n 42) \
|
2019-09-10 19:32:17 +08:00
|
|
|
; ./mdbx_chk -vvnw $(TEST_DB) && ([ ! -e $(TEST_DB)-copy ] || ./mdbx_chk -vvn $(TEST_DB)-copy)
|
2018-03-19 22:51:27 +08:00
|
|
|
|
2019-10-11 03:11:28 +08:00
|
|
|
VALGRIND=valgrind --trace-children=yes --log-file=valgrind-%p.log --leak-check=full --track-origins=yes --error-exitcode=42 --suppressions=test/valgrind_suppress.txt
|
2020-05-04 00:34:47 +08:00
|
|
|
memcheck test-valgrind:
|
2020-09-20 20:47:47 +08:00
|
|
|
$(MAKE) CXXSTD= clean && $(MAKE) CXXSTD=$(CXXSTD) CFLAGS_EXTRA="-Ofast -DMDBX_USE_VALGRIND" build-test && \
|
2020-05-04 00:34:47 +08:00
|
|
|
rm -f valgrind-*.log $(TEST_DB) $(TEST_LOG) && (set -o pipefail; ( \
|
2020-09-22 05:16:26 +08:00
|
|
|
$(VALGRIND) ./mdbx_test --table=+data.integer --keygen.split=29 --datalen.min=min --datalen.max=max --progress --console=no --repeat=2 --pathname=$(TEST_DB) --dont-cleanup-after $(MDBX_TEST_EXTRA) basic && \
|
2019-10-11 06:00:40 +08:00
|
|
|
$(VALGRIND) ./mdbx_test --progress --console=no --pathname=$(TEST_DB) --dont-cleanup-before --dont-cleanup-after --copy && \
|
2020-09-22 05:16:26 +08:00
|
|
|
$(VALGRIND) ./mdbx_test --mode=-writemap,-nosync-safe,-lifo --progress --console=no --repeat=4 --pathname=$(TEST_DB) --dont-cleanup-after $(MDBX_TEST_EXTRA) basic && \
|
2020-05-04 00:34:47 +08:00
|
|
|
$(VALGRIND) ./mdbx_chk -vvn $(TEST_DB) && \
|
|
|
|
$(VALGRIND) ./mdbx_chk -vvn $(TEST_DB)-copy \
|
|
|
|
) | tee >(gzip --stdout > $(TEST_LOG)) | tail -n 42)
|
2019-10-11 03:11:28 +08:00
|
|
|
|
2020-05-04 01:12:09 +08:00
|
|
|
gcc-analyzer:
|
|
|
|
@echo "NOTE: There a lot of false-positive warnings at 2020-05-01 by pre-release GCC-10 (20200328, Red Hat 10.0.1-0.11)"
|
2020-09-20 20:47:47 +08:00
|
|
|
$(MAKE) CXXSTD=$(CXXSTD) --always-make CFLAGS_EXTRA="-Og -fanalyzer -Wno-error" build-test
|
2020-05-04 01:12:09 +08:00
|
|
|
|
|
|
|
test-ubsan:
|
2020-09-20 20:47:47 +08:00
|
|
|
$(MAKE) CXXSTD= clean && $(MAKE) CXXSTD=$(CXXSTD) CFLAGS_EXTRA="-Ofast -fsanitize=undefined -fsanitize-undefined-trap-on-error" check
|
2020-05-04 01:12:09 +08:00
|
|
|
|
|
|
|
test-asan:
|
2020-09-20 20:47:47 +08:00
|
|
|
$(MAKE) CXXSTD= clean && $(MAKE) CXXSTD=$(CXXSTD) CFLAGS_EXTRA="-Os -fsanitize=address" check
|
2020-05-04 01:12:09 +08:00
|
|
|
|
|
|
|
test-leak:
|
2020-09-20 20:47:47 +08:00
|
|
|
$(MAKE) CXXSTD= clean && $(MAKE) CXXSTD=$(CXXSTD) CFLAGS_EXTRA="-fsanitize=leak" check
|
2020-05-04 01:12:09 +08:00
|
|
|
|
|
|
|
mdbx_example: mdbx.h example/example-mdbx.c libmdbx.$(SO_SUFFIX)
|
|
|
|
$(CC) $(CFLAGS) -I. example/example-mdbx.c ./libmdbx.$(SO_SUFFIX) -o $@
|
|
|
|
|
|
|
|
build-test: all mdbx_example mdbx_test
|
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
define test-rule
|
|
|
|
$(patsubst %.cc,%.o,$(1)): $(1) $(TEST_INC) mdbx.h $(lastword $(MAKEFILE_LIST))
|
2020-09-20 23:07:33 +08:00
|
|
|
$$(CXX) $$(CXXFLAGS) $$(MDBX_OPTIONS) -c $(1) -o $$@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
|
|
|
endef
|
|
|
|
$(foreach file,$(TEST_SRC),$(eval $(call test-rule,$(file))))
|
|
|
|
|
2020-04-15 22:09:37 +08:00
|
|
|
mdbx_%: src/mdbx_%.c libmdbx.a
|
2019-11-12 16:47:23 +08:00
|
|
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $(EXE_LDFLAGS) $(LIBS) -o $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
|
|
|
mdbx_test: $(TEST_OBJ) libmdbx.$(SO_SUFFIX)
|
2019-11-12 16:47:23 +08:00
|
|
|
$(CXX) $(CXXFLAGS) $(TEST_OBJ) -Wl,-rpath . -L . -l mdbx $(EXE_LDFLAGS) $(LIBS) -o $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2019-10-11 20:54:54 +08:00
|
|
|
git_DIR := $(shell if [ -d .git ]; then echo .git; elif [ -s .git -a -f .git ]; then grep '^gitdir: ' .git | cut -d ':' -f 2; else echo "Please use libmdbx as a git-submodule or the amalgamated source code" >&2 && echo git_directory; fi)
|
|
|
|
|
2020-04-15 22:09:37 +08:00
|
|
|
src/version.c: src/version.c.in $(lastword $(MAKEFILE_LIST)) $(git_DIR)/HEAD $(git_DIR)/index $(git_DIR)/refs/tags
|
2019-08-31 22:13:02 +08:00
|
|
|
sed \
|
2019-09-10 19:32:17 +08:00
|
|
|
-e "s|@MDBX_GIT_TIMESTAMP@|$(MDBX_GIT_TIMESTAMP)|" \
|
2019-08-31 22:13:02 +08:00
|
|
|
-e "s|@MDBX_GIT_TREE@|$(shell git show --no-patch --format=%T HEAD || echo 'Please install latest get version')|" \
|
|
|
|
-e "s|@MDBX_GIT_COMMIT@|$(shell git show --no-patch --format=%H HEAD || echo 'Please install latest get version')|" \
|
2019-09-10 19:32:17 +08:00
|
|
|
-e "s|@MDBX_GIT_DESCRIBE@|$(MDBX_GIT_DESCRIBE)|" \
|
2020-06-13 02:01:41 +08:00
|
|
|
-e "s|\$${MDBX_VERSION_MAJOR}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 1)|" \
|
|
|
|
-e "s|\$${MDBX_VERSION_MINOR}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 2)|" \
|
|
|
|
-e "s|\$${MDBX_VERSION_RELEASE}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 3)|" \
|
|
|
|
-e "s|\$${MDBX_VERSION_REVISION}|$(MDBX_GIT_REVISION)|" \
|
2020-04-15 22:09:37 +08:00
|
|
|
src/version.c.in > $@
|
2019-09-05 16:57:52 +08:00
|
|
|
|
2020-04-15 22:09:37 +08:00
|
|
|
src/config.h: src/version.c $(lastword $(MAKEFILE_LIST))
|
2019-09-05 16:57:52 +08:00
|
|
|
(echo '#define MDBX_BUILD_TIMESTAMP "$(shell date +%Y-%m-%dT%H:%M:%S%z)"' \
|
2020-09-20 20:47:03 +08:00
|
|
|
&& echo '#define MDBX_BUILD_FLAGS "$(CXXSTD) $(CFLAGS) $(LDFLAGS) $(LIBS)"' \
|
2020-06-18 00:17:38 +08:00
|
|
|
&& echo '#define MDBX_BUILD_COMPILER "$(shell (LC_ALL=C $(CC) --version || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \
|
|
|
|
&& echo '#define MDBX_BUILD_TARGET "$(shell set -o pipefail; (LC_ALL=C $(CC) -v 2>&1 | grep -i '^Target:' | cut -d ' ' -f 2- || (LC_ALL=C $(CC) --version | grep -qi e2k && echo E2K) || echo 'Please use GCC or CLANG compatible compiler') | head -1)"' \
|
2019-09-10 07:19:35 +08:00
|
|
|
&& echo '#define MDBX_BUILD_SOURCERY $(MDBX_BUILD_SOURCERY)' \
|
2019-09-10 19:32:17 +08:00
|
|
|
) > $@
|
2019-09-05 16:57:52 +08:00
|
|
|
|
2020-04-15 22:09:37 +08:00
|
|
|
mdbx-dylib.o: src/config.h src/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST))
|
2019-09-10 19:32:17 +08:00
|
|
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -DLIBMDBX_EXPORTS=1 -c src/alloy.c -o $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2020-04-15 22:09:37 +08:00
|
|
|
mdbx-static.o: src/config.h src/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST))
|
2019-09-10 19:32:17 +08:00
|
|
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c src/alloy.c -o $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2020-07-12 03:27:29 +08:00
|
|
|
docs/Doxyfile: docs/Doxyfile.in src/version.c
|
|
|
|
sed \
|
|
|
|
-e "s|@MDBX_GIT_TIMESTAMP@|$(MDBX_GIT_TIMESTAMP)|" \
|
|
|
|
-e "s|@MDBX_GIT_TREE@|$(shell git show --no-patch --format=%T HEAD || echo 'Please install latest get version')|" \
|
|
|
|
-e "s|@MDBX_GIT_COMMIT@|$(shell git show --no-patch --format=%H HEAD || echo 'Please install latest get version')|" \
|
|
|
|
-e "s|@MDBX_GIT_DESCRIBE@|$(MDBX_GIT_DESCRIBE)|" \
|
|
|
|
-e "s|\$${MDBX_VERSION_MAJOR}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 1)|" \
|
|
|
|
-e "s|\$${MDBX_VERSION_MINOR}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 2)|" \
|
|
|
|
-e "s|\$${MDBX_VERSION_RELEASE}|$(shell echo '$(MDBX_GIT_VERSION)' | cut -d . -f 3)|" \
|
|
|
|
-e "s|\$${MDBX_VERSION_REVISION}|$(MDBX_GIT_REVISION)|" \
|
|
|
|
docs/Doxyfile.in > $@
|
|
|
|
|
2020-07-21 06:24:29 +08:00
|
|
|
define md-extract-section
|
|
|
|
docs/__$(1).md: $(2)
|
|
|
|
sed -n '/<!-- section-begin $(1) -->/,/<!-- section-end -->/p' $$< > $$@ && test -s $$@
|
|
|
|
|
|
|
|
endef
|
|
|
|
$(foreach section,overview mithril characteristics improvements history usage performance bindings,$(eval $(call md-extract-section,$(section),README.md)))
|
|
|
|
|
|
|
|
docs/overall.md: docs/__overview.md docs/_toc.md docs/__mithril.md docs/__history.md AUTHORS LICENSE
|
2020-07-28 20:05:35 +08:00
|
|
|
echo -e "\\mainpage Overall\n\\section brief Brief" | cat - $(filter %.md, $^) > $@ && echo -e "\n\n\nLicense\n=======\n" | cat AUTHORS - LICENSE >> $@
|
2020-07-21 06:24:29 +08:00
|
|
|
|
|
|
|
docs/intro.md: docs/_preface.md docs/__characteristics.md docs/__improvements.md docs/_restrictions.md docs/__performance.md
|
2020-07-28 20:05:35 +08:00
|
|
|
cat $^ | sed 's/^Performance comparison$$/Performance comparison {#performance}/' > $@
|
2020-07-21 06:24:29 +08:00
|
|
|
|
|
|
|
docs/usage.md: docs/__usage.md docs/_starting.md docs/__bindings.md
|
2020-09-07 20:21:21 +08:00
|
|
|
echo -e "\\page usage Usage\n\\section getting Building & Embedding" | cat - $^ | sed 's/^Bindings$$/Bindings {#bindings}/' > $@
|
2020-07-21 06:24:29 +08:00
|
|
|
|
2020-08-23 01:19:46 +08:00
|
|
|
doxygen: docs/Doxyfile docs/overall.md docs/intro.md docs/usage.md mdbx.h mdbx.h++ src/options.h ChangeLog.md AUTHORS LICENSE
|
|
|
|
rm -rf docs/html && cp mdbx.h mdbx.h++ src/options.h ChangeLog.md docs/ && (cd docs && doxygen Doxyfile) && cp AUTHORS LICENSE docs/html/
|
|
|
|
|
|
|
|
mdbx++-dylib.o: src/config.h src/mdbx.c++ mdbx.h mdbx.h++ $(lastword $(MAKEFILE_LIST))
|
|
|
|
$(CXX) $(CXXFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -DLIBMDBX_EXPORTS=1 -c src/mdbx.c++ -o $@
|
|
|
|
|
|
|
|
mdbx++-static.o: src/config.h src/mdbx.c++ mdbx.h mdbx.h++ $(lastword $(MAKEFILE_LIST))
|
|
|
|
$(CXX) $(CXXFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c src/mdbx.c++ -o $@
|
2020-07-12 03:27:29 +08:00
|
|
|
|
2020-06-04 22:13:42 +08:00
|
|
|
.PHONY: dist release-assets
|
2019-10-16 03:31:02 +08:00
|
|
|
dist: libmdbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz $(lastword $(MAKEFILE_LIST))
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2020-06-04 22:13:42 +08:00
|
|
|
release-assets: libmdbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz libmdbx-sources-$(MDBX_VERSION_SUFFIX).zip
|
|
|
|
|
|
|
|
libmdbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz: $(addprefix dist/, $(DIST_SRC) $(DIST_EXTRA))
|
|
|
|
$(TAR) -c $(shell LC_ALL=C $(TAR) --help | grep -q -- '--owner' && echo '--owner=0 --group=0') -f - -C dist $(DIST_SRC) $(DIST_EXTRA) | gzip -c -9 > $@ \
|
2019-09-11 01:00:54 +08:00
|
|
|
&& rm dist/@tmp-shared_internals.inc
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2020-06-04 22:13:42 +08:00
|
|
|
libmdbx-sources-$(MDBX_VERSION_SUFFIX).zip: $(addprefix dist/, $(DIST_SRC) $(DIST_EXTRA))
|
|
|
|
rm -rf $@ && (cd dist && $(ZIP) -9 ../$@ $(DIST_SRC) $(DIST_EXTRA)) || rm -rf $@
|
|
|
|
|
2020-04-15 22:09:37 +08:00
|
|
|
dist/mdbx.h: mdbx.h src/version.c $(lastword $(MAKEFILE_LIST))
|
2019-09-10 07:19:35 +08:00
|
|
|
mkdir -p dist && cp $< $@
|
|
|
|
|
2020-08-23 01:19:46 +08:00
|
|
|
dist/mdbx.h++: mdbx.h++ src/version.c $(lastword $(MAKEFILE_LIST))
|
|
|
|
mkdir -p dist && cp $< $@
|
|
|
|
|
2020-04-15 22:09:37 +08:00
|
|
|
dist/@tmp-shared_internals.inc: src/version.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST))
|
2019-09-10 07:19:35 +08:00
|
|
|
mkdir -p dist && sed \
|
2019-09-10 19:32:17 +08:00
|
|
|
-e 's|#pragma once|#define MDBX_ALLOY 1\n#define MDBX_BUILD_SOURCERY $(MDBX_BUILD_SOURCERY)|' \
|
2020-04-15 22:09:37 +08:00
|
|
|
-e 's|#include "../mdbx.h"|@INCLUDE "mdbx.h"|' \
|
|
|
|
-e '/#include "defs.h"/r src/defs.h' \
|
|
|
|
-e '/#include "osal.h"/r src/osal.h' \
|
|
|
|
-e '/#include "options.h"/r src/options.h' \
|
|
|
|
src/internals.h > $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
|
|
|
dist/mdbx.c: dist/@tmp-shared_internals.inc $(lastword $(MAKEFILE_LIST))
|
|
|
|
mkdir -p dist && (cat dist/@tmp-shared_internals.inc \
|
2020-04-15 22:09:37 +08:00
|
|
|
&& cat src/core.c src/osal.c src/version.c src/lck-windows.c src/lck-posix.c \
|
2019-09-10 07:19:35 +08:00
|
|
|
) | grep -v -e '#include "' -e '#pragma once' | sed 's|@INCLUDE|#include|' > $@
|
|
|
|
|
2020-08-23 01:19:46 +08:00
|
|
|
dist/mdbx.c++: dist/@tmp-shared_internals.inc src/mdbx.c++ $(lastword $(MAKEFILE_LIST))
|
|
|
|
mkdir -p dist && (cat dist/@tmp-shared_internals.inc && cat src/mdbx.c++) \
|
|
|
|
| grep -v -e '#include "' -e '#pragma once' | sed 's|@INCLUDE|#include|;s|"mdbx.h"|"mdbx.h++"|' > $@
|
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
define dist-tool-rule
|
2020-04-15 22:09:37 +08:00
|
|
|
dist/$(1).c: src/$(1).c src/wingetopt.h src/wingetopt.c \
|
2019-09-10 19:32:17 +08:00
|
|
|
dist/@tmp-shared_internals.inc $(lastword $(MAKEFILE_LIST))
|
2019-09-10 07:19:35 +08:00
|
|
|
mkdir -p dist && sed \
|
2020-04-15 22:09:37 +08:00
|
|
|
-e '/#include "internals.h"/r dist/@tmp-shared_internals.inc' \
|
|
|
|
-e '/#include "wingetopt.h"/r src/wingetopt.c' \
|
|
|
|
src/$(1).c \
|
2019-09-10 07:19:35 +08:00
|
|
|
| grep -v -e '#include "' -e '#pragma once' -e '#define MDBX_ALLOY' \
|
|
|
|
| sed 's|@INCLUDE|#include|' > $$@
|
2017-03-16 23:09:27 +08:00
|
|
|
|
2017-05-24 18:59:50 +08:00
|
|
|
endef
|
2019-09-10 19:32:17 +08:00
|
|
|
$(foreach file,$(TOOLS),$(eval $(call dist-tool-rule,$(file))))
|
2017-03-16 23:09:27 +08:00
|
|
|
|
2020-04-15 22:09:37 +08:00
|
|
|
define dist-extra-rule
|
|
|
|
dist/$(1): $(1)
|
|
|
|
mkdir -p $$(dir $$@) && sed -e '/^#> dist-cutoff-begin/,/^#< dist-cutoff-end/d' $$< > $$@
|
|
|
|
|
|
|
|
endef
|
2020-05-10 08:41:28 +08:00
|
|
|
$(foreach file,$(filter-out man1/% VERSION %.in ntdll.def,$(DIST_EXTRA)),$(eval $(call dist-extra-rule,$(file))))
|
2020-04-15 22:09:37 +08:00
|
|
|
|
|
|
|
dist/VERSION: src/version.c
|
2020-06-13 02:01:41 +08:00
|
|
|
mkdir -p dist/ && echo "$(MDBX_GIT_VERSION).$(MDBX_GIT_REVISION)" > $@
|
2020-04-15 22:09:37 +08:00
|
|
|
|
2020-05-10 08:41:28 +08:00
|
|
|
dist/ntdll.def: src/ntdll.def
|
|
|
|
mkdir -p dist/cmake/ && cp $< $@
|
|
|
|
|
2020-04-15 22:09:37 +08:00
|
|
|
dist/config.h.in: src/config.h.in
|
|
|
|
mkdir -p dist/cmake/ && cp $< $@
|
|
|
|
|
2019-09-11 01:00:54 +08:00
|
|
|
dist/man1/mdbx_%.1: src/man1/mdbx_%.1
|
|
|
|
mkdir -p dist/man1/ && cp $< $@
|
2020-04-15 22:09:37 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
endif
|
2015-01-07 22:55:19 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
################################################################################
|
|
|
|
# Cross-compilation simple test
|
2017-04-11 19:37:25 +08:00
|
|
|
|
2020-09-22 05:16:26 +08:00
|
|
|
CROSS_LIST = sparc64-linux-gnu-gcc alpha-linux-gnu-gcc mips-linux-gnu-gcc \
|
2019-09-10 07:19:35 +08:00
|
|
|
powerpc64-linux-gnu-gcc powerpc-linux-gnu-gcc \
|
2019-10-26 06:14:08 +08:00
|
|
|
arm-linux-gnueabihf-gcc aarch64-linux-gnu-gcc \
|
2020-09-21 06:39:17 +08:00
|
|
|
sh4-linux-gnu-gcc mips64-linux-gnuabi64-gcc \
|
|
|
|
hppa-linux-gnu-gcc s390x-linux-gnu-gcc
|
|
|
|
|
|
|
|
## On Ubuntu Focal (20.04) with QEMU 4.2 (1:4.2-3ubuntu6.6) & GCC 9.3 (9.3.0-17ubuntu1~20.04)
|
|
|
|
# hppa-linux-gnu-gcc - works (previously: don't supported by qemu)
|
|
|
|
# s390x-linux-gnu-gcc - works (previously: qemu hang/abort)
|
2020-09-22 05:16:26 +08:00
|
|
|
# sparc64-linux-gnu-gcc - coredump (qemu mmap-troubles, previously: qemu fails fcntl for F_SETLK/F_GETLK)
|
|
|
|
# alpha-linux-gnu-gcc - coredump (qemu mmap-troubles)
|
|
|
|
CROSS_LIST_NOQEMU =
|
2019-09-10 07:19:35 +08:00
|
|
|
|
|
|
|
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"; \
|
2020-09-20 20:47:47 +08:00
|
|
|
$(MAKE) CXXSTD= clean && CC=$$CC CXX=$$(echo $$CC | sed 's/-gcc/-g++/') EXE_LDFLAGS=-static $(MAKE) all || exit $$?; \
|
2019-09-10 07:19:35 +08:00
|
|
|
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"; \
|
2020-09-20 20:47:47 +08:00
|
|
|
$(MAKE) CXXSTD= clean && \
|
2020-09-22 05:16:26 +08:00
|
|
|
MDBX_TEST_EXTRA="$(MDBX_TEST_EXTRA)$$(echo $$CC | grep -q -e alpha -e sparc && echo ' --size-upper=64M --size-lower=64M')" \
|
2019-09-11 22:02:01 +08:00
|
|
|
CC=$$CC CXX=$$(echo $$CC | sed 's/-gcc/-g++/') EXE_LDFLAGS=-static MDBX_OPTIONS="-DMDBX_SAFE4QEMU $(MDBX_OPTIONS)" \
|
2019-11-13 20:22:02 +08:00
|
|
|
$(MAKE) test-singleprocess || exit $$?; \
|
2019-09-10 07:19:35 +08:00
|
|
|
done
|
|
|
|
|
|
|
|
#< dist-cutoff-end
|
2019-09-11 01:00:54 +08:00
|
|
|
install: $(LIBRARIES) $(TOOLS) $(HEADERS)
|
2020-04-06 07:24:16 +08:00
|
|
|
install -D -p -s -t $(DESTDIR)$(prefix)/bin$(suffix) $(TOOLS) && \
|
|
|
|
install -D -p -s -t $(DESTDIR)$(prefix)/lib$(suffix) $(filter-out libmdbx.a,$(LIBRARIES)) && \
|
|
|
|
install -D -p -t $(DESTDIR)$(prefix)/lib$(suffix) libmdbx.a && \
|
|
|
|
install -D -p -m 444 -t $(DESTDIR)$(prefix)/include $(HEADERS) && \
|
|
|
|
install -D -p -m 444 -t $(DESTDIR)$(mandir)/man1 $(addprefix $(MAN_SRCDIR), $(MANPAGES))
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm -f $(addprefix $(DESTDIR)$(prefix)/bin$(suffix)/,$(TOOLS)) \
|
|
|
|
$(addprefix $(DESTDIR)$(prefix)/lib$(suffix)/,$(LIBRARIES)) \
|
|
|
|
$(addprefix $(DESTDIR)$(prefix)/include/,$(HEADERS)) \
|
|
|
|
$(addprefix $(DESTDIR)$(mandir)/man1/,$(MANPAGES))
|
2019-09-11 01:00:54 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
################################################################################
|
|
|
|
# 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
|
2016-03-20 02:06:05 +08:00
|
|
|
|
|
|
|
ifneq ($(wildcard $(IOARENA)),)
|
|
|
|
|
|
|
|
.PHONY: bench clean-bench re-bench
|
|
|
|
|
|
|
|
clean-bench:
|
2016-04-27 22:49:10 +08:00
|
|
|
rm -rf bench-*.txt _ioarena/*
|
2016-03-20 02:06:05 +08:00
|
|
|
|
|
|
|
re-bench: clean-bench bench
|
|
|
|
|
2016-04-16 02:44:42 +08:00
|
|
|
define bench-rule
|
2019-10-11 21:03:51 +08:00
|
|
|
bench-$(1)_$(2).txt: $(3) $(IOARENA) $(lastword $(MAKEFILE_LIST))
|
2017-10-26 22:15:56 +08:00
|
|
|
LD_LIBRARY_PATH="./:$$$${LD_LIBRARY_PATH}" \
|
|
|
|
$(IOARENA) -D $(1) -B crud -m nosync -n $(2) \
|
|
|
|
| tee $$@ | grep throughput && \
|
|
|
|
LD_LIBRARY_PATH="./:$$$${LD_LIBRARY_PATH}" \
|
|
|
|
$(IOARENA) -D $(1) -B get,iterate -m sync -r 4 -n $(2) \
|
|
|
|
| tee -a $$@ | grep throughput \
|
2017-10-27 23:26:55 +08:00
|
|
|
|| mv -f $$@ $$@.error
|
2016-04-16 02:44:42 +08:00
|
|
|
|
|
|
|
endef
|
2016-03-20 02:06:05 +08:00
|
|
|
|
2019-08-19 23:11:13 +08:00
|
|
|
$(eval $(call bench-rule,mdbx,$(NN),libmdbx.$(SO_SUFFIX)))
|
2016-03-20 02:06:05 +08:00
|
|
|
|
2017-10-29 17:33:46 +08:00
|
|
|
$(eval $(call bench-rule,sophia,$(NN)))
|
|
|
|
$(eval $(call bench-rule,leveldb,$(NN)))
|
|
|
|
$(eval $(call bench-rule,rocksdb,$(NN)))
|
|
|
|
$(eval $(call bench-rule,wiredtiger,$(NN)))
|
|
|
|
$(eval $(call bench-rule,forestdb,$(NN)))
|
2017-10-26 22:15:56 +08:00
|
|
|
$(eval $(call bench-rule,lmdb,$(NN)))
|
2017-10-29 17:33:46 +08:00
|
|
|
$(eval $(call bench-rule,nessdb,$(NN)))
|
2017-10-26 22:15:56 +08:00
|
|
|
$(eval $(call bench-rule,sqlite3,$(NN)))
|
2017-10-29 17:33:46 +08:00
|
|
|
$(eval $(call bench-rule,ejdb,$(NN)))
|
|
|
|
$(eval $(call bench-rule,vedisdb,$(NN)))
|
2016-04-16 02:44:42 +08:00
|
|
|
$(eval $(call bench-rule,dummy,$(NN)))
|
|
|
|
|
|
|
|
$(eval $(call bench-rule,debug,10))
|
|
|
|
|
2017-11-14 01:36:23 +08:00
|
|
|
bench: bench-mdbx_$(NN).txt
|
|
|
|
|
|
|
|
.PHONY: bench-debug
|
|
|
|
|
|
|
|
bench-debug: bench-debug_10.txt
|
|
|
|
|
|
|
|
bench-quartet: bench-mdbx_$(NN).txt bench-lmdb_$(NN).txt bench-rocksdb_$(NN).txt bench-wiredtiger_$(NN).txt
|
2016-03-20 02:06:05 +08:00
|
|
|
|
|
|
|
endif
|