]> git.saurik.com Git - apple/xnu.git/blame - tools/tests/personas/Makefile
xnu-6153.141.1.tar.gz
[apple/xnu.git] / tools / tests / personas / Makefile
CommitLineData
490019cf
A
1include ../Makefile.common
2
3CC:=$(shell xcrun -sdk "$(SDKROOT)" -find cc)
cb323159
A
4CODESIGN:=$(shell xcrun -sdk "$(SDKROOT)" -find codesign)
5CODESIGN_ALLOCATE:=$(shell xcrun -sdk "$(SDKROOT)" -find codesign_allocate)
490019cf
A
6
7SYMROOT?=$(shell /bin/pwd)
8
9CFLAGS := -g -O2 -isysroot $(SDKROOT) -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
10
11ifdef RC_ARCHS
12 ARCHS:=$(RC_ARCHS)
13 else
14 ifeq "$(Embedded)" "YES"
15 ARCHS:=armv7 armv7s arm64
16 else
17 ARCHS:=x86_64 i386
18 endif
19endif
20
d9a64523
A
21# These are convenience functions for filtering based on substrings, as the
22# normal filter functions only accept one wildcard.
23FILTER_OUT_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),,$(string))))
24FILTER_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),$(string),)))
25
26ARCH_32:=$(call FILTER_OUT_SUBSTRING,64,$(ARCHS))
27ARCH_64:=$(call FILTER_SUBSTRING,64,$(ARCHS))
490019cf
A
28
29ARCH_32_FLAGS := $(patsubst %, -arch %, $(ARCH_32))
30ARCH_64_FLAGS := $(patsubst %, -arch %, $(ARCH_64))
31ARCH_FLAGS := $(if $(ARCH_64), $(ARCH_64_FLAGS)) $(if $(ARCH_32), $(ARCH_32_FLAGS))
32
33DSTROOT?=$(shell /bin/pwd)
34
cb323159 35TARGETS := persona_mgr persona_spawn persona_test_run.sh persona_spawn_unentitled
490019cf
A
36
37all: $(addprefix $(DSTROOT)/, $(TARGETS))
38
cb323159 39$(DSTROOT)/persona_%: persona_%.c persona_test.h Makefile persona-entitlements.plist
490019cf 40 ${CC} ${CFLAGS} ${ARCH_FLAGS} -o $(SYMROOT)/$(notdir $@) $<
cb323159
A
41 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) \
42 $(CODESIGN) -s - --entitlements persona-entitlements.plist $(SYMROOT)/$(notdir $@)
490019cf
A
43 if [ ! -e $@ ]; then ditto $(SYMROOT)/$(notdir $@) $@; fi
44
cb323159
A
45$(DSTROOT)/persona_spawn_unentitled: persona_spawn.c persona_test.h Makefile
46 ${CC} ${CFLAGS} ${ARCH_FLAGS} -o $(SYMROOT)/$(notdir $@) $<
47 if [ ! -e $@ ]; then ditto $(SYMROOT)/$(notdir $@) $@; fi
48
49$(DSTROOT)/persona_test_run.sh: persona_test_run_src.sh
d9a64523
A
50 cp $? $@
51 chmod +x $@
52
490019cf
A
53clean:
54 rm -rf $(addprefix $(DSTROOT)/,$(TARGETS)) $(addprefix $(SYMROOT)/,$(TARGETS)) $(SYMROOT)/*.dSYM