2019-08-31 22:13:02 +08:00
|
|
|
# This makefile is for GNU Make, and nowadays provided
|
|
|
|
# just for compatibility and preservation of traditions.
|
|
|
|
# Please use CMake in case of any difficulties or problems.
|
2015-01-07 22:55:19 +08:00
|
|
|
#
|
2019-08-31 22:13:02 +08:00
|
|
|
# Preprocessor macros (for MDBX_OPTIONS) of interest...
|
|
|
|
# Note that the defaults should already be correct for most platforms;
|
|
|
|
# you should not need to change any of these. Read their descriptions
|
|
|
|
# in README and source code if you do. There may be other macros of interest.
|
2019-09-10 19:32:17 +08:00
|
|
|
SHELL := /bin/bash
|
2016-06-01 06:58:23 +08:00
|
|
|
|
|
|
|
# install sandbox
|
2019-09-10 07:19:35 +08:00
|
|
|
SANDBOX ?=
|
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
|
|
|
|
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
|
2017-06-25 00:34:29 +08:00
|
|
|
CXXFLAGS = -std=c++11 $(filter-out -std=gnu11,$(CFLAGS))
|
2015-01-07 22:55:19 +08:00
|
|
|
|
2017-04-11 19:37:25 +08:00
|
|
|
# LY: '--no-as-needed,-lrt' for ability to built with modern glibc, but then run with the old
|
2019-09-10 07:19:35 +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
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
HEADERS := mdbx.h
|
|
|
|
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
|
|
|
|
2017-03-30 23:54:57 +08:00
|
|
|
.PHONY: mdbx all install clean check coverage
|
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)
|
|
|
|
|
2016-06-01 06:58:23 +08:00
|
|
|
install: $(LIBRARIES) $(TOOLS) $(HEADERS)
|
|
|
|
mkdir -p $(SANDBOX)$(prefix)/bin$(suffix) \
|
|
|
|
&& cp -t $(SANDBOX)$(prefix)/bin$(suffix) $(TOOLS) && \
|
|
|
|
mkdir -p $(SANDBOX)$(prefix)/lib$(suffix) \
|
|
|
|
&& cp -t $(SANDBOX)$(prefix)/lib$(suffix) $(LIBRARIES) && \
|
|
|
|
mkdir -p $(SANDBOX)$(prefix)/include \
|
|
|
|
&& cp -t $(SANDBOX)$(prefix)/include $(HEADERS) && \
|
|
|
|
mkdir -p $(SANDBOX)$(mandir)/man1 \
|
|
|
|
&& cp -t $(SANDBOX)$(mandir)/man1 $(MANPAGES)
|
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/* \
|
|
|
|
*.gcov *.log *.err src/*.o test/*.o example dist \
|
|
|
|
config.h src/elements/config.h src/elements/version.c *.tar*
|
2015-10-21 05:04:35 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
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`
|
|
|
|
|
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)"' \
|
|
|
|
&& 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')"' \
|
2019-09-10 19:32:17 +08:00
|
|
|
) > $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2019-09-10 19:32:17 +08:00
|
|
|
mdbx-dylib.o: config.h mdbx.c $(lastword $(MAKEFILE_LIST))
|
|
|
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -DLIBMDBX_EXPORTS=1 -c mdbx.c -o $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
2019-09-10 19:32:17 +08:00
|
|
|
mdbx-static.o: config.h mdbx.c $(lastword $(MAKEFILE_LIST))
|
|
|
|
$(CC) $(CFLAGS) $(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-09-10 19:32:17 +08:00
|
|
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $(EXE_LDFLAGS) -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
|
|
|
|
|
|
|
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
|
|
|
|
Darwin*|Mach*) echo 3;;
|
|
|
|
*) echo 12;;
|
|
|
|
esac
|
|
|
|
endef
|
2019-09-10 19:32:17 +08:00
|
|
|
|
|
|
|
TEST_DB ?= $(shell [ -d /dev/shm ] && echo /dev/shm || echo /tmp)/mdbx-test.db
|
|
|
|
TEST_LOG ?= $(shell [ -d /dev/shm ] && echo /dev/shm || echo /tmp)/mdbx-test.log
|
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))
|
|
|
|
|
2019-09-10 19:32:17 +08:00
|
|
|
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_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]' _)
|
|
|
|
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)
|
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
check: all example mdbx_test
|
2019-09-10 19:32:17 +08:00
|
|
|
rm -f $(TEST_DB) $(TEST_LOG) && (set -o pipefail; ./mdbx_test --repeat=$(TEST_ITER) --pathname=$(TEST_DB) --dont-cleanup-after basic | tee -a $(TEST_LOG) | tail -n 42) \
|
|
|
|
&& ./mdbx_chk -vvn $(TEST_DB) && ./mdbx_chk -vvn $(TEST_DB)-copy
|
2015-01-07 22:55:19 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
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
|
2019-09-10 19:32:17 +08:00
|
|
|
rm -f $(TEST_DB) $(TEST_LOG) && (set -o pipefail; \
|
|
|
|
./mdbx_test --repeat=4 --pathname=$(TEST_DB) --dont-cleanup-after --hill && \
|
|
|
|
./mdbx_test --repeat=2 --pathname=$(TEST_DB) --dont-cleanup-before --dont-cleanup-after --copy \
|
|
|
|
| tee -a $(TEST_LOG) | tail -n 42) \
|
|
|
|
&& ./mdbx_chk -vvn $(TEST_DB) && ./mdbx_chk -vvn $(TEST_DB)-copy
|
2018-03-22 03:25:46 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
check-fault: all
|
2019-09-10 19:32:17 +08:00
|
|
|
rm -f $(TEST_DB) $(TEST_LOG) && (set -o pipefail; ./mdbx_test --pathname=$(TEST_DB) --inject-writefault=42 --dump-config --dont-cleanup-after basic | tee -a $(TEST_LOG) | tail -n 42) \
|
|
|
|
; ./mdbx_chk -vvnw $(TEST_DB) && ([ ! -e $(TEST_DB)-copy ] || ./mdbx_chk -vvn $(TEST_DB)-copy)
|
2018-03-19 22:51:27 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
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
|
2019-09-10 19:32:17 +08:00
|
|
|
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $(EXE_LDFLAGS) -o $@
|
2019-09-10 07:19:35 +08:00
|
|
|
|
|
|
|
mdbx_test: $(TEST_OBJ) libmdbx.$(SO_SUFFIX)
|
|
|
|
$(CXX) $(CXXFLAGS) $(TEST_OBJ) -Wl,-rpath . -L . -l mdbx $(EXE_LDFLAGS) -o $@
|
|
|
|
|
2019-09-05 16:57:52 +08:00
|
|
|
src/elements/version.c: src/elements/version.c.in $(lastword $(MAKEFILE_LIST)) .git/HEAD .git/index .git/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)|" \
|
2019-08-31 22:13:02 +08:00
|
|
|
-e "s|\$${MDBX_VERSION_MAJOR}|$(shell echo '$(MDBX_VERSION_GIT)' | cut -d . -f 1)|" \
|
|
|
|
-e "s|\$${MDBX_VERSION_MINOR}|$(shell echo '$(MDBX_VERSION_GIT)' | cut -d . -f 2)|" \
|
|
|
|
-e "s|\$${MDBX_VERSION_RELEASE}|$(shell echo '$(MDBX_VERSION_GIT)' | cut -d . -f 3)|" \
|
|
|
|
-e "s|\$${MDBX_VERSION_REVISION}|$(shell git rev-list --count --no-merges HEAD || echo 'Please fetch tags and/or install latest git version')|" \
|
2019-09-10 19:32:17 +08:00
|
|
|
src/elements/version.c.in > $@
|
2019-09-05 16:57:52 +08:00
|
|
|
|
|
|
|
src/elements/config.h: src/elements/version.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')"' \
|
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
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
mdbx-dylib.o: src/elements/config.h src/elements/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
|
|
|
|
|
|
|
mdbx-static.o: src/elements/config.h src/elements/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
|
|
|
|
|
|
|
.PHONY: dist
|
|
|
|
dist: lidmbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz $(lastword $(MAKEFILE_LIST))
|
|
|
|
|
2019-09-10 19:32:17 +08:00
|
|
|
lidmbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz: dist/mdbx.c dist/mdbx.h \
|
2019-09-10 07:19:35 +08:00
|
|
|
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))
|
2019-09-10 19:32:17 +08:00
|
|
|
tar -c -a -f $@ --owner=0 --group=0 -C dist mdbx.c mdbx.h \
|
2019-09-10 07:19:35 +08:00
|
|
|
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 \
|
2019-09-10 19:32:17 +08:00
|
|
|
-e 's|#pragma once|#define MDBX_ALLOY 1\n#define MDBX_BUILD_SOURCERY $(MDBX_BUILD_SOURCERY)|' \
|
2019-09-10 07:19:35 +08:00
|
|
|
-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
|
2019-09-10 19:32:17 +08:00
|
|
|
dist/$(1).c: src/tools/$(1).c src/tools/wingetopt.h src/tools/wingetopt.c \
|
|
|
|
dist/@tmp-shared_internals.inc $(lastword $(MAKEFILE_LIST))
|
2019-09-10 07:19:35 +08:00
|
|
|
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' \
|
2019-09-10 19:32:17 +08:00
|
|
|
src/tools/$(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
|
|
|
|
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
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
CROSS_LIST = mips-linux-gnu-gcc \
|
|
|
|
powerpc64-linux-gnu-gcc powerpc-linux-gnu-gcc \
|
|
|
|
arm-linux-gnueabihf-gcc aarch64-linux-gnu-gcc
|
2018-03-22 03:25:46 +08:00
|
|
|
|
2019-09-10 07:19:35 +08:00
|
|
|
# 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
|
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
|
2017-11-14 01:36:23 +08:00
|
|
|
bench-$(1)_$(2).txt: $(3) $(IOARENA) Makefile
|
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
|