mdbx-make: support for make options to list available build options.

Change-Id: Ib153834241e33c672867aa402d3fc66a06a489fa
This commit is contained in:
Leonid Yuriev 2021-04-30 14:05:36 +03:00
parent 0054f5388a
commit 70b7ec0c1c
5 changed files with 63 additions and 28 deletions

View File

@ -22,7 +22,7 @@ on:
env: env:
COVERITY_SCAN_PROJECT_NAME: 'ReOpen/libmdbx' COVERITY_SCAN_PROJECT_NAME: 'ReOpen/libmdbx'
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
COVERITY_SCAN_BUILD_COMMAND: 'make MDBX_OPTIONS=-DMDBX_DEBUG=2 CXXSTD=-std=gnu++17 build-test' COVERITY_SCAN_BUILD_COMMAND: 'make MDBX_BUILD_OPTIONS=-DMDBX_DEBUG=2 CXXSTD=-std=gnu++17 build-test'
COVERITY_SCAN_NOTIFICATION_EMAIL: 'leo@yuriev.ru' COVERITY_SCAN_NOTIFICATION_EMAIL: 'leo@yuriev.ru'
COVERITY_UNSUPPORTED_COMPILER_INVOCATION: 1 COVERITY_UNSUPPORTED_COMPILER_INVOCATION: 1

View File

@ -70,7 +70,7 @@ script: |
COVERITY_SCAN_PROJECT_NAME="ReOpen/libmdbx" \ COVERITY_SCAN_PROJECT_NAME="ReOpen/libmdbx" \
COVERITY_SCAN_NOTIFICATION_EMAIL="leo@yuriev.ru" \ COVERITY_SCAN_NOTIFICATION_EMAIL="leo@yuriev.ru" \
COVERITY_SCAN_BUILD_COMMAND_PREPEND="" \ COVERITY_SCAN_BUILD_COMMAND_PREPEND="" \
COVERITY_SCAN_BUILD_COMMAND="make MDBX_OPTIONS=-DMDBX_DEBUG=2 CXXSTD=-std=gnu++17 build-test" \ COVERITY_SCAN_BUILD_COMMAND="make MDBX_BUILD_OPTIONS=-DMDBX_DEBUG=2 CXXSTD=-std=gnu++17 build-test" \
COVERITY_SCAN_BRANCH_PATTERN="$TRAVIS_BRANCH" \ COVERITY_SCAN_BRANCH_PATTERN="$TRAVIS_BRANCH" \
bash ./coverity_scan.sh || cat cov-int/scm_log.txt bash ./coverity_scan.sh || cat cov-int/scm_log.txt
fi fi

View File

