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 34ifeq ($(origin PLATFORM),undefined) 35export PLATFORMPATH := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-platform-path) 36export PLATFORM := $(shell echo $(PLATFORMPATH) | sed 's,^.*/\([^/]*\)\.platform$$,\1,') 37 38ifeq ($(PLATFORM),watchOS) 39 export PLATFORM := WatchOS 40endif 41endif 42 43SUPPORTED_EMBEDDED_PLATFORMS := iPhoneOS iPhoneOSNano tvOS AppleTVOS WatchOS BridgeOS 44 45 46Embedded = $(if $(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),YES,NO) 47 48# 49# Deployment target flag 50# 51ifeq ($(PLATFORM),MacOSX) 52 DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION) 53else ifeq ($(PLATFORM),WatchOS) 54 DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION) 55else ifeq ($(PLATFORM),tvOS) 56 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) 57else ifeq ($(PLATFORM),AppleTVOS) 58 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) 59else ifeq ($(PLATFORM),BridgeOS) 60 DEPLOYMENT_TARGET_FLAGS = -mbridgeos-version-min=$(SDKVERSION) 61else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) 62 DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION) 63else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),) 64 DEPLOYMENT_TARGET_FLAGS = 65else 66 DEPLOYMENT_TARGET_FLAGS = 67endif 68 69DEPLOYMENT_TARGET_DEFINES = -DPLATFORM_$(PLATFORM) 70 71# 72# Locate common utilities 73# These must all be exported into the environment and checked for already being 74# set to avoid calling xcrun repeatedly during a recursive make 75# 76ifeq ($(origin CC),default) 77 export CC := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find clang) 78endif 79ifeq ($(origin MIG),undefined) 80# Since mig comes from the XcodeDefault toolchain, it may complain about an 81# invalid version number if no SDKROOT environment variable is provided. 82 export MIG := SDKROOT=$(SDKROOT) $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find mig) 83endif 84ifeq ($(origin CODESIGN),undefined) 85 export CODESIGN := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find codesign) 86endif 87ifeq ($(origin CODESIGN_ALLOCATE),undefined) 88 export CODESIGN_ALLOCATE := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find codesign_allocate) 89endif 90ifeq ($(origin PLUTIL),undefined) 91 export PLUTIL := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find plutil) 92endif 93ifeq ($(origin STRIP),undefined) 94 export STRIP := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find strip) 95endif 96ifeq ($(origin DSYMUTIL),undefined) 97 export DSYMUTIL := $(shell $(XCRUN) -sdk "$(TARGETSDK)" -find dsymutil) 98endif 99 100# These are convenience functions for filtering based on substrings, as the 101# normal filter functions only accept one wildcard. 102FILTER_OUT_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),,$(string)))) 103FILTER_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),$(string),))) 104 105#arch configs if not provided 106ifdef RC_ARCHS 107ARCH_CONFIGS:=$(RC_ARCHS) 108endif 109 110ifeq ($(ARCH_CONFIGS),) 111PLATFORM_LOWERCASE:=$(shell echo "$(PLATFORM)" | tr A-Z a-z) 112ARCH_CONFIGS:=$(shell /usr/bin/plutil -extract SupportedTargets.$(PLATFORM_LOWERCASE).Archs json -o - $(SDKROOT)/SDKSettings.plist | tr '",[]' ' ') 113PLATFORM_LOWERCASE:= 114endif 115 116ARCH_CONFIGS_32:=$(call FILTER_OUT_SUBSTRING,64,$(ARCH_CONFIGS)) 117ARCH_CONFIGS_64:=$(call FILTER_SUBSTRING,64,$(ARCH_CONFIGS)) 118ARCH_CONFIGS_x86:=$(call FILTER_SUBSTRING,x86_64,$(ARCH_CONFIGS)) 119 120ARCH_FLAGS:=$(foreach argarch,$(ARCH_CONFIGS), -arch $(argarch) ) 121ARCH_FLAGS_32:=$(foreach argarch,$(ARCH_CONFIGS_32), -arch $(argarch) ) 122ARCH_FLAGS_64:=$(foreach argarch,$(ARCH_CONFIGS_64), -arch $(argarch) ) 123ARCH_FLAGS_x86:=$(foreach argarch,$(ARCH_CONFIGS_x86), -arch $(argarch) ) 124