mirror of https://github.com/upx/upx.git
cmake and make: minor updates
This commit is contained in:
parent
72f3e9b25a
commit
d9657e9831
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR)
|
||||||
|
|
||||||
# compilation config options
|
# compilation config options
|
||||||
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||||
|
@ -139,7 +139,7 @@ if(MSVC)
|
||||||
else()
|
else()
|
||||||
# protect against security threats caused by misguided compiler "optimizations"
|
# protect against security threats caused by misguided compiler "optimizations"
|
||||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||||
add_definitions(-fno-delete-null-pointer-checks)
|
add_definitions(-fno-delete-null-pointer-checks -fno-lifetime-dse)
|
||||||
endif()
|
endif()
|
||||||
add_definitions(-fno-strict-aliasing -fno-strict-overflow -funsigned-char)
|
add_definitions(-fno-strict-aliasing -fno-strict-overflow -funsigned-char)
|
||||||
# disable overambitious auto-vectorization until this actually gains something
|
# disable overambitious auto-vectorization until this actually gains something
|
||||||
|
@ -233,15 +233,18 @@ endif()
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# "make install"
|
# "make install"
|
||||||
|
# "cmake --install ."
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
|
|
||||||
# installation prefix and directories
|
# installation prefix and directories
|
||||||
if(NOT CMAKE_INSTALL_PREFIX)
|
if(NOT CMAKE_INSTALL_PREFIX)
|
||||||
message(FATAL_ERROR "ERROR: CMAKE_INSTALL_PREFIX is not defined.")
|
#message(FATAL_ERROR "ERROR: CMAKE_INSTALL_PREFIX is not defined.")
|
||||||
|
message(WARNING "WARNING: CMAKE_INSTALL_PREFIX is not defined.")
|
||||||
endif()
|
endif()
|
||||||
include(GNUInstallDirs)
|
if(CMAKE_INSTALL_PREFIX)
|
||||||
|
include(GNUInstallDirs)
|
||||||
if(DEFINED CMAKE_INSTALL_FULL_BINDIR)
|
endif()
|
||||||
|
if(CMAKE_INSTALL_PREFIX AND DEFINED CMAKE_INSTALL_FULL_BINDIR)
|
||||||
install(TARGETS upx DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
|
install(TARGETS upx DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
|
||||||
install(FILES
|
install(FILES
|
||||||
COPYING LICENSE NEWS README THANKS doc/upx-doc.html doc/upx-doc.txt
|
COPYING LICENSE NEWS README THANKS doc/upx-doc.html doc/upx-doc.txt
|
||||||
|
@ -254,8 +257,8 @@ endif()
|
||||||
# finally print some info about the build configuration
|
# finally print some info about the build configuration
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/maint/src/CMakeLists.extra.txt")
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/maint/make/CMakeLists.maint.txt")
|
||||||
include("${CMAKE_CURRENT_SOURCE_DIR}/maint/src/CMakeLists.extra.txt")
|
include("${CMAKE_CURRENT_SOURCE_DIR}/maint/make/CMakeLists.maint.txt")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(print_var)
|
function(print_var)
|
||||||
|
@ -268,7 +271,7 @@ endfunction()
|
||||||
print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION)
|
print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION)
|
||||||
print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION)
|
print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION)
|
||||||
print_var(CMAKE_CROSSCOMPILING)
|
print_var(CMAKE_CROSSCOMPILING)
|
||||||
print_var(CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_VERSION CMAKE_C_COMPILER_ARCHITECTURE_ID CMAKE_C_PLATFORM_ID CMAKE_C_COMPILER_ABI)
|
print_var(CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_VERSION CMAKE_C_COMPILER_ARCHITECTURE_ID CMAKE_C_PLATFORM_ID CMAKE_C_COMPILER_ABI)
|
||||||
print_var(CMAKE_CXX_COMPILER_ID CMAKE_CXX_COMPILER_VERSION CMAKE_CXX_COMPILER_ARCHITECTURE_ID CMAKE_CXX_PLATFORM_ID CMAKE_CXX_COMPILER_ABI)
|
print_var(CMAKE_CXX_COMPILER_ID CMAKE_CXX_COMPILER_VERSION CMAKE_CXX_COMPILER_ARCHITECTURE_ID CMAKE_CXX_PLATFORM_ID CMAKE_CXX_COMPILER_ABI)
|
||||||
print_var(CMAKE_INSTALL_PREFIX)
|
print_var(CMAKE_INSTALL_PREFIX)
|
||||||
print_var(CMAKE_CONFIGURATION_TYPES)
|
print_var(CMAKE_CONFIGURATION_TYPES)
|
||||||
|
@ -277,7 +280,7 @@ if (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release)$")
|
||||||
message(WARNING "WARNING: unsupported CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}; please use \"Debug\" or \"Release\"")
|
message(WARNING "WARNING: unsupported CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}; please use \"Debug\" or \"Release\"")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# final extra sanity checks; in case of problems you can remove these if you know what you are doing
|
# extra sanity checks to detect incompatible C vs CXX settings
|
||||||
if(NOT ",${CMAKE_C_PLATFORM_ID}," STREQUAL ",${CMAKE_CXX_PLATFORM_ID},")
|
if(NOT ",${CMAKE_C_PLATFORM_ID}," STREQUAL ",${CMAKE_CXX_PLATFORM_ID},")
|
||||||
message(FATAL_ERROR "ERROR: CMAKE_C_PLATFORM_ID CMAKE_CXX_PLATFORM_ID mismatch")
|
message(FATAL_ERROR "ERROR: CMAKE_C_PLATFORM_ID CMAKE_CXX_PLATFORM_ID mismatch")
|
||||||
endif()
|
endif()
|
||||||
|
|
29
Makefile
29
Makefile
|
@ -2,6 +2,8 @@
|
||||||
# UPX top-level Makefile - needs GNU make and CMake >= 3.13
|
# UPX top-level Makefile - needs GNU make and CMake >= 3.13
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# INFO: this Makefile is just a convenience wrapper for calling CMake
|
||||||
|
|
||||||
# NOTE: if you only have an older CMake 3.x then you can invoke cmake manually like this:
|
# NOTE: if you only have an older CMake 3.x then you can invoke cmake manually like this:
|
||||||
# mkdir -p build/release
|
# mkdir -p build/release
|
||||||
# cd build/release
|
# cd build/release
|
||||||
|
@ -39,6 +41,7 @@ debug: build/debug
|
||||||
release: build/release
|
release: build/release
|
||||||
|
|
||||||
.PHONY: PHONY
|
.PHONY: PHONY
|
||||||
|
.NOTPARALLEL: # because the actual builds use "cmake --parallel"
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# extra builds: some pre-defined build configurations
|
# extra builds: some pre-defined build configurations
|
||||||
|
@ -97,21 +100,21 @@ build/extra/cross-linux-arm/release: PHONY; $(call run_config_and_build,$@,Relea
|
||||||
build/extra/cross-linux-arm/%: export CC = arm-linux-gnueabihf-gcc
|
build/extra/cross-linux-arm/%: export CC = arm-linux-gnueabihf-gcc
|
||||||
build/extra/cross-linux-arm/%: export CXX = arm-linux-gnueabihf-g++ -Wno-psabi
|
build/extra/cross-linux-arm/%: export CXX = arm-linux-gnueabihf-g++ -Wno-psabi
|
||||||
|
|
||||||
# cross compiler: Windows win32 mingw32
|
# cross compiler: Windows x86 win32 MinGW
|
||||||
build/extra/cross-mingw32/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
build/extra/cross-windows-mingw32/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||||
build/extra/cross-mingw32/release: PHONY; $(call run_config_and_build,$@,Release)
|
build/extra/cross-windows-mingw32/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||||
build/extra/cross-mingw32/%: export CC = i686-w64-mingw32-gcc
|
build/extra/cross-windows-mingw32/%: export CC = i686-w64-mingw32-gcc
|
||||||
build/extra/cross-mingw32/%: export CXX = i686-w64-mingw32-g++
|
build/extra/cross-windows-mingw32/%: export CXX = i686-w64-mingw32-g++
|
||||||
# disable sanitize to avoid link errors with current MinGW-w64 versions
|
# disable sanitize to avoid link errors with current MinGW-w64 versions
|
||||||
build/extra/cross-mingw32/%: UPX_CMAKE_CONFIG_FLAGS += -DUPX_CONFIG_DISABLE_SANITIZE=1
|
build/extra/cross-windows-mingw32/%: UPX_CMAKE_CONFIG_FLAGS += -DUPX_CONFIG_DISABLE_SANITIZE=1
|
||||||
|
|
||||||
# cross compiler: Windows win64 mingw64
|
# cross compiler: Windows x64 win64 MinGW
|
||||||
build/extra/cross-mingw64/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
build/extra/cross-windows-mingw64/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||||
build/extra/cross-mingw64/release: PHONY; $(call run_config_and_build,$@,Release)
|
build/extra/cross-windows-mingw64/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||||
build/extra/cross-mingw64/%: export CC = x86_64-w64-mingw32-gcc
|
build/extra/cross-windows-mingw64/%: export CC = x86_64-w64-mingw32-gcc
|
||||||
build/extra/cross-mingw64/%: export CXX = x86_64-w64-mingw32-g++
|
build/extra/cross-windows-mingw64/%: export CXX = x86_64-w64-mingw32-g++
|
||||||
# disable sanitize to avoid link errors with current MinGW-w64 versions
|
# disable sanitize to avoid link errors with current MinGW-w64 versions
|
||||||
build/extra/cross-mingw64/%: UPX_CMAKE_CONFIG_FLAGS += -DUPX_CONFIG_DISABLE_SANITIZE=1
|
build/extra/cross-windows-mingw64/%: UPX_CMAKE_CONFIG_FLAGS += -DUPX_CONFIG_DISABLE_SANITIZE=1
|
||||||
|
|
||||||
#***********************************************************************
|
#***********************************************************************
|
||||||
# check git submodules
|
# check git submodules
|
||||||
|
@ -129,5 +132,3 @@ endif
|
||||||
ifeq ($(wildcard ./vendor/zlib/crc32.c),)
|
ifeq ($(wildcard ./vendor/zlib/crc32.c),)
|
||||||
$(error ERROR: missing git submodule; run 'git submodule update --init')
|
$(error ERROR: missing git submodule; run 'git submodule update --init')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.NOTPARALLEL: # top-level Makefile is sequential, but actual builds use "cmake --parallel"
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ Short overview
|
||||||
Tools needed to build/modify the UPX sources
|
Tools needed to build/modify the UPX sources
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
|
|
||||||
- A C++ compiler that supports C++ 14: clang, gcc or msvc
|
- A C++ compiler that supports C++ 17: clang, gcc or msvc
|
||||||
|
|
||||||
- GNU make
|
- GNU make
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ podman run "${flags[@]}" "$image" bash -l
|
||||||
|
|
||||||
# now we can cross-compile UPX for Windows:
|
# now we can cross-compile UPX for Windows:
|
||||||
# cd /home/upx/src/upx
|
# cd /home/upx/src/upx
|
||||||
# rm -rf ./build/extra/cross-mingw64/release
|
# rm -rf ./build/extra/cross-windows-mingw64/release
|
||||||
# make build/extra/cross-mingw64/release
|
# make build/extra/cross-windows-mingw64/release
|
||||||
|
|
||||||
# lots of other cross-compilers are installed:
|
# lots of other cross-compilers are installed:
|
||||||
# - see "ls /usr/bin/*g++*"
|
# - see "ls /usr/bin/*g++*"
|
||||||
|
|
Loading…
Reference in New Issue