@ -32,6 +32,7 @@ New features:
- [Ruby bindings](https://rubygems.org/gems/mdbx/) is available now by [Mahlon E. Smith](https://github.com/mahlonsmith). - [Ruby bindings](https://rubygems.org/gems/mdbx/) is available now by [Mahlon E. Smith](https://github.com/mahlonsmith).
- Added `MDBX_ENABLE_MADVISE` build option which controls the use of POSIX `madvise()` hints and friends. - Added `MDBX_ENABLE_MADVISE` build option which controls the use of POSIX `madvise()` hints and friends.
- The internal node sizes were refined, resulting in a reduction in large/overflow pages in some use cases and a slight increase in limits for a keys size. - The internal node sizes were refined, resulting in a reduction in large/overflow pages in some use cases and a slight increase in limits for a keys size.
- Support `make options` to list available build options.
Backward compatibility break: Backward compatibility break:

View File

@ -6,12 +6,11 @@
# #
################################################################################ ################################################################################
# #
# Preprocessor macros (for MDBX_OPTIONS) of interest. # Use `make options` to list the available libmdbx build options.
# #
# Note that the defaults should already be correct for most platforms; # Note that the defaults should already be correct for most platforms;
# you should not need to change any of these. Read their descriptions # you should not need to change any of these. Read their descriptions
# in README and source code (see src/options.h) if you do. # in README and source code (see src/options.h) if you do.
# There may be other macros of interest.
# #
SHELL := env bash SHELL := env bash
@ -30,7 +29,7 @@ INSTALL ?= install
CC ?= gcc CC ?= gcc
CFLAGS_EXTRA ?= CFLAGS_EXTRA ?=
LD ?= ld LD ?= ld
MDBX_OPTIONS ?= -DNDEBUG=1 MDBX_BUILD_OPTIONS ?= -DNDEBUG=1
CFLAGS ?= -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread -Wno-error=attributes $(CFLAGS_EXTRA) CFLAGS ?= -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread -Wno-error=attributes $(CFLAGS_EXTRA)
# -Wno-tautological-compare # -Wno-tautological-compare
CXX ?= g++ CXX ?= g++
@ -46,6 +45,51 @@ EXE_LDFLAGS ?= -pthread
################################################################################ ################################################################################
.PHONY: mdbx all install install-strip install-no-strip clean options
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
all: options $(LIBRARIES) $(TOOLS)
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 ""
@echo " MDBX_BUILD_OPTIONS =$(MDBX_BUILD_OPTIONS)"
@echo ""
@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"
#> dist-cutoff-begin
ifeq ($(wildcard mdbx.c),mdbx.c)
#< dist-cutoff-end
@echo " # in README and source code (see mdbx.c) if you do."
@grep -h '#ifndef MDBX_' mdbx.c | grep -v BUILD | uniq | sed 's/#ifndef / /'
#> dist-cutoff-begin
else
@echo " # in README and source code (see src/options.h) if you do."
@grep -h '#ifndef MDBX_' src/internals.h src/options.h | grep -v BUILD | uniq | sed 's/#ifndef / /'
endif
#< dist-cutoff-end
UNAME := $(shell uname -s 2>/dev/null || echo Unknown) UNAME := $(shell uname -s 2>/dev/null || echo Unknown)
define uname2sosuffix define uname2sosuffix
case "$(UNAME)" in case "$(UNAME)" in
@ -54,16 +98,6 @@ define uname2sosuffix
*) echo so;; *) echo so;;
esac esac
endef endef
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
.PHONY: mdbx all install install-strip install-no-strip clean
all: $(LIBRARIES) $(TOOLS)
mdbx: libmdbx.a libmdbx.$(SO_SUFFIX) mdbx: libmdbx.a libmdbx.$(SO_SUFFIX)
@ -99,19 +133,19 @@ config.h: mdbx.c $(lastword $(MAKEFILE_LIST))
) > $@ ) > $@
mdbx-dylib.o: config.h mdbx.c mdbx.h $(lastword $(MAKEFILE_LIST)) mdbx-dylib.o: config.h mdbx.c mdbx.h $(lastword $(MAKEFILE_LIST))
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -DLIBMDBX_EXPORTS=1 -c mdbx.c -o $@ $(CC) $(CFLAGS) $(MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -DLIBMDBX_EXPORTS=1 -c mdbx.c -o $@
mdbx-static.o: config.h mdbx.c mdbx.h $(lastword $(MAKEFILE_LIST)) mdbx-static.o: config.h mdbx.c mdbx.h $(lastword $(MAKEFILE_LIST))
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c mdbx.c -o $@ $(CC) $(CFLAGS) $(MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c mdbx.c -o $@
mdbx++-dylib.o: config.h mdbx.c++ mdbx.h mdbx.h++ $(lastword $(MAKEFILE_LIST)) 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 $@ $(CXX) $(CXXFLAGS) $(MDBX_BUILD_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)) 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 $@ $(CXX) $(CXXFLAGS) $(MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c mdbx.c++ -o $@
mdbx_%: mdbx_%.c libmdbx.a mdbx_%: mdbx_%.c libmdbx.a
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $(EXE_LDFLAGS) $(LIBS) -o $@ $(CC) $(CFLAGS) $(MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $(EXE_LDFLAGS) $(LIBS) -o $@
#> dist-cutoff-begin #> dist-cutoff-begin
else else
@ -222,13 +256,13 @@ build-test: all mdbx_example mdbx_test
define test-rule define test-rule
$(patsubst %.cc,%.o,$(1)): $(1) $(TEST_INC) mdbx.h $(lastword $(MAKEFILE_LIST)) $(patsubst %.cc,%.o,$(1)): $(1) $(TEST_INC) mdbx.h $(lastword $(MAKEFILE_LIST))
$$(CXX) $$(CXXFLAGS) $$(MDBX_OPTIONS) -c $(1) -o $$@ $$(CXX) $$(CXXFLAGS) $$(MDBX_BUILD_OPTIONS) -c $(1) -o $$@
endef endef
$(foreach file,$(TEST_SRC),$(eval $(call test-rule,$(file)))) $(foreach file,$(TEST_SRC),$(eval $(call test-rule,$(file))))
mdbx_%: src/mdbx_%.c libmdbx.a mdbx_%: src/mdbx_%.c libmdbx.a
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $(EXE_LDFLAGS) $(LIBS) -o $@ $(CC) $(CFLAGS) $(MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' $^ $(EXE_LDFLAGS) $(LIBS) -o $@
mdbx_test: $(TEST_OBJ) libmdbx.$(SO_SUFFIX) mdbx_test: $(TEST_OBJ) libmdbx.$(SO_SUFFIX)
$(CXX) $(CXXFLAGS) $(TEST_OBJ) -Wl,-rpath . -L . -l mdbx $(EXE_LDFLAGS) $(LIBS) -o $@ $(CXX) $(CXXFLAGS) $(TEST_OBJ) -Wl,-rpath . -L . -l mdbx $(EXE_LDFLAGS) $(LIBS) -o $@
@ -256,10 +290,10 @@ src/config.h: src/version.c $(lastword $(MAKEFILE_LIST))
) > $@ ) > $@
mdbx-dylib.o: src/config.h src/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST)) mdbx-dylib.o: src/config.h src/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST))
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -DLIBMDBX_EXPORTS=1 -c src/alloy.c -o $@ $(CC) $(CFLAGS) $(MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -DLIBMDBX_EXPORTS=1 -c src/alloy.c -o $@
mdbx-static.o: src/config.h src/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST)) mdbx-static.o: src/config.h src/version.c src/alloy.c $(ALLOY_DEPS) $(lastword $(MAKEFILE_LIST))
$(CC) $(CFLAGS) $(MDBX_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c src/alloy.c -o $@ $(CC) $(CFLAGS) $(MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c src/alloy.c -o $@
docs/Doxyfile: docs/Doxyfile.in src/version.c docs/Doxyfile: docs/Doxyfile.in src/version.c
sed \ sed \
@ -295,10 +329,10 @@ doxygen: docs/Doxyfile docs/overall.md docs/intro.md docs/usage.md mdbx.h mdbx.h
cp mdbx.h++ src/options.h ChangeLog.md docs/ && (cd docs && doxygen Doxyfile) && cp AUTHORS LICENSE docs/html/ cp 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)) 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 $@ $(CXX) $(CXXFLAGS) $(MDBX_BUILD_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)) 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 $@ $(CXX) $(CXXFLAGS) $(MDBX_BUILD_OPTIONS) '-DMDBX_CONFIG_H="config.h"' -ULIBMDBX_EXPORTS -c src/mdbx.c++ -o $@
.PHONY: dist release-assets tags .PHONY: dist release-assets tags
dist: tags dist-checked.tag libmdbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz $(lastword $(MAKEFILE_LIST)) dist: tags dist-checked.tag libmdbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz $(lastword $(MAKEFILE_LIST))
@ -417,7 +451,7 @@ cross-qemu:
echo "===================== $$CC + qemu"; \ echo "===================== $$CC + qemu"; \
$(MAKE) CXXSTD= clean && \ $(MAKE) CXXSTD= clean && \
MDBX_TEST_EXTRA="$(MDBX_TEST_EXTRA)$$(echo $$CC | grep -q -e alpha -e sparc && echo ' --size-upper=64M --size-lower=64M')" \ MDBX_TEST_EXTRA="$(MDBX_TEST_EXTRA)$$(echo $$CC | grep -q -e alpha -e sparc && echo ' --size-upper=64M --size-lower=64M')" \
CC=$$CC CXX=$$(echo $$CC | sed 's/-gcc/-g++/') EXE_LDFLAGS=-static MDBX_OPTIONS="-DMDBX_SAFE4QEMU $(MDBX_OPTIONS)" \ CC=$$CC CXX=$$(echo $$CC | sed 's/-gcc/-g++/') EXE_LDFLAGS=-static MDBX_BUILD_OPTIONS="-DMDBX_SAFE4QEMU $(MDBX_BUILD_OPTIONS)" \
$(MAKE) test-singleprocess || exit $$?; \ $(MAKE) test-singleprocess || exit $$?; \
done done

