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.
#
################################################################################
#
2022-04-06 17:22:41 +08:00
# Basic internal definitios. For a customizable variables and options see below.
#
$( info // The GNU Make $ ( MAKE_VERSION ) )
SHELL := $( shell env bash -c 'echo $$BASH' )
MAKE_VERx3 := $( shell printf "%3s%3s%3s" $( subst ., ,$( MAKE_VERSION) ) )
make_lt_3_81 := $( shell expr " $( MAKE_VERx3) " "<" " 3 81" )
2022-04-08 02:57:49 +08:00
i f n e q ( $( make_lt_ 3_ 81) , 0 )
2022-04-06 17:22:41 +08:00
$( error Please use GNU Make 3.81 or above )
e n d i f
2022-04-08 02:57:49 +08:00
make_ge_4_1 := $( shell expr " $( MAKE_VERx3) " ">=" " 4 1" )
2022-04-06 17:22:41 +08:00
SRC_PROBE_C := $( shell [ -f mdbx.c ] && echo mdbx.c || echo src/osal.c)
SRC_PROBE_CXX := $( shell [ -f mdbx.c++ ] && echo mdbx.c++ || echo src/mdbx.c++)
UNAME := $( shell uname -s 2>/dev/null || echo Unknown)
2022-04-08 02:57:49 +08:00
d e f i n e c x x _ f i l e s y s t e m _ p r o b e
int main( int argc, const char*argv[ ] ) {
mdbx::filesystem::path probe( argv[ 0] ) ;
if ( argc != 1) throw mdbx::filesystem::filesystem_error( std::string( "fake" ) , std::error_code( ) ) ;
return mdbx::filesystem::is_directory( probe.relative_path( ) ) ;
}
e n d e f
2022-04-06 17:22:41 +08:00
#
################################################################################
#
2021-04-30 19:05:36 +08:00
# Use `make options` to list the available libmdbx build options.
2020-09-20 23:07:33 +08:00
#
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.
#
2016-06-01 06:58:23 +08:00
# install sandbox
2020-04-06 07:24:16 +08:00
DESTDIR ?=
2022-04-06 17:22:41 +08:00
INSTALL ?= install
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
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
2022-04-06 17:22:41 +08:00
# toolchain
2019-09-10 07:19:35 +08:00
CC ?= gcc
2022-04-05 18:33:50 +08:00
CXX ?= g++
2020-04-11 07:37:50 +08:00
CFLAGS_EXTRA ?=
2019-09-10 07:19:35 +08:00
LD ?= ld
2022-04-06 17:22:41 +08:00
# build options
2022-07-28 22:02:51 +08:00
MDBX_BUILD_OPTIONS ?= -DNDEBUG= 1
2021-06-02 19:44:58 +08:00
MDBX_BUILD_TIMESTAMP ?= $( shell date +%Y-%m-%dT%H:%M:%S%z)
2022-07-28 22:02:51 +08:00
MDBX_BUILD_CXX ?= YES
2015-01-07 22:55:19 +08:00
2022-04-06 17:22:41 +08:00
# probe and compose common compiler flags with variable expansion trick (seems this work two times per session for GNU Make 3.81)
CFLAGS ?= $( strip $( eval CFLAGS := -std= gnu11 -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility= hidden -pthread -Wno-error= attributes $$ ( shell for opt in -fno-semantic-interposition -Wno-unused-command-line-argument -Wno-tautological-compare; do [ -z " $$ $$ ( $( CC) '-DMDBX_BUILD_FLAGS= " probe" ' $$ $$ {opt} -c $( SRC_PROBE_C) -o /dev/null >/dev/null 2>&1 || echo failed) " ] && echo " $$ $$ {opt} " ; done ) $( CFLAGS_EXTRA) ) $( CFLAGS) )
# choosing C++ standard with variable expansion trick (seems this work two times per session for GNU Make 3.81)
CXXSTD ?= $( eval CXXSTD := $$ ( shell for std in gnu++23 c++23 gnu++2b c++2b gnu++20 c++20 gnu++2a c++2a gnu++17 c++17 gnu++1z c++1z gnu++14 c++14 gnu++1y c++1y gnu+11 c++11 gnu++0x c++0x; do $( CXX) -std= $$ $$ { std} -c $( SRC_PROBE_CXX) -o /dev/null 2>probe4std-$$ $$ { std} .err >/dev/null && echo " -std= $$ $$ {std} " && exit; done ) ) $( CXXSTD)
CXXFLAGS ?= $( strip $( CXXSTD) $( filter-out -std= gnu11,$( CFLAGS) ) )
2022-04-08 05:56:47 +08:00
# libraries and options for linking
2022-04-06 17:22:41 +08:00
EXE_LDFLAGS ?= -pthread
2022-04-08 02:57:49 +08:00
i f n e q ( $( make_ge_ 4_ 1) , 1 )
2022-04-06 17:22:41 +08:00
# don't use variable expansion trick as workaround for bugs of GNU Make before 4.1
LIBS ?= $( shell $( uname2libs) )
LDFLAGS ?= $( shell $( uname2ldflags) )
2022-04-08 02:57:49 +08:00
LIB_STDCXXFS ?= $( shell echo '$(cxx_filesystem_probe)' | cat mdbx.h++ - | sed $$ '1s/\xef\xbb\xbf//' | $( CXX) -x c++ $( CXXFLAGS) -Wno-error - -Wl,--allow-multiple-definition -lstdc++fs $( LIBS) $( LDFLAGS) $( EXE_LDFLAGS) -o /dev/null 2>probe4lstdfs.err >/dev/null && echo '-Wl,--allow-multiple-definition -lstdc++fs' )
2022-04-06 17:22:41 +08:00
e l s e
# using variable expansion trick to avoid repeaded probes
LIBS ?= $( eval LIBS := $$ ( shell $$ ( uname2libs) ) ) $( LIBS)
LDFLAGS ?= $( eval LDFLAGS := $$ ( shell $$ ( uname2ldflags) ) ) $( LDFLAGS)
2022-04-08 02:57:49 +08:00
LIB_STDCXXFS ?= $( eval LIB_STDCXXFS := $$ ( shell echo '$$(cxx_filesystem_probe)' | cat mdbx.h++ - | sed $$ $$ '1s/\xef\xbb\xbf//' | $( CXX) -x c++ $( CXXFLAGS) -Wno-error - -Wl,--allow-multiple-definition -lstdc++fs $( LIBS) $( LDFLAGS) $( EXE_LDFLAGS) -o /dev/null 2>probe4lstdfs.err >/dev/null && echo '-Wl,--allow-multiple-definition -lstdc++fs' ) ) $( LIB_STDCXXFS)
2022-04-06 17:22:41 +08:00
e n d i f
2016-06-01 06:58:23 +08:00
2019-09-10 07:19:35 +08:00
################################################################################
2015-01-07 22:55:19 +08:00
2021-05-01 06:02:28 +08:00
d e f i n e u n a m e 2 s o s u f f i x
case " $( UNAME) " in
Darwin*| Mach*) echo dylib; ;
CYGWIN*| MINGW*| MSYS*| Windows*) echo dll; ;
*) echo so; ;
esac
e n d e f
2022-04-06 17:22:41 +08:00
2022-03-30 23:13:44 +08:00
d e f i n e u n a m e 2 l d f l a g s
case " $( UNAME) " in
CYGWIN*| MINGW*| MSYS*| Windows*)
2022-04-06 17:22:41 +08:00
echo '-Wl,--gc-sections,-O1' ;
2022-03-30 23:13:44 +08:00
; ;
*)
2022-04-06 17:22:41 +08:00
$( LD) --help 2>/dev/null | grep -q -- --gc-sections && echo '-Wl,--gc-sections,-z,relro,-O1' ;
$( LD) --help 2>/dev/null | grep -q -- -dead_strip && echo '-Wl,-dead_strip' ;
2022-03-30 23:13:44 +08:00
; ;
esac
e n d e f
2022-04-06 17:22:41 +08:00
# TIP: try add the'-Wl, --no-as-needed,-lrt' for ability to built with modern glibc, but then use with the old.
2022-03-30 23:13:44 +08:00
d e f i n e u n a m e 2 l i b s
case " $( UNAME) " in
CYGWIN*| MINGW*| MSYS*| Windows*)
2022-04-06 17:22:41 +08:00
echo '-lm -lntdll -lwinmm' ;
2022-03-30 23:13:44 +08:00
; ;
*SunOS*| *Solaris*)
2022-04-06 17:22:41 +08:00
echo '-lm -lkstat -lrt' ;
2022-03-30 23:13:44 +08:00
; ;
*Darwin*| OpenBSD*)
2022-04-06 17:22:41 +08:00
echo '-lm' ;
2022-03-30 23:13:44 +08:00
; ;
*)
2022-04-06 17:22:41 +08:00
echo '-lm -lrt' ;
2022-03-30 23:13:44 +08:00
; ;
esac
e n d e f
2022-04-06 17:22:41 +08:00
2021-04-30 19:05:36 +08:00
SO_SUFFIX := $( shell $( uname2sosuffix) )
HEADERS := mdbx.h mdbx.h++
LIBRARIES := libmdbx.a libmdbx.$( SO_SUFFIX)
TOOLS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk mdbx_drop
MANPAGES := mdbx_stat.1 mdbx_copy.1 mdbx_dump.1 mdbx_load.1 mdbx_chk.1 mdbx_drop.1
2021-07-03 18:51:28 +08:00
TIP := // TIP:
2021-04-30 19:05:36 +08:00
2022-03-27 19:01:18 +08:00
.PHONY : all help options lib libs tools clean install uninstall check_buildflags_tag tools -static
2022-03-04 22:49:35 +08:00
.PHONY : install -strip install -no -strip strip libmdbx mdbx show -options lib -static lib -shared
2021-05-01 06:02:28 +08:00
2022-07-28 22:02:51 +08:00
boolean = $( if $( findstring $( strip $( $1 ) ) ,YES Yes yes y ON On on 1 true True TRUE) ,1,$( if $( findstring $( strip $( $1 ) ) ,NO No no n OFF Off off 0 false False FALSE) ,,$( error Wrong value ` $( $1 ) ` of $1 for YES/NO option) ) )
select_by = $( if $( call boolean,$( 1) ) ,$( 2) ,$( 3) )
2021-05-02 00:34:46 +08:00
i f e q ( "$(origin V)" , "command line" )
MDBX_BUILD_VERBOSE := $( V)
e n d i f
i f n d e f M D B X _ B U I L D _ V E R B O S E
MDBX_BUILD_VERBOSE := 0
e n d i f
2022-07-28 22:02:51 +08:00
i f e q ( $( call boolean ,MDBX_BUILD_VERBOSE ) , 1 )
2021-05-02 00:34:46 +08:00
QUIET :=
HUSH :=
2021-07-03 18:51:28 +08:00
$( info $( TIP) Use ` make V = 0` for quiet.)
2021-05-02 00:34:46 +08:00
e l s e
QUIET := @
HUSH := >/dev/null
2021-07-03 18:51:28 +08:00
$( info $( TIP) Use ` make V = 1` for verbose.)
2021-05-02 00:34:46 +08:00
e n d i f
all : show -options $( LIBRARIES ) $( TOOLS )
2021-04-30 19:05:36 +08:00
2021-05-01 06:02:28 +08:00
help :
@echo " make all - build libraries and tools"
@echo " make help - print this help"
@echo " make options - list build options"
2022-03-04 22:49:35 +08:00
@echo " make lib - build libraries, also lib-static and lib-shared"
2022-03-27 19:01:18 +08:00
@echo " make tools - build the tools"
@echo " make tools-static - build the tools with statically linking with system libraries and compiler runtime"
2021-05-01 06:02:28 +08:00
@echo " make clean "
@echo " make install "
@echo " make uninstall "
@echo ""
@echo " make strip - strip debug symbols from binaries"
@echo " make install-no-strip - install explicitly without strip"
@echo " make install-strip - install explicitly with strip"
@echo ""
@echo " make bench - run ioarena-benchmark"
@echo " make bench-couple - run ioarena-benchmark for mdbx and lmdb"
@echo " make bench-triplet - run ioarena-benchmark for mdbx, lmdb, sqlite3"
@echo " make bench-quartet - run ioarena-benchmark for mdbx, lmdb, rocksdb, wiredtiger"
@echo " make bench-clean - remove temp database(s) after benchmark"
#> dist-cutoff-begin
@echo ""
2021-07-06 20:37:10 +08:00
@echo " make smoke - fast smoke test"
2021-05-01 06:02:28 +08:00
@echo " make test - basic test"
2021-07-06 20:37:10 +08:00
@echo " make check - smoke test with amalgamation and installation checking"
2021-07-21 03:12:38 +08:00
@echo " make long-test - execute long test which runs for several weeks, or until you interrupt it"
2021-07-06 20:37:10 +08:00
@echo " make memcheck - build with Valgrind's and smoke test with memcheck tool"
@echo " make test-valgrind - build with Valgrind's and basic test with memcheck tool"
@echo " make test-asan - build with AddressSanitizer and basic test"
@echo " make test-leak - build with LeakSanitizer and basic test"
@echo " make test-ubsan - build with UndefinedBehaviourSanitizer and basic test"
@echo " make cross-gcc - check cross-compilation without test execution"
@echo " make cross-qemu - run cross-compilation and execution basic test with QEMU"
2021-05-01 06:02:28 +08:00
@echo " make gcc-analyzer - run gcc-analyzer (mostly useless for now)"
@echo " make build-test - build test executable(s)"
2021-07-06 20:37:10 +08:00
@echo " make smoke-fault - execute transaction owner failure smoke testcase"
@echo " make smoke-singleprocess - execute single-process smoke test"
@echo " make test-singleprocess - execute single-process basic test (also used by make cross-qemu)"
2021-05-01 06:02:28 +08:00
@echo ""
@echo " make dist - build amalgamated source code"
@echo " make doxygen - build HTML documentation"
@echo " make release-assets - build release assets"
@echo " make reformat - reformat source code with clang-format"
#< dist-cutoff-end
2021-05-02 00:34:46 +08:00
show-options :
2021-06-02 19:44:58 +08:00
@echo " MDBX_BUILD_OPTIONS = $( MDBX_BUILD_OPTIONS) "
2022-07-28 22:02:51 +08:00
@echo " MDBX_BUILD_CXX = $( MDBX_BUILD_CXX) "
2021-06-02 19:44:58 +08:00
@echo " MDBX_BUILD_TIMESTAMP = $( MDBX_BUILD_TIMESTAMP) "
2021-07-03 18:51:28 +08:00
@echo '$(TIP) Use `make options` to listing available build options.'
2022-07-28 22:02:51 +08:00
@echo $( call select_by,MDBX_BUILD_CXX," CXX =`which $( CXX) ` | ` $( CXX) --version | head -1` " ," CC =`which $( CC) ` | ` $( CC) --version | head -1` " )
@echo $( call select_by,MDBX_BUILD_CXX," CXXFLAGS = $( CXXFLAGS) " ," CFLAGS = $( CFLAGS) " )
@echo $( call select_by,MDBX_BUILD_CXX," LDFLAGS = $( LDFLAGS) $( LIB_STDCXXFS) $( LIBS) $( EXE_LDFLAGS) " ," LDFLAGS = $( LDFLAGS) $( LIBS) $( EXE_LDFLAGS) " )
2021-07-03 18:51:28 +08:00
@echo '$(TIP) Use `make help` to listing available targets.'
2021-05-02 00:34:46 +08:00
2021-04-30 19:05:36 +08:00
options :
@echo " INSTALL = $( INSTALL) "
@echo " DESTDIR = $( DESTDIR) "
@echo " prefix = $( prefix) "
@echo " mandir = $( mandir) "
@echo " suffix = $( suffix) "
@echo ""
@echo " CC = $( CC) "
@echo " CFLAGS_EXTRA = $( CFLAGS_EXTRA) "
@echo " CFLAGS = $( CFLAGS) "
@echo " CXX = $( CXX) "
@echo " CXXSTD = $( CXXSTD) "
@echo " CXXFLAGS = $( CXXFLAGS) "
@echo ""
@echo " LD = $( LD) "
@echo " LDFLAGS = $( LDFLAGS) "
@echo " EXE_LDFLAGS = $( EXE_LDFLAGS) "
@echo " LIBS = $( LIBS) "
@echo ""
2021-06-02 19:44:58 +08:00
@echo " MDBX_BUILD_OPTIONS = $( MDBX_BUILD_OPTIONS) "
@echo " MDBX_BUILD_TIMESTAMP = $( MDBX_BUILD_TIMESTAMP) "
2021-04-30 19:05:36 +08:00
@echo ""
2021-05-02 00:34:46 +08:00
@echo "## Assortment items for MDBX_BUILD_OPTIONS:"
@echo "## Note that the defaults should already be correct for most platforms;"
@echo "## you should not need to change any of these. Read their descriptions"
2021-04-30 19:05:36 +08:00
#> dist-cutoff-begin
i f e q ( $( wildcard mdbx .c ) , m d b x . c )
#< dist-cutoff-end
2021-05-02 00:34:46 +08:00
@echo "## in README and source code (see mdbx.c) if you do."
2021-04-30 19:05:36 +08:00
@grep -h '#ifndef MDBX_' mdbx.c | grep -v BUILD | uniq | sed 's/#ifndef / /'
#> dist-cutoff-begin
e l s e
2021-05-02 00:34:46 +08:00
@echo "## in README and source code (see src/options.h) if you do."
2021-04-30 19:05:36 +08:00
@grep -h '#ifndef MDBX_' src/internals.h src/options.h | grep -v BUILD | uniq | sed 's/#ifndef / /'
e n d i f
#< dist-cutoff-end
2022-03-04 22:49:35 +08:00
lib libs libmdbx mdbx : libmdbx .a libmdbx .$( SO_SUFFIX )
2015-10-13 20:46:59 +08:00
2016-06-01 06:58:23 +08:00
tools : $( TOOLS )
2022-03-27 19:01:18 +08:00
tools-static : $( addsuffix .static ,$ ( TOOLS ) ) $( addsuffix .static -lto ,$ ( TOOLS ) )
2016-06-01 06:58:23 +08:00
2019-09-10 07:19:35 +08:00
strip : all
2021-05-02 00:34:46 +08:00
@echo ' STRIP libmdbx.$(SO_SUFFIX) $(TOOLS)'
$( TRACE ) strip libmdbx.$( SO_SUFFIX) $( TOOLS)
2019-09-10 07:19:35 +08:00
2015-01-07 22:55:19 +08:00
clean :
2021-05-02 00:34:46 +08:00
@echo ' REMOVE ...'
$( QUIET) rm -rf $( TOOLS) mdbx_test @* *.[ ao] *.[ ls] o *.$( SO_SUFFIX) *.dSYM *~ tmp.db/* \
2019-09-18 09:00:16 +08:00
*.gcov *.log *.err src/*.o test/*.o mdbx_example dist \
2022-03-27 19:01:18 +08:00
config.h src/config.h src/version.c *.tar* buildflags.tag \
mdbx_*.static mdbx_*.static-lto
2021-07-06 20:37:10 +08:00
2022-07-28 22:02:51 +08:00
MDBX_BUILD_FLAGS = $( strip MDBX_BUILD_CXX = $( MDBX_BUILD_CXX) $( MDBX_BUILD_OPTIONS) $( call select_by,MDBX_BUILD_CXX,$( CXXFLAGS) $( LDFLAGS) $( LIB_STDCXXFS) $( LIBS) ,$( CFLAGS) $( LDFLAGS) $( LIBS) ) )
2021-07-06 20:37:10 +08:00
check_buildflags_tag :
2021-07-15 21:55:38 +08:00
$( QUIET) if [ " $( MDBX_BUILD_FLAGS) " != " $$ (cat buildflags.tag 2>&1) " ] ; then \
2021-07-06 20:37:10 +08:00
echo -n " CLEAN for build with specified flags..." && \
2021-07-25 22:24:05 +08:00
$( MAKE) IOARENA = false CXXSTD = -s clean >/dev/null && echo " Ok" && \
2021-07-15 21:55:38 +08:00
echo '$(MDBX_BUILD_FLAGS)' > buildflags.tag; \
2021-07-06 20:37:10 +08:00
fi
2021-07-15 21:55:38 +08:00
buildflags.tag : check_buildflags_tag
2015-10-21 05:04:35 +08:00
2022-07-28 22:02:51 +08:00
lib-static libmdbx.a : mdbx -static .o $( call select_by ,MDBX_BUILD_CXX ,mdbx ++-static .o )
2021-05-02 00:34:46 +08:00
@echo ' AR $@'
$( QUIET) $( AR) rcs $@ $? $( HUSH)
2019-09-10 07:19:35 +08:00
2022-07-28 22:02:51 +08:00
lib-shared libmdbx.$(SO_SUFFIX) : mdbx -dylib .o $( call select_by ,MDBX_BUILD_CXX ,mdbx ++-dylib .o )
2021-05-02 00:34:46 +08:00
@echo ' LD $@'
2022-07-28 22:02:51 +08:00
$( QUIET) $( call select_by,MDBX_BUILD_CXX,$( CXX) $( CXXFLAGS) ,$( CC) $( CFLAGS) ) $^ -pthread -shared $( LDFLAGS) $( call select_by,MDBX_BUILD_CXX,$( LIB_STDCXXFS) ) $( LIBS) -o $@
2019-09-10 07:19:35 +08:00
#> dist-cutoff-begin
i f e q ( $( wildcard mdbx .c ) , m d b x . c )
#< dist-cutoff-end
################################################################################
2020-10-20 20:42:50 +08:00
# Amalgamated source code, i.e. distributed after `make dist`
2019-09-11 01:00:54 +08:00
MAN_SRCDIR := man1/
2019-09-10 07:19:35 +08:00
2021-07-15 21:55:38 +08:00
config.h : buildflags .tag mdbx .c $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' MAKE $@'
2021-06-02 19:44:58 +08:00
$( QUIET) ( echo '#define MDBX_BUILD_TIMESTAMP "$(MDBX_BUILD_TIMESTAMP)"' \
2021-07-15 21:55:38 +08:00
&& echo " #define MDBX_BUILD_FLAGS \" $$ (cat buildflags.tag)\" " \
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)"' \
2021-06-26 22:35:56 +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 ) )
2021-05-02 00:34:46 +08:00
@echo ' CC $@'
$( QUIET) $( CC) $( CFLAGS) $( MDBX_BUILD_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 ) )
2021-05-02 00:34:46 +08:00
@echo ' CC $@'
$( QUIET) $( CC) $( CFLAGS) $( MDBX_BUILD_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 ) )
2021-05-02 00:34:46 +08:00
@echo ' CC $@'
$( QUIET) $( CXX) $( CXXFLAGS) $( MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -DLIBMDBX_EXPORTS= 1 -c mdbx.c++ -o $@
2020-08-23 01:19:46 +08:00
mdbx++-static.o : config .h mdbx .c ++ mdbx .h mdbx .h ++ $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' CC $@'
$( QUIET) $( CXX) $( CXXFLAGS) $( MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c mdbx.c++ -o $@
2020-08-23 01:19:46 +08:00
2022-03-27 19:01:18 +08:00
mdbx_% : mdbx_ %.c mdbx -static .o
2021-05-02 00:34:46 +08:00
@echo ' CC+LD $@'
$( QUIET) $( CC) $( CFLAGS) $( MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $( EXE_LDFLAGS) $( LIBS) -o $@
2019-09-10 07:19:35 +08:00
2022-03-27 19:01:18 +08:00
mdbx_%.static : mdbx_ %.c mdbx -static .o
@echo ' CC+LD $@'
$( QUIET) $( CC) $( CFLAGS) $( MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $( EXE_LDFLAGS) -static -Wl,--strip-all -o $@
mdbx_%.static-lto : mdbx_ %.c config .h mdbx .c mdbx .h
@echo ' CC+LD $@'
2022-03-30 23:13:44 +08:00
$( QUIET) $( CC) $( CFLAGS) -Os -flto $( MDBX_BUILD_OPTIONS) '-DLIBMDBX_API=' '-DMDBX_CONFIG_H="config.h"' \
2022-03-27 19:01:18 +08:00
$< mdbx.c $( EXE_LDFLAGS) $( LIBS) -static -Wl,--strip-all -o $@
2019-09-10 07:19:35 +08:00
#> dist-cutoff-begin
e l s e
################################################################################
2019-09-10 19:32:17 +08:00
# Plain (non-amalgamated) sources with test
2019-09-10 07:19:35 +08:00
2021-07-06 20:37:10 +08:00
.PHONY : build -test build -test -with -valgrind check cross -gcc cross -qemu dist doxygen gcc -analyzer long -test
.PHONY : reformat release -assets tags smoke test test -asan smoke -fault test -leak
.PHONY : smoke -singleprocess test -singleprocess test -ubsan test -valgrind memcheck
2022-04-19 01:20:39 +08:00
.PHONY : smoke -assertion test -assertion long -test -assertion
2020-07-12 03:27:29 +08:00
2019-09-10 07:19:35 +08:00
d e f i n e u n a m e 2 o s a l
case " $( UNAME) " in
CYGWIN*| MINGW*| MSYS*| Windows*) echo windows; ;
*) echo unix; ;
esac
e n d e f
2019-09-10 19:32:17 +08:00
2019-09-10 07:19:35 +08:00
d e f i n e u n a m e 2 t i t e r
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
e n d e f
2019-09-10 19:32:17 +08:00
2021-06-24 19:56:18 +08:00
DIST_EXTRA := LICENSE README.md CMakeLists.txt GNUmakefile Makefile ChangeLog.md VERSION.txt 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-12-24 17:05:29 +08:00
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) )
2022-11-08 21:17:14 +08:00
TEST_SRC := test/osal-$( TEST_OSAL) .c++ $( filter-out $( wildcard test/osal-*.c++) , $( wildcard test/*.c++) )
TEST_INC := $( wildcard test/*.h++)
TEST_OBJ := $( patsubst %.c++,%.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'" )
2022-01-21 03:47:57 +08:00
CLANG_FORMAT ?= $( shell ( which clang-format-14 || which clang-format-13 || which clang-format) 2>/dev/null)
2020-05-02 02:20:17 +08:00
reformat :
2021-05-02 00:34:46 +08:00
@echo ' RUNNING clang-format...'
$( QUIET) if [ -n " $( CLANG_FORMAT) " ] ; then \
2022-11-08 21:17:14 +08:00
git ls-files | grep -E '\.(c|c++|h|h++)(\.in)?$$' | xargs -r $( CLANG_FORMAT) -i --style= file; \
2020-05-02 02:20:17 +08:00
else \
2022-01-21 03:47:57 +08:00
echo "clang-format version 13..14 not found for 'reformat'" ; \
2020-05-02 02:20:17 +08:00
fi
2019-09-10 07:19:35 +08:00
2019-09-11 03:41:53 +08:00
MAN_SRCDIR := src/man1/
2021-07-26 05:45:25 +08:00
ALLOY_DEPS := $( shell git ls-files src/)
2021-05-13 17:19:18 +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 git_directory_is_absent; fi )
2022-03-28 14:19:39 +08:00
MDBX_GIT_VERSION = $( shell set -o pipefail; git describe --tags '--match=v[0-9]*' 2>& - | sed -n 's|^v*\([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\)\(.*\)|\1|p' || echo 'Please fetch tags and/or use non-obsolete git version' )
2021-08-22 16:06:47 +08:00
MDBX_GIT_REVISION = $( shell set -o pipefail; git rev-list ` git describe --tags --abbrev= 0` ..HEAD --count 2>& - || echo 'Please fetch tags and/or use non-obsolete git version' )
2021-05-13 17:19:18 +08:00
MDBX_GIT_TIMESTAMP = $( shell git show --no-patch --format= %cI HEAD 2>& - || echo 'Please install latest get version' )
2022-03-28 14:19:39 +08:00
MDBX_GIT_DESCRIBE = $( shell git describe --tags --long --dirty= -dirty '--match=v[0-9]*' 2>& - || echo 'Please fetch tags and/or install non-obsolete git version' )
2022-04-24 03:18:22 +08:00
MDBX_VERSION_IDENT = $( shell set -o pipefail; echo -n '$(MDBX_GIT_DESCRIBE)' | tr -c -s '[a-zA-Z0-9.]' _)
MDBX_VERSION_NODOT = $( subst .,_,$( MDBX_VERSION_IDENT) )
MDBX_BUILD_SOURCERY = $( shell set -o pipefail; $( MAKE) IOARENA = false CXXSTD = -s src/version.c >/dev/null && ( 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' >& 2 && echo sha256sum_is_no_available) ) _$( MDBX_VERSION_NODOT)
MDBX_DIST_DIR = libmdbx-$( MDBX_VERSION_NODOT)
2019-09-10 19:32:17 +08:00
2020-09-22 05:16:26 +08:00
# Extra options mdbx_test utility
2021-07-12 15:44:00 +08:00
MDBX_SMOKE_EXTRA ?=
2020-09-22 05:16:26 +08:00
2021-06-17 19:40:52 +08:00
check : DESTDIR = $( shell pwd ) /@check -install
check : test dist install
2019-11-13 20:22:02 +08:00
2022-07-26 01:17:16 +08:00
smoke-assertion : MDBX_BUILD_OPTIONS :=$( strip $ ( MDBX_BUILD_OPTIONS ) -DMDBX_FORCE_ASSERTIONS =1)
2022-04-19 01:20:39 +08:00
smoke-assertion : smoke
2022-07-26 01:17:16 +08:00
test-assertion : MDBX_BUILD_OPTIONS :=$( strip $ ( MDBX_BUILD_OPTIONS ) -DMDBX_FORCE_ASSERTIONS =1)
2022-04-19 01:20:39 +08:00
test-assertion : smoke
2022-07-26 01:17:16 +08:00
long-test-assertion : MDBX_BUILD_OPTIONS :=$( strip $ ( MDBX_BUILD_OPTIONS ) -DMDBX_FORCE_ASSERTIONS =1)
2022-04-19 01:20:39 +08:00
long-test-assertion : smoke
2021-07-06 20:37:10 +08:00
smoke : build -test
@echo ' SMOKE `mdbx_test basic`...'
2021-05-02 00:34:46 +08:00
$( QUIET) rm -f $( TEST_DB) $( TEST_LOG) .gz && ( set -o pipefail; \
2021-07-12 15:44:00 +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_SMOKE_EXTRA) basic && \
2022-04-22 00:49:57 +08:00
./mdbx_test --mode= -writemap,-nosync-safe,-lifo --progress --console= no --repeat= $( TEST_ITER) --pathname= $( TEST_DB) --dont-cleanup-after $( MDBX_SMOKE_EXTRA) basic) \
2021-06-26 22:35:56 +08:00
| tee >( gzip --stdout >$( TEST_LOG) .gz) | 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
2021-07-06 20:37:10 +08:00
smoke-singleprocess : build -test
@echo ' SMOKE `mdbx_test --nested`...'
2021-05-02 00:34:46 +08:00
$( QUIET) rm -f $( TEST_DB) $( TEST_LOG) .gz && ( set -o pipefail; \
2021-07-12 15:44:00 +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_SMOKE_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 && \
2021-07-12 15:44:00 +08:00
./mdbx_test --mode= -writemap,-nosync-safe,-lifo --progress --console= no --repeat= 42 --pathname= $( TEST_DB) --dont-cleanup-after $( MDBX_SMOKE_EXTRA) --nested) \
2021-06-26 22:35:56 +08:00
| tee >( gzip --stdout >$( TEST_LOG) .gz) | 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
2021-07-06 20:37:10 +08:00
smoke-fault : build -test
@echo ' SMOKE `mdbx_test --inject-writefault=42 basic`...'
2021-07-12 15:44:00 +08:00
$( QUIET) rm -f $( TEST_DB) $( TEST_LOG) .gz && ( set -o pipefail; ./mdbx_test --progress --console= no --pathname= $( TEST_DB) --inject-writefault= 42 --dump-config --dont-cleanup-after $( MDBX_SMOKE_EXTRA) basic \
2021-06-26 22:35:56 +08:00
| tee >( gzip --stdout >$( TEST_LOG) .gz) | 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
2021-07-06 20:37:10 +08:00
test : build -test
@echo ' RUNNING `test/long_stochastic.sh --loops 2`...'
2022-10-13 23:59:28 +08:00
$( QUIET) test/long_stochastic.sh --loops 2 --db-upto-mb 256 --skip-make >$( TEST_LOG) || ( cat $( TEST_LOG) && false )
2021-07-06 20:37:10 +08:00
long-test : build -test
@echo ' RUNNING `test/long_stochastic.sh --loops 42`...'
2021-07-12 16:16:49 +08:00
$( QUIET) test/long_stochastic.sh --loops 42 --db-upto-mb 1024 --skip-make
2021-07-06 20:37:10 +08:00
test-singleprocess : build -test
@echo ' RUNNING `test/long_stochastic.sh --single --loops 2`...'
2022-10-13 23:59:28 +08:00
$( QUIET) test/long_stochastic.sh --single --loops 2 --db-upto-mb 256 --skip-make >$( TEST_LOG) || ( cat $( TEST_LOG) && false )
2021-07-06 20:37:10 +08:00
test-valgrind : CFLAGS_EXTRA =-Ofast -DMDBX_USE_VALGRIND
test-valgrind : build -test
@echo ' RUNNING `test/long_stochastic.sh --with-valgrind --loops 2`...'
2022-10-13 23:59:28 +08:00
$( QUIET) test/long_stochastic.sh --with-valgrind --loops 2 --db-upto-mb 256 --skip-make >$( TEST_LOG) || ( cat $( TEST_LOG) && false )
2021-07-06 20:37:10 +08:00
memcheck : VALGRIND =valgrind --trace -children =yes --log -file =valgrind -%p .log --leak -check =full --track -origins =yes --error -exitcode =42 --suppressions =test /valgrind_suppress .txt
memcheck : CFLAGS_EXTRA =-Ofast -DMDBX_USE_VALGRIND
memcheck : build -test
@echo " SMOKE \`mdbx_test basic\` under Valgrind's memcheck..."
$( QUIET) rm -f valgrind-*.log $( TEST_DB) $( TEST_LOG) .gz && ( set -o pipefail; ( \
2021-07-12 15:44:00 +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_SMOKE_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 && \
2021-07-12 15:44:00 +08:00
$( VALGRIND) ./mdbx_test --mode= -writemap,-nosync-safe,-lifo --progress --console= no --repeat= 4 --pathname= $( TEST_DB) --dont-cleanup-after $( MDBX_SMOKE_EXTRA) basic && \
2020-05-04 00:34:47 +08:00
$( VALGRIND) ./mdbx_chk -vvn $( TEST_DB) && \
$( VALGRIND) ./mdbx_chk -vvn $( TEST_DB) -copy \
2021-06-26 22:35:56 +08:00
) | tee >( gzip --stdout >$( TEST_LOG) .gz) | tail -n 42)
2019-10-11 03:11:28 +08:00
2020-05-04 01:12:09 +08:00
gcc-analyzer :
2021-05-02 00:34:46 +08:00
@echo ' RE-BUILD with `-fanalyzer` option...'
2020-05-04 01:12:09 +08:00
@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)"
2021-07-25 22:24:05 +08:00
$( QUIET) $( MAKE) IOARENA = false CXXSTD = $( CXXSTD) CFLAGS_EXTRA = "-Og -fanalyzer -Wno-error" build-test
2020-05-04 01:12:09 +08:00
test-ubsan :
2021-07-06 20:37:10 +08:00
@echo ' RE-TEST with `-fsanitize=undefined` option...'
2022-08-12 00:39:14 +08:00
$( QUIET) $( MAKE) IOARENA = false CXXSTD = $( CXXSTD) CFLAGS_EXTRA = "-DENABLE_UBSAN -Ofast -fsanitize=undefined -fsanitize-undefined-trap-on-error" test
2020-05-04 01:12:09 +08:00
test-asan :
2021-07-06 20:37:10 +08:00
@echo ' RE-TEST with `-fsanitize=address` option...'
2021-07-25 22:24:05 +08:00
$( QUIET) $( MAKE) IOARENA = false CXXSTD = $( CXXSTD) CFLAGS_EXTRA = "-Os -fsanitize=address" test
2020-05-04 01:12:09 +08:00
test-leak :
2021-07-06 20:37:10 +08:00
@echo ' RE-TEST with `-fsanitize=leak` option...'
2021-07-25 22:24:05 +08:00
$( QUIET) $( MAKE) IOARENA = false CXXSTD = $( CXXSTD) CFLAGS_EXTRA = "-fsanitize=leak" test
2020-05-04 01:12:09 +08:00
mdbx_example : mdbx .h example /example -mdbx .c libmdbx .$( SO_SUFFIX )
2021-05-02 00:34:46 +08:00
@echo ' CC+LD $@'
$( QUIET) $( CC) $( CFLAGS) -I. example/example-mdbx.c ./libmdbx.$( SO_SUFFIX) -o $@
2020-05-04 01:12:09 +08:00
build-test : all mdbx_example mdbx_test
2019-09-10 07:19:35 +08:00
d e f i n e t e s t - r u l e
2022-11-08 21:17:14 +08:00
$(patsubst %.c++,%.o,$(1)) : $( 1) $( TEST_INC ) $( HEADERS ) $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' CC $$@'
$( QUIET) $$ ( CXX) $$ ( CXXFLAGS) $$ ( MDBX_BUILD_OPTIONS) -c $( 1) -o $$ @
2019-09-10 07:19:35 +08:00
e n d e f
$( foreach file ,$ ( TEST_SRC ) ,$ ( eval $ ( call test -rule ,$ ( file ) ) ) )
2020-04-15 22:09:37 +08:00
mdbx_% : src /mdbx_ %.c libmdbx .a
2021-05-02 00:34:46 +08:00
@echo ' CC+LD $@'
$( QUIET) $( CC) $( CFLAGS) $( MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $( EXE_LDFLAGS) $( LIBS) -o $@
2019-09-10 07:19:35 +08:00
2022-03-27 19:01:18 +08:00
mdbx_%.static : src /mdbx_ %.c mdbx -static .o
@echo ' CC+LD $@'
$( QUIET) $( CC) $( CFLAGS) $( MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $( EXE_LDFLAGS) $( LIBS) -static -Wl,--strip-all -o $@
mdbx_%.static-lto : src /mdbx_ %.c src /config .h src /version .c src /alloy .c $( ALLOY_DEPS )
@echo ' CC+LD $@'
2022-03-30 23:13:44 +08:00
$( QUIET) $( CC) $( CFLAGS) -Os -flto $( MDBX_BUILD_OPTIONS) '-DLIBMDBX_API=' '-DMDBX_CONFIG_H="config.h"' \
2022-03-27 19:01:18 +08:00
$< src/alloy.c $( EXE_LDFLAGS) $( LIBS) -static -Wl,--strip-all -o $@
2019-09-10 07:19:35 +08:00
mdbx_test : $( TEST_OBJ ) libmdbx .$( SO_SUFFIX )
2021-05-02 00:34:46 +08:00
@echo ' LD $@'
$( QUIET) $( CXX) $( CXXFLAGS) $( TEST_OBJ) -Wl,-rpath . -L . -l mdbx $( EXE_LDFLAGS) $( LIBS) -o $@
2019-09-10 07:19:35 +08:00
2021-05-13 17:19:18 +08:00
$(git_DIR)/HEAD $(git_DIR)/index $(git_DIR)/refs/tags :
@echo '*** ' >& 2
@echo '*** Please don' 't use tarballs nor zips which are automatically provided by Github !' >& 2
@echo '*** These archives do not contain version information and thus are unfit to build libmdbx.' >& 2
@echo '*** You can vote for ability of disabling auto-creation such unsuitable archives at https://github.community/t/disable-tarball' >& 2
@echo '*** ' >& 2
@echo '*** Instead of above, just clone the git repository, either download a tarball or zip with the properly amalgamated source core.' >& 2
@echo '*** For embedding libmdbx use a git-submodule or the amalgamated source code.' >& 2
@echo '*** ' >& 2
@echo '*** Please, avoid using any other techniques.' >& 2
@echo '*** ' >& 2
@false
2019-10-11 20:54:54 +08:00
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
2021-05-02 00:34:46 +08:00
@echo ' MAKE $@'
$( QUIET) 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) | " \
2021-06-26 22:35:56 +08:00
src/version.c.in >$@
2019-09-05 16:57:52 +08:00
2021-07-15 21:55:38 +08:00
src/config.h : buildflags .tag src /version .c $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' MAKE $@'
2021-06-02 19:44:58 +08:00
$( QUIET) ( echo '#define MDBX_BUILD_TIMESTAMP "$(MDBX_BUILD_TIMESTAMP)"' \
2021-07-15 21:55:38 +08:00
&& echo " #define MDBX_BUILD_FLAGS \" $$ (cat buildflags.tag)\" " \
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)' \
2021-06-26 22:35:56 +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 ) )
2021-05-02 00:34:46 +08:00
@echo ' CC $@'
$( QUIET) $( CC) $( CFLAGS) $( MDBX_BUILD_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 ) )
2021-05-02 00:34:46 +08:00
@echo ' CC $@'
$( QUIET) $( CC) $( CFLAGS) $( MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c src/alloy.c -o $@
2019-09-10 07:19:35 +08:00
2022-04-28 05:41:45 +08:00
docs/Doxyfile : docs /Doxyfile .in src /version .c $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' MAKE $@'
$( QUIET) sed \
2020-07-12 03:27:29 +08:00
-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) | " \
2021-06-26 22:35:56 +08:00
docs/Doxyfile.in >$@
2020-07-12 03:27:29 +08:00
2020-07-21 06:24:29 +08:00
d e f i n e m d - e x t r a c t - s e c t i o n
2022-04-28 05:41:45 +08:00
docs/__$(1).md : $( 2) $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' EXTRACT $1'
2022-04-28 05:41:45 +08:00
$( QUIET) sed -n '/<!-- section-begin $(1) -->/,/<!-- section-end -->/p' $( 2) >$$ @ && test -s $$ @
2020-07-21 06:24:29 +08:00
e n d e f
$( foreach section ,overview mithril characteristics improvements history usage performance bindings ,$ ( eval $ ( call md -extract -section ,$ ( section ) ,README .md ) ) )
2022-06-01 21:15:32 +08:00
docs/contrib.fame : src /version .c $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' MAKE $@'
2022-06-01 21:15:32 +08:00
$( QUIET) echo "" > $@ && git fame --show-email --format= md --silent-progress -w -M -C | grep '^|' >> $@
docs/overall.md : docs /__overview .md docs /_toc .md docs /__mithril .md docs /__history .md AUTHORS docs /contrib .fame LICENSE $( lastword $ ( MAKEFILE_LIST ) )
@echo ' MAKE $@'
$( QUIET) echo -e "\\mainpage Overall\n\\section brief Brief" | cat - $( filter %.md, $^) >$@ && echo -e "\n\n\nLicense\n=======\n" | cat AUTHORS docs/contrib.fame - 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
2021-05-02 00:34:46 +08:00
@echo ' MAKE $@'
2022-04-28 05:41:45 +08:00
$( QUIET) cat $^ | sed 's/^Performance comparison$$/Performance comparison {#performance}/;s/^Improvements beyond LMDB$$/Improvements beyond LMDB {#improvements}/' >$@
2020-07-21 06:24:29 +08:00
docs/usage.md : docs /__usage .md docs /_starting .md docs /__bindings .md
2021-05-02 00:34:46 +08:00
@echo ' MAKE $@'
2021-06-26 22:35:56 +08:00
$( QUIET) echo -e "\\page usage Usage\n\\section getting Building & Embedding" | cat - $^ | sed 's/^Bindings$$/Bindings {#bindings}/' >$@
2020-07-21 06:24:29 +08:00
2022-04-28 05:41:45 +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 $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' RUNNING doxygen...'
$( QUIET) rm -rf docs/html && \
2021-06-26 22:35:56 +08:00
cat mdbx.h | tr '\n' '\r' | sed -e 's/LIBMDBX_INLINE_API\s*(\s*\([^,]\+\),\s*\([^,]\+\),\s*(\s*\([^)]\+\)\s*)\s*)\s*{/inline \1 \2(\3) {/g' | tr '\r' '\n' >docs/mdbx.h && \
2021-05-02 00:34:46 +08:00
cp mdbx.h++ src/options.h ChangeLog.md docs/ && ( cd docs && doxygen Doxyfile $( HUSH) ) && cp AUTHORS LICENSE docs/html/
2020-08-23 01:19:46 +08:00
mdbx++-dylib.o : src /config .h src /mdbx .c ++ mdbx .h mdbx .h ++ $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' CC $@'
$( QUIET) $( CXX) $( CXXFLAGS) $( MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -DLIBMDBX_EXPORTS= 1 -c src/mdbx.c++ -o $@
2020-08-23 01:19:46 +08:00
mdbx++-static.o : src /config .h src /mdbx .c ++ mdbx .h mdbx .h ++ $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' CC $@'
$( QUIET) $( CXX) $( CXXFLAGS) $( MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c src/mdbx.c++ -o $@
2020-07-12 03:27:29 +08:00
2022-04-24 03:18:22 +08:00
dist : tags dist -checked .tag libmdbx -sources -$( MDBX_VERSION_IDENT ) .tar .gz $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' AMALGAMATION is done'
2020-11-18 20:10:19 +08:00
tags :
2021-05-02 00:34:46 +08:00
@echo ' FETCH git tags...'
$( QUIET) git fetch --tags --force
2019-09-10 07:19:35 +08:00
2022-04-24 16:08:41 +08:00
release-assets : libmdbx -amalgamated -$( MDBX_GIT_VERSION ) .zpaq \
libmdbx-amalgamated-$( MDBX_GIT_VERSION) .tar.xz \
libmdbx-amalgamated-$( MDBX_GIT_VERSION) .tar.bz2 \
libmdbx-amalgamated-$( MDBX_GIT_VERSION) .tar.gz \
libmdbx-amalgamated-$( subst .,_,$( MDBX_GIT_VERSION) ) .zip
2022-04-24 05:06:52 +08:00
$( QUIET) ( [ \
" $$ (set -o pipefail; git describe | sed -n '/^v[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\} $$ /p' || echo fail-left) " \
= = \
" $$ (git describe --tags --dirty=-dirty || echo fail-right) " ] \
|| ( echo 'ERROR: Is not a valid release because not in the clean state with a suitable annotated tag!!!' >& 2 && false ) ) \
&& echo ' RELEASE ASSETS are done'
2020-06-04 22:13:42 +08:00
2021-01-22 19:17:53 +08:00
dist-checked.tag : $( addprefix dist /, $ ( DIST_SRC ) $ ( DIST_EXTRA ) )
2021-05-02 00:34:46 +08:00
@echo -n ' VERIFY amalgamated sources...'
2021-07-26 05:45:25 +08:00
$( QUIET) rm -rf $@ dist/@tmp-shared_internals.inc \
2021-04-30 00:50:25 +08:00
&& if grep -R "define xMDBX_ALLOY" dist | grep -q MDBX_BUILD_SOURCERY; then echo "sed output is WRONG!" >& 2; exit 2; fi \
2021-07-26 05:45:25 +08:00
&& rm -rf dist-check && cp -r -p dist dist-check && ( $( MAKE) IOARENA = false CXXSTD = $( CXXSTD) -C dist-check >dist-check.log 2>dist-check.err || ( cat dist-check.err && exit 1) ) \
&& touch $@ || ( echo " FAILED! See dist-check.log and dist-check.err" >& 2; exit 2) && echo " Ok"
2021-01-22 19:17:53 +08:00
2022-04-24 05:06:52 +08:00
%.tar.gz : dist -checked .tag
2021-05-02 00:34:46 +08:00
@echo ' CREATE $@'
2021-06-26 22:35:56 +08:00
$( QUIET) $( 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-10 07:19:35 +08:00
2022-04-24 16:08:41 +08:00
%.tar.xz : dist -checked .tag
@echo ' CREATE $@'
$( QUIET) $( TAR) -c $( shell LC_ALL = C $( TAR) --help | grep -q -- '--owner' && echo '--owner=0 --group=0' ) -f - -C dist $( DIST_SRC) $( DIST_EXTRA) | xz -9 -z >$@
%.tar.bz2 : dist -checked .tag
@echo ' CREATE $@'
$( QUIET) $( TAR) -c $( shell LC_ALL = C $( TAR) --help | grep -q -- '--owner' && echo '--owner=0 --group=0' ) -f - -C dist $( DIST_SRC) $( DIST_EXTRA) | bzip2 -9 -z >$@
2022-04-24 05:06:52 +08:00
%.zip : dist -checked .tag
2021-05-02 00:34:46 +08:00
@echo ' CREATE $@'
2022-04-24 16:08:41 +08:00
$( QUIET) rm -rf $@ && ( cd dist && $( ZIP) -9 ../$@ $( DIST_SRC) $( DIST_EXTRA) ) & >zip.log
%.zpaq : dist -checked .tag
@echo ' CREATE $@'
$( QUIET) rm -rf $@ && ( cd dist && zpaq a ../$@ $( DIST_SRC) $( DIST_EXTRA) -m59) & >zpaq.log
2020-06-04 22:13:42 +08:00
2020-04-15 22:09:37 +08:00
dist/mdbx.h : mdbx .h src /version .c $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' COPY $@'
$( QUIET) mkdir -p dist && cp $< $@
2019-09-10 07:19:35 +08:00
2020-08-23 01:19:46 +08:00
dist/mdbx.h++ : mdbx .h ++ src /version .c $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' COPY $@'
$( QUIET) mkdir -p dist && cp $< $@
2020-08-23 01:19:46 +08:00
2020-04-15 22:09:37 +08:00
dist/@tmp-shared_internals.inc : src /version .c $( ALLOY_DEPS ) $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' ALLOYING...'
$( QUIET) mkdir -p dist \
2021-06-26 22:35:56 +08:00
&& echo '#define xMDBX_ALLOY 1' >dist/@tmp-sed.inc && echo '#define MDBX_BUILD_SOURCERY $(MDBX_BUILD_SOURCERY)' >>dist/@tmp-sed.inc \
2021-01-26 07:37:18 +08:00
&& sed \
-e '/#pragma once/r dist/@tmp-sed.inc' \
2020-04-15 22:09:37 +08:00
-e 's|#include "../mdbx.h"|@INCLUDE "mdbx.h"|' \
2022-06-02 23:59:58 +08:00
-e '/#include "base.h"/r src/base.h' \
2020-04-15 22:09:37 +08:00
-e '/#include "osal.h"/r src/osal.h' \
-e '/#include "options.h"/r src/options.h' \
2022-05-08 04:41:45 +08:00
-e '/ clang-format o/d' -e '/ \*INDENT-O/d' \
2021-06-26 22:35:56 +08:00
src/internals.h >$@ \
2021-01-26 07:37:18 +08:00
&& rm -rf dist/@tmp-sed.inc
2019-09-10 07:19:35 +08:00
dist/mdbx.c : dist /@tmp -shared_internals .inc $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' MAKE $@'
$( QUIET) mkdir -p dist && ( cat dist/@tmp-shared_internals.inc \
2022-01-04 23:41:53 +08:00
&& cat src/core.c src/osal.c src/version.c src/lck-windows.c src/lck-posix.c | sed \
-e '/#include "debug_begin.h"/r src/debug_begin.h' \
-e '/#include "debug_end.h"/r src/debug_end.h' \
2022-05-08 04:41:45 +08:00
) | sed -e '/#include "/d;/#pragma once/d' -e 's|@INCLUDE|#include|' \
-e '/ clang-format o/d;/ \*INDENT-O/d' >$@
2019-09-10 07:19:35 +08:00
2020-08-23 01:19:46 +08:00
dist/mdbx.c++ : dist /@tmp -shared_internals .inc src /mdbx .c ++ $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' MAKE $@'
$( QUIET) mkdir -p dist && ( cat dist/@tmp-shared_internals.inc && cat src/mdbx.c++) \
2022-05-08 04:41:45 +08:00
| sed -e '/#include "/d;/#pragma once/d' -e 's|@INCLUDE|#include|;s|"mdbx.h"|"mdbx.h++"|' \
-e '/ clang-format o/d;/ \*INDENT-O/d' >$@
2020-08-23 01:19:46 +08:00
2019-09-10 07:19:35 +08:00
d e f i n e d i s t - t o o l - r u l e
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) )
2021-05-02 00:34:46 +08:00
@echo ' MAKE $$@'
$( QUIET) 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' \
2022-05-08 04:41:45 +08:00
-e '/ clang-format o/d' -e '/ \*INDENT-O/d' \
2020-04-15 22:09:37 +08:00
src/$( 1) .c \
2022-05-08 04:41:45 +08:00
| sed -e '/#include "/d;/#pragma once/d;/#define xMDBX_ALLOY/d' -e 's|@INCLUDE|#include|' \
-e '/ clang-format o/d;/ \*INDENT-O/d' >$$ @
2017-03-16 23:09:27 +08:00
2017-05-24 18:59:50 +08:00
e n d e f
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
d e f i n e d i s t - e x t r a - r u l e
dist/$(1) : $( 1)
2021-05-02 00:34:46 +08:00
@echo ' REFINE $$@'
2021-06-26 22:35:56 +08:00
$( QUIET) mkdir -p $$ ( dir $$ @) && sed -e '/^#> dist-cutoff-begin/,/^#< dist-cutoff-end/d' $$ < >$$ @
2020-04-15 22:09:37 +08:00
e n d e f
2021-06-24 19:56:18 +08:00
$( foreach file ,$ ( filter -out man 1/% VERSION .txt %.in ntdll .def ,$ ( DIST_EXTRA ) ) ,$ ( eval $ ( call dist -extra -rule ,$ ( file ) ) ) )
2020-04-15 22:09:37 +08:00
2021-06-24 19:56:18 +08:00
dist/VERSION.txt : src /version .c
2021-05-02 00:34:46 +08:00
@echo ' MAKE $@'
2021-06-26 22:35:56 +08:00
$( QUIET) 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
2021-05-02 00:34:46 +08:00
@echo ' COPY $@'
$( QUIET) mkdir -p dist/cmake/ && cp $< $@
2020-05-10 08:41:28 +08:00
2020-04-15 22:09:37 +08:00
dist/config.h.in : src /config .h .in
2021-05-02 00:34:46 +08:00
@echo ' COPY $@'
$( QUIET) mkdir -p dist/cmake/ && cp $< $@
2020-04-15 22:09:37 +08:00
2019-09-11 01:00:54 +08:00
dist/man1/mdbx_%.1 : src /man 1/mdbx_ %.1
2021-05-02 00:34:46 +08:00
@echo ' COPY $@'
$( QUIET) mkdir -p dist/man1/ && cp $< $@
2020-04-15 22:09:37 +08:00
2019-09-10 07:19:35 +08:00
e n d i f
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
2021-08-26 07:23:31 +08:00
CROSS_LIST = 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
2021-05-02 00:34:46 +08:00
## On Ubuntu Focal (20.04) with QEMU 4.2 (1:4.2-3ubuntu6.6) & GCC 9.3 (9.3.0-17ubuntu1~20.04)
2020-09-21 06:39:17 +08:00
# 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)
2022-10-11 00:27:34 +08:00
CROSS_LIST_NOQEMU = sparc64-linux-gnu-gcc alpha-linux-gnu-gcc riscv64-linux-gnu-gcc
2019-09-10 07:19:35 +08:00
cross-gcc :
2021-05-02 00:34:46 +08:00
@echo ' Re-building by cross-compiler for: $(CROSS_LIST_NOQEMU) $(CROSS_LIST)'
2019-09-10 07:19:35 +08:00
@echo "CORRESPONDING CROSS-COMPILERs ARE REQUIRED."
2022-10-11 00:27:34 +08:00
@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 riscv64-linux-gnu-gcc"
2021-05-02 00:34:46 +08:00
$( QUIET) for CC in $( CROSS_LIST_NOQEMU) $( CROSS_LIST) ; do \
2019-09-10 07:19:35 +08:00
echo " ===================== $$ CC " ; \
2021-07-25 22:24:05 +08:00
$( MAKE) IOARENA = false CXXSTD = clean && CC = $$ CC CXX = $$ ( echo $$ CC | sed 's/-gcc/-g++/' ) EXE_LDFLAGS = -static $( MAKE) IOARENA = false 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 :
2021-05-02 00:34:46 +08:00
@echo ' Re-building by cross-compiler and re-check by QEMU for: $(CROSS_LIST)'
2019-09-10 07:19:35 +08:00
@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"
2021-05-02 00:34:46 +08:00
$( QUIET) for CC in $( CROSS_LIST) ; do \
2019-09-10 07:19:35 +08:00
echo " ===================== $$ CC + qemu " ; \
2021-07-25 22:24:05 +08:00
$( MAKE) IOARENA = false CXXSTD = clean && \
2021-04-30 19:05:36 +08:00
CC = $$ CC CXX = $$ ( echo $$ CC | sed 's/-gcc/-g++/' ) EXE_LDFLAGS = -static MDBX_BUILD_OPTIONS = " -DMDBX_SAFE4QEMU $( MDBX_BUILD_OPTIONS) " \
2021-08-26 22:56:39 +08:00
$( MAKE) IOARENA = false smoke-singleprocess test-singleprocess || exit $$ ?; \
2019-09-10 07:19:35 +08:00
done
#< dist-cutoff-end
2021-03-26 19:45:03 +08:00
2019-09-11 01:00:54 +08:00
install : $( LIBRARIES ) $( TOOLS ) $( HEADERS )
2021-05-02 00:34:46 +08:00
@echo ' INSTALLING...'
2021-06-17 19:20:32 +08:00
$( QUIET) mkdir -p $( DESTDIR) $( prefix) /bin$( suffix) && \
$( INSTALL) -p $( EXE_INSTALL_FLAGS) $( TOOLS) $( DESTDIR) $( prefix) /bin$( suffix) / && \
mkdir -p $( DESTDIR) $( prefix) /lib$( suffix) / && \
$( INSTALL) -p $( EXE_INSTALL_FLAGS) $( filter-out libmdbx.a,$( LIBRARIES) ) $( DESTDIR) $( prefix) /lib$( suffix) / && \
mkdir -p $( DESTDIR) $( prefix) /lib$( suffix) / && \
$( INSTALL) -p libmdbx.a $( DESTDIR) $( prefix) /lib$( suffix) / && \
mkdir -p $( DESTDIR) $( prefix) /include/ && \
$( INSTALL) -p -m 444 $( HEADERS) $( DESTDIR) $( prefix) /include/ && \
mkdir -p $( DESTDIR) $( mandir) /man1/ && \
$( INSTALL) -p -m 444 $( addprefix $( MAN_SRCDIR) , $( MANPAGES) ) $( DESTDIR) $( mandir) /man1/
2021-03-26 19:45:03 +08:00
install-strip : EXE_INSTALL_FLAGS = -s
install-strip : install
install-no-strip : EXE_INSTALL_FLAGS =
install-no-strip : install
2020-04-06 07:24:16 +08:00
uninstall :
2021-05-02 00:34:46 +08:00
@echo ' UNINSTALLING/REMOVE...'
$( QUIET) rm -f $( addprefix $( DESTDIR) $( prefix) /bin$( suffix) /,$( TOOLS) ) \
2020-04-06 07:24:16 +08:00
$( 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
2021-07-25 22:24:05 +08:00
i f e q ( $( origin IOARENA ) , u n d e f i n e d )
IOARENA := $( shell \
2019-09-10 07:19:35 +08:00
( test -x ../ioarena/@BUILD/src/ioarena && echo ../ioarena/@BUILD/src/ioarena) || \
( test -x ../../@BUILD/src/ioarena && echo ../../@BUILD/src/ioarena) || \
2021-05-13 17:19:18 +08:00
( test -x ../../src/ioarena && echo ../../src/ioarena) || which ioarena 2>& - || \
2021-07-25 22:24:05 +08:00
( echo false && echo '$(TIP) Clone and build the https://github.com/pmwkaa/ioarena.git within a neighbouring directory for availability of benchmarking.' >& 2) )
e n d i f
2019-09-10 07:19:35 +08:00
NN ?= 25000000
2020-10-01 04:42:55 +08:00
BENCH_CRUD_MODE ?= nosync
2016-03-20 02:06:05 +08:00
2021-05-01 06:02:28 +08:00
bench-clean :
2021-05-02 00:34:46 +08:00
@echo ' REMOVE bench-*.txt _ioarena/*'
$( QUIET) rm -rf bench-*.txt _ioarena/*
2016-03-20 02:06:05 +08:00
2021-05-01 06:02:28 +08:00
re-bench : bench -clean bench
2016-03-20 02:06:05 +08:00
2021-07-25 23:18:57 +08:00
i f e q ( $( or $ ( IOARENA ) ,false ) , f a l s e )
bench bench-quartet bench-triplet bench-couple :
$( QUIET) echo 'The `ioarena` benchmark is required.' >& 2 && \
echo 'Please clone and build the https://github.com/pmwkaa/ioarena.git within a neighbouring `ioarena` directory.' >& 2 && \
false
e l s e
.PHONY : bench bench -clean bench -couple re -bench bench -quartet bench -triplet
2016-04-16 02:44:42 +08:00
d e f i n e b e n c h - r u l e
2019-10-11 21:03:51 +08:00
bench-$(1)_$(2).txt : $( 3) $( IOARENA ) $( lastword $ ( MAKEFILE_LIST ) )
2021-05-02 00:34:46 +08:00
@echo ' RUNNING ioarena for $1/$2...'
2022-08-07 00:35:09 +08:00
$( QUIET) ( export LD_LIBRARY_PATH = " ./: $$ $$ {LD_LIBRARY_PATH} " ; \
ldd $( IOARENA) && \
2020-10-01 04:42:55 +08:00
$( IOARENA) -D $( 1) -B crud -m $( BENCH_CRUD_MODE) -n $( 2) \
2022-08-07 00:35:09 +08:00
| tee $$ @ | grep throughput && \
$( IOARENA) -D $( 1) -B iterate,get,iterate,get,iterate -m $( BENCH_CRUD_MODE) -r 4 -n $( 2) \
| tee -a $$ @ | grep throughput \
) || mv -f $$ @ $$ @.error
2016-04-16 02:44:42 +08:00
e n d e f
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 ,sqlite 3,$ ( 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 ) ) )
2017-11-14 01:36:23 +08:00
bench : bench -mdbx_ $( NN ) .txt
bench-quartet : bench -mdbx_ $( NN ) .txt bench -lmdb_ $( NN ) .txt bench -rocksdb_ $( NN ) .txt bench -wiredtiger_ $( NN ) .txt
2020-09-30 18:59:38 +08:00
bench-triplet : bench -mdbx_ $( NN ) .txt bench -lmdb_ $( NN ) .txt bench -sqlite 3_ $( NN ) .txt
2020-10-07 21:14:59 +08:00
bench-couple : bench -mdbx_ $( NN ) .txt bench -lmdb_ $( NN ) .txt
2016-03-20 02:06:05 +08:00
2021-05-01 06:02:28 +08:00
# $(eval $(call bench-rule,debug,10))
# .PHONY: bench-debug
# bench-debug: bench-debug_10.txt
2016-03-20 02:06:05 +08:00
e n d i f