]>
Commit | Line | Data |
---|---|---|
1 | include ../Makefile.common | |
2 | ||
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) | |
12 | ||
13 | OBJROOT?=$(shell /bin/pwd)/BUILD/obj | |
14 | SYMROOT?=$(shell /bin/pwd)/BUILD/sym | |
15 | DSTROOT?=$(shell /bin/pwd)/BUILD/dst | |
16 | ||
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 \ | |
20 | exit.nopie exit.pie \ | |
21 | printexecinfo run test | |
22 | OBJECTS = exit-asm.o exit.o printexecinfo.o run.o | |
23 | ||
24 | default: $(addprefix $(DSTROOT)/,$(EXECUTABLES)) | |
25 | ||
26 | clean: | |
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)) | |
31 | ||
32 | # DEPENDENCIES | |
33 | $(addprefix $(DSTROOT)/,$(EXECUTABLES)): | DSTROOT SYMROOT | |
34 | ||
35 | $(addprefix $(OBJROOT)/,$(OBJECTS)): | OBJROOT | |
36 | ||
37 | DSTROOT SYMROOT OBJROOT: | |
38 | $(_v)mkdir -p $($@) | |
39 | ||
40 | # OBJECTS | |
41 | ||
42 | $(OBJROOT)/exit-asm.o: exit-asm.S | OBJROOT | |
43 | $(CC) -c -o $@ $< $(CFLAGS) | |
44 | ||
45 | $(OBJROOT)/exit.o: exit.c | OBJROOT | |
46 | $(CC) -c -o $@ $< $(CFLAGS) | |
47 | ||
48 | $(OBJROOT)/printexecinfo.o: printexecinfo.c | OBJROOT | |
49 | $(CC) -c -o $@ $< $(CFLAGS) | |
50 | ||
51 | $(OBJROOT)/run.o: run.c | OBJROOT | |
52 | $(CC) -c -o $@ $< $(CFLAGS) | |
53 | ||
54 | # EXECUTABLES | |
55 | ||
56 | $(DSTROOT)/exit.nodyld: $(OBJROOT)/exit-asm.o | |
57 | $(CC) -o $@ $< $(LDFLAGS) -e _main -nostartfiles -nodefaultlibs -static -Wl,-segalign,0x4000 | |
58 | $(CODESIGN) -s - $@ | |
59 | ||
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 | |
62 | $(CODESIGN) -s - $@ | |
63 | ||
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 | |
66 | $(CODESIGN) -s - $@ | |
67 | ||
68 | $(DSTROOT)/exit.nopie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o | |
69 | $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie -nostartfiles -nodefaultlibs -lSystem | |
70 | $(CODESIGN) -s - $@ | |
71 | ||
72 | $(DSTROOT)/exit.pie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o | |
73 | $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie -nostartfiles -nodefaultlibs -lSystem | |
74 | $(CODESIGN) -s - $@ | |
75 | ||
76 | $(DSTROOT)/exit.nopie: $(OBJROOT)/exit.o | |
77 | $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie | |
78 | $(CODESIGN) -s - $@ | |
79 | ||
80 | $(DSTROOT)/exit.pie: $(OBJROOT)/exit.o | |
81 | $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie | |
82 | $(CODESIGN) -s - $@ | |
83 | ||
84 | $(DSTROOT)/printexecinfo: $(OBJROOT)/printexecinfo.o | |
85 | $(CC) -o $@ $< $(LDFLAGS) | |
86 | $(CODESIGN) -s - $@ | |
87 | ||
88 | $(DSTROOT)/run: $(OBJROOT)/run.o | |
89 | $(CC) -o $(SYMROOT)/run $< $(LDFLAGS) | |
90 | $(DSYMUTIL) $(SYMROOT)/run | |
91 | $(STRIP) -S -o $@ $(SYMROOT)/run | |
92 | $(CODESIGN) -s - $@ | |
93 | ||
94 | $(DSTROOT)/test: test.sh | |
95 | install -m 755 $< $@ |