xref: /xnu-11215/tools/tests/execperf/Makefile (revision a3bb9fcc)
1855239e5SApple OSS DistributionsSDKROOT ?= /
2*a3bb9fccSApple OSS Distributionsifeq "$(RC_TARGET_CONFIG)" "iPhone"
3*a3bb9fccSApple OSS DistributionsEmbedded?=YES
4*a3bb9fccSApple OSS Distributionselse
5*a3bb9fccSApple OSS DistributionsEmbedded?=$(shell echo $(SDKROOT) | grep -iq iphoneos && echo YES || echo NO)
6*a3bb9fccSApple OSS Distributionsendif
7*a3bb9fccSApple OSS Distributions
8*a3bb9fccSApple OSS Distributionsifdef RC_ARCHS
9*a3bb9fccSApple OSS Distributions    ARCHS:=$(RC_ARCHS)
10*a3bb9fccSApple OSS Distributions  else
11*a3bb9fccSApple OSS Distributions    ifeq "$(Embedded)" "YES"
12*a3bb9fccSApple OSS Distributions      ARCHS:=armv7 armv7s arm64
13*a3bb9fccSApple OSS Distributions    else
14*a3bb9fccSApple OSS Distributions      ARCHS:=x86_64 i386
15*a3bb9fccSApple OSS Distributions  endif
16*a3bb9fccSApple OSS Distributionsendif
17*a3bb9fccSApple OSS Distributions
18*a3bb9fccSApple OSS DistributionsCC = $(shell xcrun -sdk "$(SDKROOT)" -find cc)
19*a3bb9fccSApple OSS DistributionsSTRIP = $(shell xcrun -sdk "$(SDKROOT)" -find strip)
20*a3bb9fccSApple OSS DistributionsCODESIGN = $(shell xcrun -sdk "$(SDKROOT)" -find codesign)
21*a3bb9fccSApple OSS Distributionsexport CODESIGN_ALLOCATE := $(shell xcrun -sdk "$(SDKROOT)" -find codesign_allocate)
22*a3bb9fccSApple OSS DistributionsDSYMUTIL = $(shell xcrun -sdk "$(SDKROOT)" -find dsymutil)
23855239e5SApple OSS DistributionsCFLAGS = -O0 -g -isysroot $(SDKROOT) $(patsubst %, -arch %,$(ARCHS))
24*a3bb9fccSApple OSS DistributionsLDFLAGS = -dead_strip \
25855239e5SApple OSS Distributions	-isysroot $(SDKROOT) $(patsubst %, -arch %,$(ARCHS))
26*a3bb9fccSApple OSS Distributions
27*a3bb9fccSApple OSS DistributionsOBJROOT?=$(shell /bin/pwd)/BUILD/obj
28*a3bb9fccSApple OSS DistributionsSYMROOT?=$(shell /bin/pwd)/BUILD/sym
29*a3bb9fccSApple OSS DistributionsDSTROOT?=$(shell /bin/pwd)/BUILD/dst
30855239e5SApple OSS Distributions
31855239e5SApple OSS DistributionsEXECUTABLES = exit.nodyld \
32855239e5SApple OSS Distributions	exit.nopie.dyld-but-no-Libsystem exit.pie.dyld-but-no-Libsystem \
33855239e5SApple OSS Distributions	exit.nopie.dyld-and-Libsystem exit.pie.dyld-and-Libsystem \
34855239e5SApple OSS Distributions	exit.nopie exit.pie \
35*a3bb9fccSApple OSS Distributions	printexecinfo run test
36*a3bb9fccSApple OSS DistributionsOBJECTS = exit-asm.o exit.o printexecinfo.o run.o
37855239e5SApple OSS Distributions
38*a3bb9fccSApple OSS Distributionsdefault: $(addprefix $(DSTROOT)/,$(EXECUTABLES))
39855239e5SApple OSS Distributions
40855239e5SApple OSS Distributionsclean:
41*a3bb9fccSApple OSS Distributions	rm -f $(addprefix $(OBJROOT)/,$(OBJECTS))
42*a3bb9fccSApple OSS Distributions	rm -f $(addprefix $(SYMROOT)/,$(EXECUTABLES))
43*a3bb9fccSApple OSS Distributions	rm -rf $(addsuffix .dSYM,$(addprefix $(SYMROOT)/,$(EXECUTABLES)))
44*a3bb9fccSApple OSS Distributions	rm -f $(addprefix $(DSTROOT)/,$(EXECUTABLES))
45855239e5SApple OSS Distributions
46*a3bb9fccSApple OSS Distributions# DEPENDENCIES
47*a3bb9fccSApple OSS Distributions$(addprefix $(DSTROOT)/,$(EXECUTABLES)): DSTROOT SYMROOT
48855239e5SApple OSS Distributions
49*a3bb9fccSApple OSS Distributions$(addprefix $(OBJROOT)/,$(OBJECTS)): OBJROOT
50*a3bb9fccSApple OSS Distributions
51*a3bb9fccSApple OSS DistributionsDSTROOT SYMROOT OBJROOT:
52*a3bb9fccSApple OSS Distributions	mkdir -p $($@)
53855239e5SApple OSS Distributions
54855239e5SApple OSS Distributions# OBJECTS
55855239e5SApple OSS Distributions
56*a3bb9fccSApple OSS Distributions$(OBJROOT)/exit-asm.o: exit-asm.S OBJROOT
57855239e5SApple OSS Distributions	$(CC) -c -o $@ $< $(CFLAGS)
58855239e5SApple OSS Distributions
59*a3bb9fccSApple OSS Distributions$(OBJROOT)/exit.o: exit.c OBJROOT
60855239e5SApple OSS Distributions	$(CC) -c -o $@ $< $(CFLAGS)
61855239e5SApple OSS Distributions
62*a3bb9fccSApple OSS Distributions$(OBJROOT)/printexecinfo.o: printexecinfo.c OBJROOT
63*a3bb9fccSApple OSS Distributions	$(CC) -c -o $@ $< $(CFLAGS)
64*a3bb9fccSApple OSS Distributions
65*a3bb9fccSApple OSS Distributions$(OBJROOT)/run.o: run.c OBJROOT
66855239e5SApple OSS Distributions	$(CC) -c -o $@ $< $(CFLAGS)
67855239e5SApple OSS Distributions
68855239e5SApple OSS Distributions# EXECUTABLES
69855239e5SApple OSS Distributions
70*a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.nodyld: $(OBJROOT)/exit-asm.o
71*a3bb9fccSApple OSS Distributions	$(CC) -o $@ $< $(LDFLAGS) -e _main -nostartfiles -nodefaultlibs -static -Wl,-segalign,0x4000
72855239e5SApple OSS Distributions	$(CODESIGN) -s - $@
73855239e5SApple OSS Distributions
74*a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.nopie.dyld-but-no-Libsystem: $(OBJROOT)/exit-asm.o
75*a3bb9fccSApple OSS Distributions	$(CC) -o $@ $< $(LDFLAGS) -e _main -Wl,-no_pie -nostartfiles -nodefaultlibs -Wl,-no_new_main
76855239e5SApple OSS Distributions	$(CODESIGN) -s - $@
77855239e5SApple OSS Distributions
78*a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.pie.dyld-but-no-Libsystem: $(OBJROOT)/exit-asm.o
79*a3bb9fccSApple OSS Distributions	$(CC) -o $@ $< $(LDFLAGS) -e _main -Wl,-pie -nostartfiles -nodefaultlibs -Wl,-no_new_main
80855239e5SApple OSS Distributions	$(CODESIGN) -s - $@
81855239e5SApple OSS Distributions
82*a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.nopie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o
83*a3bb9fccSApple OSS Distributions	$(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie -nostartfiles -nodefaultlibs -lSystem
84855239e5SApple OSS Distributions	$(CODESIGN) -s - $@
85855239e5SApple OSS Distributions
86*a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.pie.dyld-and-Libsystem: $(OBJROOT)/exit-asm.o
87*a3bb9fccSApple OSS Distributions	$(CC) -o $@ $< $(LDFLAGS) -Wl,-pie -nostartfiles -nodefaultlibs -lSystem
88855239e5SApple OSS Distributions	$(CODESIGN) -s - $@
89855239e5SApple OSS Distributions
90*a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.nopie: $(OBJROOT)/exit.o
91*a3bb9fccSApple OSS Distributions	$(CC) -o $@ $< $(LDFLAGS) -Wl,-no_pie
92855239e5SApple OSS Distributions	$(CODESIGN) -s - $@
93855239e5SApple OSS Distributions
94*a3bb9fccSApple OSS Distributions$(DSTROOT)/exit.pie: $(OBJROOT)/exit.o
95*a3bb9fccSApple OSS Distributions	$(CC) -o $@ $< $(LDFLAGS) -Wl,-pie
96855239e5SApple OSS Distributions	$(CODESIGN) -s - $@
97855239e5SApple OSS Distributions
98*a3bb9fccSApple OSS Distributions$(DSTROOT)/printexecinfo: $(OBJROOT)/printexecinfo.o
99855239e5SApple OSS Distributions	$(CC) -o $@ $< $(LDFLAGS)
100855239e5SApple OSS Distributions	$(CODESIGN) -s - $@
101855239e5SApple OSS Distributions
102*a3bb9fccSApple OSS Distributions$(DSTROOT)/run: $(OBJROOT)/run.o
103*a3bb9fccSApple OSS Distributions	$(CC) -o $(SYMROOT)/run $< $(LDFLAGS)
104*a3bb9fccSApple OSS Distributions	$(DSYMUTIL) $(SYMROOT)/run
105*a3bb9fccSApple OSS Distributions	$(STRIP) -S -o $@ $(SYMROOT)/run
106*a3bb9fccSApple OSS Distributions	$(CODESIGN) -s - $@
107855239e5SApple OSS Distributions
108*a3bb9fccSApple OSS Distributions$(DSTROOT)/test: test.sh
109*a3bb9fccSApple OSS Distributions	install -m 755 $< $@
110