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