1# 2# Common definitions for test directories 3# 4 5ifeq ($(RC_XBS),YES) 6_v = 7XCRUN := /usr/bin/xcrun -verbose 8else ifeq ($(VERBOSE),YES) 9_v = 10XCRUN := /usr/bin/xcrun -verbose 11else 12_v = @ 13XCRUN := /usr/bin/xcrun 14endif 15 16SDKROOT ?= macosx 17 18# SDKROOT may be passed as a shorthand like "iphoneos.internal". We 19# must resolve these to a full path and override SDKROOT. 20ifeq ($(origin SDKROOT_RESOLVED),undefined) 21export SDKROOT_RESOLVED := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-path) 22ifeq ($(strip $(SDKROOT)_$(SDKROOT_RESOLVED)),/_) 23SDKROOT_RESOLVED := / 24endif 25endif 26override SDKROOT = $(SDKROOT_RESOLVED) 27TARGETSDK:=$(SDKROOT_RESOLVED) 28SDKROOTPATH:=$(SDKROOT_RESOLVED) 29 30ifeq ($(origin SDKVERSION),undefined) 31export SDKVERSION := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-version) 32endif 33 34export PLATFORMPATH := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-platform-path) 35export SDKPLATFORM := $(shell echo $(PLATFORMPATH) | sed 's,^.*/\([^/]*\)\.platform$$,\1,') 36 37ifeq ($(origin PLATFORM),undefined) 38export PLATFORM := $(SDKPLATFORM) 39 40ifeq ($(PLATFORM),watchOS) 41 export PLATFORM := WatchOS 42endif 43 44 45endif 46 47SUPPORTED_EMBEDDED_PLATFORMS := iPhoneOS iPhoneOSNano tvOS AppleTVOS WatchOS BridgeOS 48 49 50Embedded = $(if $(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),YES,NO) 51 52# 53# Deployment target flag 54# 55ifeq ($(PLATFORM),MacOSX) 56 DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION) 57else ifeq ($(PLATFORM),WatchOS) 58 DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION) 59else ifeq ($(PLATFORM),tvOS) 60 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) 61else ifeq ($(PLATFORM),AppleTVOS) 62 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) 63else ifeq ($(PLATFORM),BridgeOS) 64 DEPLOYMENT_TARGET_FLAGS = -mbridgeos-version-min=$(SDKVERSION) 65else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) 66 DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION) 67else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),) 68 DEPLOYMENT_TARGET_FLAGS = 69else 70 DEPLOYMENT_TARGET_FLAGS = 71endif 72 73DEPLOYMENT_TARGET_DEFINES = -DXNU_PLATFORM_$(PLATFORM) 74 75# 76# Locate common utilities 77# These must all be exported into the environment and checked for already being 78# set to avoid calling xcrun repeatedly during a recursive make 79# 80ifeq ($(origin CC),default) 81 export CC := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find clang) 82endif 83ifeq ($(origin MIG),undefined) 84# Since mig comes from the XcodeDefault toolchain, it may complain about an 85# invalid version number if no SDKROOT environment variable is provided. 86 export MIG := SDKROOT=$(SDKROOT) $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find mig) 87endif 88ifeq ($(origin CODESIGN),undefined) 89 export CODESIGN := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find codesign) 90endif 91ifeq ($(origin CODESIGN_ALLOCATE),undefined) 92 export CODESIGN_ALLOCATE := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find codesign_allocate) 93endif 94ifeq ($(origin PLUTIL),undefined) 95 export PLUTIL := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find plutil) 96endif 97ifeq ($(origin STRIP),undefined) 98 export STRIP := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find strip) 99endif 100ifeq ($(origin DSYMUTIL),undefined) 101 export DSYMUTIL := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find dsymutil) 102endif 103 104# These are convenience functions for filtering based on substrings, as the 105# normal filter functions only accept one wildcard. 106FILTER_OUT_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),,$(string)))) 107FILTER_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),$(string),))) 108 109#arch configs if not provided 110ifdef RC_ARCHS 111ARCH_CONFIGS:=$(RC_ARCHS) 112endif 113 114ifeq ($(ARCH_CONFIGS),) 115PLATFORM_LOWERCASE:=$(shell echo "$(SDKPLATFORM)" | tr A-Z a-z) 116ARCH_CONFIGS:=$(shell /usr/bin/plutil -extract SupportedTargets.$(PLATFORM_LOWERCASE).Archs json -o - $(SDKROOT)/SDKSettings.plist | tr '",[]' ' ') 117PLATFORM_LOWERCASE:= 118endif 119 120ARCH_CONFIGS:=$(call FILTER_OUT_SUBSTRING,armv7,$(ARCH_CONFIGS)) 121 122ARCH_CONFIGS_64:=$(call FILTER_SUBSTRING,64,$(ARCH_CONFIGS)) 123ARCH_CONFIGS_x86:=$(call FILTER_SUBSTRING,x86_64,$(ARCH_CONFIGS)) 124 125ARCH_FLAGS:=$(foreach argarch,$(ARCH_CONFIGS), -arch $(argarch) ) 126ARCH_FLAGS_64:=$(foreach argarch,$(ARCH_CONFIGS_64), -arch $(argarch) ) 127ARCH_FLAGS_x86:=$(foreach argarch,$(ARCH_CONFIGS_x86), -arch $(argarch) ) 128