📄 makefile
字号:
## UPX stub Makefile - needs GNU make 3.81 or better## You also will need a number of special build tools like various# cross-assemblers and cross-compilers - please see README.SRC# for details.#MAKEFLAGS += -rR.SUFFIXES:.SECONDEXPANSION:.NOTPARALLEL:export LC_ALL = Cexport SHELL = /bin/sh# internal make variablescomma := ,empty :=space := $(empty) $(empty)tab := $(empty) $(empty)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)endififndef srcdirsrcdir := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))srcdir := $(shell echo '$(srcdir)' | sed 's,/*$$,,')endififndef top_srcdirtop_srcdir := $(srcdir)/../..endifinclude $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)# update $PATH for our special stub build toolsifneq ($(wildcard $(HOME)/local/bin/bin-upx/.),)export PATH := $(HOME)/local/bin/bin-upx:$(PATH)endififneq ($(wildcard $(HOME)/bin/bin-upx/.),)export PATH := $(HOME)/bin/bin-upx:$(PATH)endif# /***********************************************************************# //# ************************************************************************/ifndef STUBSSTUBS += amd64-linux.elf-entry.hSTUBS += amd64-linux.elf-fold.hSTUBS += amd64-linux.kernel.vmlinux.hSTUBS += amd64-linux.kernel.vmlinux-head.hSTUBS += amd64-linux.kernel.vmlinuz.hSTUBS += arm-linux.elf-entry.hSTUBS += arm-linux.elf-fold.hSTUBS += arm-linux.kernel.vmlinux.hSTUBS += arm-linux.kernel.vmlinux-head.hSTUBS += armeb-linux.elf-entry.hSTUBS += armeb-linux.elf-fold.hSTUBS += armeb-linux.kernel.vmlinux.hSTUBS += armeb-linux.kernel.vmlinux-head.hSTUBS += arm.v4a-wince.pe.hSTUBS += arm.v4t-wince.pe.hSTUBS += i086-dos16.com.hSTUBS += i086-dos16.exe.hSTUBS += i086-dos16.sys.hSTUBS += i386-bsd.elf-entry.hSTUBS += i386-bsd.elf-fold.hSTUBS += i386-bsd.elf.execve-entry.hSTUBS += i386-bsd.elf.execve-fold.hSTUBS += i386-darwin.macho-entry.hSTUBS += i386-darwin.macho-fold.hSTUBS += i386-openbsd.elf-fold.hSTUBS += i386-dos32.djgpp2.hSTUBS += i386-dos32.djgpp2-stubify.hSTUBS += i386-dos32.tmt.hSTUBS += i386-dos32.watcom.le.hSTUBS += i386-linux.elf-entry.hSTUBS += i386-linux.elf-fold.hSTUBS += i386-linux.elf.execve-entry.hSTUBS += i386-linux.elf.execve-fold.hSTUBS += i386-linux.elf.interp-entry.hSTUBS += i386-linux.elf.interp-fold.hSTUBS += i386-linux.elf.shell-entry.hSTUBS += i386-linux.elf.shell-fold.hSTUBS += i386-linux.kernel.vmlinux.hSTUBS += i386-linux.kernel.vmlinux-head.hSTUBS += i386-linux.kernel.vmlinuz.hSTUBS += i386-win32.pe.hSTUBS += m68k-atari.tos.hSTUBS += mips.r3000-linux.elf-entry.hSTUBS += mips.r3000-linux.elf-fold.hSTUBS += mipsel.r3000-ps1.hSTUBS += mipsel.r3000-linux.elf-entry.hSTUBS += mipsel.r3000-linux.elf-fold.hSTUBS += powerpc-darwin.macho-entry.hSTUBS += powerpc-darwin.macho-fold.hSTUBS += powerpc-linux.elf-entry.hSTUBS += powerpc-linux.elf-fold.hSTUBS += powerpc-linux.kernel.vmlinux.hSTUBS += powerpc-linux.kernel.vmlinux-head.hendififndef default.targetsifeq ($(wildcard .all-stamp),)default.targets =default: @echo "UPX info: type 'make all' if you have all the required build tools."elsedefault.targets = alldefault: $$(default.targets)endifendifall.targets ?= .upx-stubtools-stamp tmp/.tmp-stamp .all-stampall: $$(all.targets).upx-stubtools-stamp: $(MAKEFILE_LIST) upx-stubtools-check-version 20060823 @echo "timestamp" > $@%/.tmp-stamp: @mkdir -p $(dir $@) @echo "timestamp" > $@.PRECIOUS: %/.tmp-stamp.all-stamp: $$(STUBS) @echo "timestamp" > $@ifeq ($(wildcard .all-stamp),)mostlyclean clean: distcleanelsemostlyclean clean: maintainer-cleanendifdistclean: rm -f .*-stamp rm -rf tmpmaintainer-clean: rm -f .upx-stubtools-stamp rm -rf tmp rm -f $(STUBS).PHONY: default all mostlyclean clean distclean maintainer-clean# util var for use in the rules - basename of the current targetoverride T = $(basename $(notdir $@))# clear some vars, just in caseLABEL_PREFIX =PP_FLAGS =tc_bfdarch =tc_bfdname =tc_list =tc_objdump_disasm_options =# commandsECHO_e = /bin/echo -eECHO_E = /bin/echo -EPERL = perlPYTHON = pythonUNIX2DOS := $(PERL) -i -pe 's/$$/\r/;'# trim (strip) trailing whitespaceRTRIM := sed -e 's/[ $(tab)]*$$//'# squeeze duplicate blank lines, delete empty first & last lineBLSQUEEZE := $(RTRIM) | cat --squeeze-blank | sed -e '1{/^$$/d}' -e '$${/^$$/d}'# delete blank linesBLDEL := $(RTRIM) | sed -e '/^$$/d'# delete blank lines at top (beginning) of fileBLDELTOP := sed -e '/./,$$!d'# delete blank lines at bottom (end) of fileBLDELBOT := sed -e ':a' -e '/^\n*$$/{$$d;N;ba' -e '}'# /***********************************************************************# // setup toolchain globals# ************************************************************************/# enumerate the names of all variables that will get tested (from basename and $(tc_list))__tc_varlist = tc.$(basename $(notdir $@)).$1 $(foreach v,$(tc_list),tc.$v.$1)# return the name of the first variable that is not empty__tc_varsearch = $(firstword $(foreach v,$1,$(if $($v),$v,)))# error sentinel for missing commands__tc_FALSE = false tc_FALSE: '1:$1 2:$2 3:$3 4:$4 5:$5' '$@' '$<' '$(tc_list)'# call (expand) the first variable that is not empty # [move the next comment line within the "tc" macro for debugging] # tc debug '1:$1 2:$2 3:$3 4:$4 5:$5' '$@' '$<' '$(tc_list)'define tc $(call $(call __tc_varsearch,$(call __tc_varlist,$1) __tc_FALSE),$2,$3,$4,$5)endef# default toolstc.default.bin2h = $(PYTHON) $(top_srcdir)/src/stub/scripts/bin2h.py --ident=auto-stub##tc.default.bin2h-c = $(call tc,bin2h) --compress=14,15,0tc.default.bin2h-c = $(call tc,bin2h) --compress=0tc.default.brandelf = $(PYTHON) $(top_srcdir)/src/stub/scripts/brandelf.py $(if $(tc_bfdname),--bfdname=$(tc_bfdname))tc.default.gpp_inc = $(PYTHON) $(top_srcdir)/src/stub/scripts/gpp_inc.pytc.default.gpp_mkdep = $(PYTHON) $(top_srcdir)/src/stub/scripts/gpp_inc.py -o /dev/nulltc.default.pp-as = i386-linux-gcc-3.4.6 -E -nostdinc -x assembler-with-cpp -Walltc.default.sstrip = sstriptc.default.xstrip = $(PYTHON) $(top_srcdir)/src/stub/scripts/xstrip.py# default multiarch-binutilstc.default.m-ar = multiarch-ar-2.17tc.default.m-ld = multiarch-ld-2.17 $(if $(tc_bfdname),-b $(tc_bfdname))tc.default.m-nm = multiarch-nm-2.17 $(if $(tc_bfdname),--target=$(tc_bfdname))tc.default.m-objcopy = multiarch-objcopy-2.17 $(if $(tc_bfdname),-F $(tc_bfdname))tc.default.m-objdump = multiarch-objdump-2.17 $(if $(tc_bfdname),-b $(tc_bfdname)) $(if $(tc_bfdarch),-m $(tc_bfdarch))tc.default.m-readelf = multiarch-readelf-2.17# default binutilstc.default.ld = $(call tc,m-ld)tc.default.nm = $(call tc,m-nm)tc.default.objcopy = $(call tc,m-objcopy)tc.default.objdump = $(call tc,m-objdump)tc.default.readelf = $(call tc,m-readelf)# default binutils functionsdefine tc.default.f-embed_objinfo chmod a-x $1 $(call tc,objcopy) --strip-unneeded $1 $(call tc,objcopy) -R .text -R .data -R .bss $1 $(call tc,objcopy) -R .comment -R .note -R .note.GNU-stack -R .reginfo $1 $(call tc,objdump) -Dr $(tc_objdump_disasm_options) $1 | $(RTRIM) > $1.disasm $(call tc,objdump) -htr -w $1 | $(BLSQUEEZE) | sed -e '1s/^.*: *file format/file format/' > $1.dump $(call tc,xstrip) --with-dump=$1.dump --create-bindump=$1.bindump $1 cat $1.dump >> $1endefdefine tc.default.f-objstrip chmod a-x $1 $(call tc,objcopy) -R .comment -R .note -R .note.GNU-stack -R .reginfo $1endef# some common arch settingstc.arch-i086.gcc = i386-linux-gcc-3.4.6 -m32 -march=i386 -nostdinc -MMD -MT $@tc.arch-i086.wdis = $(WATCOM)/binl/wdistc.arch-i386.gcc = i386-linux-gcc-3.4.6 -m32 -march=i386 -nostdinc -MMD -MT $@tc.arch-i386.djasm = djasm# /***********************************************************************# // amd64-linux.elf# ************************************************************************/amd64-linux.elf%.h : tc_list = amd64-linux.elf defaultamd64-linux.elf%.h : tc_bfdname = elf64-x86-64tc.amd64-linux.elf.gcc = amd64-linux-gcc-3.4.4 -m64 -nostdinc -MMD -MT $@tc.amd64-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tablestc.amd64-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wstrict-prototypes -Wwrite-strings -Werroramd64-linux.elf-entry.h: $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,f-embed_objinfo,tmp/$T.bin) $(call tc,bin2h) tmp/$T.bin $@amd64-linux.elf-fold.h : tmp/$$T.o tmp/amd64-linux.elf-main.o $(srcdir)/src/$$T.lds# # FIXME: multiarch-ld-2.18 creates a huge file here, so use 2.17# ####$(call tc,ld) --strip-all -T $(srcdir)/src/$T.lds -Map tmp/$T.map $(filter %.o,$^) -o tmp/$T.bin multiarch-ld-2.17 --strip-all -T $(srcdir)/src/$T.lds -Map tmp/$T.map $(filter %.o,$^) -o tmp/$T.bin $(call tc,f-objstrip,tmp/$T.bin) $(call tc,sstrip) tmp/$T.bin $(call tc,bin2h) tmp/$T.bin $@tmp/amd64-linux.elf-fold.o : $(srcdir)/src/$$T.S $(call tc,gcc) -c $< -o $@ $(call tc,f-objstrip,$@)tmp/amd64-linux.elf-main.o : $(srcdir)/src/$$T.c $(call tc,gcc) -c -Os $< -o $@ $(call tc,f-objstrip,$@) $(call tc,objdump) -dr $(tc_objdump_disasm_options) $@ | $(RTRIM) > $@.disasm# /***********************************************************************# // amd64-linux.kernel.vmlinux# // amd64-linux.kernel.vmlinuz# // amd64-linux.kernel.vmlinux-head# ************************************************************************/# info: we use the tc settings from arch-i386 !!amd64-linux.kernel.vmlinu%.h : tc_list = arch-i386 defaultamd64-linux.kernel.vmlinu%.h : tc_bfdname = elf32-i386amd64-linux.kernel.vmlinu%.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,f-embed_objinfo,tmp/$T.bin) $(call tc,bin2h-c) tmp/$T.bin $@amd64-linux.kernel.vmlinux-head.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.o $(call tc,objcopy) --output-target binary --only-section .text tmp/$T.o tmp/$T.bin $(call tc,bin2h) tmp/$T.bin $@# /***********************************************************************# // arm-linux.elf# ************************************************************************/arm-linux.elf%.h : tc_list = arm-linux.elf defaultarm-linux.elf%.h : tc_bfdname = elf32-littlearmtc.arm-linux.elf.gcc = arm-linux-gcc-4.1.0 -march=armv4 -nostdinc -MMD -MT $@tc.arm-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tablestc.arm-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wstrict-prototypes -Wwrite-strings -Werrorarm-linux.elf-entry.h : $(srcdir)/src/$$T.S $(call tc,gcc) -march=armv4 -c $< -o tmp/$T.bin $(call tc,f-embed_objinfo,tmp/$T.bin) $(call tc,bin2h) tmp/$T.bin $@arm-linux.elf-fold.h : tmp/$$T.o tmp/arm-linux.elf-main.o $(srcdir)/src/$$T.lds $(call tc,ld) --strip-all -T $(srcdir)/src/$T.lds -Map tmp/$T.map $(filter %.o,$^) -o tmp/$T.bin $(call tc,f-objstrip,tmp/$T.bin) $(call tc,sstrip) tmp/$T.bin $(call tc,bin2h) tmp/$T.bin $@tmp/arm-linux.elf-fold.o : $(srcdir)/src/$$T.S $(call tc,gcc) -c $< -o $@ $(call tc,f-objstrip,$@)tmp/arm-linux.elf-main.o : $(srcdir)/src/$$T.c $(call tc,gcc) -c -Os $< -o $@ $(call tc,f-objstrip,$@) $(call tc,objdump) -dr $(tc_objdump_disasm_options) $@ | $(RTRIM) > $@.disasm# /***********************************************************************# // arm-linux.kernel.vmlinux# // arm-linux.kernel.vmlinuz# // arm-linux.kernel.vmlinux-head# ************************************************************************/arm-linux.kernel.vmlinu%.h : tc_list = arm-linux.kernel defaultarm-linux.kernel.vmlinu%.h : tc_bfdname = elf32-littlearmtc.arm-linux.kernel.gcc = arm-linux-gcc-4.1.0 -march=armv5 -nostdinc -MMD -MT $@tc.arm-linux.kernel.gcc += -fno-exceptions -fno-asynchronous-unwind-tablestc.arm-linux.kernel.gcc += -Wall -W -Wcast-align -Wcast-qual -Wstrict-prototypes -Wwrite-strings -Werrorarm-linux.kernel.vmlinu%.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin $(call tc,f-embed_objinfo,tmp/$T.bin) $(call tc,bin2h-c) tmp/$T.bin $@arm-linux.kernel.vmlinux-head.h : $(srcdir)/src/$$T.S $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.o $(call tc,objcopy) --output-target binary --only-section .text tmp/$T.o tmp/$T.bin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -