From a7e0b3ccdf8c78a8bcc0c6f982ca85a8401fd3aa Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Sat, 9 Nov 2019 15:15:25 +0300 Subject: [PATCH] mdbx-build: SunOS/Solaris/OpenIndiana support, etc. --- CMakeLists.dist-minimal | 6 ++++++ GNUmakefile | 10 ++++++---- Makefile | 6 ++++-- src/CMakeLists.txt | 4 ++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CMakeLists.dist-minimal b/CMakeLists.dist-minimal index 1f138af6..fde7d3cf 100644 --- a/CMakeLists.dist-minimal +++ b/CMakeLists.dist-minimal @@ -161,6 +161,9 @@ if(MDBX_BUILD_SHARED_LIBRARY) if(WIN32) target_link_libraries(mdbx PRIVATE ntdll.lib) endif() + if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Solaris") + target_link_libraries(mdbx PRIVATE kstat) + endif() endif() # static library used for tools, to avoid rpath/dll-path troubles @@ -176,6 +179,9 @@ endif() if(WIN32) target_link_libraries(mdbx-static INTERFACE ntdll.lib) endif() +if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Solaris") + target_link_libraries(mdbx-static INTERFACE kstat) +endif() # mdbx-tools foreach(TOOL mdbx_chk mdbx_copy mdbx_stat mdbx_dump mdbx_load) diff --git a/GNUmakefile b/GNUmakefile index d470d655..430b052f 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -21,11 +21,13 @@ suffix ?= CC ?= gcc LD ?= ld MDBX_OPTIONS ?= -DNDEBUG=1 -CFLAGS ?= -Os -g3 -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread -Wno-error=attributes +CFLAGS ?= -O2 -g -Wall -Werror -Wextra -Wpedantic -ffunction-sections -fPIC -fvisibility=hidden -std=gnu11 -pthread -Wno-error=attributes # -Wno-tautological-compare -# LY: '--no-as-needed,-lrt' for ability to built with modern glibc, but then run with the old -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') +# HITH: Try append '--no-as-needed,-lrt' for ability to built with modern glibc, but then run with the old. +LIBS ?= $(shell uname | grep -qi SunOS && echo "-lkstat") $(shell uname | grep -qi -e Darwin -e OpenBSD || echo "-lrt") + +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') $(LIBS) EXE_LDFLAGS ?= -pthread ################################################################################ @@ -209,7 +211,7 @@ mdbx-static.o: src/elements/config.h src/elements/version.c src/alloy.c $(ALLOY_ dist: libmdbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz $(lastword $(MAKEFILE_LIST)) libmdbx-sources-$(MDBX_VERSION_SUFFIX).tar.gz: $(addprefix dist/, $(DIST_SRC) $(DIST_EXTRA)) $(addprefix dist/man1/,$(MANPAGES)) - tar -c -a -f $@ --owner=0 --group=0 -C dist $(DIST_SRC) $(DIST_EXTRA) \ + tar -c --owner=0 --group=0 -C dist $(DIST_SRC) $(DIST_EXTRA) -f - | gzip -c > $@ \ && rm dist/@tmp-shared_internals.inc dist/mdbx.h: mdbx.h src/elements/version.c $(lastword $(MAKEFILE_LIST)) diff --git a/Makefile b/Makefile index 070257a8..c1b6f68a 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ all check test dist: Makefile - @CC=$(CC) CXX=$(CXX) `which gmake || which gnumake || echo 'echo "GNU Make is required"'` $(MAKEFLAGS) -f GNUmakefile $@ - + @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` \ + `which gmake || which gnumake || echo 'echo "GNU Make is required"; exit 2;'` \ + $(MAKEFLAGS) -f GNUmakefile $@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 04aead5f..7018135c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -101,6 +101,10 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") endif() endif() +if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Solaris") + target_link_libraries(mdbx ${MDBX_LIBDEP_MODE} kstat) +endif() + set_target_properties(mdbx PROPERTIES INTERPROCEDURAL_OPTIMIZATION $ C_STANDARD ${MDBX_C_STANDARD} C_STANDARD_REQUIRED ON