2 # Commands for the build environment
17 _vstdout = > /dev/null
21 XCRUN = /usr/bin/xcrun -verbose -log
23 XCRUN = /usr/bin/xcrun
30 export PLATFORM := $(shell xcodebuild -sdk $(SDKROOT) -version PlatformPath | head -1 | sed 's,^.*/\([^/]*\)\.platform$$,\1,')
32 export PLATFORM := MacOSX
36 # CC/CXX get defined by make(1) by default, so we can't check them
37 # against the empty string to see if they haven't been set
38 ifeq ($(origin CC),default)
39 ifneq ($(findstring iPhone,$(PLATFORM)),)
40 export CC := $(shell $(XCRUN) -sdk $(SDKROOT) -find gcc-4.2)
42 export CC := $(shell $(XCRUN) -sdk $(SDKROOT) -find cc)
45 ifeq ($(origin CXX),default)
46 ifneq ($(findstring iPhone,$(PLATFORM)),)
47 export CXX := $(shell $(XCRUN) -sdk $(SDKROOT) -find g++-4.2)
49 export CXX := $(shell $(XCRUN) -sdk $(SDKROOT) -find c++)
53 export MIG := $(shell $(XCRUN) -sdk $(SDKROOT) -find mig)
59 export RELPATH := $(shell $(XCRUN) -sdk $(SDKROOT) -find relpath)
62 export STRIP := $(shell $(XCRUN) -sdk $(SDKROOT) -find strip)
65 export LIPO := $(shell $(XCRUN) -sdk $(SDKROOT) -find lipo)
68 export LIBTOOL := $(shell $(XCRUN) -sdk $(SDKROOT) -find libtool)
71 export NM := $(shell $(XCRUN) -sdk $(SDKROOT) -find nm)
74 export UNIFDEF := $(shell $(XCRUN) -sdk $(SDKROOT) -find unifdef)
77 export DECOMMENT := $(shell $(XCRUN) -sdk $(SDKROOT) -find decomment)
80 export DSYMUTIL := $(shell $(XCRUN) -sdk $(SDKROOT) -find dsymutil)
83 export CTFCONVERT := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfconvert)
86 export CTFMERGE := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfmerge)
89 export CTFSCRUB := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfdump) -r
92 export NMEDIT := $(shell $(XCRUN) -sdk $(SDKROOT) -find nmedit)
95 # Platform-specific tools
96 ifneq ($(findstring iPhone,$(PRODUCT)),)
97 ifeq ($(IPHONEOS_OPTIMIZE),)
98 export IPHONEOS_OPTIMIZE := $(shell $(XCRUN) -sdk $(SDKROOT) -find iphoneos-optimize)
102 # Scripts or tools we build ourselves
103 SEG_HACK := $(OBJROOT)/SETUP/setsegname/setsegname
104 KEXT_CREATE_SYMBOL_SET := $(OBJROOT)/SETUP/kextsymboltool/kextsymboltool
105 NEWVERS = $(SRCROOT)/config/newvers.pl
114 MKDIR = /bin/mkdir -p
116 INSTALL = /usr/bin/install
117 TAR = /usr/bin/gnutar
118 BASENAME = /usr/bin/basename
121 # Platform-specific tools
122 ifeq (iPhoneOS,$(PLATFORM))
123 ifeq ($(IPHONEOS_OPTIMIZE),)
124 export IPHONEOS_OPTIMIZE := $(shell $(XCRUN) -sdk $(SDKROOT) -find iphoneos-optimize || echo /usr/bin/true)
128 CTFINSERT = $(XCRUN) -sdk $(SDKROOT) ctf_insert
131 # Command to generate host binaries. Intentionally not
132 # $(CC), which controls the target compiler
135 export HOST_CC := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find cc)
138 export HOST_FLEX := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find flex)
140 ifeq ($(HOST_BISON),)
141 export HOST_BISON := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find bison)
143 ifeq ($(HOST_CODESIGN),)
144 export HOST_CODESIGN := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find codesign)
148 # Command to build libkmod.a/libkmodc++.a, which are
149 # linked into kext binaries, and should be built as if
150 # they followed system-wide policies
152 ifeq ($(LIBKMOD_CC),)
153 export LIBKMOD_CC := $(shell $(XCRUN) -sdk $(SDKROOT) -find cc)