]> git.saurik.com Git - apple/xnu.git/blob - makedefs/MakeInc.cmd
12f5203b1f5ce3e43b6842a2fa41b2184c4575fb
[apple/xnu.git] / makedefs / MakeInc.cmd
1 #
2 # Commands for the build environment
3 #
4 ##
5 # Verbosity
6 ##
7 ifeq ($(RC_XBS),YES)
8 VERBOSE = YES
9 else
10 VERBOSE = NO
11 endif
12 ifeq ($(VERBOSE),YES)
13 _v =
14 _vstdout =
15 else
16 _v = @
17 _vstdout = > /dev/null
18 endif
19
20 ifeq ($(VERBOSE),YES)
21 XCRUN = /usr/bin/xcrun -verbose -log
22 else
23 XCRUN = /usr/bin/xcrun
24 endif
25
26 SDKROOT ?= /
27 HOST_SDKROOT ?= /
28 HOST_SPARSE_SDKROOT ?= /
29
30 # SDKROOT may be passed as a shorthand like "iphoneos.internal". We
31 # must resolve these to a full path and override SDKROOT.
32
33 ifeq ($(SDKROOT_RESOLVED),)
34 ifeq ($(SDKROOT),/)
35 export SDKROOT_RESOLVED := /
36 else
37 export SDKROOT_RESOLVED := $(shell xcodebuild -sdk $(SDKROOT) -version Path | head -1)
38 endif
39 endif
40 override SDKROOT = $(SDKROOT_RESOLVED)
41
42 ifeq ($(PLATFORM),)
43 export PLATFORM := $(shell xcodebuild -sdk $(SDKROOT) -version PlatformPath | head -1 | sed 's,^.*/\([^/]*\)\.platform$$,\1,')
44 ifeq ($(PLATFORM),)
45 export PLATFORM := MacOSX
46 endif
47 endif
48
49 ifeq ($(PLATFORM),iPhoneOS)
50 DEVELOPER_DIR ?= $(shell xcode-select -print-path)
51 export HOST_SPARSE_SDKROOT := $(DEVELOPER_DIR)/SDKs/iPhoneHostSideTools.sparse.sdk
52 endif
53
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)
59 else
60 export CC := $(shell $(XCRUN) -sdk $(SDKROOT) -find clang)
61 endif
62 endif
63 ifeq ($(origin CXX),default)
64 ifneq ($(findstring iPhone,$(PLATFORM)),)
65 export CXX := $(shell $(XCRUN) -sdk $(SDKROOT) -find clang++)
66 else
67 export CXX := $(shell $(XCRUN) -sdk $(SDKROOT) -find clang++)
68 endif
69 endif
70 ifeq ($(MIG),)
71 export MIG := $(shell $(XCRUN) -sdk $(SDKROOT) -find mig)
72 endif
73 ifeq ($(MIGCC),)
74 export MIGCC := $(CC)
75 endif
76 ifeq ($(STRIP),)
77 export STRIP := $(shell $(XCRUN) -sdk $(SDKROOT) -find strip)
78 endif
79 ifeq ($(LIPO),)
80 export LIPO := $(shell $(XCRUN) -sdk $(SDKROOT) -find lipo)
81 endif
82 ifeq ($(LIBTOOL),)
83 export LIBTOOL := $(shell $(XCRUN) -sdk $(SDKROOT) -find libtool)
84 endif
85 ifeq ($(NM),)
86 export NM := $(shell $(XCRUN) -sdk $(SDKROOT) -find nm)
87 endif
88 ifeq ($(UNIFDEF),)
89 export UNIFDEF := $(shell $(XCRUN) -sdk $(SDKROOT) -find unifdef)
90 endif
91 ifeq ($(DSYMUTIL),)
92 export DSYMUTIL := $(shell $(XCRUN) -sdk $(SDKROOT) -find dsymutil)
93 endif
94 ifeq ($(CTFCONVERT),)
95 export CTFCONVERT := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfconvert)
96 endif
97 ifeq ($(CTFMERGE),)
98 export CTFMERGE := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfmerge)
99 endif
100 ifeq ($(CTFSCRUB),)
101 export CTFSCRUB := $(shell $(XCRUN) -sdk $(SDKROOT) -find ctfdump) -r
102 endif
103 ifeq ($(NMEDIT),)
104 export NMEDIT := $(shell $(XCRUN) -sdk $(SDKROOT) -find nmedit)
105 endif
106
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)
111 endif
112 ifeq ($(IPHONEOS_OPTIMIZE),)
113 export IPHONEOS_OPTIMIZE := $(shell $(XCRUN) -sdk $(SDKROOT) -find iphoneos-optimize)
114 endif
115 endif
116
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
123
124 # Standard BSD tools
125 RM = /bin/rm -f
126 CP = /bin/cp
127 MV = /bin/mv
128 LN = /bin/ln -fs
129 CAT = /bin/cat
130 MKDIR = /bin/mkdir -p
131 FIND = /usr/bin/find
132 XARGS = /usr/bin/xargs
133 INSTALL = /usr/bin/install
134 TAR = /usr/bin/gnutar
135 BASENAME = /usr/bin/basename
136 TR = /usr/bin/tr
137
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)
142 endif
143 ifeq ($(IPHONEOS_OPTIMIZE),)
144 export IPHONEOS_OPTIMIZE := $(shell $(XCRUN) -sdk $(SDKROOT) -find iphoneos-optimize || echo /usr/bin/true)
145 endif
146 endif
147
148 CTFINSERT = $(XCRUN) -sdk $(SDKROOT) ctf_insert
149
150 #
151 # Command to generate host binaries. Intentionally not
152 # $(CC), which controls the target compiler
153 #
154 ifeq ($(HOST_CC),)
155 export HOST_CC := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find cc)
156 endif
157 ifeq ($(HOST_FLEX),)
158 export HOST_FLEX := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find flex)
159 endif
160 ifeq ($(HOST_BISON),)
161 export HOST_BISON := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find bison)
162 endif
163 ifeq ($(HOST_CODESIGN),)
164 export HOST_CODESIGN := $(shell $(XCRUN) -sdk $(HOST_SDKROOT) -find codesign)
165 endif
166
167 # vim: set ft=make: