xref: /xnu-12377.1.9/makedefs/MakeInc.cmd (revision f6217f891ac0bb64f3d375211650a4c1ff8ca1ea)
1*f6217f89SApple OSS Distributions# -*- mode: makefile;-*-
2*f6217f89SApple OSS Distributions#
3*f6217f89SApple OSS Distributions# Copyright (C) 1999-2020 Apple Inc. All rights reserved.
4*f6217f89SApple OSS Distributions#
5*f6217f89SApple OSS Distributions# MakeInc.cmd contains command paths for use during
6*f6217f89SApple OSS Distributions# the build, as well as make fragments and text
7*f6217f89SApple OSS Distributions# strings that may be evaluated as utility functions.
8*f6217f89SApple OSS Distributions#
9*f6217f89SApple OSS Distributions
10*f6217f89SApple OSS Distributions#
11*f6217f89SApple OSS Distributions# Commands for the build environment
12*f6217f89SApple OSS Distributions#
13*f6217f89SApple OSS Distributions
14*f6217f89SApple OSS Distributions#
15*f6217f89SApple OSS Distributions# Build Logging and Verbosity
16*f6217f89SApple OSS Distributions#
17*f6217f89SApple OSS Distributions
18*f6217f89SApple OSS Distributionsifeq ($(RC_XBS),YES)
19*f6217f89SApple OSS Distributions	VERBOSE = YES
20*f6217f89SApple OSS Distributionselse
21*f6217f89SApple OSS Distributions	VERBOSE = NO
22*f6217f89SApple OSS Distributionsendif
23*f6217f89SApple OSS Distributions
24*f6217f89SApple OSS DistributionsBASH = bash
25*f6217f89SApple OSS Distributions
26*f6217f89SApple OSS DistributionsECHO = echo
27*f6217f89SApple OSS Distributions
28*f6217f89SApple OSS DistributionsERR = $(ECHO) > /dev/stderr
29*f6217f89SApple OSS DistributionsPRINTF = printf
30*f6217f89SApple OSS Distributions
31*f6217f89SApple OSS DistributionsQUIET ?= 0
32*f6217f89SApple OSS Distributionsifneq ($(QUIET),0)
33*f6217f89SApple OSS Distributions	PRINTF = printf > /dev/null
34*f6217f89SApple OSS Distributions	ifeq ($(VERBOSE),YES)
35*f6217f89SApple OSS Distributions		override VERBOSE = NO
36*f6217f89SApple OSS Distributions	endif
37*f6217f89SApple OSS Distributionsendif
38*f6217f89SApple OSS Distributions
39*f6217f89SApple OSS Distributions# Helper functions for logging operations.
40*f6217f89SApple OSS DistributionsLOG_PFX_LEN = 15
41*f6217f89SApple OSS DistributionsLOG_PFX_LEN_ADJ = $(LOG_PFX_LEN)
42*f6217f89SApple OSS DistributionsLOG = $(PRINTF) "$2%$4s$(Color0) $3%s$(Color0)\n" "$1"
43*f6217f89SApple OSS Distributions
44*f6217f89SApple OSS DistributionsCONCISE ?= 0
45*f6217f89SApple OSS Distributionsifneq ($(CONCISE),0)
46*f6217f89SApple OSS Distributions	# Concise logging puts all logs on the same line (CSI K to clear and
47*f6217f89SApple OSS Distributions	# carriage return).
48*f6217f89SApple OSS Distributions	LOG = $(PRINTF) "$2%$4s$(Color0) $3%s$(Color0)\033[K\r" "$1"
49*f6217f89SApple OSS Distributionsendif
50*f6217f89SApple OSS Distributions
51*f6217f89SApple OSS Distributions_LOG_COMP = $(call LOG,$1,$(ColorC),$(ColorF),$(LOG_PFX_LEN_ADJ))
52*f6217f89SApple OSS Distributions_LOG_HOST = $(call LOG,$1,$(ColorH),$(ColorF),$(LOG_PFX_LEN))
53*f6217f89SApple OSS Distributions_LOG_HOST_LINK = $(call LOG,$1,$(ColorH),$(ColorLF),$(LOG_PFX_LEN))
54*f6217f89SApple OSS Distributions
55*f6217f89SApple OSS Distributions# Special operations.
56*f6217f89SApple OSS DistributionsLOG_LDFILELIST = $(call LOG,LDFILELIST,$(ColorL),$(ColorLF),$(LOG_PFX_LEN_ADJ))
57*f6217f89SApple OSS DistributionsLOG_MIG = $(call LOG,MIG,$(ColorM),$(ColorF),$(LOG_PFX_LEN_ADJ))
58*f6217f89SApple OSS DistributionsLOG_LD = $(call LOG,LD,$(ColorL),$(ColorF),$(LOG_PFX_LEN_ADJ))
59*f6217f89SApple OSS DistributionsLOG_ALIGN = $(call LOG,--------->,$(Color0),$(Color0),$(LOG_PFX_LEN))
60*f6217f89SApple OSS Distributions
61*f6217f89SApple OSS Distributions# Compiling/machine-specific operations.
62*f6217f89SApple OSS DistributionsLOG_CC = $(call _LOG_COMP,CC)
63*f6217f89SApple OSS DistributionsLOG_CXX = $(call _LOG_COMP,C++)
64*f6217f89SApple OSS DistributionsLOG_AS = $(call _LOG_COMP,AS)
65*f6217f89SApple OSS DistributionsLOG_LTO = $(call _LOG_COMP,LTO)
66*f6217f89SApple OSS DistributionsLOG_SYMBOLSET = $(call _LOG_COMP,SYMSET)
67*f6217f89SApple OSS DistributionsLOG_SYMBOLSETPLIST = $(call _LOG_COMP,SYMSETPLIST)
68*f6217f89SApple OSS DistributionsLOG_VERIFIER = $(call _LOG_COMP,VERIFIER)
69*f6217f89SApple OSS Distributions
70*f6217f89SApple OSS Distributions# Host-side operations.
71*f6217f89SApple OSS DistributionsLOG_TIGHTBEAMC = $(call _LOG_HOST,TIGHTBEAMC)
72*f6217f89SApple OSS DistributionsLOG_IIG = $(call _LOG_HOST,IIG)
73*f6217f89SApple OSS DistributionsLOG_HOST_CC = $(call _LOG_HOST,CC)
74*f6217f89SApple OSS DistributionsLOG_HOST_LD = $(call _LOG_HOST,LD)
75*f6217f89SApple OSS DistributionsLOG_HOST_CODESIGN = $(call _LOG_HOST,CODESIGN)
76*f6217f89SApple OSS DistributionsLOG_HOST_BISON = $(call _LOG_HOST,BISON)
77*f6217f89SApple OSS DistributionsLOG_HOST_FLEX = $(call _LOG_HOST,FLEX)
78*f6217f89SApple OSS DistributionsLOG_INSTALL = $(call _LOG_HOST,INSTALL)
79*f6217f89SApple OSS DistributionsLOG_INSTALLVARIANT = $(call _LOG_HOST,INSTALLVARIANT)
80*f6217f89SApple OSS DistributionsLOG_INSTALLSYM = $(call _LOG_HOST,INSTALLSYM)
81*f6217f89SApple OSS DistributionsLOG_INSTALLHDR = $(call _LOG_HOST,INSTALLHDR)
82*f6217f89SApple OSS DistributionsLOG_INSTALLMACROS = $(call _LOG_HOST,INSTALLMACROS)
83*f6217f89SApple OSS DistributionsLOG_INSTALLPY = $(call _LOG_HOST,INSTALLPY)
84*f6217f89SApple OSS DistributionsLOG_MAN = $(call _LOG_HOST,MAN)
85*f6217f89SApple OSS DistributionsLOG_MANLINK = $(call _LOG_HOST,MANLINK)
86*f6217f89SApple OSS DistributionsLOG_ALIAS = $(call _LOG_HOST,ALIAS)
87*f6217f89SApple OSS DistributionsLOG_STRIP = $(call _LOG_HOST,STRIP)
88*f6217f89SApple OSS DistributionsLOG_DSYMUTIL = $(call _LOG_HOST,DSYMUTIL)
89*f6217f89SApple OSS DistributionsLOG_LIBTOOL = $(call _LOG_HOST,LIBTOOL)
90*f6217f89SApple OSS DistributionsLOG_FILEPREP = $(call _LOG_HOST,FILEPREP)
91*f6217f89SApple OSS Distributions
92*f6217f89SApple OSS Distributions# Host-side linking operations.
93*f6217f89SApple OSS DistributionsLOG_GENASSYM = $(call _LOG_HOST_LINK,GENASSYM)
94*f6217f89SApple OSS DistributionsLOG_GENERATE= $(call _LOG_HOST_LINK,GENERATE)
95*f6217f89SApple OSS DistributionsLOG_CTFCONVERT = $(call _LOG_HOST_LINK,CTFCONVERT)
96*f6217f89SApple OSS DistributionsLOG_CTFMERGE = $(call _LOG_HOST_LINK,CTFMERGE)
97*f6217f89SApple OSS DistributionsLOG_CTFINSERT = $(call _LOG_HOST_LINK,CTFINSERT)
98*f6217f89SApple OSS DistributionsLOG_DSYMUTIL = $(call _LOG_HOST_LINK,DSYMUTIL)
99*f6217f89SApple OSS DistributionsLOG_SUPPORTED_KPI = $(call _LOG_HOST_LINK,SUPPORTED_KPI)
100*f6217f89SApple OSS Distributions
101*f6217f89SApple OSS Distributions
102*f6217f89SApple OSS Distributionsifeq ($(VERBOSE),YES)
103*f6217f89SApple OSS Distributions	_v =
104*f6217f89SApple OSS Distributions	_vstdout =
105*f6217f89SApple OSS Distributions	_vstderr =
106*f6217f89SApple OSS Distributions	XCRUN = /usr/bin/xcrun -verbose
107*f6217f89SApple OSS Distributionselse
108*f6217f89SApple OSS Distributions	_v = @
109*f6217f89SApple OSS Distributions	_vstdout = > /dev/null
110*f6217f89SApple OSS Distributions	_vstderr = 2> /dev/null
111*f6217f89SApple OSS Distributions	XCRUN = /usr/bin/xcrun
112*f6217f89SApple OSS Distributionsendif
113*f6217f89SApple OSS Distributions
114*f6217f89SApple OSS DistributionsVERBOSE_GENERATED_MAKE_FRAGMENTS = NO
115*f6217f89SApple OSS Distributions
116*f6217f89SApple OSS Distributions#
117*f6217f89SApple OSS Distributions# Defaults
118*f6217f89SApple OSS Distributions#
119*f6217f89SApple OSS Distributions
120*f6217f89SApple OSS DistributionsSDKROOT ?= macosx
121*f6217f89SApple OSS DistributionsHOST_SDKROOT ?= macosx
122*f6217f89SApple OSS Distributions
123*f6217f89SApple OSS Distributions# SDKROOT may be passed as a shorthand like "iphoneos.internal". We
124*f6217f89SApple OSS Distributions# must resolve these to a full path and override SDKROOT.
125*f6217f89SApple OSS Distributions
126*f6217f89SApple OSS Distributionsifeq ($(origin SDKROOT_RESOLVED),undefined)
127*f6217f89SApple OSS Distributionsexport SDKROOT_RESOLVED := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-path)
128*f6217f89SApple OSS Distributionsifeq ($(strip $(SDKROOT)_$(SDKROOT_RESOLVED)),/_)
129*f6217f89SApple OSS Distributionsexport SDKROOT_RESOLVED := /
130*f6217f89SApple OSS Distributionsendif
131*f6217f89SApple OSS Distributionsendif
132*f6217f89SApple OSS Distributionsoverride SDKROOT = $(SDKROOT_RESOLVED)
133*f6217f89SApple OSS Distributions
134*f6217f89SApple OSS Distributionsifeq ($(origin HOST_SDKROOT_RESOLVED),undefined)
135*f6217f89SApple OSS Distributionsexport HOST_SDKROOT_RESOLVED := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -show-sdk-path)
136*f6217f89SApple OSS Distributionsifeq ($(strip $(HOST_SDKROOT_RESOLVED)),)
137*f6217f89SApple OSS Distributionsexport HOST_SDKROOT_RESOLVED := /
138*f6217f89SApple OSS Distributionsendif
139*f6217f89SApple OSS Distributionsendif
140*f6217f89SApple OSS Distributionsoverride HOST_SDKROOT = $(HOST_SDKROOT_RESOLVED)
141*f6217f89SApple OSS Distributions
142*f6217f89SApple OSS Distributionsifeq ($(origin SDKVERSION),undefined)
143*f6217f89SApple OSS Distributions     export SDKVERSION := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-version)
144*f6217f89SApple OSS Distributionsendif
145*f6217f89SApple OSS Distributions
146*f6217f89SApple OSS Distributionsifeq ($(origin PLATFORM),undefined)
147*f6217f89SApple OSS Distributions	export PLATFORMPATH := $(shell $(XCRUN) -sdk $(SDKROOT) -show-sdk-platform-path)
148*f6217f89SApple OSS Distributions	export PLATFORM := $(shell echo $(PLATFORMPATH) | sed 's,^.*/\([^/]*\)\.platform$$,\1,' | sed 's,\.[^.]*$$,,')
149*f6217f89SApple OSS Distributions	ifeq ($(PLATFORM),)
150*f6217f89SApple OSS Distributions		export PLATFORM := MacOSX
151*f6217f89SApple OSS Distributions	else ifeq ($(shell echo $(PLATFORM) | tr A-Z a-z),watchos)
152*f6217f89SApple OSS Distributions		export PLATFORM := WatchOS
153*f6217f89SApple OSS Distributions	endif
154*f6217f89SApple OSS Distributionsendif
155*f6217f89SApple OSS Distributions
156*f6217f89SApple OSS Distributionsifeq ($(PLATFORM),DriverKit)
157*f6217f89SApple OSS Distributions	ifeq ($(origin COHORT_SDKROOT_RESOLVED),undefined)
158*f6217f89SApple OSS Distributions		SDK_NAME = $(notdir $(SDKROOT))
159*f6217f89SApple OSS Distributions		export COHORT_NAME := $(shell echo $(SDK_NAME) | sed -e 's|DriverKit.\([a-zA-Z]*\)$(SDKVERSION)\([.Internal]*\).sdk|\1\2|g' | tr A-Z a-z)
160*f6217f89SApple OSS Distributions		export COHORT_SDKROOT_RESOLVED := $(shell $(XCRUN) -sdk $(COHORT_NAME) -show-sdk-path)
161*f6217f89SApple OSS Distributions		ifeq ($(strip $(COHORT_SDKROOT_RESOLVED)),)
162*f6217f89SApple OSS Distributions		export COHORT_SDKROOT_RESOLVED := $(SDKROOT_RESOLVED)
163*f6217f89SApple OSS Distributions		endif
164*f6217f89SApple OSS Distributions	endif
165*f6217f89SApple OSS Distributions	override COHORT_SDKROOT = $(COHORT_SDKROOT_RESOLVED)
166*f6217f89SApple OSS Distributions	export PLATFORMPATH = $(shell $(XCRUN) -sdk $(COHORT_SDKROOT) -show-sdk-platform-path)
167*f6217f89SApple OSS Distributions	export PLATFORM := DriverKit
168*f6217f89SApple OSS Distributions	export DRIVERKIT ?= 1
169*f6217f89SApple OSS Distributions	export DRIVERKITROOT ?= /System/DriverKit
170*f6217f89SApple OSS Distributions	export DRIVERKITRUNTIMEROOT = $(DRIVERKITROOT)/Runtime
171*f6217f89SApple OSS Distributionselse
172*f6217f89SApple OSS Distributions	override COHORT_SDKROOT = $(SDKROOT)
173*f6217f89SApple OSS Distributionsendif
174*f6217f89SApple OSS Distributions
175*f6217f89SApple OSS Distributionsifeq ($(PLATFORM),MacOSX)
176*f6217f89SApple OSS Distributions	ifeq (DriverKit,$(shell echo $(SDKROOT_RESOLVED) | sed 's|^.*/\([^./1-9]*\)\(\.[^./1-9]*\)\{0,1\}[1-9][^/]*\.sdk$$|\1|'))
177*f6217f89SApple OSS Distributions		export PLATFORM := DriverKit
178*f6217f89SApple OSS Distributions		export DRIVERKIT ?= 1
179*f6217f89SApple OSS Distributions		export DRIVERKITROOT ?= /System/DriverKit
180*f6217f89SApple OSS Distributions		export DRIVERKITRUNTIMEROOT = $(DRIVERKITROOT)/Runtime
181*f6217f89SApple OSS Distributions	endif
182*f6217f89SApple OSS Distributionsendif
183*f6217f89SApple OSS Distributions
184*f6217f89SApple OSS Distributionsifeq ($(PLATFORM),ExclaveKit)
185*f6217f89SApple OSS Distributions	ifeq ($(origin COHORT_SDKROOT_RESOLVED),undefined)
186*f6217f89SApple OSS Distributions		SDK_NAME = $(notdir $(SDKROOT))
187*f6217f89SApple OSS Distributions		export COHORT_NAME := $(shell echo $(SDK_NAME) | sed -e 's|ExclaveKit.\([a-zA-Z]*\)$(SDKVERSION)\([.Internal]*\).sdk|\1\2|g' | tr A-Z a-z)
188*f6217f89SApple OSS Distributions		export COHORT_SDKROOT_RESOLVED := $(shell $(XCRUN) -sdk $(COHORT_NAME) -show-sdk-path)
189*f6217f89SApple OSS Distributions		ifeq ($(strip $(COHORT_SDKROOT_RESOLVED)),)
190*f6217f89SApple OSS Distributions		export COHORT_SDKROOT_RESOLVED := $(SDKROOT_RESOLVED)
191*f6217f89SApple OSS Distributions		endif
192*f6217f89SApple OSS Distributions	endif
193*f6217f89SApple OSS Distributions	override COHORT_SDKROOT = $(COHORT_SDKROOT_RESOLVED)
194*f6217f89SApple OSS Distributions	export PLATFORMPATH = $(shell $(XCRUN) -sdk $(COHORT_SDKROOT) -show-sdk-platform-path)
195*f6217f89SApple OSS Distributions	export PLATFORM := ExclaveKit
196*f6217f89SApple OSS Distributions	export EXCLAVEKIT ?= 1
197*f6217f89SApple OSS Distributions	export EXCLAVEKITROOT ?= /System/ExclaveKit
198*f6217f89SApple OSS Distributionsendif
199*f6217f89SApple OSS Distributions
200*f6217f89SApple OSS Distributionsifeq ($(PLATFORM),ExclaveCore)
201*f6217f89SApple OSS Distributions	ifeq ($(origin COHORT_SDKROOT_RESOLVED),undefined)
202*f6217f89SApple OSS Distributions		SDK_NAME = $(notdir $(SDKROOT))
203*f6217f89SApple OSS Distributions		export COHORT_NAME := $(shell echo $(SDK_NAME) | sed -e 's|ExclaveCore.\([a-zA-Z]*\)$(SDKVERSION)\([.Internal]*\).sdk|\1\2|g' | tr A-Z a-z)
204*f6217f89SApple OSS Distributions		export COHORT_SDKROOT_RESOLVED := $(shell $(XCRUN) -sdk $(COHORT_NAME) -show-sdk-path)
205*f6217f89SApple OSS Distributions		ifeq ($(strip $(COHORT_SDKROOT_RESOLVED)),)
206*f6217f89SApple OSS Distributions		export COHORT_SDKROOT_RESOLVED := $(SDKROOT_RESOLVED)
207*f6217f89SApple OSS Distributions		endif
208*f6217f89SApple OSS Distributions	endif
209*f6217f89SApple OSS Distributions	override COHORT_SDKROOT = $(COHORT_SDKROOT_RESOLVED)
210*f6217f89SApple OSS Distributions	export PLATFORMPATH = $(shell $(XCRUN) -sdk $(COHORT_SDKROOT) -show-sdk-platform-path)
211*f6217f89SApple OSS Distributions	export PLATFORM := ExclaveCore
212*f6217f89SApple OSS Distributions	export EXCLAVECORE ?= 1
213*f6217f89SApple OSS Distributions	export EXCLAVECOREROOT ?= /System/ExclaveCore
214*f6217f89SApple OSS Distributionsendif
215*f6217f89SApple OSS Distributions
216*f6217f89SApple OSS Distributions# CC/CXX get defined by make(1) by default, so we can't check them
217*f6217f89SApple OSS Distributions# against the empty string to see if they haven't been set
218*f6217f89SApple OSS Distributionsifeq ($(origin CC),default)
219*f6217f89SApple OSS Distributions	export CC := $(shell $(XCRUN) -sdk $(SDKROOT) -find clang)
220*f6217f89SApple OSS Distributionsendif
221*f6217f89SApple OSS Distributionsifeq ($(origin CXX),default)
222*f6217f89SApple OSS Distributions	export CXX := $(shell $(XCRUN) -sdk $(SDKROOT) -find clang++)
223*f6217f89SApple OSS Distributionsendif
224*f6217f89SApple OSS Distributionsifeq ($(origin MIG),undefined)
225*f6217f89SApple OSS Distributions	export MIG := $(shell $(XCRUN) -sdk $(SDKROOT) -find mig)
226*f6217f89SApple OSS Distributionsendif
227*f6217f89SApple OSS Distributionsifeq ($(origin MIGCOM),undefined)
228*f6217f89SApple OSS Distributions	export MIGCOM := $(shell $(XCRUN) -sdk $(SDKROOT) -find migcom)
229*f6217f89SApple OSS Distributionsendif
230*f6217f89SApple OSS Distributionsifeq ($(origin MIGCC),undefined)
231*f6217f89SApple OSS Distributions	export MIGCC := $(CC)
232*f6217f89SApple OSS Distributionsendif
233*f6217f89SApple OSS Distributionsifeq ($(origin IIG),undefined)
234*f6217f89SApple OSS Distributions	export IIG := $(shell $(XCRUN) -sdk $(SDKROOT) -find iig)
235*f6217f89SApple OSS Distributionsendif
236*f6217f89SApple OSS Distributionsifeq ($(origin STRIP),undefined)
237*f6217f89SApple OSS Distributions	export STRIP := $(shell $(XCRUN) -sdk $(SDKROOT) -find strip)
238*f6217f89SApple OSS Distributionsendif
239*f6217f89SApple OSS Distributionsifeq ($(origin LIPO),undefined)
240*f6217f89SApple OSS Distributions	export LIPO := $(shell $(XCRUN) -sdk $(SDKROOT) -find lipo)
241*f6217f89SApple OSS Distributionsendif
242*f6217f89SApple OSS Distributionsifeq ($(origin LIBTOOL),undefined)
243*f6217f89SApple OSS Distributions	export LIBTOOL := $(shell $(XCRUN) -sdk $(SDKROOT) -find libtool)
244*f6217f89SApple OSS Distributionsendif
245*f6217f89SApple OSS Distributionsifeq ($(origin OTOOL),undefined)
246*f6217f89SApple OSS Distributions	export OTOOL := $(shell $(XCRUN) -sdk $(SDKROOT) -find otool)
247*f6217f89SApple OSS Distributionsendif
248*f6217f89SApple OSS Distributionsifeq ($(origin NM),undefined)
249*f6217f89SApple OSS Distributions	export NM := $(shell $(XCRUN) -sdk $(SDKROOT) -find nm)
250*f6217f89SApple OSS Distributionsendif
251*f6217f89SApple OSS Distributionsifeq ($(origin UNIFDEF),undefined)
252*f6217f89SApple OSS Distributions	export UNIFDEF := $(shell $(XCRUN) -sdk $(SDKROOT) -find unifdef)
253*f6217f89SApple OSS Distributionsendif
254*f6217f89SApple OSS Distributionsifeq ($(origin DSYMUTIL),undefined)
255*f6217f89SApple OSS Distributions	export DSYMUTIL := $(shell $(XCRUN) -sdk $(SDKROOT) -find dsymutil)
256*f6217f89SApple OSS Distributionsendif
257*f6217f89SApple OSS Distributionsifeq ($(origin NMEDIT),undefined)
258*f6217f89SApple OSS Distributions	export NMEDIT := $(shell $(XCRUN) -sdk $(SDKROOT) -find nmedit)
259*f6217f89SApple OSS Distributionsendif
260*f6217f89SApple OSS Distributionsifeq ($(origin GIT),undefined)
261*f6217f89SApple OSS Distributions	export GIT := $(shell $(XCRUN) -sdk $(SDKROOT) -find git)
262*f6217f89SApple OSS Distributionsendif
263*f6217f89SApple OSS Distributionsifeq ($(origin SCAN_BUILD),undefined)
264*f6217f89SApple OSS Distributions	export SCAN_BUILD := $(shell $(XCRUN) -sdk $(SDKROOT) -find scan-build 2> /dev/null)
265*f6217f89SApple OSS Distributionsendif
266*f6217f89SApple OSS Distributionsifeq ($(origin CTFINSERT),undefined)
267*f6217f89SApple OSS Distributions	export CTFINSERT := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctf_insert 2> /dev/null)
268*f6217f89SApple OSS Distributionsendif
269*f6217f89SApple OSS Distributionsifeq ($(origin CTFCONVERT),undefined)
270*f6217f89SApple OSS Distributions	export CTFCONVERT := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfconvert 2> /dev/null)
271*f6217f89SApple OSS Distributionsendif
272*f6217f89SApple OSS Distributionsifeq ($(origin CTFMERGE),undefined)
273*f6217f89SApple OSS Distributions	export CTFMERGE := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfmerge 2> /dev/null)
274*f6217f89SApple OSS Distributions	ifeq (,$(wildcard $(CTFMERGE)))
275*f6217f89SApple OSS Distributions		export DO_CTFMERGE := 0
276*f6217f89SApple OSS Distributions	endif
277*f6217f89SApple OSS Distributionsendif
278*f6217f89SApple OSS Distributionsifeq ($(origin CTFDUMP),undefined)
279*f6217f89SApple OSS Distributions	export CTFDUMP := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfdump 2> /dev/null)
280*f6217f89SApple OSS Distributionsendif
281*f6217f89SApple OSS Distributionsifeq ($(origin DOCC),undefined)
282*f6217f89SApple OSS Distributions	export DOCC := $(shell $(XCRUN) -sdk $(SDKROOT) -find docc 2> /dev/null)
283*f6217f89SApple OSS Distributionsendif
284*f6217f89SApple OSS Distributionsifeq ($(origin PYTHON),undefined)
285*f6217f89SApple OSS Distributions	export PYTHON := $(shell $(XCRUN) -sdk $(SDKROOT) -find python3 2> /dev/null)
286*f6217f89SApple OSS Distributionsendif
287*f6217f89SApple OSS Distributionsifeq ($(origin OBJDUMP),undefined)
288*f6217f89SApple OSS Distributions	export OBJDUMP := $(shell $(XCRUN) -sdk $(SDKROOT) -find objdump 2> /dev/null)
289*f6217f89SApple OSS Distributionsendif
290*f6217f89SApple OSS Distributions
291*f6217f89SApple OSS Distributions#
292*f6217f89SApple OSS Distributions# Platform options
293*f6217f89SApple OSS Distributions#
294*f6217f89SApple OSS DistributionsSUPPORTED_EMBEDDED_PLATFORMS := iPhoneOS iPhoneOSNano tvOS AppleTVOS WatchOS BridgeOS
295*f6217f89SApple OSS DistributionsSUPPORTED_SIMULATOR_PLATFORMS := iPhoneSimulator iPhoneNanoSimulator tvSimulator AppleTVSimulator WatchSimulator
296*f6217f89SApple OSS Distributions
297*f6217f89SApple OSS Distributions
298*f6217f89SApple OSS DistributionsSUPPORTED_PLATFORMS := MacOSX DriverKit ExclaveKit ExclaveCore $(SUPPORTED_SIMULATOR_PLATFORMS) $(SUPPORTED_EMBEDDED_PLATFORMS)
299*f6217f89SApple OSS Distributions
300*f6217f89SApple OSS Distributions# Platform-specific tools
301*f6217f89SApple OSS DistributionsEDM_DBPATH ?= $(PLATFORMPATH)/usr/local/standalone/firmware/device_map.db
302*f6217f89SApple OSS Distributions
303*f6217f89SApple OSS Distributions# Scripts or tools we build ourselves
304*f6217f89SApple OSS Distributions#
305*f6217f89SApple OSS Distributions# setsegname - Rename segments in a Mach-O object file
306*f6217f89SApple OSS Distributions# kextsymboltool - Create kext pseudo-kext Mach-O kexts binaries
307*f6217f89SApple OSS Distributions# decomment - Strip out comments to detect whether a file is comments-only
308*f6217f89SApple OSS Distributions# installfile - Atomically copy files, esp. when multiple architectures
309*f6217f89SApple OSS Distributions#               are trying to install the same target header
310*f6217f89SApple OSS Distributions# replacecontents - Write contents to a file and update modtime *only* if
311*f6217f89SApple OSS Distributions#                   contents differ
312*f6217f89SApple OSS Distributions# vm_sanitize_enforcement - Reject MIG files that use types that do not enforce
313*f6217f89SApple OSS Distributions#                           sanitization for VM inputs
314*f6217f89SApple OSS Distributions#
315*f6217f89SApple OSS DistributionsSEG_HACK = $(OBJROOT)/SETUP/setsegname/setsegname
316*f6217f89SApple OSS DistributionsKEXT_CREATE_SYMBOL_SET = $(OBJROOT)/SETUP/kextsymboltool/kextsymboltool
317*f6217f89SApple OSS DistributionsDECOMMENT = $(OBJROOT)/SETUP/decomment/decomment
318*f6217f89SApple OSS DistributionsNEWVERS = $(SRCROOT)/config/newvers.pl
319*f6217f89SApple OSS DistributionsINSTALL = $(OBJROOT)/SETUP/installfile/installfile
320*f6217f89SApple OSS DistributionsREPLACECONTENTS = $(OBJROOT)/SETUP/replacecontents/replacecontents
321*f6217f89SApple OSS DistributionsVM_SANITIZE_ADOPTION_CHECK = $(SRCROOT)/tools/vm_sanitize_enforcement.py
322*f6217f89SApple OSS Distributions
323*f6217f89SApple OSS Distributions# Standard BSD tools
324*f6217f89SApple OSS DistributionsRM = /bin/rm -f
325*f6217f89SApple OSS DistributionsRMDIR = /bin/rmdir
326*f6217f89SApple OSS DistributionsCP = /bin/cp
327*f6217f89SApple OSS DistributionsMV = /bin/mv
328*f6217f89SApple OSS DistributionsLN = /bin/ln -fs
329*f6217f89SApple OSS DistributionsCAT = /bin/cat
330*f6217f89SApple OSS DistributionsMKDIR = /bin/mkdir -p
331*f6217f89SApple OSS DistributionsCHMOD = /bin/chmod
332*f6217f89SApple OSS DistributionsFIND = /usr/bin/find
333*f6217f89SApple OSS DistributionsXARGS = /usr/bin/xargs
334*f6217f89SApple OSS DistributionsPAX = /bin/pax
335*f6217f89SApple OSS DistributionsBASENAME = /usr/bin/basename
336*f6217f89SApple OSS DistributionsDIRNAME = /usr/bin/dirname
337*f6217f89SApple OSS DistributionsTR = /usr/bin/tr
338*f6217f89SApple OSS DistributionsTOUCH = /usr/bin/touch
339*f6217f89SApple OSS DistributionsSLEEP = /bin/sleep
340*f6217f89SApple OSS DistributionsAWK = /usr/bin/awk
341*f6217f89SApple OSS DistributionsSED = /usr/bin/sed
342*f6217f89SApple OSS DistributionsPLUTIL = /usr/bin/plutil
343*f6217f89SApple OSS DistributionsPATCH = /usr/bin/patch
344*f6217f89SApple OSS DistributionsGREP = /usr/bin/grep
345*f6217f89SApple OSS Distributions
346*f6217f89SApple OSS Distributions#
347*f6217f89SApple OSS Distributions# Command to generate host binaries. Intentionally not
348*f6217f89SApple OSS Distributions# $(CC), which controls the target compiler
349*f6217f89SApple OSS Distributions#
350*f6217f89SApple OSS Distributionsifeq ($(origin HOST_OS_VERSION),undefined)
351*f6217f89SApple OSS Distributions	export HOST_OS_VERSION	:= $(shell sw_vers -productVersion)
352*f6217f89SApple OSS Distributionsendif
353*f6217f89SApple OSS Distributionsifeq ($(origin HOST_CC),undefined)
354*f6217f89SApple OSS Distributions	export HOST_CC		:= $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find clang)
355*f6217f89SApple OSS Distributionsendif
356*f6217f89SApple OSS Distributionsifeq ($(origin HOST_FLEX),undefined)
357*f6217f89SApple OSS Distributions	export HOST_FLEX	:= $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find flex)
358*f6217f89SApple OSS Distributionsendif
359*f6217f89SApple OSS Distributionsifeq ($(origin HOST_BISON),undefined)
360*f6217f89SApple OSS Distributions	export HOST_BISON	:= $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find bison)
361*f6217f89SApple OSS Distributionsendif
362*f6217f89SApple OSS Distributionsifeq ($(origin HOST_GM4),undefined)
363*f6217f89SApple OSS Distributions	export HOST_GM4		:= $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find gm4)
364*f6217f89SApple OSS Distributionsendif
365*f6217f89SApple OSS Distributionsifeq ($(origin HOST_CODESIGN),undefined)
366*f6217f89SApple OSS Distributions	export HOST_CODESIGN	:= /usr/bin/codesign
367*f6217f89SApple OSS Distributionsendif
368*f6217f89SApple OSS Distributionsifeq ($(origin HOST_CODESIGN_ALLOCATE),undefined)
369*f6217f89SApple OSS Distributions	export HOST_CODESIGN_ALLOCATE	:= $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find codesign_allocate)
370*f6217f89SApple OSS Distributionsendif
371*f6217f89SApple OSS Distributions
372*f6217f89SApple OSS Distributions#
373*f6217f89SApple OSS Distributions# The following variables are functions invoked with "call", and thus
374*f6217f89SApple OSS Distributions# behave similarly to externally compiled commands
375*f6217f89SApple OSS Distributions#
376*f6217f89SApple OSS Distributions
377*f6217f89SApple OSS Distributions_function_filter_out_vmapple_sptm_build_config = $(if \
378*f6217f89SApple OSS Distributions										$(and \
379*f6217f89SApple OSS Distributions											$(filter SPTM,$(call function_extract_kernel_config_from_build_config,$(1))), \
380*f6217f89SApple OSS Distributions											$(filter VMAPPLE,$(call function_extract_machine_config_from_build_config,$(1))) \
381*f6217f89SApple OSS Distributions										) \
382*f6217f89SApple OSS Distributions										,,$(1) \
383*f6217f89SApple OSS Distributions									)
384*f6217f89SApple OSS Distributions
385*f6217f89SApple OSS Distributions# $(1) is an expanded kernel config from a TARGET_CONFIGS_UC tuple
386*f6217f89SApple OSS Distributions# $(2) is an expanded arch config from a TARGET_CONFIGS_UC tuple
387*f6217f89SApple OSS Distributions# $(3) is an expanded machine config from a TARGET_CONFIGS_UC tuple
388*f6217f89SApple OSS Distributions_function_create_build_configs_join = $(strip $(1))^$(strip $(2))^$(strip $(3))
389*f6217f89SApple OSS Distributions
390*f6217f89SApple OSS Distributions# $(1) is an un-expanded kernel config from a TARGET_CONFIGS_UC tuple
391*f6217f89SApple OSS Distributions# $(2) is an un-expanded arch config from a TARGET_CONFIGS_UC tuple
392*f6217f89SApple OSS Distributions# $(3) is an un-expanded machine config from a TARGET_CONFIGS_UC tuple
393*f6217f89SApple OSS Distributions_function_create_build_configs_do_expand =          $(call _function_create_build_configs_join, \
394*f6217f89SApple OSS Distributions							   $(if $(filter DEFAULT,$(1)), \
395*f6217f89SApple OSS Distributions								$(DEFAULT_KERNEL_CONFIG), \
396*f6217f89SApple OSS Distributions								$(1) \
397*f6217f89SApple OSS Distributions							    ), \
398*f6217f89SApple OSS Distributions							   $(if $(filter DEFAULT,$(2)), \
399*f6217f89SApple OSS Distributions								$(DEFAULT_ARCH_CONFIG), \
400*f6217f89SApple OSS Distributions								$(2) \
401*f6217f89SApple OSS Distributions							    ), \
402*f6217f89SApple OSS Distributions							   $(if $(filter DEFAULT,$(3)), \
403*f6217f89SApple OSS Distributions								$(if $(filter DEFAULT,$(2)), \
404*f6217f89SApple OSS Distributions								     $(DEFAULT_$(DEFAULT_ARCH_CONFIG)_MACHINE_CONFIG), \
405*f6217f89SApple OSS Distributions								     $(DEFAULT_$(strip $(2))_MACHINE_CONFIG) \
406*f6217f89SApple OSS Distributions								), \
407*f6217f89SApple OSS Distributions								$(3) \
408*f6217f89SApple OSS Distributions							    ) \
409*f6217f89SApple OSS Distributions						     )
410*f6217f89SApple OSS Distributions
411*f6217f89SApple OSS Distributions# $(1) is an un-expanded kernel config from a TARGET_CONFIGS_UC tuple
412*f6217f89SApple OSS Distributions# $(2) is an un-expanded arch config from a TARGET_CONFIGS_UC tuple
413*f6217f89SApple OSS Distributions# $(3) is an un-expanded machine config from a TARGET_CONFIGS_UC tuple, that may be multiplexed (e.g. ConfigA&ConfigB)
414*f6217f89SApple OSS Distributions# This function splits any multiplexed machine configs into separate items.
415*f6217f89SApple OSS Distributions_function_create_build_configs_do_expand_with_muxed_machine_config = $(foreach machine_config, $(subst &, ,$(3)), \
416*f6217f89SApple OSS Distributions												$(call _function_filter_out_vmapple_sptm_build_config,\
417*f6217f89SApple OSS Distributions													$(call _function_create_build_configs_do_expand,$(1),$(2),$(machine_config)) \
418*f6217f89SApple OSS Distributions												) \
419*f6217f89SApple OSS Distributions											)
420*f6217f89SApple OSS Distributions
421*f6217f89SApple OSS Distributions# $(1) is an un-expanded TARGET_CONFIGS_UC list, which must be consumed
422*f6217f89SApple OSS Distributions#      3 elements at a time
423*f6217f89SApple OSS Distributionsfunction_create_build_configs = $(sort \
424*f6217f89SApple OSS Distributions					$(strip \
425*f6217f89SApple OSS Distributions						 $(call _function_create_build_configs_do_expand_with_muxed_machine_config, \
426*f6217f89SApple OSS Distributions							$(word 1,$(1)), \
427*f6217f89SApple OSS Distributions							$(word 2,$(1)), \
428*f6217f89SApple OSS Distributions							$(word 3,$(1)), \
429*f6217f89SApple OSS Distributions						  ) \
430*f6217f89SApple OSS Distributions						 $(if $(word 4,$(1)), \
431*f6217f89SApple OSS Distributions						      $(call function_create_build_configs, \
432*f6217f89SApple OSS Distributions							     $(wordlist 4,$(words $(1)),$(1)) \
433*f6217f89SApple OSS Distributions						       ), \
434*f6217f89SApple OSS Distributions						  ) \
435*f6217f89SApple OSS Distributions					  ) \
436*f6217f89SApple OSS Distributions				   )
437*f6217f89SApple OSS Distributions
438*f6217f89SApple OSS Distributions# Similar to build configs, but alias configs are a 4-tuple
439*f6217f89SApple OSS Distributions
440*f6217f89SApple OSS Distributions# $(1) is an expanded kernel config from a TARGET_CONFIGS_ALIASES_UC tuple
441*f6217f89SApple OSS Distributions# $(2) is an expanded arch config from a TARGET_CONFIGS_ALIASES_UC tuple
442*f6217f89SApple OSS Distributions# $(3) is an expanded kernel machine config from a TARGET_CONFIGS_ALIASES_UC tuple
443*f6217f89SApple OSS Distributions# $(4) is an expanded SoC platform config from a TARGET_CONFIGS_ALIASES_UC tuple,
444*f6217f89SApple OSS Distributions#      which should be an alias of $(3)
445*f6217f89SApple OSS Distributions_function_create_alias_configs_join = $(strip $(1))^$(strip $(2))^$(strip $(3))^$(strip $(4))
446*f6217f89SApple OSS Distributions
447*f6217f89SApple OSS Distributions_function_create_alias_configs_do_expand =	    $(call _function_create_alias_configs_join, \
448*f6217f89SApple OSS Distributions							   $(if $(filter DEFAULT,$(1)), \
449*f6217f89SApple OSS Distributions							        $(DEFAULT_KERNEL_CONFIG), \
450*f6217f89SApple OSS Distributions								$(1) \
451*f6217f89SApple OSS Distributions							    ), \
452*f6217f89SApple OSS Distributions							   $(if $(filter DEFAULT,$(2)), \
453*f6217f89SApple OSS Distributions								$(DEFAULT_ARCH_CONFIG), \
454*f6217f89SApple OSS Distributions								$(2) \
455*f6217f89SApple OSS Distributions							    ), \
456*f6217f89SApple OSS Distributions							   $(3), \
457*f6217f89SApple OSS Distributions							   $(4) \
458*f6217f89SApple OSS Distributions						     )
459*f6217f89SApple OSS Distributions
460*f6217f89SApple OSS Distributions# $(1) is an un-expanded kernel config from a TARGET_CONFIGS_UC tuple
461*f6217f89SApple OSS Distributions# $(2) is an un-expanded arch config from a TARGET_CONFIGS_UC tuple
462*f6217f89SApple OSS Distributions# $(3) is an un-expanded machine config from a TARGET_CONFIGS_UC tuple, that may be multiplexed (e.g. ConfigA&ConfigB)
463*f6217f89SApple OSS Distributions# $(4) is an expanded SoC platform config from a TARGET_CONFIGS_ALIASES_UC tuple,
464*f6217f89SApple OSS Distributions#      which should be an alias of $(3)
465*f6217f89SApple OSS Distributions# This function splits any multiplexed machine configs into separate items.
466*f6217f89SApple OSS Distributions_function_create_alias_configs_do_expand_with_muxed_machine_config = $(foreach machine_config, $(subst &, ,$(3)), \
467*f6217f89SApple OSS Distributions												$(call _function_filter_out_vmapple_sptm_build_config,\
468*f6217f89SApple OSS Distributions													$(call _function_create_alias_configs_do_expand,$(1),$(2),$(machine_config),$(4)) \
469*f6217f89SApple OSS Distributions												) \
470*f6217f89SApple OSS Distributions											)
471*f6217f89SApple OSS Distributions
472*f6217f89SApple OSS Distributionsfunction_create_alias_configs = $(sort \
473*f6217f89SApple OSS Distributions					$(strip \
474*f6217f89SApple OSS Distributions						 $(call _function_create_alias_configs_do_expand_with_muxed_machine_config, \
475*f6217f89SApple OSS Distributions							$(word 1,$(1)), \
476*f6217f89SApple OSS Distributions							$(word 2,$(1)), \
477*f6217f89SApple OSS Distributions							$(word 3,$(1)), \
478*f6217f89SApple OSS Distributions							$(word 4,$(1)), \
479*f6217f89SApple OSS Distributions						  ) \
480*f6217f89SApple OSS Distributions						 $(if $(word 5,$(1)), \
481*f6217f89SApple OSS Distributions						      $(call function_create_alias_configs, \
482*f6217f89SApple OSS Distributions							     $(wordlist 5,$(words $(1)),$(1)) \
483*f6217f89SApple OSS Distributions						       ), \
484*f6217f89SApple OSS Distributions						  ) \
485*f6217f89SApple OSS Distributions					 ) \
486*f6217f89SApple OSS Distributions				 )
487*f6217f89SApple OSS Distributions
488*f6217f89SApple OSS Distributions# $(1) is a fully-expanded kernel config
489*f6217f89SApple OSS Distributions# $(2) is a fully-expanded arch config
490*f6217f89SApple OSS Distributions# $(3) is a fully-expanded machine config. "NONE" is not represented in the objdir path
491*f6217f89SApple OSS Distributionsfunction_convert_target_config_uc_to_objdir = $(if $(filter NONE,$(3)),$(strip $(1))_$(strip $(2)),$(strip $(1))_$(strip $(2))_$(strip $(3)))
492*f6217f89SApple OSS Distributions
493*f6217f89SApple OSS Distributions# $(1) is a fully-expanded build config (like "RELEASE^X86_64^NONE")
494*f6217f89SApple OSS Distributionsfunction_convert_build_config_to_objdir = $(call function_convert_target_config_uc_to_objdir, \
495*f6217f89SApple OSS Distributions						 $(word 1,$(subst ^, ,$(1))), \
496*f6217f89SApple OSS Distributions						 $(word 2,$(subst ^, ,$(1))), \
497*f6217f89SApple OSS Distributions						 $(word 3,$(subst ^, ,$(1))) \
498*f6217f89SApple OSS Distributions					   )
499*f6217f89SApple OSS Distributions
500*f6217f89SApple OSS Distributions# $(1) is a fully-expanded build config (like "RELEASE^X86_64^NONE")
501*f6217f89SApple OSS Distributionsfunction_extract_kernel_config_from_build_config  = $(word 1,$(subst ^, ,$(1)))
502*f6217f89SApple OSS Distributionsfunction_extract_arch_config_from_build_config    = $(word 2,$(subst ^, ,$(1)))
503*f6217f89SApple OSS Distributionsfunction_extract_machine_config_from_build_config = $(word 3,$(subst ^, ,$(1)))
504*f6217f89SApple OSS Distributions
505*f6217f89SApple OSS Distributions#
506*f6217f89SApple OSS Distributions# Returns build config if both architecture and kernel configuration match.
507*f6217f89SApple OSS Distributions#
508*f6217f89SApple OSS Distributions#   $(1) - list of build configs
509*f6217f89SApple OSS Distributions#   $(1) - architecture
510*f6217f89SApple OSS Distributions#   $(2) - kernel configuration
511*f6217f89SApple OSS Distributions
512*f6217f89SApple OSS Distributionsfunction_match_build_config_for_architecture_and_kernel_config = $(strip \
513*f6217f89SApple OSS Distributions			    $(foreach build_config, $(1), \
514*f6217f89SApple OSS Distributions			      $(if \
515*f6217f89SApple OSS Distributions				$(and \
516*f6217f89SApple OSS Distributions				  $(filter $(2), $(call function_extract_arch_config_from_build_config, $(build_config))), \
517*f6217f89SApple OSS Distributions				  $(filter $(3), $(call function_extract_kernel_config_from_build_config, $(build_config)))), \
518*f6217f89SApple OSS Distributions			      $(build_config), )))
519*f6217f89SApple OSS Distributions
520*f6217f89SApple OSS Distributions#
521*f6217f89SApple OSS Distributions# Returns build config if kernel configuration matches.
522*f6217f89SApple OSS Distributions#
523*f6217f89SApple OSS Distributions#   $(1) - list of build configs
524*f6217f89SApple OSS Distributions#   $(2) - kernel configuration
525*f6217f89SApple OSS Distributions
526*f6217f89SApple OSS Distributionsfunction_match_build_config_for_kernel_config = $(strip \
527*f6217f89SApple OSS Distributions			    $(foreach build_config, $(1), \
528*f6217f89SApple OSS Distributions			      $(if \
529*f6217f89SApple OSS Distributions				  $(filter $(2), $(call function_extract_kernel_config_from_build_config, $(build_config))), \
530*f6217f89SApple OSS Distributions			      $(build_config), )))
531*f6217f89SApple OSS Distributions
532*f6217f89SApple OSS Distributions# $(1) is an input word
533*f6217f89SApple OSS Distributions# $(2) is a list of colon-separate potential substitutions like "FOO:BAR BAZ:QUX"
534*f6217f89SApple OSS Distributions# $(3) is a fallback if no substitutions were made
535*f6217f89SApple OSS Distributionsfunction_substitute_word_with_replacement = $(strip $(if $(2),								\
536*f6217f89SApple OSS Distributions							 $(if $(filter $(word 1,$(subst :, ,$(word 1,$(2)))),$(1)),	\
537*f6217f89SApple OSS Distributions							      $(word 2,$(subst :, ,$(word 1,$(2)))),		\
538*f6217f89SApple OSS Distributions							      $(call function_substitute_word_with_replacement,$(1),$(wordlist 2,$(words $(2)),$(2)),$(3))), \
539*f6217f89SApple OSS Distributions							 $(3)								\
540*f6217f89SApple OSS Distributions						     )									\
541*f6217f89SApple OSS Distributions					     )
542*f6217f89SApple OSS Distributions
543*f6217f89SApple OSS Distributions# $(1) is a string of form "arch;platform(&platform)*", where multiple platforms are separated by the "&" delimiter.
544*f6217f89SApple OSS Distributions# Output is the arch.
545*f6217f89SApple OSS Distributionsfunction_get_arch = $(word 1,$(subst ;, ,$(1)))
546*f6217f89SApple OSS Distributions
547*f6217f89SApple OSS Distributions# $(1) is a string of form "arch;platform(&platform)*", where multiple platforms are separated by the "&" delimiter.
548*f6217f89SApple OSS Distributions# Output is a space separated list of the platforms.
549*f6217f89SApple OSS Distributionsfunction_get_platforms = $(subst &, ,$(word 2,$(subst ;, ,$(1))))
550*f6217f89SApple OSS Distributions
551*f6217f89SApple OSS Distributions# $(1) is a string of form "arch;platform(&platform)*", where multiple platforms are separated by the "&" delimiter.
552*f6217f89SApple OSS Distributionsfunction_parse_product_configs = $(foreach platform,$(call function_get_platforms,$(1)),$(call function_get_arch,$(1));$(platform);)
553*f6217f89SApple OSS Distributions
554*f6217f89SApple OSS Distributions# You can't assign a variable to an empty space without these
555*f6217f89SApple OSS Distributions# shenanigans
556*f6217f89SApple OSS Distributionsempty :=
557*f6217f89SApple OSS Distributionsspace := $(empty) $(empty)
558*f6217f89SApple OSS Distributions
559*f6217f89SApple OSS Distributions# Arithmetic
560*f6217f89SApple OSS Distributions# $(1) is the number to increment
561*f6217f89SApple OSS DistributionsNUM32 = x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x
562*f6217f89SApple OSS Distributionsincrement = $(words x $(wordlist 1,$(1),$(NUM32)))
563*f6217f89SApple OSS Distributionsdecrement = $(words $(wordlist 2,$(1),$(NUM32)))
564*f6217f89SApple OSS Distributions
565*f6217f89SApple OSS Distributions# Create a sequence from 1 to $(1)
566*f6217f89SApple OSS Distributions# F(N) = if N > 0: return F(N-1) + "N" else: return ""
567*f6217f89SApple OSS Distributionssequence = $(if $(wordlist 1,$(1),$(NUM32)),$(call sequence,$(call decrement,$(1))) $(1),)
568*f6217f89SApple OSS Distributions
569*f6217f89SApple OSS Distributions# Reverse a list of words in $(1)
570*f6217f89SApple OSS Distributionsreverse = $(if $(word 2,$(1)),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(word 1,$(1))
571*f6217f89SApple OSS Distributions
572*f6217f89SApple OSS Distributions# vim: set ft=make:
573