1 include ../Makefile.common
3 CC = $(shell xcrun -sdk "$(SDKROOT)" -find cc)
4 STRIP = $(shell xcrun -sdk "$(SDKROOT)" -find strip)
5 CODESIGN = $(shell xcrun -sdk "$(SDKROOT)" -find codesign)
6 export CODESIGN_ALLOCATE := $(shell xcrun -sdk "$(SDKROOT)" -find codesign_allocate)
7 DSYMUTIL = $(shell xcrun -sdk "$(SDKROOT)" -find dsymutil)
8 CFLAGS = -O0 -g -isysroot $(SDKROOT) $(ARCH_FLAGS)
9 CFLAGS += -Wl,-sectcreate,__INFO_FILTER,__disable,/dev/null
10 LDFLAGS = -dead_strip \
11 -isysroot $(SDKROOT) $(ARCH_FLAGS)
13 OBJROOT?=$(shell /bin/pwd)/BUILD/obj
14 SYMROOT?=$(shell /bin/pwd)/BUILD/sym
15 DSTROOT?=$(shell /bin/pwd)/BUILD/dst
17 EXECUTABLES = exit.nodyld \
18 exit.nopie.dyld-but-no-Libsystem exit.pie.dyld-but-no-Libsystem \
19 exit.nopie.dyld-and-Libsystem exit.pie.dyld-and-Libsystem \
21 printexecinfo run test
22 OBJECTS = exit-asm.o exit.o printexecinfo.o run.o
24 default: $(addprefix $(DSTROOT)/,$(EXECUTABLES))
27 rm -f $(addprefix $(OBJROOT)/,$(OBJECTS))
28 rm -f $(addprefix $(SYMROOT)/,$(EXECUTABLES))
29 rm -rf $(addsuffix .dSYM,$(addprefix $(SYMROOT)/,$(EXECUTABLES)))
30 rm -f $(addprefix $(DSTROOT)/,$(EXECUTABLES))
33 $(addprefix $(DSTROOT)/,$(EXECUTABLES)): | DSTROOT SYMROOT
35 $(addprefix $(OBJROOT)/,$(OBJECTS)): | OBJROOT
37 DSTROOT SYMROOT OBJROOT:
42 $(OBJROOT)/exit-asm.o: exit-asm.S | OBJROOT
43 $(CC) -c -o $@ $< $(CFLAGS)
45 $(OBJROOT)/exit.o: exit.c | OBJROOT
46 $(CC) -c -o $@ $< $(CFLAGS)
48 $(OBJROOT)/printexecinfo.o: printexecinfo.c | OBJROOT
49 $(CC) -c -o $@ $< $(CFLAGS)
51 $(OBJROOT)/run.o: run.c | OBJROOT
52 $(CC) -c -o $@ $< $(CFLAGS)
56 $(DSTROOT)/exit.nodyld: $(OBJROOT)/exit-asm.o
57 $(CC) -o $@ $< $(LDFLAGS) -e _main -nostartfiles -nodefaultlibs -static -Wl,-segalign,0x4000
60 $(DSTROOT)/exit.nopie.dyld-but-no-Libsystem: $(OBJROOT)/exit-asm.o
61 $(CC) -o $@ $< $(LDFLAGS) -e _main -Wl,-no_pie -nostartfiles -nodefaultlibs -Wl,-no_new_main
64 $(DSTROOT)/exit.pie.dyld-but-no-Libsystem: $(OBJROOT)/exit-asm.o
65 $(CC) -o $@ $< $(LDFLAGS) -e _main -Wl,-pie -nostartfiles -nodefaultlibs -Wl,-no_new_main
68 $(DSTROOT)/exit.nopie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o
69 $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie -nostartfiles -nodefaultlibs -lSystem
72 $(DSTROOT)/exit.pie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o
73 $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie -nostartfiles -nodefaultlibs -lSystem
76 $(DSTROOT)/exit.nopie: $(OBJROOT)/exit.o
77 $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie
80 $(DSTROOT)/exit.pie: $(OBJROOT)/exit.o
81 $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie
84 $(DSTROOT)/printexecinfo: $(OBJROOT)/printexecinfo.o
85 $(CC) -o $@ $< $(LDFLAGS)
88 $(DSTROOT)/run: $(OBJROOT)/run.o
89 $(CC) -o $(SYMROOT)/run $< $(LDFLAGS)
90 $(DSYMUTIL) $(SYMROOT)/run
91 $(STRIP) -S -o $@ $(SYMROOT)/run
94 $(DSTROOT)/test: test.sh