]> git.saurik.com Git - apple/xnu.git/blob - makedefs/MakeInc.def
4e49fe6a71320f217dd09f6f5d44c3d144ea392f
[apple/xnu.git] / makedefs / MakeInc.def
1 export SOURCE=$(shell /bin/pwd)
2 export RELATIVE_SOURCE_PATH ?= .
3
4 #
5 # gnumake 3.77 support
6 #
7 export USE_APPLE_PB_SUPPORT = all
8
9 #
10 # Incremental Build option
11 #
12 ifndef INCR_EXPORTHDRS
13 ifeq ($(shell test -d $$OBJROOT/EXPORT_HDRS;echo $$?),0)
14 export INCR_EXPORTHDRS = TRUE
15 else
16 export INCR_EXPORTHDRS = FALSE
17 endif
18 endif
19
20
21 #
22 # Component List
23 #
24 ifndef COMPONENT_LIST
25 export COMPONENT_LIST = osfmk bsd libkern iokit pexpert libsa security
26 export COMPONENT_LIST_UC := $(shell printf "%s" "$(COMPONENT_LIST)" | $(TR) a-z A-Z)
27 endif
28 ifndef COMPONENT
29 export COMPONENT := $(firstword $(subst /, ,$(RELATIVE_SOURCE_PATH)))
30 export COMPONENT_IMPORT_LIST := $(filter-out $(COMPONENT),$(COMPONENT_LIST))
31 else
32 ifeq ($(COMPONENT), .)
33 export COMPONENT := $(if $(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(word 2,$(subst /, ,$(RELATIVE_SOURCE_PATH))),$(firstword $(subst /, ,$(RELATIVE_SOURCE_PATH))))
34 export COMPONENT_IMPORT_LIST := $(filter-out $(COMPONENT),$(COMPONENT_LIST))
35 endif
36 endif
37
38 # Architecture options
39 #
40 ifndef SUPPORTED_ARCH_CONFIGS
41 export SUPPORTED_ARCH_CONFIGS = I386 X86_64
42 endif
43
44 ifndef ARCH_CONFIGS
45 ifdef RC_ARCHS
46 export ARCH_CONFIGS := $(shell printf "%s" "$(RC_ARCHS)" | $(TR) a-z A-Z | sed -E 's/ARMV[0-9][A-Z]?/ARM/g')
47 else
48 ifeq ($(PLATFORM),iPhoneOS)
49 export ARCH_CONFIGS := ARM
50 else
51 export ARCH_CONFIGS := $(shell arch | $(TR) a-z A-Z | sed -E 's/ARMV[0-9][A-Z]?/ARM/g')
52 endif
53 endif
54 endif
55 ifdef ARCH_CONFIG
56 ifndef ARCH_CONFIG_LC
57 export ARCH_CONFIG_LC := $(shell printf "%s" "$(ARCH_CONFIG)" | $(TR) A-Z a-z)
58 endif
59 endif
60
61 #
62 # Platform options
63 #
64 ifndef SUPPORTED_PLATFORMS
65 export SUPPORTED_PLATFORMS = MacOSX iPhoneOS iPhoneSimulator
66 endif
67
68 # PLATFORM is set earlier in MakeInc.cmd, closer to where decisions about
69 # platform tools are made
70
71 #
72 # Kernel Configuration options
73 #
74 ifndef SUPPORTED_KERNEL_CONFIGS
75 export SUPPORTED_KERNEL_CONFIGS = RELEASE DEVELOPMENT DEBUG PROFILE
76 endif
77
78 ifndef DEFAULT_KERNEL_CONFIG
79 ifeq ($(RC_ProjectName),xnu_debug)
80 export DEFAULT_KERNEL_CONFIG = DEBUG
81 else
82 export DEFAULT_KERNEL_CONFIG = RELEASE
83 endif
84 endif
85
86 # If KERNEL_CONFIGS is specified it should override KERNEL_CONFIG.
87 # If KERNEL_CONFIG is specified it will override the default. Will quit with
88 # error if more than one config is specified.
89 # If DEFAULT_KERNEL_CONFIG is not specified then it will be built RELEASE.
90 ifndef KERNEL_CONFIGS
91 ifndef KERNEL_CONFIG
92 export KERNEL_CONFIGS = $(DEFAULT_KERNEL_CONFIG)
93 else
94 export KERNEL_CONFIGS = $(KERNEL_CONFIG)
95 endif
96 endif
97
98 ifndef KERNEL_CONFIG
99 export KERNEL_CONFIG = $(firstword $(KERNEL_CONFIGS))
100 endif
101
102 ifneq ($(words $(KERNEL_CONFIG)), 1)
103 $(error There were $(words $(KERNEL_CONFIG)) parameters passed to KERNEL_CONFIG = $(KERNEL_CONFG). \
104 Are you sure? To specify multiple configurations please use KERNEL_CONFIGS)
105 endif
106
107 ifndef MACHINE_CONFIG
108 export MACHINE_CONFIG = DEFAULT
109 endif
110
111
112 #
113 # Machine Configuration options
114 #
115 export SUPPORTED_I386_MACHINE_CONFIGS := DEFAULT
116 export SUPPORTED_X86_64_MACHINE_CONFIGS := DEFAULT
117
118
119 #
120 # Target configuration options. NOTE - target configurations will
121 # override ARCH_CONFIGS and KERNEL_CONFIGS.
122 #
123 # Target configs come in groups of three parameters. The first is the
124 # kernel configuration, the second is the architecture configuration,
125 # and the third is the machine configuration. You may pass in as
126 # many groups of configurations as you wish. Each item passed in is
127 # separated by whitespace.
128 #
129 # Example:
130 # TARGET_CONFIGS="release x86_64 default debug i386 default release arm S5l8920X"
131 # Parameters may be in upper or lower case (they are converted to upper).
132 #
133 # "default" parameter is a special case. It means use the default value for
134 # that parameter. Here are the default values for each configuration:
135 #
136 # default kernel configuration = DEFAULT_KERNEL_CONFIG
137 # default architecture configuration = system architecture where you are running make.
138 # default machine configuration for i386 = none at this time.
139 # default machine configuration for x86_64 = none at this time.
140 # default machine configuration for arm = "S5L8920X".
141 #
142 ifndef TARGET_CONFIGS_UC
143 ifdef TARGET_CONFIGS
144 export TARGET_CONFIGS_UC := $(strip $(shell printf "%s" "$(TARGET_CONFIGS)" | $(TR) a-z A-Z))
145 export MACHINE_CONFIG = $(word 3, $(TARGET_CONFIGS_UC))
146 export DEFAULT_KERNEL_CONFIG = $(word 1, $(TARGET_CONFIGS_UC))
147 else
148
149 ifneq ($(filter %_embedded,$(MAKECMDGOALS)),)
150 # generate set of standard embedded configs
151 export TARGET_CONFIGS = $(TARGET_CONFIGS_EMBEDDED)
152 else ifneq ($(filter %_devicemap,$(MAKECMDGOALS)),)
153 DEVICEMAP_PLATFORMS = $(shell $(EMBEDDED_DEVICE_MAP) -query SELECT DISTINCT Platform FROM Targets | $(TR) [:lower:] [:upper:])
154 export TARGET_CONFIGS = $(foreach my_kernel_config,$(KERNEL_CONFIGS_EMBEDDED),$(foreach my_arch,$(ARCH_CONFIGS),$(foreach my_machine_config,$(filter $(DEVICEMAP_PLATFORMS),$(SUPPORTED_$(my_arch)_MACHINE_CONFIGS)),$(my_kernel_config) $(my_arch) $(my_machine_config) )))
155 else
156 # generate TARGET_CONFIGS using KERNEL_CONFIGS and ARCH_CONFIGS and MACHINE_CONFIG (which defaults to "DEFAULT")
157 export TARGET_CONFIGS = $(strip $(foreach my_arch_config, $(ARCH_CONFIGS), $(foreach my_kern_config, $(KERNEL_CONFIGS), $(my_kern_config) $(my_arch_config) $(MACHINE_CONFIG))))
158 endif
159 export TARGET_CONFIGS_UC := $(shell printf "%s" "$(TARGET_CONFIGS)" | $(TR) a-z A-Z)
160 export MACHINE_CONFIG = $(word 3, $(TARGET_CONFIGS_UC))
161 export DEFAULT_KERNEL_CONFIG = $(word 1, $(TARGET_CONFIGS_UC))
162 endif
163 endif
164
165 export MACHINE_CONFIG_LC := $(shell printf "%s" "$(MACHINE_CONFIG)" | $(TR) A-Z a-z)
166 export KERNEL_CONFIG_LC := $(shell printf "%s" "$(KERNEL_CONFIG)" | $(TR) A-Z a-z)
167
168 #
169 # Validate configuration options
170 #
171 ifneq ($(ARCH_CONFIG),)
172 ifeq ($(filter $(ARCH_CONFIG),$(SUPPORTED_ARCH_CONFIGS)),)
173 $(error Unsupported ARCH_CONFIG $(ARCH_CONFIG))
174 endif
175 endif
176
177 ifneq ($(KERNEL_CONFIG),)
178 ifeq ($(filter $(KERNEL_CONFIG),$(SUPPORTED_KERNEL_CONFIGS)),)
179 $(error Unsupported KERNEL_CONFIG $(KERNEL_CONFIG))
180 endif
181 endif
182
183 ifneq ($(MACHINE_CONFIG),)
184 ifneq ($(ARCH_CONFIG),)
185 ifeq ($(filter $(MACHINE_CONFIG),$(SUPPORTED_$(ARCH_CONFIG)_MACHINE_CONFIGS)),)
186 $(error Unsupported MACHINE_CONFIG $(MACHINE_CONFIG))
187 endif
188 endif
189 endif
190
191 ifneq ($(PLATFORM),)
192 ifeq ($(filter $(PLATFORM),$(SUPPORTED_PLATFORMS)),)
193 $(error Unsupported PLATFORM $(PLATFORM))
194 endif
195 endif
196
197 #
198 # Kernel Configuration to install
199 #
200 # supported install architecture : I386 X86_64
201 #
202 export INSTALL_TYPE = $(DEFAULT_KERNEL_CONFIG)
203
204 ifndef INSTALL_ARCHS
205 export INSTALL_ARCHS = $(strip $(foreach my_config, $(SUPPORTED_ARCH_CONFIGS), $(filter $(TARGET_CONFIGS_UC),$(my_config))))
206 export INSTALL_ARCHS_LC := $(shell printf "%s" "$(INSTALL_ARCHS)" | $(TR) A-Z a-z)
207 endif
208
209 export INSTALL_ARCH_DEFAULT = $(firstword $(INSTALL_ARCHS))
210 ifeq ($(INSTALL_ARCH_DEFAULT),)
211 $(error Could not determine INSTALL_ARCH_DEFAULT)
212 endif
213
214 #
215 # Deployment target flag
216 #
217 ifndef DEPLOYMENT_TARGET_FLAGS
218 SDKVERSION=$(shell xcodebuild -sdk $(SDKROOT) -version SDKVersion | head -1)
219 ifeq ($(PLATFORM),MacOSX)
220 export DEPLOYMENT_TARGET_FLAGS := -mmacosx-version-min=$(SDKVERSION)
221 else ifeq ($(PLATFORM),iPhoneOS)
222 export DEPLOYMENT_TARGET_FLAGS := -miphoneos-version-min=$(SDKVERSION)
223 else ifeq ($(PLATFORM),iPhoneSimulator)
224 export DEPLOYMENT_TARGET_FLAGS :=
225 else
226 export DEPLOYMENT_TARGET_FLAGS :=
227 endif
228 endif
229
230 #
231 # Standard defines list
232 #
233 export DEFINES = -DAPPLE -DKERNEL -DKERNEL_PRIVATE -DXNU_KERNEL_PRIVATE \
234 -DPRIVATE -D__MACHO__=1 -Dvolatile=__volatile $(IDENT)
235
236 #
237 # Compiler command
238 #
239 KCC := $(CC)
240 KC++ := $(CXX)
241
242 #
243 # Compiler warning flags
244 #
245
246 CWARNFLAGS_STD = \
247 -Wall -Werror -Wno-format-y2k -Wextra -Wstrict-prototypes \
248 -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual \
249 -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wchar-subscripts \
250 -Winline -Wnested-externs -Wredundant-decls -Wextra-tokens
251
252 # Certain warnings are non-fatal (8474835)
253 CWARNFLAGS_STD += -Wno-error=cast-align
254
255 # Can be overridden in Makefile.template or Makefile.$arch
256 export CWARNFLAGS ?= $(CWARNFLAGS_STD)
257
258 define add_perfile_cflags
259 $(1)_CWARNFLAGS_ADD += $2
260 endef
261
262 CXXWARNFLAGS_STD = \
263 -Wall -Werror -Wno-format-y2k -Wextra -Wpointer-arith -Wreturn-type \
264 -Wcast-qual -Wwrite-strings -Wswitch -Wcast-align -Wchar-subscripts \
265 -Wredundant-decls -Wextra-tokens
266
267 # Certain warnings are non-fatal (8474835, 9000888)
268 CXXWARNFLAGS_STD += -Wno-error=cast-align -Wno-error=overloaded-virtual
269
270 # Can be overridden in Makefile.template or Makefile.$arch
271 export CXXWARNFLAGS ?= $(CXXWARNFLAGS_STD)
272
273 define add_perfile_cxxflags
274 $(1)_CXXWARNFLAGS_ADD += $2
275 endef
276
277 #
278 # Setup for parallel sub-makes based on 2 times number of logical CPUs
279 #
280 ifndef MAKEJOBS
281 export MAKEJOBS = --jobs=$(shell expr `/usr/sbin//sysctl -n hw.logicalcpu` \* 2)
282 endif
283
284 #
285 # Default ARCH_FLAGS, for use with compiler/linker/assembler/mig drivers
286
287 ARCH_FLAGS_I386 = -arch i386
288 ARCH_FLAGS_X86_64 = -arch x86_64
289
290
291 #
292 # Default CFLAGS
293 #
294 ifdef RC_CFLAGS
295 export OTHER_CFLAGS = $(subst $(addprefix -arch ,$(RC_ARCHS)),,$(RC_CFLAGS))
296 endif
297
298 export DSYMRESDIR = ./Contents/Resources/
299 export DSYMBUILDDIR = ./Contents/Resources/DWARF/
300
301 #
302 # We must not use -fno-keep-inline-functions, or it will remove the dtrace
303 # probes from the kernel.
304 #
305 export CFLAGS_GEN = $(DEBUG_CFLAGS) -nostdinc \
306 -freorder-blocks -fno-builtin -fno-common \
307 -fsigned-bitfields $(OTHER_CFLAGS)
308
309 ifeq ($(BUILD_STABS),1)
310 export CFLAGS_GEN += -gstabs+
311 export BUILD_DWARF = 0
312 export BUILD_STABS = 1
313 else
314 export CFLAGS_GEN += -gdwarf-2
315 export BUILD_DWARF = 1
316 export BUILD_STABS = 0
317 endif
318
319 export CFLAGS_RELEASE =
320 export CFLAGS_DEVELOPMENT =
321 export CFLAGS_DEBUG = -fstack-protector-all
322 export CFLAGS_PROFILE = -pg
323
324 export CFLAGS_I386 = -static -Di386 -DI386 -D__I386__ \
325 -DPAGE_SIZE_FIXED -msoft-float \
326 -integrated-as
327 export CFLAGS_X86_64 = -Dx86_64 -DX86_64 -D__X86_64__ -DLP64 \
328 -DPAGE_SIZE_FIXED -mkernel -msoft-float \
329 -integrated-as
330
331
332 ifeq (-arch armv7,$(ARCH_FLAGS_ARM))
333 CFLAGS_ARM += -mthumb
334 endif
335 ifeq (-arch armv6,$(ARCH_FLAGS_ARM))
336 CFLAGS_ARM += -mthumb
337 endif
338
339
340 export CFLAGS_RELEASEI386 = -O2
341 export CFLAGS_DEVELOPMENTI386 = -O2
342 export CFLAGS_DEBUGI386 = -O0
343 export CFLAGS_PROFILEI386 = -O2
344
345 export CFLAGS_RELEASEX86_64 = -O2
346 export CFLAGS_DEVELOPMENTX86_64 = -O2
347 # No space optimization for the DEBUG kernel for the benefit of gdb:
348 export CFLAGS_DEBUGX86_64 = -O0
349 export CFLAGS_PROFILEX86_64 = -O2
350
351 export CFLAGS_RELEASEARM = -O2
352 export CFLAGS_DEVELOPMENTARM = -O2
353 export CFLAGS_DEBUGARM = -O0
354 export CFLAGS_PROFILEARM = -O2
355
356 export CFLAGS = $(CFLAGS_GEN) \
357 $($(addsuffix $(MACHINE_CONFIG),MACHINE_FLAGS_)) \
358 $($(addsuffix $(ARCH_CONFIG),ARCH_FLAGS_)) \
359 $($(addsuffix $(ARCH_CONFIG),CFLAGS_)) \
360 $($(addsuffix $(KERNEL_CONFIG),CFLAGS_)) \
361 $($(addsuffix $(ARCH_CONFIG), $(addsuffix $(KERNEL_CONFIG),CFLAGS_))) \
362 $(DEPLOYMENT_TARGET_FLAGS) \
363 $(DEFINES)
364
365 #
366 # Default C++ flags
367 #
368
369 OTHER_CXXFLAGS =
370
371 CXXFLAGS_GEN = -fapple-kext $(OTHER_CXXFLAGS)
372
373 CXXFLAGS = $(CXXFLAGS_GEN) \
374 $($(addsuffix $(ARCH_CONFIG),CXXFLAGS_)) \
375 $($(addsuffix $(KERNEL_CONFIG),CXXFLAGS_))
376
377 #
378 # Assembler command
379 #
380 AS = $(CC)
381 S_KCC = $(CC)
382
383 #
384 # Default SFLAGS
385 #
386 export SFLAGS_GEN = -D__ASSEMBLER__ $(OTHER_CFLAGS)
387
388 export SFLAGS_RELEASE =
389 export SFLAGS_DEVELOPMENT =
390 export SFLAGS_DEBUG =
391 export SFLAGS_PROFILE =
392
393 export SFLAGS_I386 = $(CFLAGS_I386)
394 export SFLAGS_X86_64 = $(CFLAGS_X86_64)
395
396
397 export SFLAGS = $(SFLAGS_GEN) \
398 $($(addsuffix $(MACHINE_CONFIG),MACHINE_FLAGS_)) \
399 $($(addsuffix $(ARCH_CONFIG),ARCH_FLAGS_)) \
400 $($(addsuffix $(ARCH_CONFIG),SFLAGS_)) \
401 $($(addsuffix $(KERNEL_CONFIG),SFLAGS_)) \
402 $(DEPLOYMENT_TARGET_FLAGS) \
403 $(DEFINES)
404
405
406 #
407 # Linker command
408 #
409 LD = $(KC++) -nostdlib
410
411 #
412 # Default LDFLAGS
413 #
414 export LDFLAGS_KERNEL_GEN = \
415 -nostdlib \
416 -fapple-kext \
417 -Wl,-e,__start \
418 -Wl,-sectalign,__TEXT,__text,0x1000 \
419 -Wl,-sectalign,__TEXT,initcode,0x1000 \
420 -Wl,-sectalign,__DATA,__common,0x1000 \
421 -Wl,-sectalign,__DATA,__bss,0x1000 \
422 -Wl,-sectcreate,__PRELINK_TEXT,__text,/dev/null \
423 -Wl,-sectcreate,__PRELINK_STATE,__kernel,/dev/null \
424 -Wl,-sectcreate,__PRELINK_STATE,__kexts,/dev/null \
425 -Wl,-sectcreate,__PRELINK_INFO,__info,/dev/null \
426 -Wl,-new_linker \
427 -Wl,-pagezero_size,0x0 \
428 -Wl,-version_load_command \
429 -Wl,-function_starts
430
431 # Availability of DWARF allows DTrace CTF (compressed type format) to be constructed.
432 # ctf_insert creates the CTF section. It needs reserved padding in the
433 # headers for the load command segment and the CTF section structures.
434 ifeq ($(BUILD_DWARF),1)
435 export LDFLAGS_KERNEL_GEN += \
436 -Wl,-headerpad,152
437 endif
438
439 export LDFLAGS_KERNEL_RELEASE =
440 export LDFLAGS_KERNEL_DEVELOPMENT =
441 export LDFLAGS_KERNEL_DEBUG =
442 export LDFLAGS_KERNEL_PROFILE =
443
444 export LDFLAGS_KERNEL_RELEASEI386 = \
445 -Wl,-segaddr,__INITPT,0x00100000 \
446 -Wl,-segaddr,__INITGDT,0x00106000 \
447 -Wl,-segaddr,__SLEEP,0x00107000 \
448 -Wl,-segaddr,__HIB,0x00108000 \
449 -Wl,-image_base,0x200000 \
450 -Wl,-seg_page_size,__TEXT,0x200000
451
452 export LDFLAGS_KERNEL_DEBUGI386 = $(LDFLAGS_KERNEL_RELEASEI386)
453 export LDFLAGS_KERNEL_DEVELOPMENTI386 = $(LDFLAGS_KERNEL_RELEASEI386)
454 export LDFLAGS_KERNEL_PROFILEI386 = $(LDFLAGS_KERNEL_RELEASEI386)
455
456 # KASLR static slide config:
457 ifndef SLIDE
458 SLIDE=0x00
459 endif
460 KERNEL_MIN_ADDRESS := 0xffffff8000000000
461 KERNEL_BASE_OFFSET := 0x100000
462 KERNEL_STATIC_SLIDE := $(shell printf "0x%016x" \
463 $$[ $(SLIDE) << 21 ])
464 KERNEL_STATIC_BASE := $(shell printf "0x%016x" \
465 $$[ $(KERNEL_MIN_ADDRESS) + $(KERNEL_BASE_OFFSET) ])
466 KERNEL_HIB_SECTION_BASE := $(shell printf "0x%016x" \
467 $$[ $(KERNEL_STATIC_BASE) + $(KERNEL_STATIC_SLIDE) ])
468 KERNEL_TEXT_BASE := $(shell printf "0x%016x" \
469 $$[ $(KERNEL_HIB_SECTION_BASE) + 0x100000 ])
470
471 export LDFLAGS_KERNEL_RELEASEX86_64 = \
472 -Wl,-pie \
473 -Wl,-segaddr,__HIB,$(KERNEL_HIB_SECTION_BASE) \
474 -Wl,-image_base,$(KERNEL_TEXT_BASE) \
475 -Wl,-seg_page_size,__TEXT,0x200000 \
476 -Wl,-sectalign,__DATA,__const,0x1000 \
477 -Wl,-sectalign,__DATA,__sysctl_set,0x1000 \
478 -Wl,-sectalign,__HIB,__bootPT,0x1000 \
479 -Wl,-sectalign,__HIB,__desc,0x1000 \
480 -Wl,-sectalign,__HIB,__data,0x1000 \
481 -Wl,-sectalign,__HIB,__text,0x1000 \
482 -Wl,-sectalign,__HIB,__const,0x1000 \
483 -Wl,-sectalign,__HIB,__bss,0x1000 \
484 -Wl,-sectalign,__HIB,__common,0x1000 \
485
486 # Define KERNEL_BASE_OFFSET so known at compile time:
487 export CFLAGS_X86_64 += -DKERNEL_BASE_OFFSET=$(KERNEL_BASE_OFFSET)
488
489 export LDFLAGS_KERNEL_DEBUGX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
490 export LDFLAGS_KERNEL_DEVELOPMENTX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
491 export LDFLAGS_KERNEL_PROFILEX86_64 = $(LDFLAGS_KERNEL_RELEASEX86_64)
492
493 export LDFLAGS_KERNEL_RELEASEARM = \
494 -Wl,-pie \
495 -Wl,-static \
496 -Wl,-image_base,0x80001000 \
497 -Wl,-exported_symbols_list,$(TARGET)/kernel-kpi.exp
498
499 export LDFLAGS_KERNEL_DEVELOPMENTARM = \
500 -Wl,-pie \
501 -Wl,-static \
502 -Wl,-image_base,0x80001000
503
504 export LDFLAGS_KERNEL_DEBUGARM = $(LDFLAGS_KERNEL_DEVELOPMENTARM)
505
506 # Offset image base by page to have iBoot load kernel TEXT correctly.
507 # First page is used for various purposes : sleep token, reset vector.
508
509 export LDFLAGS_KERNEL = $(LDFLAGS_KERNEL_GEN) \
510 $($(addsuffix $(MACHINE_CONFIG),MACHINE_FLAGS_)) \
511 $($(addsuffix $(ARCH_CONFIG),ARCH_FLAGS_)) \
512 $($(addsuffix $(ARCH_CONFIG),LDFLAGS_KERNEL_)) \
513 $($(addsuffix $(KERNEL_CONFIG),LDFLAGS_KERNEL_)) \
514 $($(addsuffix $(ARCH_CONFIG), $(addsuffix $(KERNEL_CONFIG),LDFLAGS_KERNEL_))) \
515 $(DEPLOYMENT_TARGET_FLAGS)
516
517 #
518 # Default runtime libraries to be linked with the kernel
519 #
520 export LD_KERNEL_LIBS = -lcc_kext
521
522
523 #
524 # Default INCFLAGS
525 #
526 export INCFLAGS_IMPORT = $(patsubst %, -I$(OBJROOT)/EXPORT_HDRS/%, $(COMPONENT_IMPORT_LIST))
527 export INCFLAGS_EXTERN = -I$(OBJROOT)/EXTERN_HDRS -I$(SRCROOT)/EXTERNAL_HEADERS -I$(SRCROOT)/EXTERNAL_HEADERS/bsd
528 export INCFLAGS_GEN = -I$(SRCROOT)/$(COMPONENT) -I$(OBJROOT)/EXPORT_HDRS/$(COMPONENT)
529 export INCFLAGS_POSIX = -I$(OBJROOT)/EXPORT_HDRS/bsd
530 export INCFLAGS_LOCAL = -I.
531
532 export INCFLAGS = $(INCFLAGS_LOCAL) $(INCFLAGS_GEN) $(INCFLAGS_IMPORT) $(INCFLAGS_EXTERN) $(INCFLAGS_MAKEFILE)
533
534 #
535 # Default MIGFLAGS
536 #
537 export MIGFLAGS = $(DEFINES) $(INCFLAGS) $($(addsuffix $(ARCH_CONFIG),CFLAGS_)) \
538 $($(addsuffix $(ARCH_CONFIG),ARCH_FLAGS_)) \
539 $(DEPLOYMENT_TARGET_FLAGS)
540
541 #
542 # Support for LLVM Link Time Optimization (LTO)
543 #
544
545 ifeq ($(BUILD_LTO),1)
546 export CFLAGS_GEN += -flto
547 export CXXFLAGS_GEN += -flto
548 export LDFLAGS_KERNEL_GEN += -Wl,-object_path_lto,$(TARGET)/lto.o
549 export CFLAGS_NOLTO_FLAG = -fno-lto
550 export BUILD_MACHO_OBJ = 0
551 export BUILD_LTO = 1
552 else
553 export CFLAGS_NOLTO_FLAG =
554 export BUILD_MACHO_OBJ = 1
555 export BUILD_LTO = 0
556 endif
557
558 #
559 # Support for LLVM Integrated Assembler with clang driver
560 #
561 ifeq ($(BUILD_INTEGRATED_ASSEMBLER),1)
562 export SFLAGS_GEN += -integrated-as
563 export CFLAGS_GEN += -integrated-as
564 export CXXFLAGS_GEN += -integrated-as
565 export SFLAGS_NOINTEGRATEDAS_FLAGS = -no-integrated-as
566 export CFLAGS_NOINTEGRATEDAS_FLAGS = -no-integrated-as
567 else
568 export SFLAGS_NOINTEGRATEDAS_FLAGS =
569 export CFLAGS_NOINTEGRATEDAS_FLAGS =
570 endif
571
572 #
573 # Default VPATH
574 #
575 empty:=
576 space:= $(empty) $(empty)
577 export VPATH_IMPORT = $(subst $(space),:,$(patsubst %,$(OBJROOT)/EXPORT_HDRS/%,$(strip $(COMPONENT_IMPORT_LIST)))):
578 export VPATH_EXTERN = $(OBJROOT)/EXTERN_HDRS:
579 export VPATH_GEN = .:$(SOURCE):
580
581 export VPATH = $(VPATH_GEN)$(VPATH_IMPORT)$(VPATH_EXTERN)$(VPATH_MAKEFILE)
582
583 #
584 # Macros that control installation of kernel and its header files
585 #
586 # install flags for header files
587 #
588 INSTALL_FLAGS = -c -m 0444
589 FILE_INSTALL_FLAGS = -c -m 0644
590 DATA_INSTALL_FLAGS = -c -m 0644
591
592 #
593 # Header file destinations
594 #
595 ifeq ($(RC_ProjectName),xnu_headers_Sim)
596 HEADER_INSTALL_PREFIX = $(SDKROOT)
597 else
598 HEADER_INSTALL_PREFIX =
599 endif
600
601 FRAMEDIR = $(HEADER_INSTALL_PREFIX)/System/Library/Frameworks
602
603 SINCVERS = B
604 SINCFRAME = $(FRAMEDIR)/System.framework
605 SINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Headers
606 SPINCDIR = $(SINCFRAME)/Versions/$(SINCVERS)/PrivateHeaders
607 SRESDIR = $(SINCFRAME)/Versions/$(SINCVERS)/Resources
608
609 ifndef INCDIR
610 INCDIR = $(HEADER_INSTALL_PREFIX)/usr/include
611 endif
612 ifndef LCLDIR
613 LCLDIR = $(SPINCDIR)
614 endif
615
616 KINCVERS = A
617 KINCFRAME = $(FRAMEDIR)/Kernel.framework
618 KINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Headers
619 KPINCDIR = $(KINCFRAME)/Versions/$(KINCVERS)/PrivateHeaders
620 KRESDIR = $(KINCFRAME)/Versions/$(KINCVERS)/Resources
621
622 XNU_PRIVATE_UNIFDEF = -UMACH_KERNEL_PRIVATE -UBSD_KERNEL_PRIVATE -UIOKIT_KERNEL_PRIVATE -ULIBKERN_KERNEL_PRIVATE -ULIBSA_KERNEL_PRIVATE -UPEXPERT_KERNEL_PRIVATE -UXNU_KERNEL_PRIVATE
623
624 PLATFORM_UNIFDEF = $(foreach x,$(SUPPORTED_PLATFORMS),$(if $(filter $(PLATFORM),$(x)),-DPLATFORM_$(x),-UPLATFORM_$(x)))
625
626 SPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UKERNEL -DPRIVATE -U_OPEN_SOURCE_
627 SINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UKERNEL -UPRIVATE -D_OPEN_SOURCE_
628 KPINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) -DKERNEL_PRIVATE -DPRIVATE -DKERNEL -U_OPEN_SOURCE_
629 KINCFRAME_UNIFDEF = $(PLATFORM_UNIFDEF) $(XNU_PRIVATE_UNIFDEF) -UKERNEL_PRIVATE -UPRIVATE -DKERNEL -D_OPEN_SOURCE_
630
631
632 #
633 # Component Header file destinations
634 #
635 EXPDIR = EXPORT_HDRS/$(COMPONENT)
636
637 #
638 # Strip Flags
639 #
640 export STRIP_FLAGS_RELEASE = -S -x
641 export STRIP_FLAGS_DEVELOPMENT = -S -x
642 export STRIP_FLAGS_DEBUG = -S
643 export STRIP_FLAGS_PROFILE = -S -x
644
645 export STRIP_FLAGS = $($(addsuffix $(KERNEL_CONFIG),STRIP_FLAGS_))
646
647 #
648 # dsymutil flags
649 #
650 export DSYMUTIL_FLAGS_I386 = --arch=i386
651 export DSYMUTIL_FLAGS_X86_64 = --arch=x86_64
652
653 export DSYMUTIL_FLAGS = $($(addsuffix $(ARCH_CONFIG),DSYMUTIL_FLAGS_))
654
655 #
656 # Man Page destination
657 #
658 MANDIR = usr/share/man
659
660 #
661 # DEBUG alias location
662 #
663 DEVELOPER_EXTRAS_DIR = AppleInternal/Developer/Extras
664
665 #
666 # This must be here before any rules are possibly defined by the
667 # machine dependent makefile fragment so that a plain "make" command
668 # always works. The config program will emit an appropriate rule to
669 # cause "all" to depend on every kernel configuration it generates.
670 #
671
672 default: all
673
674 # vim: set ft=make: