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