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