10f3703acSApple OSS Distributionsinclude ../Makefile.common 2a3bb9fccSApple OSS Distributions 3a3bb9fccSApple OSS DistributionsCC = $(shell xcrun -sdk "$(SDKROOT)" -find cc) 4a3bb9fccSApple OSS DistributionsSTRIP = $(shell xcrun -sdk "$(SDKROOT)" -find strip) 5a3bb9fccSApple OSS DistributionsCODESIGN = $(shell xcrun -sdk "$(SDKROOT)" -find codesign) 6a3bb9fccSApple OSS Distributionsexport CODESIGN_ALLOCATE := $(shell xcrun -sdk "$(SDKROOT)" -find codesign_allocate) 7a3bb9fccSApple OSS DistributionsDSYMUTIL = $(shell xcrun -sdk "$(SDKROOT)" -find dsymutil) 8*bb611c8fSApple OSS DistributionsCFLAGS = -O0 -g -isysroot $(SDKROOT) $(ARCH_FLAGS) 9*bb611c8fSApple OSS DistributionsCFLAGS += -Wl,-sectcreate,__INFO_FILTER,__disable,/dev/null 10a3bb9fccSApple OSS DistributionsLDFLAGS = -dead_strip \ 11*bb611c8fSApple OSS Distributions -isysroot $(SDKROOT) $(ARCH_FLAGS) 12a3bb9fccSApple OSS Distributions 13a3bb9fccSApple OSS DistributionsOBJROOT?=$(shell /bin/pwd)/BUILD/obj 14a3bb9fccSApple OSS DistributionsSYMROOT?=$(shell /bin/pwd)/BUILD/sym 15a3bb9fccSApple OSS DistributionsDSTROOT?=$(shell /bin/pwd)/BUILD/dst 16855239e5SApple OSS Distributions 17855239e5SApple OSS DistributionsEXECUTABLES = exit.nodyld \ 18855239e5SApple OSS Distributions exit.nopie.dyld-but-no-Libsystem exit.pie.dyld-but-no-Libsystem \ 19855239e5SApple OSS Distributions exit.nopie.dyld-and-Libsystem exit.pie.dyld-and-Libsystem \ 20855239e5SApple OSS Distributions exit.nopie exit.pie \ 21a3bb9fccSApple OSS Distributions printexecinfo run test 22a3bb9fccSApple OSS DistributionsOBJECTS = exit-asm.o exit.o printexecinfo.o run.o 23855239e5SApple OSS Distributions 24a3bb9fccSApple OSS Distributionsdefault: $(addprefix $(DSTROOT)/,$(EXECUTABLES)) 25855239e5SApple OSS Distributions 26855239e5SApple OSS Distributionsclean: 27a3bb9fccSApple OSS Distributions rm -f $(addprefix $(OBJROOT)/,$(OBJECTS)) 28a3bb9fccSApple OSS Distributions rm -f $(addprefix $(SYMROOT)/,$(EXECUTABLES)) 29a3bb9fccSApple OSS Distributions rm -rf $(addsuffix .dSYM,$(addprefix $(SYMROOT)/,$(EXECUTABLES))) 30a3bb9fccSApple OSS Distributions rm -f $(addprefix $(DSTROOT)/,$(EXECUTABLES)) 31855239e5SApple OSS Distributions 32a3bb9fccSApple OSS Distributions# DEPENDENCIES 3388cc0b97SApple OSS Distributions$(addprefix $(DSTROOT)/,$(EXECUTABLES)): | DSTROOT SYMROOT 34855239e5SApple OSS Distributions 3588cc0b97SApple OSS Distributions$(addprefix $(OBJROOT)/,$(OBJECTS)): | OBJROOT 36a3bb9fccSApple OSS Distributions 37a3bb9fccSApple OSS DistributionsDSTROOT SYMROOT OBJROOT: 3888cc0b97SApple OSS Distributions $(_v)mkdir -p $($@) 39855239e5SApple OSS Distributions 40855239e5SApple OSS Distributions# OBJECTS 41855239e5SApple OSS Distributions 4288cc0b97SApple OSS Distributions$(OBJROOT)/exit-asm.o: exit-asm.S | OBJROOT 43855239e5SApple OSS Distributions $(CC) -c -o $@ $< $(CFLAGS) 44855239e5SApple OSS Distributions 4588cc0b97SApple OSS Distributions$(OBJROOT)/exit.o: exit.c | OBJROOT 46855239e5SApple OSS Distributions $(CC) -c -o $@ $< $(CFLAGS) 47855239e5SApple OSS Distributions 4888cc0b97SApple OSS Distributions$(OBJROOT)/printexecinfo.o: printexecinfo.c | OBJROOT 49a3bb9fccSApple OSS Distributions $(CC) -c -o $@ $< $(CFLAGS) 50a3bb9fccSApple OSS Distributions 5188cc0b97SApple OSS Distributions$(OBJROOT)/run.o: run.c | OBJROOT 52855239e5SApple OSS Distributions $(CC) -c -o $@ $< $(CFLAGS) 53855239e5SApple OSS Distributions 54855239e5SApple OSS Distributions# EXECUTABLES 55855239e5SApple OSS Distributions 56a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.nodyld: $(OBJROOT)/exit-asm.o 57a3bb9fccSApple OSS Distributions $(CC) -o $@ $< $(LDFLAGS) -e _main -nostartfiles -nodefaultlibs -static -Wl,-segalign,0x4000 58855239e5SApple OSS Distributions $(CODESIGN) -s - $@ 59855239e5SApple OSS Distributions 60a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.nopie.dyld-but-no-Libsystem: $(OBJROOT)/exit-asm.o 61a3bb9fccSApple OSS Distributions $(CC) -o $@ $< $(LDFLAGS) -e _main -Wl,-no_pie -nostartfiles -nodefaultlibs -Wl,-no_new_main 62855239e5SApple OSS Distributions $(CODESIGN) -s - $@ 63855239e5SApple OSS Distributions 64a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.pie.dyld-but-no-Libsystem: $(OBJROOT)/exit-asm.o 65a3bb9fccSApple OSS Distributions $(CC) -o $@ $< $(LDFLAGS) -e _main -Wl,-pie -nostartfiles -nodefaultlibs -Wl,-no_new_main 66855239e5SApple OSS Distributions $(CODESIGN) -s - $@ 67855239e5SApple OSS Distributions 68a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.nopie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o 69a3bb9fccSApple OSS Distributions $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie -nostartfiles -nodefaultlibs -lSystem 70855239e5SApple OSS Distributions $(CODESIGN) -s - $@ 71855239e5SApple OSS Distributions 72a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.pie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o 73a3bb9fccSApple OSS Distributions $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie -nostartfiles -nodefaultlibs -lSystem 74855239e5SApple OSS Distributions $(CODESIGN) -s - $@ 75855239e5SApple OSS Distributions 76a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.nopie: $(OBJROOT)/exit.o 77a3bb9fccSApple OSS Distributions $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie 78855239e5SApple OSS Distributions $(CODESIGN) -s - $@ 79855239e5SApple OSS Distributions 80a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.pie: $(OBJROOT)/exit.o 81a3bb9fccSApple OSS Distributions $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie 82855239e5SApple OSS Distributions $(CODESIGN) -s - $@ 83855239e5SApple OSS Distributions 84a3bb9fccSApple OSS Distributions$(DSTROOT)/printexecinfo: $(OBJROOT)/printexecinfo.o 85855239e5SApple OSS Distributions $(CC) -o $@ $< $(LDFLAGS) 86855239e5SApple OSS Distributions $(CODESIGN) -s - $@ 87855239e5SApple OSS Distributions 88a3bb9fccSApple OSS Distributions$(DSTROOT)/run: $(OBJROOT)/run.o 89a3bb9fccSApple OSS Distributions $(CC) -o $(SYMROOT)/run $< $(LDFLAGS) 90a3bb9fccSApple OSS Distributions $(DSYMUTIL) $(SYMROOT)/run 91a3bb9fccSApple OSS Distributions $(STRIP) -S -o $@ $(SYMROOT)/run 92a3bb9fccSApple OSS Distributions $(CODESIGN) -s - $@ 93855239e5SApple OSS Distributions 94a3bb9fccSApple OSS Distributions$(DSTROOT)/test: test.sh 95a3bb9fccSApple OSS Distributions install -m 755 $< $@ 96