View File

@ -1,6 +1,6 @@
# This is thunk-Makefile for calling GNU Make 3.80 or above # This is thunk-Makefile for calling GNU Make 3.80 or above
all bench bench-quartet build-test check clean clean-bench cross-gcc cross-qemu dist doxygen gcc-analyzer install mdbx memcheck reformat release-assets strip test test-asan test-fault test-leak test-singleprocess test-ubsan test-valgrind tools \ all options bench bench-quartet build-test check clean clean-bench cross-gcc cross-qemu dist doxygen gcc-analyzer install mdbx memcheck reformat release-assets strip test test-asan test-fault test-leak test-singleprocess test-ubsan test-valgrind tools \
mdbx_test mdbx_chk mdbx_load mdbx_dump mdbx_stat mdbx_drop mdbx_copy: mdbx_test mdbx_chk mdbx_load mdbx_dump mdbx_stat mdbx_drop mdbx_copy:
@CC=$(CC) \ @CC=$(CC) \
CXX=`if test -n "$(CXX)" && which "$(CXX)" > /dev/null; then echo "$(CXX)"; elif test -n "$(CCC)" && which "$(CCC)" > /dev/null; then echo "$(CCC)"; else echo "c++"; fi` \ CXX=`if test -n "$(CXX)" && which "$(CXX)" > /dev/null; then echo "$(CXX)"; elif test -n "$(CCC)" && which "$(CCC)" > /dev/null; then echo "$(CCC)"; else echo "c++"; fi` \