]> git.saurik.com Git - apple/xnu.git/blob - tools/tests/Makefile.common
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tools / tests / Makefile.common
1 #
2 # Common definitions for test directories
3 #
4
5 XCRUN := /usr/bin/xcrun
6 SDKROOT ?= macosx.internal
7
8 # SDKROOT may be passed as a shorthand like "iphoneos.internal". We
9 # must resolve these to a full path and override SDKROOT.
10
11 SDKROOT_RESOLVED := $(shell xcrun -sdk $(SDKROOT) -show-sdk-path)
12 ifeq ($(strip $(SDKROOT)_$(SDKROOT_RESOLVED)),/_)
13 SDKROOT_RESOLVED := /
14 endif
15 override SDKROOT = $(SDKROOT_RESOLVED)
16
17 SDKVERSION := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-version)
18
19 PLATFORMPATH := $(shell xcrun -sdk $(SDKROOT) -show-sdk-platform-path)
20 PLATFORM := $(shell echo $(PLATFORMPATH) | sed 's,^.*/\([^/]*\)\.platform$$,\1,')
21
22 ifeq ($(PLATFORM),watchOS)
23 PLATFORM := WatchOS
24 endif
25
26 SUPPORTED_EMBEDDED_PLATFORMS := iPhoneOS iPhoneOSNano tvOS AppleTVOS WatchOS BridgeOS
27 Embedded = $(if $(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),YES,NO)
28
29 #
30 # Deployment target flag
31 #
32 ifeq ($(PLATFORM),MacOSX)
33 DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION)
34 else ifeq ($(PLATFORM),WatchOS)
35 DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION)
36 else ifeq ($(PLATFORM),tvOS)
37 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION)
38 else ifeq ($(PLATFORM),AppleTVOS)
39 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION)
40 else ifeq ($(PLATFORM),BridgeOS)
41 DEPLOYMENT_TARGET_FLAGS = -mbridgeos-version-min=$(SDKVERSION)
42 else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
43 DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION)
44 else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
45 DEPLOYMENT_TARGET_FLAGS =
46 else
47 DEPLOYMENT_TARGET_FLAGS =
48 endif
49
50 DEPLOYMENT_TARGET_DEFINES = -DPLATFORM_$(PLATFORM)
51
52 ifeq ($(RC_XBS),YES)
53 _v =
54 else ifeq ($(VERBOSE),YES)
55 _v =
56 else
57 _v = @
58 endif
59
60 # These are convenience functions for filtering based on substrings, as the
61 # normal filter functions only accept one wildcard.
62 FILTER_OUT_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),,$(string))))
63 FILTER_SUBSTRING=$(strip $(foreach string,$(2),$(if $(findstring $(1),$(string)),$(string),)))
64
65 #arch configs if not provided
66 ifdef RC_ARCHS
67 ARCH_CONFIGS:=$(RC_ARCHS)
68 endif
69
70 ifeq ($(ARCH_CONFIGS),)
71 PLATFORM_LOWERCASE:=$(shell echo "$(PLATFORM)" | tr A-Z a-z)
72 ARCH_CONFIGS:=$(shell /usr/bin/plutil -extract SupportedTargets.$(PLATFORM_LOWERCASE).Archs json -o - $(SDKROOT)/SDKSettings.plist | tr '",[]' ' ')
73 PLATFORM_LOWERCASE:=
74 endif
75
76 ARCH_CONFIGS_32:=$(call FILTER_OUT_SUBSTRING,64,$(ARCH_CONFIGS))
77 ARCH_CONFIGS_64:=$(call FILTER_SUBSTRING,64,$(ARCH_CONFIGS))
78 ARCH_CONFIGS_x86:=$(call FILTER_SUBSTRING,x86_64,$(ARCH_CONFIGS))
79
80 ARCH_FLAGS:=$(foreach argarch,$(ARCH_CONFIGS), -arch $(argarch) )
81 ARCH_FLAGS_32:=$(foreach argarch,$(ARCH_CONFIGS_32), -arch $(argarch) )
82 ARCH_FLAGS_64:=$(foreach argarch,$(ARCH_CONFIGS_64), -arch $(argarch) )
83 ARCH_FLAGS_x86:=$(foreach argarch,$(ARCH_CONFIGS_x86), -arch $(argarch) )