make: update src/Makefile
This commit is contained in:
parent
79e9b0762c
commit
be30c26dbb
54
src/Makefile
54
src/Makefile
@ -1,17 +1,14 @@
|
|||||||
#
|
#
|
||||||
# UPX Makefile - needs GNU make
|
# UPX Makefile - needs GNU make
|
||||||
#
|
#
|
||||||
# Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
|
|
||||||
#
|
# NOTE: this Makefile is deprecated, please use the CMake build instead !
|
||||||
|
|
||||||
MAKEFLAGS += -r
|
MAKEFLAGS += -r
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
export SHELL = /bin/sh
|
export SHELL = /bin/sh
|
||||||
|
|
||||||
# build configuration options for this Makefile
|
# build configuration options for this Makefile
|
||||||
# 2021-03-07 BUILD_TYPE_DEBUG is off because CI build amd64-win64-gcc-9
|
|
||||||
# fails because it lacks libsantizer.spec, which is required
|
|
||||||
# by -fsanitize=undefined which is turned on by BUILD_TYPE_DEBUG.
|
|
||||||
BUILD_TYPE_DEBUG ?= 0
|
BUILD_TYPE_DEBUG ?= 0
|
||||||
BUILD_TYPE_SANITIZE ?= 0
|
BUILD_TYPE_SANITIZE ?= 0
|
||||||
BUILD_USE_DEPEND ?= 1
|
BUILD_USE_DEPEND ?= 1
|
||||||
@ -29,6 +26,20 @@ ifneq ($(srcdir),.)
|
|||||||
vpath %.h .:$(srcdir)
|
vpath %.h .:$(srcdir)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# check git submodules
|
||||||
|
ifeq ($(wildcard $(top_srcdir)/vendor/doctest/doctest/.),)
|
||||||
|
$(error ERROR: missing git submodule; run 'git submodule update --init')
|
||||||
|
endif
|
||||||
|
ifeq ($(wildcard $(top_srcdir)/vendor/lzma-sdk/C/.),)
|
||||||
|
$(error ERROR: missing git submodule; run 'git submodule update --init')
|
||||||
|
endif
|
||||||
|
ifeq ($(wildcard $(top_srcdir)/vendor/ucl/include/.),)
|
||||||
|
$(error ERROR: missing git submodule; run 'git submodule update --init')
|
||||||
|
endif
|
||||||
|
ifeq ($(wildcard $(top_srcdir)/vendor/zlib/crc32.c),)
|
||||||
|
$(error ERROR: missing git submodule; run 'git submodule update --init')
|
||||||
|
endif
|
||||||
|
|
||||||
# toolchain
|
# toolchain
|
||||||
CXX ?= g++
|
CXX ?= g++
|
||||||
CXXLD = $(CXX)
|
CXXLD = $(CXX)
|
||||||
@ -48,21 +59,23 @@ upx_SOURCES := $(sort $(wildcard $(srcdir)/*.cpp))
|
|||||||
upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext)))
|
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'))
|
GITREV_SHORT := $(strip $(shell cd '$(top_srcdir)' && git rev-parse --short=12 HEAD || echo 'ERROR'))
|
||||||
ifneq ($(UPX_VERSION_GITREV),)
|
ifneq ($(GITREV_SHORT),)
|
||||||
GITREV_PLUS := $(strip $(shell cd '$(top_srcdir)' && git diff --exit-code HEAD >/dev/null && echo '' || echo '+'))
|
GITREV_PLUS := $(strip $(shell cd '$(top_srcdir)' && git diff --quiet >/dev/null && echo '' || echo '+'))
|
||||||
DEFS += '-DUPX_VERSION_GITREV="$(UPX_VERSION_GITREV)$(GITREV_PLUS)"'
|
DEFS += '-DUPX_VERSION_GITREV="$(GITREV_SHORT)$(GITREV_PLUS)"'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# we need UCL and zlib - you can set envvar UPX_UCLDIR
|
INCLUDES += -I$(top_srcdir)/vendor/doctest
|
||||||
|
# we need UCL and zlib - you can set envvar UPX_UCLDIR
|
||||||
ifneq ($(wildcard $(UPX_UCLDIR)/include/ucl/ucl.h),)
|
ifneq ($(wildcard $(UPX_UCLDIR)/include/ucl/ucl.h),)
|
||||||
INCLUDES += -I$(UPX_UCLDIR)/include
|
INCLUDES += -I$(UPX_UCLDIR)/include
|
||||||
LIBS += $(addprefix -L,$(dir $(wildcard $(UPX_UCLDIR)/libucl$(libext) $(UPX_UCLDIR)/src/.libs/libucl$(libext))))
|
LIBS += $(addprefix -L,$(dir $(wildcard $(UPX_UCLDIR)/libucl$(libext) $(UPX_UCLDIR)/src/.libs/libucl$(libext))))
|
||||||
|
else
|
||||||
|
# please use the CMake build
|
||||||
|
##INCLUDES += -I$(top_srcdir)/vendor/ucl/include
|
||||||
endif
|
endif
|
||||||
LIBS += -lucl -lz
|
LIBS += -lucl -lz
|
||||||
# LZMA from https://github.com/upx/upx-lzma-sdk
|
|
||||||
include $(top_srcdir)/src/stub/src/c/Makevars.lzma
|
|
||||||
|
|
||||||
# default flags that you can change or override
|
# default flags that you can change or override
|
||||||
ifeq ($(BUILD_TYPE_DEBUG),1)
|
ifeq ($(BUILD_TYPE_DEBUG),1)
|
||||||
@ -76,13 +89,15 @@ ifeq ($(BUILD_TYPE_SANITIZE),1)
|
|||||||
else ifeq ($(BUILD_TYPE_SANITIZE),2)
|
else ifeq ($(BUILD_TYPE_SANITIZE),2)
|
||||||
# lightweight sanitizer
|
# lightweight sanitizer
|
||||||
# TODO: can we make this the default for release builds?
|
# TODO: can we make this the default for release builds?
|
||||||
CXXFLAGS_SANITIZE ?= -fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-strong -fstack-protector-all
|
CXXFLAGS_SANITIZE ?= -fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all
|
||||||
else ifeq ($(BUILD_TYPE_DEBUG),1)
|
else ifeq ($(BUILD_TYPE_DEBUG),1)
|
||||||
# default sanitizer for debug builds
|
# default sanitizer for debug builds
|
||||||
CXXFLAGS_SANITIZE ?= -fsanitize=undefined -fstack-protector-strong -fstack-protector-all
|
#CXXFLAGS_SANITIZE ?= -fsanitize=undefined -fstack-protector-all
|
||||||
|
CXXFLAGS_SANITIZE ?= -fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all
|
||||||
else
|
else
|
||||||
# default sanitizer for release builds
|
# default sanitizer for release builds
|
||||||
CXXFLAGS_SANITIZE ?= -fstack-protector-strong
|
#CXXFLAGS_SANITIZE ?= -fstack-protector-strong
|
||||||
|
CXXFLAGS_SANITIZE ?= -fstack-protector
|
||||||
endif
|
endif
|
||||||
ifeq ($(findstring clang,$(CXX)),)
|
ifeq ($(findstring clang,$(CXX)),)
|
||||||
CXXFLAGS_NO_DELETE_NULL_POINTER_CHECKS ?= -fno-delete-null-pointer-checks
|
CXXFLAGS_NO_DELETE_NULL_POINTER_CHECKS ?= -fno-delete-null-pointer-checks
|
||||||
@ -97,6 +112,8 @@ mf.CXXFLAGS += $(CXXFLAGS_OPTIMIZE)
|
|||||||
mf.CXXFLAGS += $(CXXFLAGS_NO_DELETE_NULL_POINTER_CHECKS)
|
mf.CXXFLAGS += $(CXXFLAGS_NO_DELETE_NULL_POINTER_CHECKS)
|
||||||
mf.CXXFLAGS += -fno-strict-aliasing -fno-strict-overflow
|
mf.CXXFLAGS += -fno-strict-aliasing -fno-strict-overflow
|
||||||
mf.CXXFLAGS += -funsigned-char
|
mf.CXXFLAGS += -funsigned-char
|
||||||
|
# disable overambitious auto-vectorization until this actually gains something
|
||||||
|
mf.CXXFLAGS += -fno-tree-vectorize
|
||||||
mf.CXXFLAGS += $(CXXFLAGS_SANITIZE)
|
mf.CXXFLAGS += $(CXXFLAGS_SANITIZE)
|
||||||
mf.CXXFLAGS += -Wall -Wextra -Wcast-align -Wcast-qual -Wmissing-declarations -Wpointer-arith -Wshadow -Wvla -Wwrite-strings
|
mf.CXXFLAGS += -Wall -Wextra -Wcast-align -Wcast-qual -Wmissing-declarations -Wpointer-arith -Wshadow -Wvla -Wwrite-strings
|
||||||
##mf.CXXFLAGS += -Wsuggest-override
|
##mf.CXXFLAGS += -Wsuggest-override
|
||||||
@ -118,20 +135,17 @@ upx$(exeext): $(upx_OBJECTS) $(upx_DEPENDENCIES)
|
|||||||
$(strip $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -o $@ -E $<)
|
$(strip $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -o $@ -E $<)
|
||||||
|
|
||||||
# object overrides
|
# object overrides
|
||||||
compress_lzma$(objext) : INCLUDES += -I$(UPX_LZMADIR)
|
compress_lzma$(objext) : INCLUDES += -I$(top_srcdir)/vendor/lzma-sdk
|
||||||
# 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) : override CXXFLAGS_SANITIZE =
|
compress_lzma$(objext) : override CXXFLAGS_SANITIZE =
|
||||||
filteri$(objext) : override CXXFLAGS_SANITIZE =
|
filteri$(objext) : override CXXFLAGS_SANITIZE =
|
||||||
# disable some warnings
|
|
||||||
compress_lzma$(objext) : upx_CXXFLAGS += -Wno-shadow
|
|
||||||
p_mach$(objext) : upx_CXXFLAGS += -Wno-cast-align
|
|
||||||
|
|
||||||
ifeq ($(BUILD_USE_DEPEND),1)
|
ifeq ($(BUILD_USE_DEPEND),1)
|
||||||
./.depend: $(sort $(wildcard $(srcdir)/*.cpp $(srcdir)/*.h)) $(MAKEFILE_LIST)
|
./.depend: $(sort $(wildcard $(srcdir)/*.cpp $(srcdir)/*.h)) $(MAKEFILE_LIST)
|
||||||
@rm -f $@
|
@rm -f $@
|
||||||
@echo "Updating $@"
|
@echo "Updating $@"
|
||||||
@$(strip $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -MM) $(filter %.cpp,$^) > $@
|
@$(strip $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) -MM) $(filter %.cpp,$^) > $@
|
||||||
./.depend : INCLUDES += -I$(UPX_LZMADIR)
|
./.depend : INCLUDES += -I$(top_srcdir)/vendor/lzma-sdk
|
||||||
else
|
else
|
||||||
./.depend:
|
./.depend:
|
||||||
.PHONY: ./.depend
|
.PHONY: ./.depend
|
||||||
|
|||||||
@ -2,13 +2,9 @@
|
|||||||
# that version works fine since 2006 and that is the only version
|
# that version works fine since 2006 and that is the only version
|
||||||
# that is actually sufficiently tested!!!
|
# that is actually sufficiently tested!!!
|
||||||
|
|
||||||
|
ifeq ($(wildcard $(top_srcdir)/vendor/lzma-sdk/C/.),)
|
||||||
|
$(error ERROR: missing git submodule; run 'git submodule update --init')
|
||||||
|
endif
|
||||||
|
|
||||||
override UPX_LZMADIR := $(top_srcdir)/vendor/lzma-sdk
|
override UPX_LZMADIR := $(top_srcdir)/vendor/lzma-sdk
|
||||||
override UPX_LZMA_VERSION := 0x443
|
override UPX_LZMA_VERSION := 0x443
|
||||||
|
|
||||||
ifeq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
|
|
||||||
ifneq ($(wildcard $(top_srcdir)/.git/.),)
|
|
||||||
$(error ERROR: missing git submodule; run 'git submodule update --init --recursive')
|
|
||||||
else
|
|
||||||
$(error ERROR: missing directory vendor/lzma-sdk/; visit https://github.com/upx/upx-vendor-lzma-sdk )
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user