]>
Commit | Line | Data |
---|---|---|
39236c6e | 1 | # -*- mode: makefile;-*- |
1c79356b | 2 | # |
3e170ce0 | 3 | # Copyright (C) 1999-2014 Apple Inc. All rights reserved. |
1c79356b | 4 | # |
39236c6e A |
5 | # MakeInc.def contains global definitions for building, |
6 | # linking, and installing files. | |
1c79356b | 7 | # |
1c79356b | 8 | |
6d2010ae | 9 | # |
39236c6e | 10 | # Architecture Configuration options |
6d2010ae | 11 | # |
fe8ab488 | 12 | SUPPORTED_ARCH_CONFIGS := X86_64 X86_64H |
6d2010ae | 13 | |
2d21ac55 | 14 | # |
1c79356b A |
15 | # Kernel Configuration options |
16 | # | |
39236c6e | 17 | SUPPORTED_KERNEL_CONFIGS = RELEASE DEVELOPMENT DEBUG PROFILE |
2d21ac55 | 18 | |
316670eb A |
19 | # |
20 | # Machine Configuration options | |
21 | # | |
39236c6e A |
22 | |
23 | SUPPORTED_X86_64_MACHINE_CONFIGS = NONE | |
fe8ab488 | 24 | SUPPORTED_X86_64H_MACHINE_CONFIGS = NONE |
6d2010ae | 25 | |
6d2010ae | 26 | |
2d21ac55 | 27 | |
6d2010ae | 28 | # |
39236c6e | 29 | # Setup up *_LC variables during recursive invocations |
6d2010ae | 30 | # |
6d2010ae | 31 | |
39236c6e A |
32 | ifndef CURRENT_ARCH_CONFIG_LC |
33 | export CURRENT_ARCH_CONFIG_LC := $(shell printf "%s" "$(CURRENT_ARCH_CONFIG)" | $(TR) A-Z a-z) | |
6d2010ae A |
34 | endif |
35 | ||
39236c6e A |
36 | ifndef CURRENT_KERNEL_CONFIG_LC |
37 | export CURRENT_KERNEL_CONFIG_LC := $(shell printf "%s" "$(CURRENT_KERNEL_CONFIG)" | $(TR) A-Z a-z) | |
316670eb | 38 | endif |
6d2010ae | 39 | |
39236c6e A |
40 | ifndef CURRENT_MACHINE_CONFIG_LC |
41 | export CURRENT_MACHINE_CONFIG_LC := $(shell printf "%s" "$(CURRENT_MACHINE_CONFIG)" | $(TR) A-Z a-z) | |
6d2010ae A |
42 | endif |
43 | ||
39236c6e | 44 | |
2d21ac55 | 45 | # |
39236c6e | 46 | # Component List |
2d21ac55 | 47 | # |
39236c6e A |
48 | COMPONENT_LIST = osfmk bsd libkern iokit pexpert libsa security |
49 | COMPONENT = $(if $(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(firstword $(subst /, ,$(RELATIVE_SOURCE_PATH)))) | |
50 | COMPONENT_IMPORT_LIST = $(filter-out $(COMPONENT),$(COMPONENT_LIST)) | |
1c79356b | 51 | |
1c79356b | 52 | |
316670eb A |
53 | # |
54 | # Deployment target flag | |
55 | # | |
316670eb | 56 | ifeq ($(PLATFORM),MacOSX) |
39236c6e | 57 | DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION) |
3e170ce0 A |
58 | else ifeq ($(PLATFORM),WatchOS) |
59 | DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION) | |
60 | else ifeq ($(PLATFORM),tvOS) | |
61 | DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) | |
62 | else ifeq ($(PLATFORM),AppleTVOS) | |
63 | DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION) | |
64 | else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) | |
39236c6e | 65 | DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION) |
3e170ce0 | 66 | else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),) |
39236c6e | 67 | DEPLOYMENT_TARGET_FLAGS = |
316670eb | 68 | else |
39236c6e | 69 | DEPLOYMENT_TARGET_FLAGS = |
316670eb A |
70 | endif |
71 | ||
3e170ce0 A |
72 | DEPLOYMENT_TARGET_DEFINES = -DPLATFORM_$(PLATFORM) |
73 | ||
39236c6e | 74 | |
1c79356b A |
75 | # |
76 | # Standard defines list | |
77 | # | |
39236c6e | 78 | DEFINES = -DAPPLE -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE \ |
fe8ab488 | 79 | -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile $(CONFIG_DEFINES) \ |
39236c6e | 80 | $(SEED_DEFINES) |
1c79356b A |
81 | |
82 | # | |
83 | # Compiler command | |
84 | # | |
39236c6e A |
85 | KCC = $(CC) |
86 | KC++ = $(CXX) | |
9bccf70c | 87 | |
3e170ce0 A |
88 | GENASSYM_KCC = $(CC) |
89 | ||
91447636 A |
90 | # |
91 | # Compiler warning flags | |
92 | # | |
93 | ||
94 | CWARNFLAGS_STD = \ | |
6d2010ae A |
95 | -Wall -Werror -Wno-format-y2k -Wextra -Wstrict-prototypes \ |
96 | -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual \ | |
97 | -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wchar-subscripts \ | |
fe8ab488 A |
98 | -Winline -Wnested-externs -Wredundant-decls -Wextra-tokens \ |
99 | -Wunreachable-code | |
6d2010ae | 100 | |
6d2010ae | 101 | # Can be overridden in Makefile.template or Makefile.$arch |
91447636 A |
102 | export CWARNFLAGS ?= $(CWARNFLAGS_STD) |
103 | ||
6d2010ae A |
104 | define add_perfile_cflags |
105 | $(1)_CWARNFLAGS_ADD += $2 | |
106 | endef | |
107 | ||
91447636 | 108 | CXXWARNFLAGS_STD = \ |
6d2010ae A |
109 | -Wall -Werror -Wno-format-y2k -Wextra -Wpointer-arith -Wreturn-type \ |
110 | -Wcast-qual -Wwrite-strings -Wswitch -Wcast-align -Wchar-subscripts \ | |
fe8ab488 A |
111 | -Wredundant-decls -Wextra-tokens \ |
112 | -Wunreachable-code | |
6d2010ae | 113 | |
39236c6e A |
114 | # overloaded-virtual warnings are non-fatal (9000888) |
115 | CXXWARNFLAGS_STD += -Wno-error=overloaded-virtual | |
91447636 | 116 | |
6d2010ae | 117 | # Can be overridden in Makefile.template or Makefile.$arch |
91447636 A |
118 | export CXXWARNFLAGS ?= $(CXXWARNFLAGS_STD) |
119 | ||
6d2010ae A |
120 | define add_perfile_cxxflags |
121 | $(1)_CXXWARNFLAGS_ADD += $2 | |
122 | endef | |
9bccf70c | 123 | |
2d21ac55 A |
124 | # |
125 | # Default ARCH_FLAGS, for use with compiler/linker/assembler/mig drivers | |
126 | ||
b0d623f7 | 127 | ARCH_FLAGS_X86_64 = -arch x86_64 |
fe8ab488 | 128 | ARCH_FLAGS_X86_64H = -arch x86_64h |
c910b4d9 | 129 | |
2d21ac55 | 130 | |
1c79356b A |
131 | # |
132 | # Default CFLAGS | |
133 | # | |
134 | ifdef RC_CFLAGS | |
39236c6e | 135 | OTHER_CFLAGS = $(subst $(addprefix -arch ,$(RC_ARCHS)),,$(RC_CFLAGS)) |
1c79356b A |
136 | endif |
137 | ||
39236c6e A |
138 | # |
139 | # Debug info | |
140 | # | |
39236c6e A |
141 | DSYMINFODIR = Contents |
142 | DSYMKGMACROSDIR = Contents/Resources | |
143 | DSYMLLDBMACROSDIR = Contents/Resources/Python | |
144 | DSYMDWARFDIR = Contents/Resources/DWARF | |
145 | ||
146 | DEBUG_CFLAGS := -gdwarf-2 | |
147 | BUILD_DSYM := 1 | |
2d21ac55 A |
148 | |
149 | # | |
150 | # We must not use -fno-keep-inline-functions, or it will remove the dtrace | |
151 | # probes from the kernel. | |
152 | # | |
39236c6e | 153 | CFLAGS_GEN = $(DEBUG_CFLAGS) -nostdinc \ |
3e170ce0 | 154 | -fno-builtin -fno-common \ |
316670eb | 155 | -fsigned-bitfields $(OTHER_CFLAGS) |
1c79356b | 156 | |
39236c6e A |
157 | CFLAGS_RELEASE = |
158 | CFLAGS_DEVELOPMENT = | |
159 | CFLAGS_DEBUG = | |
160 | CFLAGS_PROFILE = -pg | |
1c79356b | 161 | |
39236c6e | 162 | CFLAGS_X86_64 = -Dx86_64 -DX86_64 -D__X86_64__ -DLP64 \ |
fe8ab488 A |
163 | -DPAGE_SIZE_FIXED -mkernel -msoft-float |
164 | ||
165 | CFLAGS_X86_64H = $(CFLAGS_X86_64) | |
316670eb | 166 | |
2d21ac55 | 167 | |
39236c6e A |
168 | CFLAGS_RELEASEX86_64 = -O2 |
169 | CFLAGS_DEVELOPMENTX86_64 = -O2 | |
b0d623f7 | 170 | # No space optimization for the DEBUG kernel for the benefit of gdb: |
39236c6e A |
171 | CFLAGS_DEBUGX86_64 = -O0 |
172 | CFLAGS_PROFILEX86_64 = -O2 | |
173 | ||
fe8ab488 A |
174 | CFLAGS_RELEASEX86_64H = -O2 |
175 | CFLAGS_DEVELOPMENTX86_64H = -O2 | |
176 | # No space optimization for the DEBUG kernel for the benefit of gdb: | |
177 | CFLAGS_DEBUGX86_64H = -O0 | |
178 | CFLAGS_PROFILEX86_64H = -O2 | |
179 | ||
39236c6e A |
180 | CFLAGS_RELEASEARM = -O2 |
181 | CFLAGS_DEVELOPMENTARM = -O2 | |
182 | CFLAGS_DEBUGARM = -O0 | |
183 | CFLAGS_PROFILEARM = -O2 | |
184 | ||
fe8ab488 | 185 | |
39236c6e A |
186 | CFLAGS = $(CFLAGS_GEN) \ |
187 | $($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \ | |
188 | $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ | |
189 | $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) \ | |
190 | $($(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_)) \ | |
191 | $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_))) \ | |
316670eb | 192 | $(DEPLOYMENT_TARGET_FLAGS) \ |
3e170ce0 | 193 | $(DEPLOYMENT_TARGET_DEFINES) \ |
1c79356b A |
194 | $(DEFINES) |
195 | ||
6d2010ae | 196 | # |
55e303ae | 197 | # Default C++ flags |
1c79356b | 198 | # |
6d2010ae A |
199 | |
200 | OTHER_CXXFLAGS = | |
316670eb A |
201 | |
202 | CXXFLAGS_GEN = -fapple-kext $(OTHER_CXXFLAGS) | |
1c79356b | 203 | |
39236c6e A |
204 | # For the moment, do not use gnu++11 |
205 | #CXXFLAGS_ARM = -std=gnu++11 | |
206 | ||
fe8ab488 | 207 | |
55e303ae | 208 | CXXFLAGS = $(CXXFLAGS_GEN) \ |
39236c6e A |
209 | $($(addsuffix $(CURRENT_ARCH_CONFIG),CXXFLAGS_)) \ |
210 | $($(addsuffix $(CURRENT_KERNEL_CONFIG),CXXFLAGS_)) | |
211 | ||
1c79356b A |
212 | |
213 | # | |
214 | # Assembler command | |
215 | # | |
0c530ab8 A |
216 | AS = $(CC) |
217 | S_KCC = $(CC) | |
1c79356b A |
218 | |
219 | # | |
220 | # Default SFLAGS | |
221 | # | |
fe8ab488 | 222 | SFLAGS_GEN = -D__ASSEMBLER__ -DASSEMBLER $(OTHER_CFLAGS) |
1c79356b | 223 | |
39236c6e A |
224 | SFLAGS_RELEASE = |
225 | SFLAGS_DEVELOPMENT = | |
226 | SFLAGS_DEBUG = | |
227 | SFLAGS_PROFILE = | |
1c79356b | 228 | |
39236c6e | 229 | SFLAGS_X86_64 = $(CFLAGS_X86_64) |
fe8ab488 | 230 | SFLAGS_X86_64H = $(CFLAGS_X86_64H) |
1c79356b | 231 | |
39236c6e A |
232 | SFLAGS = $(SFLAGS_GEN) \ |
233 | $($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \ | |
234 | $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ | |
235 | $($(addsuffix $(CURRENT_ARCH_CONFIG),SFLAGS_)) \ | |
236 | $($(addsuffix $(CURRENT_KERNEL_CONFIG),SFLAGS_)) \ | |
316670eb | 237 | $(DEPLOYMENT_TARGET_FLAGS) \ |
3e170ce0 | 238 | $(DEPLOYMENT_TARGET_DEFINES) \ |
1c79356b A |
239 | $(DEFINES) |
240 | ||
241 | # | |
242 | # Linker command | |
243 | # | |
0c530ab8 | 244 | LD = $(KC++) -nostdlib |
1c79356b A |
245 | |
246 | # | |
247 | # Default LDFLAGS | |
248 | # | |
39236c6e A |
249 | # Availability of DWARF allows DTrace CTF (compressed type format) to be constructed. |
250 | # ctf_insert creates the CTF section. It needs reserved padding in the | |
251 | # headers for the load command segment and the CTF section structures. | |
252 | # | |
253 | LDFLAGS_KERNEL_GEN = \ | |
6d2010ae | 254 | -nostdlib \ |
0c530ab8 | 255 | -fapple-kext \ |
0c530ab8 | 256 | -Wl,-e,__start \ |
0c530ab8 A |
257 | -Wl,-sectalign,__TEXT,__text,0x1000 \ |
258 | -Wl,-sectalign,__DATA,__common,0x1000 \ | |
259 | -Wl,-sectalign,__DATA,__bss,0x1000 \ | |
b0d623f7 A |
260 | -Wl,-sectcreate,__PRELINK_TEXT,__text,/dev/null \ |
261 | -Wl,-sectcreate,__PRELINK_STATE,__kernel,/dev/null \ | |
262 | -Wl,-sectcreate,__PRELINK_STATE,__kexts,/dev/null \ | |
316670eb A |
263 | -Wl,-sectcreate,__PRELINK_INFO,__info,/dev/null \ |
264 | -Wl,-new_linker \ | |
265 | -Wl,-pagezero_size,0x0 \ | |
266 | -Wl,-version_load_command \ | |
39236c6e A |
267 | -Wl,-function_starts \ |
268 | -Wl,-headerpad,152 | |
b0d623f7 | 269 | |
39236c6e A |
270 | LDFLAGS_KERNEL_RELEASE = |
271 | LDFLAGS_KERNEL_DEVELOPMENT = | |
272 | LDFLAGS_KERNEL_DEBUG = | |
273 | LDFLAGS_KERNEL_PROFILE = | |
b0d623f7 | 274 | |
316670eb A |
275 | # KASLR static slide config: |
276 | ifndef SLIDE | |
277 | SLIDE=0x00 | |
278 | endif | |
39236c6e A |
279 | KERNEL_MIN_ADDRESS = 0xffffff8000000000 |
280 | KERNEL_BASE_OFFSET = 0x100000 | |
281 | KERNEL_STATIC_SLIDE = $(shell printf "0x%016x" \ | |
282 | $$[ $(SLIDE) << 21 ]) | |
283 | KERNEL_STATIC_BASE = $(shell printf "0x%016x" \ | |
284 | $$[ $(KERNEL_MIN_ADDRESS) + $(KERNEL_BASE_OFFSET) ]) | |
285 | KERNEL_HIB_SECTION_BASE = $(shell printf "0x%016x" \ | |
286 | $$[ $(KERNEL_STATIC_BASE) + $(KERNEL_STATIC_SLIDE) ]) | |
287 | KERNEL_TEXT_BASE = $(shell printf "0x%016x" \ | |
288 | $$[ $(KERNEL_HIB_SECTION_BASE) + 0x100000 ]) | |
289 | ||
290 | LDFLAGS_KERNEL_RELEASEX86_64 = \ | |
316670eb A |
291 | -Wl,-pie \ |
292 | -Wl,-segaddr,__HIB,$(KERNEL_HIB_SECTION_BASE) \ | |
293 | -Wl,-image_base,$(KERNEL_TEXT_BASE) \ | |
294 | -Wl,-seg_page_size,__TEXT,0x200000 \ | |
295 | -Wl,-sectalign,__DATA,__const,0x1000 \ | |
296 | -Wl,-sectalign,__DATA,__sysctl_set,0x1000 \ | |
297 | -Wl,-sectalign,__HIB,__bootPT,0x1000 \ | |
298 | -Wl,-sectalign,__HIB,__desc,0x1000 \ | |
299 | -Wl,-sectalign,__HIB,__data,0x1000 \ | |
300 | -Wl,-sectalign,__HIB,__text,0x1000 \ | |
301 | -Wl,-sectalign,__HIB,__const,0x1000 \ | |
302 | -Wl,-sectalign,__HIB,__bss,0x1000 \ | |
303 | -Wl,-sectalign,__HIB,__common,0x1000 \ | |
3e170ce0 A |
304 | -Wl,-sectalign,__HIB,__llvm_prf_cnts,0x1000 \ |
305 | -Wl,-sectalign,__HIB,__llvm_prf_names,0x1000 \ | |
306 | -Wl,-sectalign,__HIB,__llvm_prf_data,0x1000 \ | |
307 | -Wl,-sectalign,__HIB,__textcoal_nt,0x1000 \ | |
39236c6e | 308 | $(LDFLAGS_NOSTRIP_FLAG) |
316670eb A |
309 | |
310 | # Define KERNEL_BASE_OFFSET so known at compile time: | |
39236c6e | 311 | CFLAGS_X86_64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET) |
fe8ab488 | 312 | CFLAGS_X86_64H += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET) |
2d21ac55 | 313 | |
39236c6e A |
314 | LDFLAGS_KERNEL_DEBUGX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) |
315 | LDFLAGS_KERNEL_DEVELOPMENTX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) | |
316 | LDFLAGS_KERNEL_PROFILEX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64) | |
d1ecb069 | 317 | |
fe8ab488 A |
318 | LDFLAGS_KERNEL_RELEASEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64) |
319 | LDFLAGS_KERNEL_DEBUGX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) | |
320 | LDFLAGS_KERNEL_DEVELOPMENTX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) | |
321 | LDFLAGS_KERNEL_PROFILEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H) | |
322 | ||
d1ecb069 | 323 | |
39236c6e A |
324 | LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \ |
325 | $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ | |
326 | $($(addsuffix $(CURRENT_ARCH_CONFIG),LDFLAGS_KERNEL_)) \ | |
327 | $($(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_)) \ | |
328 | $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_))) \ | |
316670eb | 329 | $(DEPLOYMENT_TARGET_FLAGS) |
1c79356b A |
330 | |
331 | # | |
332 | # Default runtime libraries to be linked with the kernel | |
333 | # | |
39236c6e | 334 | LD_KERNEL_LIBS = -lcc_kext |
1c79356b | 335 | |
39236c6e A |
336 | # |
337 | # DTrace support | |
338 | # | |
339 | ifeq ($(CURRENT_KERNEL_CONFIG),RELEASE) | |
340 | ifneq ($(filter ARM%,$(CURRENT_ARCH_CONFIG)),) | |
341 | DO_CTFCONVERT = 0 | |
342 | DO_CTFMERGE = 0 | |
343 | DO_CTFMACHO = 0 | |
344 | else | |
345 | DO_CTFCONVERT = $(SUPPORTS_CTFCONVERT) | |
346 | DO_CTFMERGE = 1 | |
347 | DO_CTFMACHO = $(NEEDS_CTF_MACHOS) | |
348 | endif | |
349 | else | |
350 | DO_CTFCONVERT = $(SUPPORTS_CTFCONVERT) | |
351 | DO_CTFMERGE = 1 | |
352 | DO_CTFMACHO = $(NEEDS_CTF_MACHOS) | |
353 | endif | |
b0d623f7 | 354 | |
1c79356b A |
355 | # |
356 | # Default INCFLAGS | |
357 | # | |
39236c6e A |
358 | INCFLAGS_IMPORT = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST)) |
359 | INCFLAGS_EXTERN = -I$(SRCROOT)/EXTERNAL_HEADERS | |
360 | INCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT) | |
361 | INCFLAGS_LOCAL = -I. | |
1c79356b | 362 | |
39236c6e | 363 | INCFLAGS = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE) |
1c79356b A |
364 | |
365 | # | |
366 | # Default MIGFLAGS | |
367 | # | |
fe8ab488 | 368 | MIGFLAGS = $(DEFINES) $(INCFLAGS) -novouchers $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \ |
39236c6e | 369 | $(DEPLOYMENT_TARGET_FLAGS) |
316670eb | 370 | |
3e170ce0 A |
371 | |
372 | # Support for LLVM Profile Guided Optimization (PGO) | |
373 | ||
374 | ifeq ($(BUILD_PROFILE),1) | |
375 | CFLAGS_GEN += -fprofile-instr-generate -DPROFILE | |
376 | CXXFLAGS_GEN += -fprofile-instr-generate -DPROFILE | |
377 | endif | |
378 | ||
379 | ifdef USE_PROFILE | |
380 | CFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE) | |
381 | CXXFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE) | |
382 | LDFLAGS_KERNEL_GEN += -fprofile-instr-use=$(USE_PROFILE) | |
383 | ||
384 | CFLAGS_GEN += -Wno-error=profile-instr-out-of-date | |
385 | endif | |
386 | ||
316670eb A |
387 | # |
388 | # Support for LLVM Link Time Optimization (LTO) | |
389 | # | |
fe8ab488 A |
390 | # LTO can be explicitly enabled or disabled with BUILD_LTO=1|0 |
391 | # and defaults to enabled except for DEBUG kernels | |
392 | # | |
39236c6e A |
393 | # CFLAGS_NOLTO_FLAG is needed on a per-file basis (for files |
394 | # that deal poorly with LTO, or files that must be machine | |
395 | # code *.o files for xnu to build (i.e, setsegname runs on | |
396 | # them). | |
397 | # | |
398 | # LDFLAGS_NOSTRIP_FLAG is used to support configurations that | |
399 | # do not utilize an export list. For these configs to build, | |
400 | # we need to prevent the LTO logic from dead stripping them. | |
316670eb | 401 | |
fe8ab488 A |
402 | LTO_ENABLED_RELEASE = 1 |
403 | LTO_ENABLED_DEVELOPMENT = 1 | |
404 | LTO_ENABLED_DEBUG = 0 | |
405 | ||
406 | ifneq ($(BUILD_LTO),) | |
407 | USE_LTO = $(BUILD_LTO) | |
408 | else | |
409 | USE_LTO = $(LTO_ENABLED_$(CURRENT_KERNEL_CONFIG)) | |
410 | endif | |
411 | ||
3e170ce0 | 412 | SUPPORTS_CTFCONVERT = 0 |
fe8ab488 | 413 | ifeq ($(USE_LTO),1) |
39236c6e A |
414 | CFLAGS_GEN += -flto |
415 | CXXFLAGS_GEN += -flto | |
fe8ab488 | 416 | LDFLAGS_KERNEL_GEN += -Wl,-mllvm,-inline-threshold=125 -Wl,-object_path_lto,$(TARGET)/lto.o # -Wl,-mllvm -Wl,-disable-fp-elim |
39236c6e A |
417 | LDFLAGS_NOSTRIP_FLAG = -rdynamic |
418 | CFLAGS_NOLTO_FLAG = -fno-lto | |
39236c6e | 419 | NEEDS_CTF_MACHOS = 1 |
316670eb | 420 | else |
39236c6e A |
421 | LDFLAGS_NOSTRIP_FLAG = |
422 | CFLAGS_NOLTO_FLAG = | |
3e170ce0 | 423 | ifneq ($(CTFCONVERT),) |
39236c6e | 424 | SUPPORTS_CTFCONVERT = 1 |
3e170ce0 | 425 | endif |
39236c6e | 426 | NEEDS_CTF_MACHOS = 0 |
316670eb | 427 | endif |
1c79356b | 428 | |
3e170ce0 A |
429 | ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1) |
430 | BUILD_DSYM := 0 | |
431 | DO_CTFCONVERT := 0 | |
432 | DO_CTFMERGE := 0 | |
433 | DO_CTFMACHO := 0 | |
434 | KCC = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CC) | |
435 | KC++ = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CXX) | |
436 | S_KCC = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CC) | |
437 | STRIP = true | |
438 | endif | |
439 | ||
1c79356b A |
440 | # |
441 | # Default VPATH | |
442 | # | |
39236c6e | 443 | export VPATH = .:$(SOURCE) |
1c79356b A |
444 | |
445 | # | |
2d21ac55 | 446 | # Macros that control installation of kernel and its header files |
1c79356b A |
447 | # |
448 | # install flags for header files | |
449 | # | |
39236c6e A |
450 | INSTALL_FLAGS = -c -S -m 0444 |
451 | DATA_INSTALL_FLAGS = -c -S -m 0644 | |
452 | EXEC_INSTALL_FLAGS = -c -S -m 0755 | |
1c79356b A |
453 | |
454 | # | |
455 | # Header file destinations | |
456 | # | |
3e170ce0 | 457 | FRAMEDIR = /System/Library/Frameworks |
6d2010ae A |
458 | |
459 | SINCVERS = B | |
460 | SINCFRAME = $(FRAMEDIR)/System.framework | |
461 | SINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Headers | |
462 | SPINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/PrivateHeaders | |
463 | SRESDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Resources | |
464 | ||
1c79356b | 465 | ifndef INCDIR |
3e170ce0 | 466 | INCDIR = /usr/include |
1c79356b A |
467 | endif |
468 | ifndef LCLDIR | |
6d2010ae | 469 | LCLDIR = $(SPINCDIR) |
1c79356b A |
470 | endif |
471 | ||
472 | KINCVERS = A | |
473 | KINCFRAME = $(FRAMEDIR)/Kernel.framework | |
474 | KINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Headers | |
0b4e3aa0 | 475 | KPINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/PrivateHeaders |
91447636 A |
476 | KRESDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Resources |
477 | ||
478 | XNU_PRIVATE_UNIFDEF = -UMACH_KERNEL_PRIVATE -UBSD_KERNEL_PRIVATE -UIOKIT_KERNEL_PRIVATE -ULIBKERN_KERNEL_PRIVATE -ULIBSA_KERNEL_PRIVATE -UPEXPERT_KERNEL_PRIVATE -UXNU_KERNEL_PRIVATE | |
479 | ||
6d2010ae | 480 | |
39236c6e A |
481 | PLATFORM_UNIFDEF = $(foreach x,$(SUPPORTED_PLATFORMS),$(if $(filter $(PLATFORM),$(x)),-DPLATFORM_$(x) $(foreach token,$(PLATFORM_UNIFDEF_BLACKLIST_TOKENS_$(x)),-U$(token)),-UPLATFORM_$(x))) |
482 | ||
483 | SPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ | |
484 | SINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ | |
485 | KPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -DKERNEL_PRIVATE -DPRIVATE -DKERNEL -U_OPEN_SOURCE_ -U__OPEN_SOURCE__ | |
486 | KINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UPRIVATE -DKERNEL -D_OPEN_SOURCE_ -D__OPEN_SOURCE__ | |
1c79356b A |
487 | |
488 | # | |
39236c6e | 489 | # Compononent Header file destinations |
1c79356b A |
490 | # |
491 | EXPDIR = EXPORT_HDRS/$(COMPONENT) | |
492 | ||
493 | # | |
494 | # Strip Flags | |
495 | # | |
39236c6e | 496 | STRIP_FLAGS_RELEASE = -S -x |
fe8ab488 | 497 | STRIP_FLAGS_DEVELOPMENT = -S |
39236c6e A |
498 | STRIP_FLAGS_DEBUG = -S |
499 | STRIP_FLAGS_PROFILE = -S -x | |
1c79356b | 500 | |
39236c6e | 501 | STRIP_FLAGS = $($(addsuffix $(CURRENT_KERNEL_CONFIG),STRIP_FLAGS_)) |
1c79356b | 502 | |
2d21ac55 A |
503 | # |
504 | # dsymutil flags | |
505 | # | |
fe8ab488 | 506 | DSYMUTIL_FLAGS_GEN = --minimize |
2d21ac55 | 507 | |
fe8ab488 A |
508 | DSYMUTIL_FLAGS_X86_64 = --arch=x86_64 |
509 | DSYMUTIL_FLAGS_X86_64H = --arch=x86_64h | |
510 | ||
511 | DSYMUTIL_FLAGS = $(DSYMUTIL_FLAGS_GEN) \ | |
512 | $($(addsuffix $(CURRENT_ARCH_CONFIG),DSYMUTIL_FLAGS_)) | |
2d21ac55 | 513 | |
9bccf70c A |
514 | # |
515 | # Man Page destination | |
516 | # | |
39236c6e | 517 | MANDIR = /usr/share/man |
9bccf70c | 518 | |
b0d623f7 A |
519 | # |
520 | # DEBUG alias location | |
521 | # | |
39236c6e | 522 | DEVELOPER_EXTRAS_DIR = /AppleInternal/CoreOS/xnu_debug |
2d21ac55 | 523 | |
1c79356b | 524 | # |
39236c6e | 525 | # mach_kernel install location |
1c79356b | 526 | # |
39236c6e | 527 | INSTALL_KERNEL_DIR = / |
1c79356b | 528 | |
fe8ab488 A |
529 | # |
530 | # new OS X install location | |
531 | # | |
532 | SYSTEM_LIBRARY_KERNELS_DIR = /System/Library/Kernels | |
533 | ||
534 | # | |
535 | # File names in DSTROOT | |
536 | # | |
537 | ||
538 | ifeq ($(PLATFORM),MacOSX) | |
539 | KERNEL_FILE_NAME_PREFIX = kernel | |
540 | else | |
541 | KERNEL_FILE_NAME_PREFIX = mach | |
542 | endif | |
543 | ||
544 | ifeq ($(CURRENT_MACHINE_CONFIG),NONE) | |
545 | ifeq ($(CURRENT_KERNEL_CONFIG),RELEASE) | |
546 | KERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX) | |
547 | KERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX).py | |
548 | else | |
549 | KERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC) | |
550 | KERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX).py | |
551 | endif | |
552 | else | |
553 | KERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC).$(CURRENT_MACHINE_CONFIG_LC) | |
554 | KERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX)_$(CURRENT_KERNEL_CONFIG_LC).py | |
555 | endif | |
556 | ||
39236c6e A |
557 | # |
558 | # System.kext pseudo-kext install location | |
559 | # | |
560 | INSTALL_EXTENSIONS_DIR = /System/Library/Extensions | |
561 | ||
562 | # | |
fe8ab488 | 563 | # KDK location |
39236c6e A |
564 | # |
565 | INSTALL_KERNEL_SYM_DIR = /System/Library/Extensions/KDK | |
566 | ||
567 | # | |
568 | # Misc. Etc. | |
569 | # | |
570 | INSTALL_SHARE_MISC_DIR = /usr/share/misc | |
571 | INSTALL_DTRACE_SCRIPTS_DIR = /usr/lib/dtrace | |
572 | ||
573 | # | |
574 | # Overrides for XBS build aliases | |
575 | # | |
576 | ifeq ($(RC_ProjectName),xnu_debug) | |
577 | INSTALL_KERNEL_DIR := $(DEVELOPER_EXTRAS_DIR) | |
fe8ab488 A |
578 | INSTALL_KERNEL_SYM_DIR := $(DEVELOPER_EXTRAS_DIR) |
579 | INSTALL_KERNEL_SYM_TO_KDK = 1 | |
39236c6e | 580 | INSTALL_XNU_DEBUG_FILES = 1 |
3e170ce0 | 581 | else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),) |
39236c6e A |
582 | INSTALL_KERNEL_SYM_TO_KDK = 1 |
583 | USE_BINARY_PLIST = 1 | |
3e170ce0 | 584 | else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),) |
39236c6e | 585 | USE_BINARY_PLIST = 1 |
fe8ab488 A |
586 | else ifeq ($(PLATFORM),MacOSX) |
587 | INSTALL_KERNEL_DIR := $(SYSTEM_LIBRARY_KERNELS_DIR) | |
588 | INSTALL_KERNEL_SYM_DIR := $(SYSTEM_LIBRARY_KERNELS_DIR) | |
589 | INSTALL_KERNEL_SYM_TO_KDK = $(if $(filter YES,$(DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT)),1,0) | |
39236c6e | 590 | endif |
1c79356b | 591 | |
2d21ac55 | 592 | # vim: set ft=make: |