diff --git a/src/stub/Makefile b/src/stub/Makefile index 145f2d0c..caa05b83 100644 --- a/src/stub/Makefile +++ b/src/stub/Makefile @@ -11,6 +11,7 @@ MAKEFLAGS += -rR .SUFFIXES: .SECONDEXPANSION: export SHELL = /bin/sh +export LC_ALL = C ifneq ($(findstring $(firstword $(MAKE_VERSION)),3.79 3.79.1 3.80),) $(error GNU make 3.81 or better is required) @@ -77,20 +78,20 @@ endif ifndef default.targets ifeq ($(wildcard .all-stamp),) default.targets = -default: $(default.targets) +default: $$(default.targets) @echo "UPX info: type 'make all' if you have all the required build tools." else default.targets = all -default: $(default.targets) +default: $$(default.targets) endif endif all.targets ?= tmp/.tmp-stamp .all-stamp -all: $(all.targets) +all: $$(all.targets) tmp/.tmp-stamp: @mkdir -p $(dir $@) @echo "timestamp" > $@ -.all-stamp: $(STUBS) +.all-stamp: $$(STUBS) @echo "timestamp" > $@ ifeq ($(wildcard .all-stamp),) @@ -613,9 +614,11 @@ tmp/powerpc-darwin.macho-main.o : $(srcdir)/src/$$T.c # // dependencies # ************************************************************************/ +ifneq ($(STUBS),) # FIXME: we want a dependency-only-prerequisite here ##$(STUBS): | tmp/.tmp-stamp ##$(STUBS): $(MAKEFILE_LIST) +endif -include tmp/*.d diff --git a/src/stub/src/arch/amd64/Makefile.extra b/src/stub/src/arch/amd64/Makefile.extra index 2556cffe..1d51d22c 100644 --- a/src/stub/src/arch/amd64/Makefile.extra +++ b/src/stub/src/arch/amd64/Makefile.extra @@ -1,28 +1,36 @@ MAKEFLAGS += -rR .SUFFIXES: .SECONDEXPANSION: -export SHELL = /bin/sh -ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),) - -STUBS += lzma_d_cf.S lzma_d_cs.S +ifndef top_srcdir +__dir_list = . .. ../.. ../../.. ../../../.. ../../../../.. +__dir_list += ../../../../../.. ../../../../../../.. ../../../../../../../.. +__dir_search = $(firstword $(foreach v,$1,$(if $(wildcard $v/$2),$v)) $3) +top_srcdir := $(call __dir_search,$(__dir_list),src/bele.h,NOT_FOUND) +endif default.targets = all -all.targets = tmp/.tmp-stamp $(STUBS) -include $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))../../../Makefile +STUBS = NO_STUBS +include $(top_srcdir)/src/stub/Makefile +STUBS = # /*********************************************************************** # // amd64-lzma # ************************************************************************/ +ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),) + +STUBS += lzma_d_cf.S lzma_d_cs.S + lzma_d_cf.S : tc_list = amd64-lzma amd64-linux.elf default lzma_d_cs.S : tc_list = amd64-lzma amd64-linux.elf default tc.amd64-lzma.gcc = $(tc.amd64-linux.elf.gcc) -tc.amd64-lzma.gcc += -ffunction-sections tc.amd64-lzma.gcc += -Os +tc.amd64-lzma.gcc += -ffunction-sections tc.amd64-lzma.gcc += -I$(UPX_LZMADIR) +tc.amd64-lzma.gcc += -I$(top_srcdir)/src lzma_d_c%.S : lzma_d_c.c $(call tc,gcc) $(PP_FLAGS) -c $< -o tmp/$T.o @@ -32,10 +40,7 @@ lzma_d_c%.S : lzma_d_c.c $(call tc,objdump) -b binary -m i386:x86-64 -D tmp/$T.out > tmp/$T.out.lst $(call tc,bin2h) --mode=gas tmp/$T.out $@ -lzma_d_cf.S : PP_FLAGS = -DFAST -lzma_d_cs.S : PP_FLAGS = -DSMALL - -lzma_d_cf.S : $(MAKEFILE_LIST) -lzma_d_cs.S : $(MAKEFILE_LIST) +lzma_d_cf.% : PP_FLAGS = -DFAST +lzma_d_cs.% : PP_FLAGS = -DSMALL endif diff --git a/src/stub/src/arch/amd64/lzma_d_c.c b/src/stub/src/arch/amd64/lzma_d_c.c index cbe8cb08..9d2c2c96 100644 --- a/src/stub/src/arch/amd64/lzma_d_c.c +++ b/src/stub/src/arch/amd64/lzma_d_c.c @@ -31,7 +31,7 @@ #define ACC_LIBC_NAKED #define ACC_OS_FREESTANDING -#include "../../../../miniacc.h" +#include "miniacc.h" #undef _LZMA_IN_CB #undef _LZMA_OUT_READ diff --git a/src/stub/src/arch/arm/v4a/Makefile.extra b/src/stub/src/arch/arm/v4a/Makefile.extra index 59e20911..fe446a38 100644 --- a/src/stub/src/arch/arm/v4a/Makefile.extra +++ b/src/stub/src/arch/arm/v4a/Makefile.extra @@ -1,21 +1,28 @@ MAKEFLAGS += -rR .SUFFIXES: .SECONDEXPANSION: -export SHELL = /bin/sh -ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),) - -STUBS += lzma_d_cf.S lzma_d_cs.S +ifndef top_srcdir +__dir_list = . .. ../.. ../../.. ../../../.. ../../../../.. +__dir_list += ../../../../../.. ../../../../../../.. ../../../../../../../.. +__dir_search = $(firstword $(foreach v,$1,$(if $(wildcard $v/$2),$v)) $3) +top_srcdir := $(call __dir_search,$(__dir_list),src/bele.h,NOT_FOUND) +endif default.targets = all -all.targets = tmp/.tmp-stamp $(STUBS) -include $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))../../../../Makefile +STUBS = NO_STUBS +include $(top_srcdir)/src/stub/Makefile +STUBS = # /*********************************************************************** # // arm-lzma # ************************************************************************/ +ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),) + +STUBS += lzma_d_cf.S lzma_d_cs.S + lzma_d_cf.S : tc_list = arm-lzma arm-linux.elf default lzma_d_cs.S : tc_list = arm-lzma arm-linux.elf default @@ -24,6 +31,7 @@ tc.arm-lzma.gcc += -march=armv4 -fPIC tc.arm-lzma.gcc += -Os tc.arm-lzma.gcc += -ffunction-sections tc.arm-lzma.gcc += -I$(UPX_LZMADIR) +tc.arm-lzma.gcc += -I$(top_srcdir)/src lzma_d_c%.S : lzma_d_c.c $(call tc,gcc) $(PP_FLAGS) -c $< -o tmp/$T.o @@ -33,10 +41,7 @@ lzma_d_c%.S : lzma_d_c.c $(call tc,objdump) -b binary -m armv4 -D tmp/$T.out > tmp/$T.out.lst $(call tc,bin2h) --mode=gas tmp/$T.out $@ -lzma_d_cf.S : PP_FLAGS = -DFAST -lzma_d_cs.S : PP_FLAGS = -DSMALL - -lzma_d_cf.S : $(MAKEFILE_LIST) -lzma_d_cs.S : $(MAKEFILE_LIST) +lzma_d_cf.% : PP_FLAGS = -DFAST +lzma_d_cs.% : PP_FLAGS = -DSMALL endif diff --git a/src/stub/src/arch/arm/v4a/lzma_d_c.c b/src/stub/src/arch/arm/v4a/lzma_d_c.c index 7b342011..9d2c2c96 100644 --- a/src/stub/src/arch/arm/v4a/lzma_d_c.c +++ b/src/stub/src/arch/arm/v4a/lzma_d_c.c @@ -31,7 +31,7 @@ #define ACC_LIBC_NAKED #define ACC_OS_FREESTANDING -#include "../../../../../miniacc.h" +#include "miniacc.h" #undef _LZMA_IN_CB #undef _LZMA_OUT_READ diff --git a/src/stub/src/arch/arm/v4t/Makefile.extra b/src/stub/src/arch/arm/v4t/Makefile.extra index 34c0f8d2..ea86bc64 100644 --- a/src/stub/src/arch/arm/v4t/Makefile.extra +++ b/src/stub/src/arch/arm/v4t/Makefile.extra @@ -1,21 +1,28 @@ MAKEFLAGS += -rR .SUFFIXES: .SECONDEXPANSION: -export SHELL = /bin/sh -ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),) - -STUBS += lzma_d_cf.S lzma_d_cs.S +ifndef top_srcdir +__dir_list = . .. ../.. ../../.. ../../../.. ../../../../.. +__dir_list += ../../../../../.. ../../../../../../.. ../../../../../../../.. +__dir_search = $(firstword $(foreach v,$1,$(if $(wildcard $v/$2),$v)) $3) +top_srcdir := $(call __dir_search,$(__dir_list),src/bele.h,NOT_FOUND) +endif default.targets = all -all.targets = tmp/.tmp-stamp $(STUBS) -include $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))../../../../Makefile +STUBS = NO_STUBS +include $(top_srcdir)/src/stub/Makefile +STUBS = # /*********************************************************************** # // arm-lzma # ************************************************************************/ +ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),) + +STUBS += lzma_d_cf.S lzma_d_cs.S + lzma_d_cf.S : tc_list = arm-lzma arm-linux.elf default lzma_d_cs.S : tc_list = arm-lzma arm-linux.elf default @@ -24,6 +31,7 @@ tc.arm-lzma.gcc += -march=armv4t -mthumb -fPIC tc.arm-lzma.gcc += -Os tc.arm-lzma.gcc += -ffunction-sections tc.arm-lzma.gcc += -I$(UPX_LZMADIR) +tc.arm-lzma.gcc += -I$(top_srcdir)/src lzma_d_c%.S : lzma_d_c.c $(call tc,gcc) $(PP_FLAGS) -c $< -o tmp/$T.o @@ -33,10 +41,7 @@ lzma_d_c%.S : lzma_d_c.c $(call tc,objdump) -b binary -m armv4t -M force-thumb -D tmp/$T.out > tmp/$T.out.lst $(call tc,bin2h) --mode=gas tmp/$T.out $@ -lzma_d_cf.S : PP_FLAGS = -DFAST -lzma_d_cs.S : PP_FLAGS = -DSMALL - -lzma_d_cf.S : $(MAKEFILE_LIST) -lzma_d_cs.S : $(MAKEFILE_LIST) +lzma_d_cf.% : PP_FLAGS = -DFAST +lzma_d_cs.% : PP_FLAGS = -DSMALL endif diff --git a/src/stub/src/arch/arm/v4t/lzma_d_c.c b/src/stub/src/arch/arm/v4t/lzma_d_c.c index 7b342011..9d2c2c96 100644 --- a/src/stub/src/arch/arm/v4t/lzma_d_c.c +++ b/src/stub/src/arch/arm/v4t/lzma_d_c.c @@ -31,7 +31,7 @@ #define ACC_LIBC_NAKED #define ACC_OS_FREESTANDING -#include "../../../../../miniacc.h" +#include "miniacc.h" #undef _LZMA_IN_CB #undef _LZMA_OUT_READ diff --git a/src/stub/src/arch/i386/Makefile.extra b/src/stub/src/arch/i386/Makefile.extra index eaab8ac2..198a51db 100644 --- a/src/stub/src/arch/i386/Makefile.extra +++ b/src/stub/src/arch/i386/Makefile.extra @@ -1,27 +1,35 @@ MAKEFLAGS += -rR .SUFFIXES: .SECONDEXPANSION: -export SHELL = /bin/sh -ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),) - -STUBS += lzma_d_cf.ash lzma_d_cs.ash +ifndef top_srcdir +__dir_list = . .. ../.. ../../.. ../../../.. ../../../../.. +__dir_list += ../../../../../.. ../../../../../../.. ../../../../../../../.. +__dir_search = $(firstword $(foreach v,$1,$(if $(wildcard $v/$2),$v)) $3) +top_srcdir := $(call __dir_search,$(__dir_list),src/bele.h,NOT_FOUND) +endif default.targets = all -all.targets = tmp/.tmp-stamp $(STUBS) -include $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))../../../Makefile +STUBS = NO_STUBS +include $(top_srcdir)/src/stub/Makefile +STUBS = # /*********************************************************************** # // i386-lzma # ************************************************************************/ +ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),) + +STUBS += lzma_d_cf.ash lzma_d_cs.ash + lzma_d_cf.ash : tc_list = i386-lzma i386-linux.elf arch-i386 default lzma_d_cs.ash : tc_list = i386-lzma i386-linux.elf arch-i386 default tc.i386-lzma.gcc = $(tc.i386-linux.elf.gcc) tc.i386-lzma.gcc += -ffunction-sections tc.i386-lzma.gcc += -I$(UPX_LZMADIR) +tc.i386-lzma.gcc += -I$(top_srcdir)/src lzma_d_c%.ash : lzma_d_c.c $(call tc,gcc) $(PP_FLAGS) -c $< -o tmp/$T.o @@ -31,10 +39,7 @@ lzma_d_c%.ash : lzma_d_c.c $(call tc,objdump) -b binary -m i386 -D tmp/$T.out > tmp/$T.out.lst $(call tc,bin2h) --mode=nasm tmp/$T.out $@ -lzma_d_cf.ash : PP_FLAGS = -DFAST -lzma_d_cs.ash : PP_FLAGS = -DSMALL - -lzma_d_cf.ash : $(MAKEFILE_LIST) -lzma_d_cs.ash : $(MAKEFILE_LIST) +lzma_d_cf.% : PP_FLAGS = -DFAST +lzma_d_cs.% : PP_FLAGS = -DSMALL endif diff --git a/src/stub/src/arch/i386/lzma_d_c.c b/src/stub/src/arch/i386/lzma_d_c.c index cbe8cb08..9d2c2c96 100644 --- a/src/stub/src/arch/i386/lzma_d_c.c +++ b/src/stub/src/arch/i386/lzma_d_c.c @@ -31,7 +31,7 @@ #define ACC_LIBC_NAKED #define ACC_OS_FREESTANDING -#include "../../../../miniacc.h" +#include "miniacc.h" #undef _LZMA_IN_CB #undef _LZMA_OUT_READ diff --git a/src/stub/src/arch/powerpc/32/Makefile.extra b/src/stub/src/arch/powerpc/32/Makefile.extra index 184daaf4..97e06b21 100644 --- a/src/stub/src/arch/powerpc/32/Makefile.extra +++ b/src/stub/src/arch/powerpc/32/Makefile.extra @@ -1,21 +1,28 @@ MAKEFLAGS += -rR .SUFFIXES: .SECONDEXPANSION: -export SHELL = /bin/sh -ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),) - -STUBS += lzma_d_cf.S lzma_d_cs.S +ifndef top_srcdir +__dir_list = . .. ../.. ../../.. ../../../.. ../../../../.. +__dir_list += ../../../../../.. ../../../../../../.. ../../../../../../../.. +__dir_search = $(firstword $(foreach v,$1,$(if $(wildcard $v/$2),$v)) $3) +top_srcdir := $(call __dir_search,$(__dir_list),src/bele.h,NOT_FOUND) +endif default.targets = all -all.targets = tmp/.tmp-stamp $(STUBS) -include $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))../../../../Makefile +STUBS = NO_STUBS +include $(top_srcdir)/src/stub/Makefile +STUBS = # /*********************************************************************** # // powerpc-lzma # ************************************************************************/ +ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),) + +STUBS += lzma_d_cf.S lzma_d_cs.S + lzma_d_cf.S : tc_list = powerpc-lzma powerpc-linux.elf default lzma_d_cs.S : tc_list = powerpc-lzma powerpc-linux.elf default @@ -24,6 +31,7 @@ tc.powerpc-lzma.gcc += -mcpu=405 -fPIC tc.powerpc-lzma.gcc += -Os tc.powerpc-lzma.gcc += -ffunction-sections tc.powerpc-lzma.gcc += -I$(UPX_LZMADIR) +tc.powerpc-lzma.gcc += -I$(top_srcdir)/src lzma_d_c%.S : lzma_d_c.c $(call tc,gcc) $(PP_FLAGS) -c $< -o tmp/$T.o @@ -33,10 +41,7 @@ lzma_d_c%.S : lzma_d_c.c $(call tc,objdump) -b binary -m powerpc -D tmp/$T.out > tmp/$T.out.lst $(call tc,bin2h) --mode=gas tmp/$T.out $@ -lzma_d_cf.S : PP_FLAGS = -DFAST -lzma_d_cs.S : PP_FLAGS = -DSMALL - -lzma_d_cf.S : $(MAKEFILE_LIST) -lzma_d_cs.S : $(MAKEFILE_LIST) +lzma_d_cf.% : PP_FLAGS = -DFAST +lzma_d_cs.% : PP_FLAGS = -DSMALL endif diff --git a/src/stub/src/arch/powerpc/32/lzma_d_c.c b/src/stub/src/arch/powerpc/32/lzma_d_c.c index 7b342011..9d2c2c96 100644 --- a/src/stub/src/arch/powerpc/32/lzma_d_c.c +++ b/src/stub/src/arch/powerpc/32/lzma_d_c.c @@ -31,7 +31,7 @@ #define ACC_LIBC_NAKED #define ACC_OS_FREESTANDING -#include "../../../../../miniacc.h" +#include "miniacc.h" #undef _LZMA_IN_CB #undef _LZMA_OUT_READ