diff --git a/CMakeLists.txt b/CMakeLists.txt index a1842d8..8f3d311 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -540,12 +540,27 @@ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/../" CACHE PATH "Installation prefix" FORCE) ENDIF() execute_process( - COMMAND sh -c "echo $(../bin/osversion).$(../bin/machinetype)" - OUTPUT_VARIABLE release_dir - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMAND sh "${CMAKE_SOURCE_DIR}/bin/osversion" + OUTPUT_VARIABLE os_ver OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE res ) -INSTALL(TARGETS lde DESTINATION ${release_dir}) +if(NOT res EQUAL 0) + message(FATAL_ERROR "osversion script failed") +endif() + +execute_process( + COMMAND sh "${CMAKE_SOURCE_DIR}/bin/machinetype" + OUTPUT_VARIABLE machine_type + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE res +) +if(NOT res EQUAL 0) + message(FATAL_ERROR "machinetype script failed") +endif() + +set(release_dir "${os_ver}.${machine_type}")INSTALL(TARGETS lde DESTINATION ${release_dir}) + IF(MAIKO_DISPLAY_X11) INSTALL(TARGETS ldex ldeinit DESTINATION ${release_dir}) ENDIF() diff --git a/bin/linux-common.mk b/bin/linux-common.mk index 7129f74..d19943f 100644 --- a/bin/linux-common.mk +++ b/bin/linux-common.mk @@ -2,11 +2,17 @@ include linux-compiler.mk +BSD_CFLAGS := +BSD_LDFLAGS := ifeq ($(USE_LIBBSD),T) - include linux-libbsd.mk -else - BSD_CFLAGS := - BSD_LDFLAGS := + # Use LIBBSD - but only if glibc < 2.38 + # Because we only need strlcat, strlcpy and friends from libbsd + # and they are included in glibc from 2.38 on. + GLIBC_VERSION := $(shell ldd --version | head -1 | sed -e "s/^.*\([0-9]\.[0-9][0-9]\)/\\1/") + GLIBC_CHECK := $(shell echo "$(GLIBC_VERSION) >= 2.38" | bc) + ifneq ($(GLIBC_CHECK),1) + include linux-libbsd.mk + endif endif ifeq ($(USE_DISPLAY),x) @@ -26,7 +32,12 @@ OPTFLAGS ?= -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) $(ADDITIONAL_DFLAGS) LDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS) -LDELDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS) + +ifeq ($(USE_DISPLAY),x) + LDELDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS) +else + LDELDFLAGS = -lc -lm $(BSD_LDFLAGS) +endif OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/linux-libbsd.mk b/bin/linux-libbsd.mk index 733a9f4..dde1ef9 100644 --- a/bin/linux-libbsd.mk +++ b/bin/linux-libbsd.mk @@ -4,7 +4,7 @@ ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),cleanup) - CHK_PKG_CONFIG := $(shell command -v pkg-config) + CHK_PKG_CONFIG := $(shell /bin/sh -c "command -v pkg-config") ifeq ($(CHK_PKG_CONFIG),) # pkg-config not found, print an error $(error "pkg-config not found. Please install it to build this project.") @@ -12,13 +12,15 @@ ifneq ($(MAKECMDGOALS),clean) CHK_LIBBSD_DEV := $(shell pkg-config --exists libbsd-overlay && echo true) ifneq ($(CHK_LIBBSD_DEV),true) - $(error "libbsd-dev (or libbsd-devel) package not found. Please install it to build this project.") + $(error "libbsd-dev (or libbsd-devel) package not found. Please install it to build this project.") endif - endif -endif -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) + BSD_CFLAGS := $(shell pkg-config --cflags libbsd-overlay) + + BSD_LDFLAGS := $(shell pkg-config --libs libbsd-overlay) + + endif # clean +endif # cleanup -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) diff --git a/bin/makefile-linux.386-sdl b/bin/makefile-linux.386-sdl index 18c26fb..f3f6365 100644 --- a/bin/makefile-linux.386-sdl +++ b/bin/makefile-linux.386-sdl @@ -1,7 +1,7 @@ # Options for Linux, Intel 386/486 and SDL -GCC_CFLAGS := -m64 $(GCC_CFLAGS) -CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) +GCC_CFLAGS := -m32 $(GCC_CFLAGS) +CLANG_CFLAGS := -m32 $(CLANG_CFLAGS) USE_DISPLAY=sdl USE_LIBBSD=T