From 51eab2a4b7f392f768ad3d5c1a16a460dd69fac8 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Wed, 28 Sep 2016 13:07:39 +0200 Subject: [PATCH] Update Makefile configuration variables. --- .appveyor.yml | 8 ++++---- .github/travis_build.sh | 4 ++-- Makefile | 7 ------- src/Makefile | 36 ++++++++++++++++++------------------ 4 files changed, 24 insertions(+), 31 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index eb0d22a5..abfd4e60 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,10 +5,10 @@ os: Visual Studio 2015 environment: matrix: -# - { C: msvc-10.0-x86, CL_VERSION: 16.00, VS_VERSION: 2010 } -### - { C: msvc-10.0-x64, CL_VERSION: 16.00, VS_VERSION: 2010 } # x64 is not installed -# - { C: msvc-11.0-x86, CL_VERSION: 17.00, VS_VERSION: 2012 } -### - { C: msvc-11.0-x64, CL_VERSION: 17.00, VS_VERSION: 2012 } # x64 is not installed +# - { C: msvc-10.0-x86, CL_VERSION: 16.00, VS_VERSION: 2010 } # missing strtoull() +### - { C: msvc-10.0-x64, CL_VERSION: 16.00, VS_VERSION: 2010 } # AppVeyor: x64 compiler is not installed +# - { C: msvc-11.0-x86, CL_VERSION: 17.00, VS_VERSION: 2012 } # missing strtoull() +### - { C: msvc-11.0-x64, CL_VERSION: 17.00, VS_VERSION: 2012 } # AppVeyor: x64 compiler is not installed - { C: msvc-12.0-x86, CL_VERSION: 18.00, VS_VERSION: 2013 } - { C: msvc-12.0-x64, CL_VERSION: 18.00, VS_VERSION: 2013 } - { C: msvc-14.0-x86, CL_VERSION: 19.00, VS_VERSION: 2015 } diff --git a/.github/travis_build.sh b/.github/travis_build.sh index 42e6dadf..b608e255 100644 --- a/.github/travis_build.sh +++ b/.github/travis_build.sh @@ -79,11 +79,11 @@ if [[ $B =~ (^|\+)coverage($|\+) ]]; then EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage" fi if [[ $B =~ (^|\+)debug($|\+) ]]; then - make="$make USE_DEBUG=1" + make="$make BUILD_TYPE_DEBUG=1" fi if [[ $B =~ (^|\+)sanitize($|\+) ]]; then case $TRAVIS_OS_NAME-$CC in linux-gcc*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fuse-ld=gold" ;; esac - make="$make USE_SANITIZE=1" + make="$make BUILD_TYPE_SANITIZE=1" fi if [[ $B =~ (^|\+)scan-build($|\+) ]]; then make="$SCAN_BUILD $make" diff --git a/Makefile b/Makefile index 50040bfa..32b72a21 100644 --- a/Makefile +++ b/Makefile @@ -8,15 +8,10 @@ MAKEFLAGS += -rR .SUFFIXES: export SHELL = /bin/sh -ifneq ($(findstring $(firstword $(MAKE_VERSION)),3.77 3.78 3.78.1 3.79 3.79.1 3.80),) -$(error GNU make 3.81 or better is required) -endif - srcdir = . top_srcdir = . include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local) - # info: src/stub needs special build tools from https://github.com/upx/upx-stubtools BUILD_STUB = 0 ifneq ($(wildcard $(HOME)/local/bin/bin-upx/upx-stubtools-check-version),) @@ -26,7 +21,6 @@ ifneq ($(wildcard $(HOME)/bin/bin-upx/upx-stubtools-check-version),) BUILD_STUB = 1 endif - default: @echo "UPX info: please choose a target for 'make'" @@ -37,7 +31,6 @@ endif $(MAKE) -C src $@ $(MAKE) -C doc $@ - .PHONY: default all mostlyclean clean distclean maintainer-clean # vim:set ts=8 sw=8 noet: diff --git a/src/Makefile b/src/Makefile index 69a9f919..703c9597 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,9 +4,10 @@ # Copyright (C) 1996-2016 Markus Franz Xaver Johannes Oberhumer # -# build configuration options -#USE_DEBUG = 1 -#USE_SANITIZE = 1 +# build configuration options for this Makefile +BUILD_TYPE_DEBUG ?= 0 +BUILD_TYPE_SANITIZE ?= 0 +BUILD_USE_DEPEND ?= 1 MAKEFLAGS += -r ifneq ($(upx_CXX),) @@ -22,10 +23,6 @@ endif export SHELL = /bin/sh override e = $($1) $(EXTRA_$1) $(upx_$1) $(upx_EXTRA_$1) $($(basename $(notdir $@)).$1) -ifneq ($(findstring $(firstword $(MAKE_VERSION)),3.77 3.78 3.78.1 3.79 3.79.1 3.80),) -$(error GNU make 3.81 or better is required) -endif - ifndef srcdir srcdir := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) srcdir := $(shell echo '$(srcdir)' | sed 's,/*$$,,') @@ -65,7 +62,7 @@ include $(top_srcdir)/src/stub/src/c/Makevars.lzma DEFS += -DWITH_LZMA=$(UPX_LZMA_VERSION) CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) -ifdef USE_DEBUG +ifeq ($(BUILD_TYPE_DEBUG),1) CXXFLAGS += -O0 -g else CXXFLAGS += -O2 @@ -79,7 +76,7 @@ CXXFLAGS += -Wall -W -Wcast-align -Wcast-qual -Wmissing-declarations -Wpointer-a CXXFLAGS_WERROR ?= -Werror CXXFLAGS += $(CXXFLAGS_WERROR) -ifdef USE_SANITIZE +ifeq ($(BUILD_TYPE_SANITIZE),1) CXXFLAGS_SANITIZE := -fsanitize=address,undefined -fno-omit-frame-pointer -DACC_CFG_NO_UNALIGNED CXXFLAGS += $(CXXFLAGS_SANITIZE) LDFLAGS += $(CXXFLAGS_SANITIZE) @@ -88,35 +85,36 @@ compress_lzma$(objext) filteri$(objext) : CXXFLAGS := $(filter-out $(CXXFLAGS_SA endif -all: upx$(exeext) | .depend -.DELETE_ON_ERROR: upx$(exeext) $(upx_OBJECTS) .depend +all: upx$(exeext) | ./.depend +.DELETE_ON_ERROR: upx$(exeext) $(upx_OBJECTS) ./.depend upx$(exeext): $(upx_OBJECTS) $(upx_DEPENDENCIES) $($(notdir $@).PRE_LINK_STEP) $(strip $(CXXLD) $(call e,CPPFLAGS) $(call e,CXXFLAGS) $(call e,LDFLAGS) -o $@ $(upx_OBJECTS) $(call e,LDADD) $(call e,LIBS)) $($(notdir $@).POST_LINK_STEP) -%.o : %.cpp | .depend +%.o : %.cpp | ./.depend $(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -c $<) -.depend: $(sort $(wildcard $(srcdir)/*.cpp $(srcdir)/*.h)) $(MAKEFILE_LIST) +ifeq ($(BUILD_USE_DEPEND),1) +./.depend: $(sort $(wildcard $(srcdir)/*.cpp $(srcdir)/*.h)) $(MAKEFILE_LIST) @rm -f $@ -ifeq (1,1) @echo "Updating $@" @$(strip $(CXX) $(call e,CPPFLAGS) -MM) $(filter %.cpp,$^) > $@ else - @echo "timestamp" > $@ +./.depend: +.PHONY: ./.depend endif -.depend compress_lzma$(objext) : INCLUDES += -I$(UPX_LZMADIR) +./.depend compress_lzma$(objext) : INCLUDES += -I$(UPX_LZMADIR) compress_lzma$(objext) : CXXFLAGS += -Wno-shadow p_mach$(objext) : CXXFLAGS += -Wno-cast-align mostlyclean clean distclean maintainer-clean: - rm -f *.d *.map *.o *.obj *.res .depend upx.exe upx.out upx.ttp upx$(exeext) + rm -f *.d *.map *.o *.obj *.res ./.depend upx.exe upx.out upx.ttp upx$(exeext) .PHONY: all mostlyclean clean distclean maintainer-clean @@ -126,7 +124,9 @@ else ifeq ($(MAKECMDGOALS),distclean) else ifeq ($(MAKECMDGOALS),maintainer-clean) else ifeq ($(MAKECMDGOALS),clang-format) else --include .depend +ifeq ($(BUILD_USE_DEPEND),1) +-include ./.depend +endif help$(objext): $(MAKEFILE_LIST) endif