2022-08-17 15:30:22 +00:00
|
|
|
#
|
|
|
|
# UPX top-level Makefile - needs GNU make and CMake >= 3.13
|
2023-06-15 17:42:54 +00:00
|
|
|
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
2022-08-17 15:30:22 +00:00
|
|
|
#
|
|
|
|
|
2023-01-04 23:57:01 +00:00
|
|
|
# INFO: this Makefile is just a convenience wrapper for calling CMake
|
|
|
|
|
2023-07-06 16:03:37 +00:00
|
|
|
# HINT: if you only have an older CMake 3.x then you can invoke cmake manually like this:
|
2022-08-17 15:30:22 +00:00
|
|
|
# mkdir -p build/release
|
|
|
|
# cd build/release
|
2023-09-30 08:46:39 +00:00
|
|
|
# cmake ../.. # run config
|
2024-06-14 13:15:55 +00:00
|
|
|
# make -j4 # and run build
|
2022-08-17 15:30:22 +00:00
|
|
|
|
|
|
|
CMAKE = cmake
|
|
|
|
UPX_CMAKE_BUILD_FLAGS += --parallel
|
2022-10-19 22:31:02 +00:00
|
|
|
ifneq ($(VERBOSE),)
|
2023-06-09 12:12:05 +00:00
|
|
|
#UPX_CMAKE_BUILD_FLAGS += --verbose # requires CMake >= 3.14
|
2023-02-21 14:19:24 +00:00
|
|
|
UPX_CMAKE_CONFIG_FLAGS += -DCMAKE_VERBOSE_MAKEFILE=ON
|
2022-10-19 22:31:02 +00:00
|
|
|
endif
|
2023-01-17 22:43:24 +00:00
|
|
|
# enable this if you prefer Ninja for the actual builds:
|
|
|
|
#UPX_CMAKE_CONFIG_FLAGS += -G Ninja
|
2022-08-17 15:30:22 +00:00
|
|
|
|
|
|
|
#***********************************************************************
|
|
|
|
# default
|
|
|
|
#***********************************************************************
|
|
|
|
|
2023-12-09 07:52:25 +00:00
|
|
|
.DEFAULT_GOAL = build/release
|
|
|
|
|
2023-01-01 18:43:57 +00:00
|
|
|
run_cmake_config = $(CMAKE) -S . -B $1 $(UPX_CMAKE_CONFIG_FLAGS) -DCMAKE_BUILD_TYPE=$2
|
|
|
|
run_cmake_build = $(CMAKE) --build $1 $(UPX_CMAKE_BUILD_FLAGS) --config $2
|
2023-12-02 00:48:26 +00:00
|
|
|
# avoid re-running run_cmake_config if .upx_cmake_config_done.txt already exists
|
2024-07-23 10:24:09 +00:00
|
|
|
run_config = $(if $(wildcard $1/CMakeFiles/.*_cmake_config_done.txt),,$(call run_cmake_config,$1,$2))
|
2023-01-01 18:43:57 +00:00
|
|
|
run_build = $(call run_cmake_build,$1,$2)
|
2022-08-17 15:30:22 +00:00
|
|
|
|
|
|
|
build/debug: PHONY
|
|
|
|
$(call run_config,$@,Debug)
|
|
|
|
$(call run_build,$@,Debug)
|
|
|
|
|
|
|
|
build/release: PHONY
|
|
|
|
$(call run_config,$@,Release)
|
|
|
|
$(call run_build,$@,Release)
|
|
|
|
|
2023-01-04 23:57:01 +00:00
|
|
|
.NOTPARALLEL: # because the actual builds use "cmake --parallel"
|
2023-03-14 23:19:55 +00:00
|
|
|
.PHONY: PHONY
|
|
|
|
.SECONDEXPANSION:
|
2023-01-24 20:52:10 +00:00
|
|
|
.SUFFIXES:
|
2022-12-20 10:40:48 +00:00
|
|
|
|
2023-10-05 01:51:27 +00:00
|
|
|
# shortcuts (all => debug + release)
|
2024-03-23 19:18:28 +00:00
|
|
|
debug: build/debug PHONY
|
|
|
|
release: build/release PHONY
|
|
|
|
all build/all: build/debug build/release PHONY
|
2024-03-25 10:07:40 +00:00
|
|
|
build/%/all: $$(dir $$@)debug $$(dir $$@)release PHONY ;
|
2023-10-05 01:51:27 +00:00
|
|
|
|
2024-04-26 08:36:01 +00:00
|
|
|
#***********************************************************************
|
|
|
|
# test
|
|
|
|
#***********************************************************************
|
|
|
|
|
2024-04-28 20:18:47 +00:00
|
|
|
CTEST = ctest
|
2024-04-26 08:36:01 +00:00
|
|
|
CTEST_JOBS ?= 8
|
2024-04-28 20:18:47 +00:00
|
|
|
CTEST_FLAGS = --output-on-failure --parallel $(CTEST_JOBS)
|
2024-04-26 08:36:01 +00:00
|
|
|
|
2024-05-07 08:05:44 +00:00
|
|
|
build/debug+test: $$(dir $$@)debug PHONY; cd "$(dir $@)debug" && $(CTEST) $(CTEST_FLAGS) -C Debug
|
|
|
|
build/%/debug+test: $$(dir $$@)debug PHONY; cd "$(dir $@)debug" && $(CTEST) $(CTEST_FLAGS) -C Debug
|
|
|
|
build/release+test: $$(dir $$@)release PHONY; cd "$(dir $@)release" && $(CTEST) $(CTEST_FLAGS) -C Release
|
|
|
|
build/%/release+test: $$(dir $$@)release PHONY; cd "$(dir $@)release" && $(CTEST) $(CTEST_FLAGS) -C Release
|
2024-04-26 08:36:01 +00:00
|
|
|
build/%/all+test: $$(dir $$@)debug+test $$(dir $$@)release+test PHONY ;
|
|
|
|
|
|
|
|
# shortcuts
|
|
|
|
debug+test: build/debug+test PHONY
|
|
|
|
release+test: build/release+test PHONY
|
|
|
|
all+test build/all+test: build/debug+test build/release+test PHONY
|
|
|
|
|
2024-04-28 20:18:47 +00:00
|
|
|
test: $$(patsubst %+test,%,$$(.DEFAULT_GOAL))+test PHONY
|
2024-04-26 08:36:01 +00:00
|
|
|
|
2023-04-18 15:02:13 +00:00
|
|
|
#
|
2023-10-05 01:51:27 +00:00
|
|
|
# END of Makefile
|
2023-04-18 15:02:13 +00:00
|
|
|
#
|
2023-01-26 07:50:30 +00:00
|
|
|
|
2023-10-05 01:51:27 +00:00
|
|
|
# extra pre-defined build configurations and some utility; optional
|
2024-07-23 10:24:09 +00:00
|
|
|
-include ./Makevars-local.mk
|
|
|
|
-include ./misc/make/Makefile-extra.mk
|
2023-01-24 20:52:10 +00:00
|
|
|
|
2023-10-05 01:51:27 +00:00
|
|
|
# developer convenience
|
2023-12-20 10:44:01 +00:00
|
|
|
ifneq ($(wildcard /usr/bin/env),) # need Unix utils like bash, perl, sed, xargs, etc.
|
2024-07-23 10:24:09 +00:00
|
|
|
ifneq ($(and $(wildcard ./misc/scripts/.),$(wildcard ./doc/upx.pod)),)
|
2024-03-28 19:21:11 +00:00
|
|
|
check-whitespace clang-format run-testsuite run-testsuite-all run-testsuite-debug run-testsuite-release: src/Makefile PHONY
|
2023-10-05 01:51:27 +00:00
|
|
|
$(MAKE) -C src $@
|
2023-01-19 18:17:26 +00:00
|
|
|
endif
|
2023-12-20 10:44:01 +00:00
|
|
|
endif
|