]> git.saurik.com Git - apple/xnu.git/blame_incremental - tools/tests/execperf/Makefile
xnu-3248.60.10.tar.gz
[apple/xnu.git] / tools / tests / execperf / Makefile
... / ...
CommitLineData
1include ../Makefile.common
2
3ifdef 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
11endif
12
13CC = $(shell xcrun -sdk "$(SDKROOT)" -find cc)
14STRIP = $(shell xcrun -sdk "$(SDKROOT)" -find strip)
15CODESIGN = $(shell xcrun -sdk "$(SDKROOT)" -find codesign)
16export CODESIGN_ALLOCATE := $(shell xcrun -sdk "$(SDKROOT)" -find codesign_allocate)
17DSYMUTIL = $(shell xcrun -sdk "$(SDKROOT)" -find dsymutil)
18CFLAGS = -O0 -g -isysroot $(SDKROOT) $(patsubst %, -arch %,$(ARCHS))
19LDFLAGS = -dead_strip \
20 -isysroot $(SDKROOT) $(patsubst %, -arch %,$(ARCHS))
21
22OBJROOT?=$(shell /bin/pwd)/BUILD/obj
23SYMROOT?=$(shell /bin/pwd)/BUILD/sym
24DSTROOT?=$(shell /bin/pwd)/BUILD/dst
25
26EXECUTABLES = 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 \
30 printexecinfo run test
31OBJECTS = exit-asm.o exit.o printexecinfo.o run.o
32
33default: $(addprefix $(DSTROOT)/,$(EXECUTABLES))
34
35clean:
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))
40
41# DEPENDENCIES
42$(addprefix $(DSTROOT)/,$(EXECUTABLES)): | DSTROOT SYMROOT
43
44$(addprefix $(OBJROOT)/,$(OBJECTS)): | OBJROOT
45
46DSTROOT SYMROOT OBJROOT:
47 $(_v)mkdir -p $($@)
48
49# OBJECTS
50
51$(OBJROOT)/exit-asm.o: exit-asm.S | OBJROOT
52 $(CC) -c -o $@ $< $(CFLAGS)
53
54$(OBJROOT)/exit.o: exit.c | OBJROOT
55 $(CC) -c -o $@ $< $(CFLAGS)
56
57$(OBJROOT)/printexecinfo.o: printexecinfo.c | OBJROOT
58 $(CC) -c -o $@ $< $(CFLAGS)
59
60$(OBJROOT)/run.o: run.c | OBJROOT
61 $(CC) -c -o $@ $< $(CFLAGS)
62
63# EXECUTABLES
64
65$(DSTROOT)/exit.nodyld: $(OBJROOT)/exit-asm.o
66 $(CC) -o $@ $< $(LDFLAGS) -e _main -nostartfiles -nodefaultlibs -static -Wl,-segalign,0x4000
67 $(CODESIGN) -s - $@
68
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
71 $(CODESIGN) -s - $@
72
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
75 $(CODESIGN) -s - $@
76
77$(DSTROOT)/exit.nopie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o
78 $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie -nostartfiles -nodefaultlibs -lSystem
79 $(CODESIGN) -s - $@
80
81$(DSTROOT)/exit.pie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o
82 $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie -nostartfiles -nodefaultlibs -lSystem
83 $(CODESIGN) -s - $@
84
85$(DSTROOT)/exit.nopie: $(OBJROOT)/exit.o
86 $(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie
87 $(CODESIGN) -s - $@
88
89$(DSTROOT)/exit.pie: $(OBJROOT)/exit.o
90 $(CC) -o $@ $< $(LDFLAGS) -Wl,-pie
91 $(CODESIGN) -s - $@
92
93$(DSTROOT)/printexecinfo: $(OBJROOT)/printexecinfo.o
94 $(CC) -o $@ $< $(LDFLAGS)
95 $(CODESIGN) -s - $@
96
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 - $@
102
103$(DSTROOT)/test: test.sh
104 install -m 755 $< $@