upx/Makefile

90 lines
3.1 KiB
Makefile
Raw Permalink Normal View History

#
# 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
#
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:
# 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
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
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
#***********************************************************************
# default
#***********************************************************************
2023-12-09 07:52:25 +00:00
.DEFAULT_GOAL = build/release
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))
run_build = $(call run_cmake_build,$1,$2)
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"
.PHONY: PHONY
.SECONDEXPANSION:
2023-01-24 20:52:10 +00:00
.SUFFIXES:
2022-12-20 10:40:48 +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 ;
#***********************************************************************
# test
#***********************************************************************
2024-04-28 20:18:47 +00:00
CTEST = ctest
CTEST_JOBS ?= 8
2024-04-28 20:18:47 +00:00
CTEST_FLAGS = --output-on-failure --parallel $(CTEST_JOBS)
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
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
#
# END of Makefile
#
2023-01-26 07:50:30 +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
# developer convenience
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
$(MAKE) -C src $@
endif
endif