diff --git a/CMakeLists.txt b/CMakeLists.txt index 0015adc7..dfff4a37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -750,7 +750,9 @@ endif(MDBX_INSTALL_STATIC) ################################################################################ # collect options & build info -string(TIMESTAMP MDBX_BUILD_TIMESTAMP UTC) +if(NOT DEFINED MDBX_BUILD_TIMESTAMP) + string(TIMESTAMP MDBX_BUILD_TIMESTAMP UTC) +endif() set(MDBX_BUILD_FLAGS ${CMAKE_C_FLAGS}) if(MDBX_BUILD_CXX) set(MDBX_BUILD_FLAGS ${CMAKE_CXX_FLAGS}) diff --git a/ChangeLog.md b/ChangeLog.md index 24dd621e..fce9260a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -17,6 +17,10 @@ ChangeLog - Finalize C++ API (few typos and trivia bugs are still likely for now). - Packages for [Astra Linux](https://astralinux.ru/), [ALT Linux](https://www.altlinux.org/), [ROSA Linux](https://www.rosalinux.ru/), etc. +New features: + + - Allow to predefine/override `MDBX_BUILD_TIMESTAMP` for builds reproducibility (https://github.com/erthink/libmdbx/issues/201). + ## v0.10.1 at 2021-06-01 diff --git a/GNUmakefile b/GNUmakefile index 01f52189..15d1d52f 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -29,7 +29,8 @@ INSTALL ?= install CC ?= gcc CFLAGS_EXTRA ?= LD ?= ld -MDBX_BUILD_OPTIONS ?= -DNDEBUG=1 +MDBX_BUILD_OPTIONS ?=-DNDEBUG=1 +MDBX_BUILD_TIMESTAMP ?=$(shell date +%Y-%m-%dT%H:%M:%S%z) CFLAGS ?= -std=gnu11 -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -pthread -Wno-error=attributes $(CFLAGS_EXTRA) # -Wno-tautological-compare CXX ?= g++ @@ -123,7 +124,8 @@ help: #< dist-cutoff-end show-options: - @echo " MDBX_BUILD_OPTIONS =$(MDBX_BUILD_OPTIONS)" + @echo " MDBX_BUILD_OPTIONS = $(MDBX_BUILD_OPTIONS)" + @echo " MDBX_BUILD_TIMESTAMP = $(MDBX_BUILD_TIMESTAMP)" @echo '## TIP: Use `make options` to listing available build options.' @echo " CFLAGS =$(CFLAGS)" @echo " CXXFLAGS =$(CXXFLAGS)" @@ -149,7 +151,8 @@ options: @echo " EXE_LDFLAGS =$(EXE_LDFLAGS)" @echo " LIBS =$(LIBS)" @echo "" - @echo " MDBX_BUILD_OPTIONS =$(MDBX_BUILD_OPTIONS)" + @echo " MDBX_BUILD_OPTIONS = $(MDBX_BUILD_OPTIONS)" + @echo " MDBX_BUILD_TIMESTAMP = $(MDBX_BUILD_TIMESTAMP)" @echo "" @echo "## Assortment items for MDBX_BUILD_OPTIONS:" @echo "## Note that the defaults should already be correct for most platforms;" @@ -198,7 +201,7 @@ MAN_SRCDIR := man1/ config.h: mdbx.c $(lastword $(MAKEFILE_LIST)) @echo ' MAKE $@' - $(QUIET)(echo '#define MDBX_BUILD_TIMESTAMP "$(shell date +%Y-%m-%dT%H:%M:%S%z)"' \ + $(QUIET)(echo '#define MDBX_BUILD_TIMESTAMP "$(MDBX_BUILD_TIMESTAMP)"' \ && echo '#define MDBX_BUILD_FLAGS "$(CXXSTD) $(CFLAGS) $(LDFLAGS) $(LIBS)"' \ && 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)"' \ @@ -388,7 +391,7 @@ src/version.c: src/version.c.in $(lastword $(MAKEFILE_LIST)) $(git_DIR)/HEAD $(g src/config.h: src/version.c $(lastword $(MAKEFILE_LIST)) @echo ' MAKE $@' - $(QUIET)(echo '#define MDBX_BUILD_TIMESTAMP "$(shell date +%Y-%m-%dT%H:%M:%S%z)"' \ + $(QUIET)(echo '#define MDBX_BUILD_TIMESTAMP "$(MDBX_BUILD_TIMESTAMP)"' \ && echo '#define MDBX_BUILD_FLAGS "$(CXXSTD) $(CFLAGS) $(LDFLAGS) $(LIBS)"' \ && 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)"' \ diff --git a/src/core.c b/src/core.c index 500e481c..b08a00f4 100644 --- a/src/core.c +++ b/src/core.c @@ -21978,7 +21978,7 @@ __dll_export #ifdef MDBX_BUILD_TIMESTAMP MDBX_BUILD_TIMESTAMP #else - __DATE__ " " __TIME__ + "\"" __DATE__ " " __TIME__ "\"" #endif /* MDBX_BUILD_TIMESTAMP */ ,