]> git.saurik.com Git - apple/xnu.git/blob - makedefs/MakeInc.def
xnu-4570.51.1.tar.gz
[apple/xnu.git] / makedefs / MakeInc.def
1 # -*- mode: makefile;-*-
2 #
3 # Copyright (C) 1999-2017 Apple Inc. All rights reserved.
4 #
5 # MakeInc.def contains global definitions for building,
6 # linking, and installing files.
7 #
8
9 #
10 # Architecture Configuration options
11 #
12 SUPPORTED_ARCH_CONFIGS := X86_64 X86_64H
13
14 #
15 # Kernel Configuration options
16 #
17 SUPPORTED_KERNEL_CONFIGS = RELEASE DEVELOPMENT DEBUG PROFILE KASAN
18
19 #
20 # Machine Configuration options
21 #
22
23 SUPPORTED_X86_64_MACHINE_CONFIGS = NONE
24 SUPPORTED_X86_64H_MACHINE_CONFIGS = NONE
25
26
27 #
28 # Setup up *_LC variables during recursive invocations
29 #
30
31 ifndef CURRENT_ARCH_CONFIG_LC
32 export CURRENT_ARCH_CONFIG_LC := $(shell printf "%s" "$(CURRENT_ARCH_CONFIG)" | $(TR) A-Z a-z)
33 endif
34
35 ifndef CURRENT_KERNEL_CONFIG_LC
36 export CURRENT_KERNEL_CONFIG_LC := $(shell printf "%s" "$(CURRENT_KERNEL_CONFIG)" | $(TR) A-Z a-z)
37 endif
38
39 ifndef CURRENT_MACHINE_CONFIG_LC
40 export CURRENT_MACHINE_CONFIG_LC := $(shell printf "%s" "$(CURRENT_MACHINE_CONFIG)" | $(TR) A-Z a-z)
41 endif
42
43 #
44 # Component List
45 #
46 COMPONENT_LIST = osfmk bsd libkern iokit pexpert libsa security san
47 COMPONENT = $(if $(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(firstword $(subst /, ,$(RELATIVE_SOURCE_PATH))))
48 COMPONENT_IMPORT_LIST = $(filter-out $(COMPONENT),$(COMPONENT_LIST))
49
50
51 #
52 # Deployment target flag
53 #
54 ifeq ($(PLATFORM),MacOSX)
55 DEPLOYMENT_TARGET_FLAGS = -mmacosx-version-min=$(SDKVERSION)
56 else ifeq ($(PLATFORM),WatchOS)
57 DEPLOYMENT_TARGET_FLAGS = -mwatchos-version-min=$(SDKVERSION)
58 else ifeq ($(PLATFORM),tvOS)
59 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION)
60 else ifeq ($(PLATFORM),AppleTVOS)
61 DEPLOYMENT_TARGET_FLAGS = -mtvos-version-min=$(SDKVERSION)
62 else ifeq ($(PLATFORM),BridgeOS)
63 DEPLOYMENT_TARGET_FLAGS = -mbridgeos-version-min=$(SDKVERSION) -DXNU_TARGET_OS_BRIDGE
64 else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
65 DEPLOYMENT_TARGET_FLAGS = -miphoneos-version-min=$(SDKVERSION)
66 else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
67 DEPLOYMENT_TARGET_FLAGS =
68 else
69 DEPLOYMENT_TARGET_FLAGS =
70 endif
71
72 DEPLOYMENT_TARGET_DEFINES = -DPLATFORM_$(PLATFORM)
73
74
75 #
76 # Standard defines list
77 #
78 DEFINES = -DAPPLE -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE \
79 -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile $(CONFIG_DEFINES) \
80 $(SEED_DEFINES)
81
82 #
83 # Compiler command
84 #
85 KCC = $(CC)
86 KC++ = $(CXX)
87
88 GENASSYM_KCC = $(CC)
89
90 #
91 # Compiler warning flags
92 #
93
94 USE_WERROR := 1
95 ifneq ($(BUILD_WERROR),)
96 USE_WERROR := $(BUILD_WERROR)
97 endif
98
99 ifeq ($(USE_WERROR),1)
100 WERROR := -Werror
101 endif
102
103 # Shared C/C++ warning flags
104 WARNFLAGS_STD := \
105 -Weverything \
106 -Wno-pedantic \
107 $(WERROR) \
108 -Wno-assign-enum \
109 -Wno-bad-function-cast \
110 -Wno-c++98-compat \
111 -Wno-c++-compat \
112 -Wno-conditional-uninitialized \
113 -Wno-conversion \
114 -Wnull-conversion \
115 -Wstring-conversion \
116 -Wliteral-conversion \
117 -Wnon-literal-null-conversion \
118 -Wint-conversion \
119 -Wenum-conversion \
120 -Wfloat-conversion \
121 -Wconstant-conversion \
122 -Wpointer-bool-conversion \
123 -Wno-covered-switch-default \
124 -Wno-disabled-macro-expansion \
125 -Wno-documentation-unknown-command \
126 -Wno-format-non-iso \
127 -Wno-format-nonliteral \
128 -Wno-reserved-id-macro \
129 -Wno-language-extension-token \
130 -Wno-missing-variable-declarations \
131 -Wno-packed \
132 -Wno-padded \
133 -Wno-partial-availability \
134 -Wno-shift-sign-overflow \
135 -Wno-switch-enum \
136 -Wno-undef \
137 -Wno-unused-macros \
138 -Wno-used-but-marked-unused \
139 -Wno-variadic-macros \
140 -Wno-vla \
141 -Wno-zero-length-array
142
143 WARNFLAGS_STD := $(WARNFLAGS_STD) \
144 -Wno-unknown-warning-option \
145 -Wno-error=shadow-field \
146 -Wno-error=cast-qual
147
148 CWARNFLAGS_STD = \
149 $(WARNFLAGS_STD)
150
151 # Can be overridden in Makefile.template or Makefile.$arch
152 export CWARNFLAGS ?= $(CWARNFLAGS_STD)
153
154 define add_perfile_cflags
155 $(1)_CWARNFLAGS_ADD += $2
156 endef
157
158 CXXWARNFLAGS_STD = \
159 $(WARNFLAGS_STD) \
160 -Wno-c++98-compat-pedantic \
161 -Wno-exit-time-destructors \
162 -Wno-global-constructors \
163 -Wno-old-style-cast \
164 -Wno-zero-as-null-pointer-constant
165
166 # Can be overridden in Makefile.template or Makefile.$arch
167 export CXXWARNFLAGS ?= $(CXXWARNFLAGS_STD)
168
169 define add_perfile_cxxflags
170 $(1)_CXXWARNFLAGS_ADD += $2
171 endef
172
173 #
174 # Default ARCH_FLAGS, for use with compiler/linker/assembler/mig drivers
175
176 ARCH_FLAGS_X86_64 = -arch x86_64
177 ARCH_FLAGS_X86_64H = -arch x86_64h
178
179
180
181 #
182 # Default CFLAGS
183 #
184 ifdef RC_NONARCH_CFLAGS
185 OTHER_CFLAGS = $(RC_NONARCH_CLFAGS)
186 endif
187
188 #
189 # Debug info
190 #
191 DSYMINFODIR = Contents
192 DSYMKGMACROSDIR = Contents/Resources
193 DSYMLLDBMACROSDIR = Contents/Resources/Python
194 DSYMDWARFDIR = Contents/Resources/DWARF
195
196 DEBUG_CFLAGS := -g
197 BUILD_DSYM := 1
198
199 #
200 # We must not use -fno-keep-inline-functions, or it will remove the dtrace
201 # probes from the kernel.
202 #
203 CFLAGS_GEN = $(DEBUG_CFLAGS) -nostdinc \
204 -fno-builtin -fno-common \
205 -fsigned-bitfields $(OTHER_CFLAGS)
206
207 CFLAGS_RELEASE =
208 CFLAGS_DEVELOPMENT =
209 CFLAGS_DEBUG =
210 CFLAGS_KASAN = $(CFLAGS_DEVELOPMENT)
211 CFLAGS_PROFILE = -pg
212
213 CFLAGS_X86_64 = -Dx86_64 -DX86_64 -D__X86_64__ -DLP64 \
214 -DPAGE_SIZE_FIXED -mkernel -msoft-float
215
216 CFLAGS_X86_64H = $(CFLAGS_X86_64)
217
218
219 CFLAGS_RELEASEX86_64 = -O2
220 CFLAGS_DEVELOPMENTX86_64 = -O2
221 CFLAGS_KASANX86_64 = $(CFLAGS_DEVELOPMENTX86_64)
222 # No space optimization for the DEBUG kernel for the benefit of gdb:
223 CFLAGS_DEBUGX86_64 = -O0
224 CFLAGS_PROFILEX86_64 = -O2
225
226 CFLAGS_RELEASEX86_64H = -O2
227 CFLAGS_DEVELOPMENTX86_64H = -O2
228 CFLAGS_KASANX86_64H = $(CFLAGS_DEVELOPMENTX86_64H)
229 # No space optimization for the DEBUG kernel for the benefit of gdb:
230 CFLAGS_DEBUGX86_64H = -O0
231 CFLAGS_PROFILEX86_64H = -O2
232
233 CFLAGS_RELEASEARM = -O2
234 CFLAGS_DEVELOPMENTARM = -O2
235 CFLAGS_DEBUGARM = -O0
236 CFLAGS_PROFILEARM = -O2
237
238
239
240 #
241 # KASAN support
242 #
243
244
245 ifeq ($(CURRENT_KERNEL_CONFIG),KASAN)
246 KASAN = 1
247 endif
248
249 ifeq ($(KASAN),1)
250
251 BUILD_LTO = 0
252 KASAN_SHIFT_X86_64=0xdffffe1000000000
253 KASAN_SHIFT_X86_64H=$(KASAN_SHIFT_X86_64)
254 KASAN_SHIFT=$($(addsuffix $(CURRENT_ARCH_CONFIG),KASAN_SHIFT_))
255 KASAN_BLACKLIST=$(OBJROOT)/san/kasan-blacklist-$(CURRENT_ARCH_CONFIG_LC)
256 CFLAGS_GEN += -DKASAN=1 -DKASAN_SHIFT=$(KASAN_SHIFT) -fsanitize=address \
257 -mllvm -asan-globals-live-support \
258 -mllvm -asan-mapping-offset=$(KASAN_SHIFT) \
259 -fsanitize-blacklist=$(KASAN_BLACKLIST)
260
261 endif
262
263 CFLAGS = $(CFLAGS_GEN) \
264 $($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \
265 $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
266 $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) \
267 $($(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_)) \
268 $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),CFLAGS_))) \
269 $(DEPLOYMENT_TARGET_FLAGS) \
270 $(DEPLOYMENT_TARGET_DEFINES) \
271 $(DEFINES)
272
273 #
274 # Default C++ flags
275 #
276
277 OTHER_CXXFLAGS =
278
279 CXXFLAGS_GEN = -std=gnu++11 -fapple-kext $(OTHER_CXXFLAGS)
280
281 CXXFLAGS = $(CXXFLAGS_GEN) \
282 $($(addsuffix $(CURRENT_ARCH_CONFIG),CXXFLAGS_)) \
283 $($(addsuffix $(CURRENT_KERNEL_CONFIG),CXXFLAGS_))
284
285 #
286 # Assembler command
287 #
288 AS = $(CC)
289 S_KCC = $(CC)
290
291 #
292 # Default SFLAGS
293 #
294 SFLAGS_GEN = -D__ASSEMBLER__ -DASSEMBLER $(OTHER_CFLAGS)
295
296 SFLAGS_RELEASE =
297 SFLAGS_DEVELOPMENT =
298 SFLAGS_KASAN = $(SFLAGS_DEVELOPMENT) -DKASAN=1
299 SFLAGS_DEBUG =
300 SFLAGS_PROFILE =
301
302 SFLAGS_X86_64 = $(CFLAGS_X86_64)
303 SFLAGS_X86_64H = $(CFLAGS_X86_64H)
304
305 SFLAGS = $(SFLAGS_GEN) \
306 $($(addsuffix $(CURRENT_MACHINE_CONFIG),MACHINE_FLAGS_$(CURRENT_ARCH_CONFIG)_)) \
307 $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
308 $($(addsuffix $(CURRENT_ARCH_CONFIG),SFLAGS_)) \
309 $($(addsuffix $(CURRENT_KERNEL_CONFIG),SFLAGS_)) \
310 $(DEPLOYMENT_TARGET_FLAGS) \
311 $(DEPLOYMENT_TARGET_DEFINES) \
312 $(DEFINES)
313
314 #
315 # Linker command
316 #
317 LD = $(KC++) -nostdlib
318
319 #
320 # Default LDFLAGS
321 #
322 # Availability of DWARF allows DTrace CTF (compressed type format) to be constructed.
323 # ctf_insert creates the CTF section. It needs reserved padding in the
324 # headers for the load command segment and the CTF section structures.
325 #
326 LDFLAGS_KERNEL_GEN = \
327 -nostdlib \
328 -fapple-kext \
329 -Wl,-e,__start \
330 -Wl,-sectalign,__TEXT,__text,0x1000 \
331 -Wl,-sectalign,__DATA,__common,0x1000 \
332 -Wl,-sectalign,__DATA,__bss,0x1000 \
333 -Wl,-sectcreate,__PRELINK_TEXT,__text,/dev/null \
334 -Wl,-sectcreate,"__PLK_TEXT_EXEC",__text,/dev/null \
335 -Wl,-sectcreate,__PRELINK_DATA,__data,/dev/null \
336 -Wl,-sectcreate,"__PLK_DATA_CONST",__data,/dev/null \
337 -Wl,-sectcreate,"__PLK_LLVM_COV",__llvm_covmap,/dev/null \
338 -Wl,-sectcreate,"__PLK_LINKEDIT",__data,/dev/null \
339 -Wl,-sectcreate,__PRELINK_INFO,__info,/dev/null \
340 -Wl,-new_linker \
341 -Wl,-pagezero_size,0x0 \
342 -Wl,-version_load_command \
343 -Wl,-function_starts \
344 -Wl,-headerpad,152
345
346 LDFLAGS_KERNEL_SDK = -L$(SDKROOT)/usr/local/lib/kernel -lfirehose_kernel
347
348 LDFLAGS_KERNEL_RELEASE =
349 LDFLAGS_KERNEL_DEVELOPMENT =
350 LDFLAGS_KERNEL_KASAN = $(LDFLAGS_KERNEL_DEVELOPMENT)
351 LDFLAGS_KERNEL_DEBUG =
352 LDFLAGS_KERNEL_PROFILE =
353
354 # KASLR static slide config:
355 ifndef SLIDE
356 SLIDE=0x00
357 endif
358 KERNEL_MIN_ADDRESS = 0xffffff8000000000
359 KERNEL_BASE_OFFSET = 0x100000
360 KERNEL_STATIC_SLIDE = $(shell printf "0x%016x" \
361 $$[ $(SLIDE) << 21 ])
362 KERNEL_STATIC_BASE = $(shell printf "0x%016x" \
363 $$[ $(KERNEL_MIN_ADDRESS) + $(KERNEL_BASE_OFFSET) ])
364 KERNEL_HIB_SECTION_BASE = $(shell printf "0x%016x" \
365 $$[ $(KERNEL_STATIC_BASE) + $(KERNEL_STATIC_SLIDE) ])
366 KERNEL_TEXT_BASE = $(shell printf "0x%016x" \
367 $$[ $(KERNEL_HIB_SECTION_BASE) + 0x100000 ])
368
369 LDFLAGS_KERNEL_RELEASEX86_64 = \
370 -Wl,-pie \
371 -Wl,-segaddr,__HIB,$(KERNEL_HIB_SECTION_BASE) \
372 -Wl,-image_base,$(KERNEL_TEXT_BASE) \
373 -Wl,-seg_page_size,__TEXT,0x200000 \
374 -Wl,-sectalign,__HIB,__bootPT,0x1000 \
375 -Wl,-sectalign,__HIB,__desc,0x1000 \
376 -Wl,-sectalign,__HIB,__data,0x1000 \
377 -Wl,-sectalign,__HIB,__text,0x1000 \
378 -Wl,-sectalign,__HIB,__const,0x1000 \
379 -Wl,-sectalign,__HIB,__bss,0x1000 \
380 -Wl,-sectalign,__HIB,__common,0x1000 \
381 -Wl,-sectalign,__HIB,__llvm_prf_cnts,0x1000 \
382 -Wl,-sectalign,__HIB,__llvm_prf_names,0x1000 \
383 -Wl,-sectalign,__HIB,__llvm_prf_data,0x1000 \
384 -Wl,-sectalign,__HIB,__textcoal_nt,0x1000 \
385 -Wl,-rename_section,__DATA,__const,__CONST,__constdata \
386 -Wl,-no_zero_fill_sections \
387 $(LDFLAGS_NOSTRIP_FLAG)
388
389 ifeq ($(KASAN),1)
390 LDFLAGS_KERNEL_RELEASEX86_64 += \
391 -Wl,-sectalign,__HIB,__cstring,0x1000 \
392 -Wl,-sectalign,__HIB,__asan_globals,0x1000 \
393 -Wl,-sectalign,__HIB,__asan_liveness,0x1000 \
394 -Wl,-sectalign,__HIB,__mod_term_func,0x1000 \
395 -Wl,-rename_section,__HIB,__mod_init_func,__NULL,__mod_init_func \
396 -Wl,-rename_section,__HIB,__eh_frame,__NULL,__eh_frame
397 endif
398
399 # Define KERNEL_BASE_OFFSET so known at compile time:
400 CFLAGS_X86_64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET)
401 CFLAGS_X86_64H += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET)
402
403 LDFLAGS_KERNEL_DEBUGX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
404 LDFLAGS_KERNEL_DEVELOPMENTX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
405 LDFLAGS_KERNEL_KASANX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
406 LDFLAGS_KERNEL_PROFILEX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
407
408 LDFLAGS_KERNEL_RELEASEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64)
409 LDFLAGS_KERNEL_DEBUGX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H)
410 LDFLAGS_KERNEL_DEVELOPMENTX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H)
411 LDFLAGS_KERNEL_KASANX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H)
412 LDFLAGS_KERNEL_PROFILEX86_64H = $(LDFLAGS_KERNEL_RELEASEX86_64H)
413
414
415 LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \
416 $(LDFLAGS_KERNEL_SDK) \
417 $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
418 $($(addsuffix $(CURRENT_ARCH_CONFIG),LDFLAGS_KERNEL_)) \
419 $($(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_)) \
420 $($(addsuffix $(CURRENT_ARCH_CONFIG), $(addsuffix $(CURRENT_KERNEL_CONFIG),LDFLAGS_KERNEL_))) \
421 $(DEPLOYMENT_TARGET_FLAGS)
422
423 #
424 # Default runtime libraries to be linked with the kernel
425 #
426 LD_KERNEL_LIBS = -lcc_kext
427
428 #
429 # DTrace support
430 #
431 ifeq ($(CURRENT_KERNEL_CONFIG),RELEASE)
432 ifneq ($(filter ARM%,$(CURRENT_ARCH_CONFIG)),)
433 DO_CTFCONVERT = 0
434 DO_CTFMERGE = 0
435 DO_CTFMACHO = 0
436 else
437 DO_CTFCONVERT = $(SUPPORTS_CTFCONVERT)
438 DO_CTFMERGE = 1
439 DO_CTFMACHO = $(NEEDS_CTF_MACHOS)
440 endif
441 else
442 DO_CTFCONVERT = $(SUPPORTS_CTFCONVERT)
443 DO_CTFMERGE = 1
444 DO_CTFMACHO = $(NEEDS_CTF_MACHOS)
445 endif
446
447 #
448 # Default INCFLAGS
449 #
450 INCFLAGS_IMPORT = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST))
451 INCFLAGS_EXTERN = -I$(SRCROOT)/EXTERNAL_HEADERS
452 INCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT)
453 INCFLAGS_LOCAL = -I.
454 INCFLAGS_SDK = -I$(SDKROOT)/usr/local/include/kernel
455
456 INCFLAGS = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE) $(INCFLAGS_SDK)
457
458 #
459 # Default MIGFLAGS
460 #
461 MIGFLAGS = $(DEFINES) $(INCFLAGS) -novouchers $($(addsuffix $(CURRENT_ARCH_CONFIG),CFLAGS_)) $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) \
462 $(DEPLOYMENT_TARGET_FLAGS)
463
464 # Support for LLVM Profile Guided Optimization (PGO)
465
466 ifeq ($(BUILD_PROFILE),1)
467 CFLAGS_GEN += -fprofile-instr-generate -DPROFILE
468 CXXFLAGS_GEN += -fprofile-instr-generate -DPROFILE
469 endif
470
471 ifdef USE_PROFILE
472 CFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE)
473 CXXFLAGS_GEN += -fprofile-instr-use=$(USE_PROFILE)
474 LDFLAGS_KERNEL_GEN += -fprofile-instr-use=$(USE_PROFILE)
475
476 CFLAGS_GEN += -Wno-error=profile-instr-out-of-date
477 endif
478
479 #
480 # Support for LLVM Link Time Optimization (LTO)
481 #
482 # LTO can be explicitly enabled or disabled with BUILD_LTO=1|0
483 # and defaults to enabled except for DEBUG kernels
484 #
485 # CFLAGS_NOLTO_FLAG is needed on a per-file basis (for files
486 # that deal poorly with LTO, or files that must be machine
487 # code *.o files for xnu to build (i.e, setsegname runs on
488 # them).
489 #
490 # LDFLAGS_NOSTRIP_FLAG is used to support configurations that
491 # do not utilize an export list. For these configs to build,
492 # we need to prevent the LTO logic from dead stripping them.
493
494 LTO_ENABLED_RELEASE = 1
495 LTO_ENABLED_DEVELOPMENT = 1
496 LTO_ENABLED_DEBUG = 0
497 LTO_ENABLED_KASAN = 0
498
499 ifneq ($(BUILD_LTO),)
500 USE_LTO = $(BUILD_LTO)
501 else
502 USE_LTO = $(LTO_ENABLED_$(CURRENT_KERNEL_CONFIG))
503 endif
504
505 SUPPORTS_CTFCONVERT = 0
506 ifeq ($(USE_LTO),1)
507 CFLAGS_GEN += -flto
508 CXXFLAGS_GEN += -flto
509 LDFLAGS_KERNEL_GEN += -Wl,-mllvm,-inline-threshold=100 -Wl,-object_path_lto,$(TARGET)/lto.o
510 LDFLAGS_NOSTRIP_FLAG = -rdynamic
511 CFLAGS_NOLTO_FLAG = -fno-lto
512 NEEDS_CTF_MACHOS = 1
513 else
514 LDFLAGS_NOSTRIP_FLAG =
515 CFLAGS_NOLTO_FLAG =
516 ifneq ($(CTFCONVERT),)
517 SUPPORTS_CTFCONVERT = 1
518 endif
519 NEEDS_CTF_MACHOS = 0
520 endif
521
522 ifeq ($(BUILD_JSON_COMPILATION_DATABASE),1)
523 BUILD_DSYM := 0
524 DO_CTFCONVERT := 0
525 DO_CTFMERGE := 0
526 DO_CTFMACHO := 0
527 KCC = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CC)
528 KC++ = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CXX)
529 S_KCC = $(JSONCOMPILATIONDB) $(OBJPATH)/compile_commands.json $(PWD) $< $(CC)
530 STRIP = true
531 endif
532
533 #
534 # Default VPATH
535 #
536 export VPATH = .:$(SOURCE)
537
538
539
540 #
541 # Macros that control installation of kernel and its header files
542 #
543 # install flags for header files
544 #
545 INSTALL_FLAGS = -c -S -m 0444
546 DATA_INSTALL_FLAGS = -c -S -m 0644
547 EXEC_INSTALL_FLAGS = -c -S -m 0755
548
549 #
550 # Header file destinations
551 #
552 FRAMEDIR = /System/Library/Frameworks
553
554 SINCVERS = B
555 SINCFRAME = $(FRAMEDIR)/System.framework
556 SINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Headers
557 SPINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/PrivateHeaders
558 SRESDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Resources
559
560 ifndef INCDIR
561 INCDIR = /usr/include
562 endif
563 ifndef LCLDIR
564 LCLDIR = $(SPINCDIR)
565 endif
566
567 KINCVERS = A
568 KINCFRAME = $(FRAMEDIR)/Kernel.framework
569 KINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Headers
570 KPINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/PrivateHeaders
571 KRESDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Resources
572
573 XNU_PRIVATE_UNIFDEF = -UMACH_KERNEL_PRIVATE -UBSD_KERNEL_PRIVATE -UIOKIT_KERNEL_PRIVATE -ULIBKERN_KERNEL_PRIVATE -ULIBSA_KERNEL_PRIVATE -UPEXPERT_KERNEL_PRIVATE -UXNU_KERNEL_PRIVATE
574
575
576 PLATFORM_UNIFDEF = $(foreach x,$(SUPPORTED_PLATFORMS),$(if $(filter $(PLATFORM),$(x)),-DPLATFORM_$(x) $(foreach token,$(PLATFORM_UNIFDEF_BLACKLIST_TOKENS_$(x)),-U$(token)),-UPLATFORM_$(x)))
577
578 SPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -U_OPEN_SOURCE_ -U__OPEN_SOURCE__
579 SINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -D_OPEN_SOURCE_ -D__OPEN_SOURCE__
580 KPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -DKERNEL_PRIVATE -DPRIVATE -DKERNEL -U_OPEN_SOURCE_ -U__OPEN_SOURCE__
581 KINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) $(SEED_DEFINES) -UKERNEL_PRIVATE -UPRIVATE -DKERNEL -D_OPEN_SOURCE_ -D__OPEN_SOURCE__
582
583 #
584 # Compononent Header file destinations
585 #
586 EXPDIR = EXPORT_HDRS/$(COMPONENT)
587
588 #
589 # Strip Flags
590 #
591 STRIP_FLAGS_RELEASE = -S -x
592 STRIP_FLAGS_DEVELOPMENT = -S
593 STRIP_FLAGS_KASAN = $(STRIP_FLAGS_DEVELOPMENT)
594 STRIP_FLAGS_DEBUG = -S
595 STRIP_FLAGS_PROFILE = -S -x
596
597 STRIP_FLAGS = $($(addsuffix $(CURRENT_KERNEL_CONFIG),STRIP_FLAGS_))
598
599 #
600 # dsymutil flags
601 #
602 DSYMUTIL_FLAGS_GEN = --minimize
603
604 DSYMUTIL_FLAGS_X86_64 = --arch=x86_64
605 DSYMUTIL_FLAGS_X86_64H = --arch=x86_64h
606
607 DSYMUTIL_FLAGS = $(DSYMUTIL_FLAGS_GEN) \
608 $($(addsuffix $(CURRENT_ARCH_CONFIG),DSYMUTIL_FLAGS_))
609
610 #
611 # Man Page destination
612 #
613 MANDIR = /usr/share/man
614
615 #
616 # DEBUG alias location
617 #
618 DEVELOPER_EXTRAS_DIR = /AppleInternal/CoreOS/xnu_$(CURRENT_KERNEL_CONFIG_LC)
619
620 #
621 # mach_kernel install location
622 #
623 INSTALL_KERNEL_DIR = /
624
625 #
626 # new OS X install location
627 #
628 SYSTEM_LIBRARY_KERNELS_DIR = /System/Library/Kernels
629
630 #
631 # File names in DSTROOT
632 #
633
634 ifeq ($(PLATFORM),MacOSX)
635 KERNEL_FILE_NAME_PREFIX = kernel
636 else
637 KERNEL_FILE_NAME_PREFIX = mach
638 endif
639
640 ifeq ($(CURRENT_MACHINE_CONFIG),NONE)
641 ifeq ($(CURRENT_KERNEL_CONFIG),RELEASE)
642 KERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX)
643 KERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX).py
644 else
645 KERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC)
646 KERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX).py
647 endif
648 else
649 KERNEL_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC).$(CURRENT_MACHINE_CONFIG_LC)
650 KERNEL_LLDBBOOTSTRAP_NAME = $(KERNEL_FILE_NAME_PREFIX)_$(CURRENT_KERNEL_CONFIG_LC).py
651 endif
652
653 CURRENT_ALIAS_MACHINE_CONFIG = $(word 4,$(subst ^, ,$(CURRENT_BUILD_CONFIG)))
654 CURRENT_ALIAS_MACHINE_CONFIG_LC = $(shell printf "%s" "$(CURRENT_ALIAS_MACHINE_CONFIG)" | $(TR) A-Z a-z)
655 ifneq ($(CURRENT_ALIAS_MACHINE_CONFIG),)
656 ALIAS_FILE_NAME = $(KERNEL_FILE_NAME_PREFIX).$(CURRENT_KERNEL_CONFIG_LC).$(CURRENT_ALIAS_MACHINE_CONFIG_LC)
657 endif
658
659 #
660 # System.kext pseudo-kext install location
661 #
662 INSTALL_EXTENSIONS_DIR = /System/Library/Extensions
663
664 #
665 # KDK location
666 #
667 INSTALL_KERNEL_SYM_DIR = /System/Library/Extensions/KDK
668
669 #
670 # Misc. Etc.
671 #
672 INSTALL_SHARE_MISC_DIR = /usr/share/misc
673 INSTALL_DTRACE_SCRIPTS_DIR = /usr/lib/dtrace
674 INSTALL_DTRACE_LIBEXEC_DIR = /usr/libexec/dtrace
675
676 #
677 # Overrides for XBS build aliases
678 #
679 ifeq ($(RC_ProjectName),xnu_debug)
680 INSTALL_KERNEL_DIR := $(DEVELOPER_EXTRAS_DIR)
681 INSTALL_KERNEL_SYM_DIR := $(DEVELOPER_EXTRAS_DIR)
682 INSTALL_KERNEL_SYM_TO_KDK = 1
683 INSTALL_XNU_DEBUG_FILES = 1
684 else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
685 INSTALL_KERNEL_SYM_TO_KDK = 1
686 USE_BINARY_PLIST = 1
687 else ifneq ($(filter $(SUPPORTED_SIMULATOR_PLATFORMS),$(PLATFORM)),)
688 USE_BINARY_PLIST = 1
689 else ifeq ($(PLATFORM),MacOSX)
690 INSTALL_KERNEL_DIR := $(SYSTEM_LIBRARY_KERNELS_DIR)
691 INSTALL_KERNEL_SYM_DIR := $(SYSTEM_LIBRARY_KERNELS_DIR)
692 INSTALL_KERNEL_SYM_TO_KDK = $(if $(filter YES,$(DWARF_DSYM_FILE_SHOULD_ACCOMPANY_PRODUCT)),1,0)
693 endif
694
695 ifeq ($(RC_ProjectName),xnu_kasan)
696 INSTALL_KASAN_ONLY = 1
697 endif
698
699 # vim: set ft=make: