diff --git a/src/stub/Makefile b/src/stub/Makefile index 2e91eb54..9e43613a 100644 --- a/src/stub/Makefile +++ b/src/stub/Makefile @@ -18,6 +18,9 @@ export SHELL = /bin/sh ifneq ($(wildcard $(HOME)/local/bin/bin-upx),) export PATH := $(HOME)/local/bin/bin-upx:$(PATH) endif +ifneq ($(wildcard $(HOME)/bin/bin-upx),) +export PATH := $(HOME)/bin/bin-upx:$(PATH) +endif # /*********************************************************************** @@ -74,7 +77,7 @@ endif all: tmp/.tmp-stamp .all-stamp tmp/.tmp-stamp: - @mkdir -p tmp + @mkdir -p $(dir $@) @echo "timestamp" > $@ .all-stamp: $(STUBS) @echo "timestamp" > $@ @@ -113,7 +116,7 @@ tc.default.nasm += -I$(srcdir)/ -I$(srcdir)/src/ tc.default.nasm += -O99 -w+macro-params -w+macro-selfref -w+number-overflow -w+orphan-labels tc.default.pp-asm = i386-linux-gcc-2.95.3 -E -nostdinc -x assembler-with-cpp -Wall -Wp,-P,-C,-traditional tc.default.pp-nasm = $(tc.default.gpp_inc) --mode=nasm -I$(srcdir)/ -I$(srcdir)/src/ -tc.default.stripelf = sstrip +tc.default.sstrip = sstrip # some common settings for $(tc_list) tc.i086.app-nasm = perl -w $(srcdir)/src/arch/i086/app-nasm.pl @@ -123,13 +126,13 @@ tc.i386.app-nasm = perl -w $(srcdir)/src/arch/i386/app-nasm.pl # slightly tricky make stuff follows # error sentinel for missing commands -__tc_FALSE = false tc_FALSE: '$@' '$<' -# enumerate all variables that will get tested (from basename and $tc_list) -__tc_varlist = tc.$(basename $(notdir $@)).$1 $(foreach __tc_tmp,$(tc_list),tc.$(__tc_tmp).$1) +__tc_FALSE = false tc_FALSE: '$1' '$@' '$<' +# enumerate all variables that will get tested (from basename and $(tc_list)) +__tc_varlist = tc.$(basename $(notdir $@)).$1 $(foreach __tc_varlist_tmp,$(tc_list),tc.$(__tc_varlist_tmp).$1) # return the _name_ of the first variable that is not empty -__tc_varname = $(firstword $(foreach __tc_vn,$2,$(if $($(__tc_vn)),$(__tc_vn),)) __tc_FALSE) +__tc_varsearch = $(firstword $(foreach __tc_varsearch_tmp,$2,$(if $($(__tc_varsearch_tmp)),$(__tc_varsearch_tmp),)) $3) # expand the first variable that is not empty -tc = $($(call __tc_varname,$1,$(call __tc_varlist,$1))) +tc = $($(call __tc_varsearch,$1,$(call __tc_varlist,$1),__tc_FALSE)) # clear some vars, just in case @@ -148,6 +151,7 @@ IDENT_SUFFIX = amd64-linux.elf% : tc_list = amd64-linux.elf default tc.amd64-linux.elf.gcc = x86_64-unknown-linux-gnu-gcc-3.4.4 -m64 -nostdinc -MMD +tc.amd64-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables tc.amd64-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror tc.amd64-linux.elf.ld = x86_64-unknown-linux-gnu-ld -m elf_x86_64 tc.amd64-linux.elf.objcopy = x86_64-unknown-linux-gnu-objcopy @@ -161,7 +165,7 @@ amd64-linux.elf-entry.h : $(srcdir)/src/$$T.S amd64-linux.elf-fold.h : tmp/$$T.o tmp/amd64-linux.elf-main.o $(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^) - $(call tc,stripelf) tmp/$T.bin + $(call tc,sstrip) tmp/$T.bin $(call tc,bin2h) --ident=linux_elf64amd_fold tmp/$T.bin $@ tmp/amd64-linux.elf-fold.o : $(srcdir)/src/$$T.S @@ -169,7 +173,7 @@ tmp/amd64-linux.elf-fold.o : $(srcdir)/src/$$T.S $(call tc,objstrip) $@ tmp/amd64-linux.elf-main.o : $(srcdir)/src/$$T.c - $(call tc,gcc) -c -Os -fno-exceptions -fno-asynchronous-unwind-tables $< -o $@ + $(call tc,gcc) -c -Os $< -o $@ $(call tc,objstrip) $@ @@ -180,6 +184,7 @@ tmp/amd64-linux.elf-main.o : $(srcdir)/src/$$T.c arm-linux.elf% : tc_list = arm-linux.elf default tc.arm-linux.elf.gcc = arm-9tdmi-linux-gnu-gcc-3.4.5 -march=armv4 -nostdinc -MMD +tc.arm-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables tc.arm-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror tc.arm-linux.elf.ld = arm-9tdmi-linux-gnu-ld tc.arm-linux.elf.objcopy = arm-9tdmi-linux-gnu-objcopy @@ -192,7 +197,7 @@ arm-linux.elf-entry.h : $(srcdir)/src/$$T.S arm-linux.elf-fold.h : tmp/$$T.o tmp/arm-linux.elf-main.o $(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^) - $(call tc,stripelf) tmp/$T.bin + $(call tc,sstrip) tmp/$T.bin $(call tc,bin2h) --ident=linux_elf32arm_fold tmp/$T.bin $@ tmp/arm-linux.elf-fold.o : $(srcdir)/src/$$T.S @@ -200,7 +205,7 @@ tmp/arm-linux.elf-fold.o : $(srcdir)/src/$$T.S $(call tc,objstrip) $@ tmp/arm-linux.elf-main.o : $(srcdir)/src/$$T.c - $(call tc,gcc) -c -Os -fno-exceptions -fno-asynchronous-unwind-tables $< -o $@ + $(call tc,gcc) -c -Os $< -o $@ $(call tc,objstrip) $@ @@ -209,12 +214,9 @@ tmp/arm-linux.elf-main.o : $(srcdir)/src/$$T.c # // arm.v4t-wince.pe # ************************************************************************/ -arm.v4a-wince.pe% : tc_list = arm.v4a-wince.pe arm-wince.pe default -arm.v4t-wince.pe% : tc_list = arm.v4t-wince.pe arm-wince.pe default - -tc.arm-wince.pe.gcc = arm-9tdmi-linux-gnu-gcc-3.4.5 -nostdinc -MMD -tc.arm-wince.pe.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror -tc.arm-wince.pe.objcopy = arm-9tdmi-linux-gnu-objcopy +# info: we use the tc settings from arm-linux.elf +arm.v4a-wince.pe% : tc_list = arm-linux.elf default +arm.v4t-wince.pe% : tc_list = arm-linux.elf default arm.v4a-wince.pe.h : $(srcdir)/src/$$T.S $(call tc,gcc) -march=armv4 -nostdlib $< -o tmp/$T.out @@ -316,6 +318,7 @@ i386-dos32.watcom.le.h : $(srcdir)/src/$$T.asm i386-linux.elf% : tc_list = i386-linux.elf i386 default tc.i386-linux.elf.gcc = i386-linux-gcc-3.4.6 -m32 -nostdinc -MMD +tc.i386-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables tc.i386-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror tc.i386-linux.elf.gcc += -march=i386 -mtune=k6 tc.i386-linux.elf.gcc += -Os -fno-omit-frame-pointer @@ -336,7 +339,7 @@ i386-linux.elf-entry.h : $(srcdir)/src/$$T.asm i386-linux.elf-fold.h : tmp/$$T.o tmp/i386-linux.elf-main.o $(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^) $(call tc,objstrip) tmp/$T.bin - $(call tc,stripelf) tmp/$T.bin + $(call tc,sstrip) tmp/$T.bin $(call tc,brandelf) tmp/$T.bin $(call tc,bin2h) --ident=linux_i386elf_fold tmp/$T.bin $@ @@ -353,7 +356,7 @@ tmp/i386-linux.elf-main.o : $(srcdir)/src/$$T.c # // i386-linux.elf.execve # ************************************************************************/ -# tc settings are shared with i386-linux.elf +# note: tc_list settings are inherited from i386-linux.elf i386-linux.elf.execve-entry.h : $(srcdir)/src/$$T.asm $(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1 @@ -364,7 +367,7 @@ i386-linux.elf.execve-entry.h : $(srcdir)/src/$$T.asm i386-linux.elf.execve-fold.h : tmp/$$T.o tmp/i386-linux.elf.execve-main.o tmp/i386-linux.elf.execve-upx_itoa.o $(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^) $(call tc,objstrip) tmp/$T.bin - $(call tc,stripelf) tmp/$T.bin + $(call tc,sstrip) tmp/$T.bin $(call tc,brandelf) tmp/$T.bin $(call tc,bin2h) --ident=linux_i386exec_fold tmp/$T.bin $@ @@ -385,7 +388,7 @@ tmp/i386-linux.elf.execve-upx_itoa.o: $(srcdir)/src/$$T.asm # // i386-linux.elf.interp # ************************************************************************/ -# tc settings are shared with i386-linux.elf +# note: tc_list settings are inherited from i386-linux.elf i386-linux.elf.interp-entry.h : $(srcdir)/src/$$T.asm $(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1 @@ -396,7 +399,7 @@ i386-linux.elf.interp-entry.h : $(srcdir)/src/$$T.asm i386-linux.elf.interp-fold.h : tmp/$$T.o tmp/i386-linux.elf.interp-main.o $(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^) $(call tc,objstrip) tmp/$T.bin - $(call tc,stripelf) tmp/$T.bin + $(call tc,sstrip) tmp/$T.bin $(call tc,brandelf) tmp/$T.bin $(call tc,bin2h) --ident=linux_i386pti_fold tmp/$T.bin $@ @@ -413,7 +416,7 @@ tmp/i386-linux.elf.interp-main.o : $(srcdir)/src/$$T.c # // i386-linux.elf.shell # ************************************************************************/ -# tc settings are shared with i386-linux.elf +# note: tc_list settings are inherited from i386-linux.elf i386-linux.elf.shell-entry.h : $(srcdir)/src/$$T.asm $(call tc,pp-nasm) --MMD=$@ $< -o tmp/$T.tmp1 @@ -424,7 +427,7 @@ i386-linux.elf.shell-entry.h : $(srcdir)/src/$$T.asm i386-linux.elf.shell-fold.h : tmp/$$T.o tmp/i386-linux.elf.shell-main.o $(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^) $(call tc,objstrip) tmp/$T.bin - $(call tc,stripelf) tmp/$T.bin + $(call tc,sstrip) tmp/$T.bin $(call tc,brandelf) tmp/$T.bin $(call tc,bin2h) --ident=linux_i386sh_fold tmp/$T.bin $@ @@ -520,7 +523,8 @@ mipsel.r3000-ps1-console.h: IDENT_NAME = nrv_con_loader powerpc-linux.elf% : tc_list = powerpc-linux.elf default -tc.powerpc-linux.elf.gcc = powerpc-750-linux-gnu-gcc-3.4.4 -nostdinc -MMD +tc.powerpc-linux.elf.gcc = powerpc-750-linux-gnu-gcc-3.4.4 -mcpu=750 -nostdinc -MMD +tc.powerpc-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables tc.powerpc-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror tc.powerpc-linux.elf.ld = powerpc-750-linux-gnu-ld tc.powerpc-linux.elf.objcopy = powerpc-750-linux-gnu-objcopy @@ -534,7 +538,7 @@ powerpc-linux.elf-entry.h : $(srcdir)/src/$$T.S powerpc-linux.elf-fold.h : tmp/$$T.o tmp/powerpc-linux.elf-main.o $(call tc,ld) -T $(srcdir)/src/$T.lds -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^) -## $(call tc,stripelf) tmp/$T.bin ## FIXME / TODO +## $(call tc,sstrip) tmp/$T.bin ## FIXME / TODO $(call tc,bin2h) --ident=linux_elfppc32_fold tmp/$T.bin $@ tmp/powerpc-linux.elf-fold.o : $(srcdir)/src/$$T.S @@ -542,7 +546,7 @@ tmp/powerpc-linux.elf-fold.o : $(srcdir)/src/$$T.S $(call tc,objstrip) $@ tmp/powerpc-linux.elf-main.o : $(srcdir)/src/$$T.c - $(call tc,gcc) -c -Os -fno-exceptions -fno-asynchronous-unwind-tables $< -o $@ + $(call tc,gcc) -c -Os $< -o $@ $(call tc,objstrip) $@ @@ -560,7 +564,7 @@ powerpc-darwin.macho-entry.h : $(srcdir)/src/$$T.S powerpc-darwin.macho-fold.h : tmp/$$T.o tmp/powerpc-darwin.macho-main.o $(call tc,ld) --oformat binary -Map tmp/$T.map -o tmp/$T.bin --strip-all $(filter %.o,$^) -## $(call tc,stripelf) tmp/$T.bin ## FIXME / TODO +## $(call tc,sstrip) tmp/$T.bin ## FIXME / TODO $(call tc,bin2h) --ident=fold_machppc32 tmp/$T.bin $@ tmp/powerpc-darwin.macho-fold.o : $(srcdir)/src/$$T.S @@ -568,7 +572,7 @@ tmp/powerpc-darwin.macho-fold.o : $(srcdir)/src/$$T.S $(call tc,objstrip) $@ tmp/powerpc-darwin.macho-main.o : $(srcdir)/src/$$T.c - $(call tc,gcc) -c -Os -fno-exceptions -fno-asynchronous-unwind-tables $< -o $@ + $(call tc,gcc) -c -Os $< -o $@ $(call tc,objstrip) $@ @@ -590,7 +594,7 @@ define debug-diff -diff $(HOME)/p/compress/upx/680c27309177-upx.hg/src/stub/$2 $1 endef -debug-diff: $(STUBS) +debug-diff: all $(call debug-diff,amd64-linux.elf-entry.h,l_lx_elf64amd.h) $(call debug-diff,amd64-linux.elf-fold.h,fold_elf64amd.h) $(call debug-diff,arm-linux.elf-entry.h,l_lx_elf32arm.h) @@ -629,4 +633,4 @@ debug-diff: $(STUBS) $(call debug-diff,powerpc-linux.elf-fold.h,fold_elfppc32.h) -# vi:nowrap +# vi:ts=8:nowrap