1 include ../Makefile.common
3 CC:=$(shell xcrun -sdk "$(SDKROOT)" -find cc)
4 CODESIGN:=$(shell xcrun -sdk "$(SDKROOT)" -find codesign)
5 CODESIGN_ALLOCATE:=$(shell xcrun -sdk "$(SDKROOT)" -find codesign_allocate)
7 SYMROOT?=$(shell /bin/pwd)
9 CFLAGS := -g -O2 -isysroot $(SDKROOT) -I$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
14 ifeq "$(Embedded)" "YES"
15 ARCHS:=armv7 armv7s arm64
21 # These are convenience functions for filtering based on substrings, as the
22 # normal filter functions only accept one wildcard.
23 FILTER_OUT_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),,$(string))))
24 FILTER_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),$(string),)))
26 ARCH_32:=$(call FILTER_OUT_SUBSTRING,64,$(ARCHS))
27 ARCH_64:=$(call FILTER_SUBSTRING,64,$(ARCHS))
29 ARCH_32_FLAGS := $(patsubst %, -arch %, $(ARCH_32))
30 ARCH_64_FLAGS := $(patsubst %, -arch %, $(ARCH_64))
31 ARCH_FLAGS := $(if $(ARCH_64), $(ARCH_64_FLAGS)) $(if $(ARCH_32), $(ARCH_32_FLAGS))
33 DSTROOT?=$(shell /bin/pwd)
35 TARGETS := persona_mgr persona_spawn persona_test_run.sh persona_spawn_unentitled
37 all: $(addprefix $(DSTROOT)/, $(TARGETS))
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
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
49 $(DSTROOT)/persona_test_run.sh: persona_test_run_src.sh
54 rm -rf $(addprefix $(DSTROOT)/,$(TARGETS)) $(addprefix $(SYMROOT)/,$(TARGETS)) $(SYMROOT)/*.dSYM