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