1 include ../Makefile.common
6 ifeq "$(Embedded)" "YES"
7 ARCHS:=armv7 armv7s arm64
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)
18 CFLAGS = -O0 -g -isysroot $(SDKROOT) $(patsubst %, -arch %,$(ARCHS))
19 LDFLAGS = -dead_strip \
20 -isysroot $(SDKROOT) $(patsubst %, -arch %,$(ARCHS))
22 OBJROOT?=$(shell /bin/pwd)/BUILD/obj
23 SYMROOT?=$(shell /bin/pwd)/BUILD/sym
24 DSTROOT?=$(shell /bin/pwd)/BUILD/dst
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 \
30 printexecinfo run test
31 OBJECTS = exit-asm.o exit.o printexecinfo.o run.o
33 default: $(addprefix $(DSTROOT)/,$(EXECUTABLES))
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))
42 $(addprefix $(DSTROOT)/,$(EXECUTABLES)): | DSTROOT SYMROOT
44 $(addprefix $(OBJROOT)/,$(OBJECTS)): | OBJROOT
46 DSTROOT SYMROOT OBJROOT:
51 $(OBJROOT)/exit-asm.o: exit-asm.S | OBJROOT
52 $(CC) -c -o $@ $< $(CFLAGS)
54 $(OBJROOT)/exit.o: exit.c | OBJROOT
55 $(CC) -c -o $@ $< $(CFLAGS)
57 $(OBJROOT)/printexecinfo.o: printexecinfo.c | OBJROOT
58 $(CC) -c -o $@ $< $(CFLAGS)
60 $(OBJROOT)/run.o: run.c | OBJROOT
61 $(CC) -c -o $@ $< $(CFLAGS)
65 $(DSTROOT)/exit.nodyld: $(OBJROOT)/exit-asm.o
66 $(CC) -o $@ $< $(LDFLAGS) -e _main -nostartfiles -nodefaultlibs -static -Wl,-segalign,0x4000
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
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
77 $(DSTROOT)/exit.nopie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o
78 $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie -nostartfiles -nodefaultlibs -lSystem
81 $(DSTROOT)/exit.pie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o
82 $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie -nostartfiles -nodefaultlibs -lSystem
85 $(DSTROOT)/exit.nopie: $(OBJROOT)/exit.o
86 $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie
89 $(DSTROOT)/exit.pie: $(OBJROOT)/exit.o
90 $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie
93 $(DSTROOT)/printexecinfo: $(OBJROOT)/printexecinfo.o
94 $(CC) -o $@ $< $(LDFLAGS)
97 $(DSTROOT)/run: $(OBJROOT)/run.o
98 $(CC) -o $(SYMROOT)/run $< $(LDFLAGS)
99 $(DSYMUTIL) $(SYMROOT)/run
100 $(STRIP) -S -o $@ $(SYMROOT)/run
103 $(DSTROOT)/test: test.sh