]>
Commit | Line | Data |
---|---|---|
3e170ce0 | 1 | include ../Makefile.common |
fe8ab488 A |
2 | |
3 | ifdef RC_ARCHS | |
4 | ARCHS:=$(RC_ARCHS) | |
5 | else | |
6 | ifeq "$(Embedded)" "YES" | |
7 | ARCHS:=armv7 armv7s arm64 | |
8 | else | |
9 | ARCHS:=x86_64 i386 | |
10 | endif | |
11 | endif | |
12 | ||
13 | CC = $(shell xcrun -sdk "$(SDKROOT)" -find cc) | |
14 | STRIP = $(shell xcrun -sdk "$(SDKROOT)" -find strip) | |
15 | CODESIGN = $(shell xcrun -sdk "$(SDKROOT)" -find codesign) | |
16 | export CODESIGN_ALLOCATE := $(shell xcrun -sdk "$(SDKROOT)" -find codesign_allocate) | |
17 | DSYMUTIL = $(shell xcrun -sdk "$(SDKROOT)" -find dsymutil) | |
6d2010ae | 18 | CFLAGS = -O0 -g -isysroot $(SDKROOT) $(patsubst %, -arch %,$(ARCHS)) |
fe8ab488 | 19 | LDFLAGS = -dead_strip \ |
6d2010ae | 20 | -isysroot $(SDKROOT) $(patsubst %, -arch %,$(ARCHS)) |
fe8ab488 A |
21 | |
22 | OBJROOT?=$(shell /bin/pwd)/BUILD/obj | |
23 | SYMROOT?=$(shell /bin/pwd)/BUILD/sym | |
24 | DSTROOT?=$(shell /bin/pwd)/BUILD/dst | |
6d2010ae A |
25 | |
26 | EXECUTABLES = exit.nodyld \ | |
27 | exit.nopie.dyld-but-no-Libsystem exit.pie.dyld-but-no-Libsystem \ | |
28 | exit.nopie.dyld-and-Libsystem exit.pie.dyld-and-Libsystem \ | |
29 | exit.nopie exit.pie \ | |
fe8ab488 A |
30 | printexecinfo run test |
31 | OBJECTS = exit-asm.o exit.o printexecinfo.o run.o | |
6d2010ae | 32 | |
fe8ab488 | 33 | default: $(addprefix $(DSTROOT)/,$(EXECUTABLES)) |
6d2010ae A |
34 | |
35 | clean: | |
fe8ab488 A |
36 | rm -f $(addprefix $(OBJROOT)/,$(OBJECTS)) |
37 | rm -f $(addprefix $(SYMROOT)/,$(EXECUTABLES)) | |
38 | rm -rf $(addsuffix .dSYM,$(addprefix $(SYMROOT)/,$(EXECUTABLES))) | |
39 | rm -f $(addprefix $(DSTROOT)/,$(EXECUTABLES)) | |
6d2010ae | 40 | |
fe8ab488 | 41 | # DEPENDENCIES |
490019cf | 42 | $(addprefix $(DSTROOT)/,$(EXECUTABLES)): | DSTROOT SYMROOT |
6d2010ae | 43 | |
490019cf | 44 | $(addprefix $(OBJROOT)/,$(OBJECTS)): | OBJROOT |
fe8ab488 A |
45 | |
46 | DSTROOT SYMROOT OBJROOT: | |
490019cf | 47 | $(_v)mkdir -p $($@) |
6d2010ae A |
48 | |
49 | # OBJECTS | |
50 | ||
490019cf | 51 | $(OBJROOT)/exit-asm.o: exit-asm.S | OBJROOT |
6d2010ae A |
52 | $(CC) -c -o $@ $< $(CFLAGS) |
53 | ||
490019cf | 54 | $(OBJROOT)/exit.o: exit.c | OBJROOT |
6d2010ae A |
55 | $(CC) -c -o $@ $< $(CFLAGS) |
56 | ||
490019cf | 57 | $(OBJROOT)/printexecinfo.o: printexecinfo.c | OBJROOT |
fe8ab488 A |
58 | $(CC) -c -o $@ $< $(CFLAGS) |
59 | ||
490019cf | 60 | $(OBJROOT)/run.o: run.c | OBJROOT |
6d2010ae A |
61 | $(CC) -c -o $@ $< $(CFLAGS) |
62 | ||
63 | # EXECUTABLES | |
64 | ||
fe8ab488 A |
65 | $(DSTROOT)/exit.nodyld: $(OBJROOT)/exit-asm.o |
66 | $(CC) -o $@ $< $(LDFLAGS) -e _main -nostartfiles -nodefaultlibs -static -Wl,-segalign,0x4000 | |
6d2010ae A |
67 | $(CODESIGN) -s - $@ |
68 | ||
fe8ab488 A |
69 | $(DSTROOT)/exit.nopie.dyld-but-no-Libsystem: $(OBJROOT)/exit-asm.o |
70 | $(CC) -o $@ $< $(LDFLAGS) -e _main -Wl,-no_pie -nostartfiles -nodefaultlibs -Wl,-no_new_main | |
6d2010ae A |
71 | $(CODESIGN) -s - $@ |
72 | ||
fe8ab488 A |
73 | $(DSTROOT)/exit.pie.dyld-but-no-Libsystem: $(OBJROOT)/exit-asm.o |
74 | $(CC) -o $@ $< $(LDFLAGS) -e _main -Wl,-pie -nostartfiles -nodefaultlibs -Wl,-no_new_main | |
6d2010ae A |
75 | $(CODESIGN) -s - $@ |
76 | ||
fe8ab488 A |
77 | $(DSTROOT)/exit.nopie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o |
78 | $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie -nostartfiles -nodefaultlibs -lSystem | |
6d2010ae A |
79 | $(CODESIGN) -s - $@ |
80 | ||
fe8ab488 A |
81 | $(DSTROOT)/exit.pie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o |
82 | $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie -nostartfiles -nodefaultlibs -lSystem | |
6d2010ae A |
83 | $(CODESIGN) -s - $@ |
84 | ||
fe8ab488 A |
85 | $(DSTROOT)/exit.nopie: $(OBJROOT)/exit.o |
86 | $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie | |
6d2010ae A |
87 | $(CODESIGN) -s - $@ |
88 | ||
fe8ab488 A |
89 | $(DSTROOT)/exit.pie: $(OBJROOT)/exit.o |
90 | $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie | |
6d2010ae A |
91 | $(CODESIGN) -s - $@ |
92 | ||
fe8ab488 | 93 | $(DSTROOT)/printexecinfo: $(OBJROOT)/printexecinfo.o |
6d2010ae A |
94 | $(CC) -o $@ $< $(LDFLAGS) |
95 | $(CODESIGN) -s - $@ | |
96 | ||
fe8ab488 A |
97 | $(DSTROOT)/run: $(OBJROOT)/run.o |
98 | $(CC) -o $(SYMROOT)/run $< $(LDFLAGS) | |
99 | $(DSYMUTIL) $(SYMROOT)/run | |
100 | $(STRIP) -S -o $@ $(SYMROOT)/run | |
101 | $(CODESIGN) -s - $@ | |
6d2010ae | 102 | |
fe8ab488 A |
103 | $(DSTROOT)/test: test.sh |
104 | install -m 755 $< $@ |