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