]> git.saurik.com Git - apple/xnu.git/blame_incremental - tools/tests/personas/Makefile
xnu-6153.141.1.tar.gz
[apple/xnu.git] / tools / tests / personas / Makefile
... / ...
CommitLineData
1include ../Makefile.common
2
3CC:=$(shell xcrun -sdk "$(SDKROOT)" -find cc)
4CODESIGN:=$(shell xcrun -sdk "$(SDKROOT)" -find codesign)
5CODESIGN_ALLOCATE:=$(shell xcrun -sdk "$(SDKROOT)" -find codesign_allocate)
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
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))
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
35TARGETS := persona_mgr persona_spawn persona_test_run.sh persona_spawn_unentitled
36
37all: $(addprefix $(DSTROOT)/, $(TARGETS))
38
39$(DSTROOT)/persona_%: persona_%.c persona_test.h Makefile persona-entitlements.plist
40 ${CC} ${CFLAGS} ${ARCH_FLAGS} -o $(SYMROOT)/$(notdir $@) $<
41 env CODESIGN_ALLOCATE=$(CODESIGN_ALLOCATE) \
42 $(CODESIGN) -s - --entitlements persona-entitlements.plist $(SYMROOT)/$(notdir $@)
43 if [ ! -e $@ ]; then ditto $(SYMROOT)/$(notdir $@) $@; fi
44
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
50 cp $? $@
51 chmod +x $@
52
53clean:
54 rm -rf $(addprefix $(DSTROOT)/,$(TARGETS)) $(addprefix $(SYMROOT)/,$(TARGETS)) $(SYMROOT)/*.dSYM