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