mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Update Makefile and check_whitespace.sh.
This commit is contained in:
parent
06eb244800
commit
42d49e9d50
|
@ -81,7 +81,7 @@ build_script:
|
||||||
- set s=c:\projects\upx\src
|
- set s=c:\projects\upx\src
|
||||||
- cat .GITREV.txt
|
- cat .GITREV.txt
|
||||||
- set /p GITREV=<.GITREV.txt
|
- set /p GITREV=<.GITREV.txt
|
||||||
- cl -MT -EHsc -O2 -W4 -wd4244 -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% -DWITH_LZMA=0x443 -DUCL_NO_ASM -I%s%\lzma-sdk -Ic:\projects\deps\ucl-1.03\include -Ic:\projects\deps\zlib-1.2.8 -Feupx.exe %s%\*.cpp %BDIR%\ucl-1.03\ucl.lib %BDIR%\zlib-1.2.8\zlib.lib
|
- cl -MT -EHsc -J -O2 -W4 -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% -DWITH_LZMA=0x443 -DUCL_NO_ASM -I%s%\lzma-sdk -Ic:\projects\deps\ucl-1.03\include -Ic:\projects\deps\zlib-1.2.8 -Feupx.exe %s%\*.cpp %BDIR%\ucl-1.03\ucl.lib %BDIR%\zlib-1.2.8\zlib.lib
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- set UPX=--no-color --no-progress
|
- set UPX=--no-color --no-progress
|
||||||
|
|
30
src/Makefile
30
src/Makefile
|
@ -10,15 +10,6 @@ BUILD_TYPE_SANITIZE ?= 0
|
||||||
BUILD_USE_DEPEND ?= 1
|
BUILD_USE_DEPEND ?= 1
|
||||||
|
|
||||||
MAKEFLAGS += -r
|
MAKEFLAGS += -r
|
||||||
ifneq ($(upx_CXX),)
|
|
||||||
CXX = $(upx_CXX)
|
|
||||||
endif
|
|
||||||
ifneq ($(upx_CXXLD),)
|
|
||||||
CXXLD = $(upx_CXXLD)
|
|
||||||
else
|
|
||||||
CXXLD = $(CXX)
|
|
||||||
endif
|
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
export SHELL = /bin/sh
|
export SHELL = /bin/sh
|
||||||
override e = $($1) $(EXTRA_$1) $(upx_$1) $(upx_EXTRA_$1) $($(basename $(notdir $@)).$1)
|
override e = $($1) $(EXTRA_$1) $(upx_$1) $(upx_EXTRA_$1) $($(basename $(notdir $@)).$1)
|
||||||
|
@ -36,6 +27,9 @@ ifneq ($(srcdir),.)
|
||||||
VPATH := . $(srcdir)
|
VPATH := . $(srcdir)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# toolchain
|
||||||
|
CXX ?= g++
|
||||||
|
CXXLD = $(CXX)
|
||||||
exeext ?= .out
|
exeext ?= .out
|
||||||
libext ?= .a
|
libext ?= .a
|
||||||
objext ?= .o
|
objext ?= .o
|
||||||
|
@ -46,8 +40,8 @@ upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext)))
|
||||||
ifneq ($(wildcard $(top_srcdir)/.git/.),)
|
ifneq ($(wildcard $(top_srcdir)/.git/.),)
|
||||||
UPX_VERSION_GITREV := $(strip $(shell cd '$(top_srcdir)' && git rev-parse --short=12 HEAD || echo 'ERROR'))
|
UPX_VERSION_GITREV := $(strip $(shell cd '$(top_srcdir)' && git rev-parse --short=12 HEAD || echo 'ERROR'))
|
||||||
ifneq ($(UPX_VERSION_GITREV),)
|
ifneq ($(UPX_VERSION_GITREV),)
|
||||||
x := $(strip $(shell cd '$(top_srcdir)' && git diff --exit-code HEAD >/dev/null && echo '' || echo '+'))
|
GITREV_PLUS := $(strip $(shell cd '$(top_srcdir)' && git diff --exit-code HEAD >/dev/null && echo '' || echo '+'))
|
||||||
DEFS += '-DUPX_VERSION_GITREV="$(UPX_VERSION_GITREV)$(x)"'
|
DEFS += '-DUPX_VERSION_GITREV="$(UPX_VERSION_GITREV)$(GITREV_PLUS)"'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -63,10 +57,11 @@ DEFS += -DWITH_LZMA=$(UPX_LZMA_VERSION)
|
||||||
|
|
||||||
CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
|
CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
|
||||||
ifeq ($(BUILD_TYPE_DEBUG),1)
|
ifeq ($(BUILD_TYPE_DEBUG),1)
|
||||||
CXXFLAGS += -O0 -g
|
CXXFLAGS_OPTIMIZE ?= -O0 -g
|
||||||
else
|
else
|
||||||
CXXFLAGS += -O2
|
CXXFLAGS_OPTIMIZE ?= -O2
|
||||||
endif
|
endif
|
||||||
|
CXXFLAGS += $(CXXFLAGS_OPTIMIZE)
|
||||||
# protect against security threats caused by misguided C++ compiler "optimizations"
|
# protect against security threats caused by misguided C++ compiler "optimizations"
|
||||||
ifeq ($(findstring clang,$(CXX)),)
|
ifeq ($(findstring clang,$(CXX)),)
|
||||||
CXXFLAGS += -fno-delete-null-pointer-checks
|
CXXFLAGS += -fno-delete-null-pointer-checks
|
||||||
|
@ -78,14 +73,14 @@ CXXFLAGS_WERROR ?= -Werror
|
||||||
CXXFLAGS += $(CXXFLAGS_WERROR)
|
CXXFLAGS += $(CXXFLAGS_WERROR)
|
||||||
|
|
||||||
ifeq ($(BUILD_TYPE_SANITIZE),1)
|
ifeq ($(BUILD_TYPE_SANITIZE),1)
|
||||||
CXXFLAGS_SANITIZE := -fsanitize=address,undefined -fno-omit-frame-pointer -DACC_CFG_NO_UNALIGNED
|
CXXFLAGS_SANITIZE ?= -fsanitize=address,undefined -fno-omit-frame-pointer -DACC_CFG_NO_UNALIGNED
|
||||||
CXXFLAGS += $(CXXFLAGS_SANITIZE)
|
CXXFLAGS += $(CXXFLAGS_SANITIZE)
|
||||||
LDFLAGS += $(CXXFLAGS_SANITIZE)
|
LDFLAGS += $(CXXFLAGS_SANITIZE)
|
||||||
# these are the only 2 objects that are actually speed-sensitive
|
# these are the only 2 objects that are actually speed-sensitive
|
||||||
compress_lzma$(objext) filteri$(objext) : CXXFLAGS := $(filter-out $(CXXFLAGS_SANITIZE),$(CXXFLAGS))
|
compress_lzma$(objext) filteri$(objext) : CXXFLAGS_SANITIZE =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# rules
|
||||||
all: upx$(exeext) | ./.depend
|
all: upx$(exeext) | ./.depend
|
||||||
.DELETE_ON_ERROR: upx$(exeext) $(upx_OBJECTS) ./.depend
|
.DELETE_ON_ERROR: upx$(exeext) $(upx_OBJECTS) ./.depend
|
||||||
|
|
||||||
|
@ -97,7 +92,7 @@ upx$(exeext): $(upx_OBJECTS) $(upx_DEPENDENCIES)
|
||||||
|
|
||||||
%.o : %.cpp | ./.depend
|
%.o : %.cpp | ./.depend
|
||||||
$(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -c $<)
|
$(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -c $<)
|
||||||
%.cpp.ii : %.cpp | ./.depend
|
%.cpp.ii : %.cpp
|
||||||
$(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -E $<)
|
$(strip $(CXX) $(call e,CPPFLAGS) $(call e,CXXFLAGS) -o $@ -E $<)
|
||||||
|
|
||||||
ifeq ($(BUILD_USE_DEPEND),1)
|
ifeq ($(BUILD_USE_DEPEND),1)
|
||||||
|
@ -137,6 +132,7 @@ else ifeq ($(MAKECMDGOALS),clean)
|
||||||
else ifeq ($(MAKECMDGOALS),distclean)
|
else ifeq ($(MAKECMDGOALS),distclean)
|
||||||
else ifeq ($(MAKECMDGOALS),maintainer-clean)
|
else ifeq ($(MAKECMDGOALS),maintainer-clean)
|
||||||
else ifeq ($(MAKECMDGOALS),clang-format)
|
else ifeq ($(MAKECMDGOALS),clang-format)
|
||||||
|
else ifeq ($(MAKECMDGOALS),check-whitespace)
|
||||||
else
|
else
|
||||||
ifeq ($(BUILD_USE_DEPEND),1)
|
ifeq ($(BUILD_USE_DEPEND),1)
|
||||||
-include ./.depend
|
-include ./.depend
|
||||||
|
|
|
@ -48,9 +48,14 @@
|
||||||
// other compilers may work, but we're NOT interested into supporting them
|
// other compilers may work, but we're NOT interested into supporting them
|
||||||
# error "only clang and gcc are officially supported"
|
# error "only clang and gcc are officially supported"
|
||||||
#endif
|
#endif
|
||||||
|
// UPX sanity checks for a sane compiler
|
||||||
#if !defined(UINT_MAX) || (UINT_MAX != 0xffffffffL)
|
#if !defined(UINT_MAX) || (UINT_MAX != 0xffffffffL)
|
||||||
# error "UINT_MAX"
|
# error "UINT_MAX"
|
||||||
#endif
|
#endif
|
||||||
|
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4)
|
||||||
|
ACC_COMPILE_TIME_ASSERT_HEADER((1u << 31) << 1 == 0)
|
||||||
|
ACC_COMPILE_TIME_ASSERT_HEADER(((int)(1u << 31)) >> 31 == -1) // arithmetic right shift
|
||||||
|
ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) > 0) // -funsigned-char
|
||||||
|
|
||||||
// FIXME - quick hack for arm-wince-gcc-3.4 (Debian pocketpc-*.deb packages)
|
// FIXME - quick hack for arm-wince-gcc-3.4 (Debian pocketpc-*.deb packages)
|
||||||
#if 1 && (ACC_ARCH_ARM) && defined(__pe__) && !defined(__CEGCC__) && !defined(_WIN32)
|
#if 1 && (ACC_ARCH_ARM) && defined(__pe__) && !defined(__CEGCC__) && !defined(_WIN32)
|
||||||
|
|
|
@ -15,9 +15,10 @@ find . \
|
||||||
-type f -iname '*.exe' -prune -o \
|
-type f -iname '*.exe' -prune -o \
|
||||||
-type f -iname '*.pdf' -prune -o \
|
-type f -iname '*.pdf' -prune -o \
|
||||||
-type f -iname '*.swp' -prune -o \
|
-type f -iname '*.swp' -prune -o \
|
||||||
-type f -print0 | LC_ALL=C sort -z | \
|
-type f -print0 | \
|
||||||
xargs -0r perl -n -e '
|
LC_ALL=C sort -z | xargs -0r perl -n -e '
|
||||||
#print("$ARGV\n");
|
#print("$ARGV\n");
|
||||||
|
if (m,[\x00\x01\x02\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
|
||||||
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
|
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
|
||||||
if (m,([ \t]+)$,) {
|
if (m,([ \t]+)$,) {
|
||||||
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files
|
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files
|
||||||
|
|
|
@ -7,12 +7,15 @@ set -e; set -o pipefail
|
||||||
[[ -z $1 ]] || cd "$1" || exit 1
|
[[ -z $1 ]] || cd "$1" || exit 1
|
||||||
[[ -d .git ]] || exit 1
|
[[ -d .git ]] || exit 1
|
||||||
|
|
||||||
# info: cannot use "-z" as that needs GNU sed 4.2.2 which is not installed on Ubuntu 12.04
|
git ls-files --full-name -z | perl -0 -n -e '
|
||||||
git ls-files --full-name | sed 's/^/\.\//' |\
|
s,^,./,;
|
||||||
sed -e '/lzma-sdk$/d' -e '/\.exe$/d' |\
|
if (m,^\./src/lzma-sdk(\0|$),) { }
|
||||||
LC_ALL=C sort | \
|
elsif (m,\.bat(\0|$),) { }
|
||||||
xargs -r perl -n -e '
|
elsif (m,\.exe(\0|$),) { }
|
||||||
|
else { print; }
|
||||||
|
' | LC_ALL=C sort -z | xargs -0r perl -n -e '
|
||||||
#print("$ARGV\n");
|
#print("$ARGV\n");
|
||||||
|
if (m,[\x00\x01\x02\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
|
||||||
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
|
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
|
||||||
if (m,([ \t]+)$,) {
|
if (m,([ \t]+)$,) {
|
||||||
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files
|
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files
|
||||||
|
|
Loading…
Reference in New Issue
Block a user