mdbx-build: SunOS/Solaris/OpenIndiana support, etc.

This commit is contained in:
Leonid Yuriev 2019-11-09 15:15:25 +03:00
parent 5af02290e6
commit a7e0b3ccdf
4 changed files with 20 additions and 6 deletions

View File

@ -161,6 +161,9 @@ if(MDBX_BUILD_SHARED_LIBRARY)
if(WIN32) if(WIN32)
target_link_libraries(mdbx PRIVATE ntdll.lib) target_link_libraries(mdbx PRIVATE ntdll.lib)
endif() endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Solaris")
target_link_libraries(mdbx PRIVATE kstat)
endif()
endif() endif()
# static library used for tools, to avoid rpath/dll-path troubles # static library used for tools, to avoid rpath/dll-path troubles
@ -176,6 +179,9 @@ endif()
if(WIN32) if(WIN32)
target_link_libraries(mdbx-static INTERFACE ntdll.lib) target_link_libraries(mdbx-static INTERFACE ntdll.lib)
endif() endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Solaris")
target_link_libraries(mdbx-static INTERFACE kstat)
endif()
# mdbx-tools # mdbx-tools
foreach(TOOL mdbx_chk mdbx_copy mdbx_stat mdbx_dump mdbx_load) foreach(TOOL mdbx_chk mdbx_copy mdbx_stat mdbx_dump mdbx_load)

View File

@ -21,11 +21,13 @@ suffix ?=
CC ?= gcc CC ?= gcc
LD ?= ld LD ?= ld
MDBX_OPTIONS ?= -DNDEBUG=1 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 # -Wno-tautological-compare
# LY: '--no-as-needed,-lrt' for ability to built with modern glibc, but then run with the old # HITH: Try append '--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') 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 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)) 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)) 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 && rm dist/@tmp-shared_internals.inc
dist/mdbx.h: mdbx.h src/elements/version.c $(lastword $(MAKEFILE_LIST)) dist/mdbx.h: mdbx.h src/elements/version.c $(lastword $(MAKEFILE_LIST))

View File

@ -1,3 +1,5 @@
all check test dist: Makefile 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 $@

View File

@ -101,6 +101,10 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
endif() endif()
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 set_target_properties(mdbx PROPERTIES
INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}> INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>
C_STANDARD ${MDBX_C_STANDARD} C_STANDARD_REQUIRED ON C_STANDARD ${MDBX_C_STANDARD} C_STANDARD_REQUIRED ON