2 # Commands for the build environment
17 _vstdout = > /dev/null
21 XCRUN = /usr/bin/xcrun -verbose -log
23 XCRUN = /usr/bin/xcrun
28 HOST_SPARSE_SDKROOT ?= /
30 # SDKROOT may be passed as a shorthand like "iphoneos.internal". We
31 # must resolve these to a full path and override SDKROOT.
33 ifeq ($(SDKROOT_RESOLVED),)
35 export SDKROOT_RESOLVED := /
37 export SDKROOT_RESOLVED := $(shell xcodebuild -sdk $(SDKROOT) -version Path | head -1)
40 override SDKROOT = $(SDKROOT_RESOLVED)
43 export PLATFORM := $(shell xcodebuild -sdk $(SDKROOT) -version PlatformPath | head -1 | sed 's,^.*/\([^/]*\)\.platform$$,\1,')
45 export PLATFORM := MacOSX
49 ifeq ($(PLATFORM),iPhoneOS)
50 DEVELOPER_DIR ?= $(shell xcode-select -print-path)
51 export HOST_SPARSE_SDKROOT := $(DEVELOPER_DIR)/SDKs/iPhoneHostSideTools.sparse.sdk
54 # CC/CXX get defined by make(1) by default, so we can't check them
55 # against the empty string to see if they haven't been set
56 ifeq ($(origin CC),default)
57 ifneq ($(findstring iPhone,$(PLATFORM)),)
58 export CC := $(shell $(XCRUN) -sdk $(SDKROOT) -find clang)
60 export CC := $(shell $(XCRUN) -sdk $(SDKROOT) -find clang)
63 ifeq ($(origin CXX),default)
64 ifneq ($(findstring iPhone,$(PLATFORM)),)
65 export CXX := $(shell $(XCRUN) -sdk $(SDKROOT) -find clang++)
67 export CXX := $(shell $(XCRUN) -sdk $(SDKROOT) -find clang++)
71 export MIG := $(shell $(XCRUN) -sdk $(SDKROOT) -find mig)
77 export STRIP := $(shell $(XCRUN) -sdk $(SDKROOT) -find strip)
80 export LIPO := $(shell $(XCRUN) -sdk $(SDKROOT) -find lipo)
83 export LIBTOOL := $(shell $(XCRUN) -sdk $(SDKROOT) -find libtool)
86 export NM := $(shell $(XCRUN) -sdk $(SDKROOT) -find nm)
89 export UNIFDEF := $(shell $(XCRUN) -sdk $(SDKROOT) -find unifdef)
92 export DSYMUTIL := $(shell $(XCRUN) -sdk $(SDKROOT) -find dsymutil)
95 export CTFCONVERT := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfconvert)
98 export CTFMERGE := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfmerge)
101 export CTFSCRUB := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfdump) -r
104 export NMEDIT := $(shell $(XCRUN) -sdk $(SDKROOT) -find nmedit)
107 # Platform-specific tools
108 ifneq ($(findstring iPhone,$(PRODUCT)),)
109 ifeq ($(EMBEDDED_DEVICE_MAP),)
110 export EMBEDDED_DEVICE_MAP := $(shell $(XCRUN) -sdk $(SDKROOT) -find embedded_device_map)
112 ifeq ($(IPHONEOS_OPTIMIZE),)
113 export IPHONEOS_OPTIMIZE := $(shell $(XCRUN) -sdk $(SDKROOT) -find iphoneos-optimize)
117 # Scripts or tools we build ourselves
118 SEG_HACK := $(OBJROOT)/SETUP/setsegname/setsegname
119 KEXT_CREATE_SYMBOL_SET := $(OBJROOT)/SETUP/kextsymboltool/kextsymboltool
120 DECOMMENT := $(OBJROOT)/SETUP/decomment/decomment
121 NEWVERS = $(SRCROOT)/config/newvers.pl
122 MD := $(OBJROOT)/SETUP/md/md
130 MKDIR = /bin/mkdir -p
132 XARGS = /usr/bin/xargs
133 INSTALL = /usr/bin/install
134 TAR = /usr/bin/gnutar
135 BASENAME = /usr/bin/basename
138 # Platform-specific tools
139 ifeq (iPhoneOS,$(PLATFORM))
140 ifeq ($(EMBEDDED_DEVICE_MAP),)
141 export EMBEDDED_DEVICE_MAP := $(shell $(XCRUN) -sdk $(SDKROOT) -find embedded_device_map || echo /usr/bin/true)
143 ifeq ($(IPHONEOS_OPTIMIZE),)
144 export IPHONEOS_OPTIMIZE := $(shell $(XCRUN) -sdk $(SDKROOT) -find iphoneos-optimize || echo /usr/bin/true)
148 CTFINSERT = $(XCRUN) -sdk $(SDKROOT) ctf_insert
151 # Command to generate host binaries. Intentionally not
152 # $(CC), which controls the target compiler
155 export HOST_CC := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find cc)
158 export HOST_FLEX := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find flex)
160 ifeq ($(HOST_BISON),)
161 export HOST_BISON := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find bison)
163 ifeq ($(HOST_CODESIGN),)
164 export HOST_CODESIGN := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find codesign)