xref: /xnu-10063.121.3/makedefs/MakeInc.kernel (revision 2c2f96dc2b9a4408a43d3150ae9c105355ca3daa) !
1*2c2f96dcSApple OSS Distributions# -*- mode: makefile;-*-
2*2c2f96dcSApple OSS Distributions#
3*2c2f96dcSApple OSS Distributions# Copyright (C) 1999-2020 Apple Inc. All rights reserved.
4*2c2f96dcSApple OSS Distributions#
5*2c2f96dcSApple OSS Distributions# MakeInc.kernel augments the single-architecture
6*2c2f96dcSApple OSS Distributions# recursive build system with rules specific
7*2c2f96dcSApple OSS Distributions# to assembling and linking a kernel.
8*2c2f96dcSApple OSS Distributions#
9*2c2f96dcSApple OSS Distributions
10*2c2f96dcSApple OSS Distributions#
11*2c2f96dcSApple OSS Distributions# Validate configuration options
12*2c2f96dcSApple OSS Distributions#
13*2c2f96dcSApple OSS Distributionsifeq ($(filter $(CURRENT_ARCH_CONFIG),$(SUPPORTED_ARCH_CONFIGS)),)
14*2c2f96dcSApple OSS Distributions$(error Unsupported CURRENT_ARCH_CONFIG $(CURRENT_ARCH_CONFIG))
15*2c2f96dcSApple OSS Distributionsendif
16*2c2f96dcSApple OSS Distributions
17*2c2f96dcSApple OSS Distributionsifeq ($(filter $(CURRENT_KERNEL_CONFIG),$(SUPPORTED_KERNEL_CONFIGS)),)
18*2c2f96dcSApple OSS Distributions$(error Unsupported CURRENT_KERNEL_CONFIG $(CURRENT_KERNEL_CONFIG))
19*2c2f96dcSApple OSS Distributionsendif
20*2c2f96dcSApple OSS Distributions
21*2c2f96dcSApple OSS Distributionsifeq ($(filter $(CURRENT_MACHINE_CONFIG),$(SUPPORTED_$(CURRENT_ARCH_CONFIG)_MACHINE_CONFIGS)),)
22*2c2f96dcSApple OSS Distributions$(error Unsupported CURRENT_MACHINE_CONFIG $(CURRENT_MACHINE_CONFIG))
23*2c2f96dcSApple OSS Distributionsendif
24*2c2f96dcSApple OSS Distributions
25*2c2f96dcSApple OSS Distributionsifeq ($(filter $(PLATFORM),$(SUPPORTED_PLATFORMS)),)
26*2c2f96dcSApple OSS Distributions$(error Unsupported PLATFORM $(PLATFORM))
27*2c2f96dcSApple OSS Distributionsendif
28*2c2f96dcSApple OSS Distributions
29*2c2f96dcSApple OSS Distributions# Generate xnu version file early (from build environment or SDK/KDK)
30*2c2f96dcSApple OSS Distributionsdo_build_setup:: $(XNU_VERSION)
31*2c2f96dcSApple OSS Distributions
32*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_STATIC_LINK),1)
33*2c2f96dcSApple OSS Distributionsifeq ($(USE_LTO),1)
34*2c2f96dcSApple OSS Distributions# <rdar://problem/46252406>
35*2c2f96dcSApple OSS Distributions# To run LTO in the xnu project while linking the final result in KCB, without losing debugging info,
36*2c2f96dcSApple OSS Distributions# run ld -r on only the LTO bitcode object files to produce one mach-o for KCB to use, which is added
37*2c2f96dcSApple OSS Distributions# to the static link archive, along with the non-LTO objects (not linked, since ld -r on mach-o objects
38*2c2f96dcSApple OSS Distributions# does not preserve DWARF.)
39*2c2f96dcSApple OSS DistributionsPRE_LTO=1
40*2c2f96dcSApple OSS Distributionsendif
41*2c2f96dcSApple OSS Distributionsendif
42*2c2f96dcSApple OSS Distributions
43*2c2f96dcSApple OSS Distributions#
44*2c2f96dcSApple OSS Distributions# Rules for the highly parallel "build" phase, where each build configuration
45*2c2f96dcSApple OSS Distributions# writes into their own $(TARGET) independent of other build configs
46*2c2f96dcSApple OSS Distributions#
47*2c2f96dcSApple OSS Distributions# There are 5 primary build outputs:
48*2c2f96dcSApple OSS Distributions# 1) $(KERNEL_FILE_NAME).unstripped    (raw linked kernel, unstripped)
49*2c2f96dcSApple OSS Distributions# 2) $(KERNEL_FILE_NAME)               (stripped kernel, with optional CTF data)
50*2c2f96dcSApple OSS Distributions# 3) $(KERNEL_FILE_NAME).dSYM          (dSYM)
51*2c2f96dcSApple OSS Distributions# 4) $(KERNEL_FILE_NAME).link          (bits for static linking)
52*2c2f96dcSApple OSS Distributions# 5) lib$(KERNEL_FILE_NAME).a          (static archive for testing)
53*2c2f96dcSApple OSS Distributions
54*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_STATIC_LINK),1)
55*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_XNU_LIBRARY),1)
56*2c2f96dcSApple OSS Distributions
57*2c2f96dcSApple OSS DistributionsKERNEL_STATIC_LINK_TARGETS = \
58*2c2f96dcSApple OSS Distributions	$(TARGET)/lib$(KERNEL_FILE_NAME).a
59*2c2f96dcSApple OSS DistributionsKERNEL_STATIC_LINK_DST = \
60*2c2f96dcSApple OSS Distributions	$(DSTROOT)/$(INSTALL_KERNEL_DIR)/lib$(KERNEL_FILE_NAME).a
61*2c2f96dcSApple OSS Distributions
62*2c2f96dcSApple OSS Distributionselse
63*2c2f96dcSApple OSS Distributions
64*2c2f96dcSApple OSS DistributionsKERNEL_STATIC_LINK_TARGETS = \
65*2c2f96dcSApple OSS Distributions	$(TARGET)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).a
66*2c2f96dcSApple OSS Distributions
67*2c2f96dcSApple OSS DistributionsKERNEL_STATIC_LINK_DST = \
68*2c2f96dcSApple OSS Distributions			$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).a             \
69*2c2f96dcSApple OSS Distributions			$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).linkarguments \
70*2c2f96dcSApple OSS Distributions			$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).linkarchives  \
71*2c2f96dcSApple OSS Distributions			$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).exp           \
72*2c2f96dcSApple OSS Distributions			$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).alias.exp     \
73*2c2f96dcSApple OSS Distributions			$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros                   \
74*2c2f96dcSApple OSS Distributions			$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME)
75*2c2f96dcSApple OSS Distributions
76*2c2f96dcSApple OSS Distributionsendif
77*2c2f96dcSApple OSS Distributionsendif
78*2c2f96dcSApple OSS Distributions
79*2c2f96dcSApple OSS Distributionsdo_build_all:: do_build_kernel
80*2c2f96dcSApple OSS Distributions
81*2c2f96dcSApple OSS Distributions.PHONY: do_build_kernel
82*2c2f96dcSApple OSS Distributions
83*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_XNU_LIBRARY),1)
84*2c2f96dcSApple OSS Distributionsdo_build_kernel: $(KERNEL_STATIC_LINK_TARGETS)
85*2c2f96dcSApple OSS Distributions
86*2c2f96dcSApple OSS Distributionselse
87*2c2f96dcSApple OSS Distributions
88*2c2f96dcSApple OSS Distributionsdo_build_kernel: $(TARGET)/$(KERNEL_FILE_NAME) $(TARGET)/$(KERNEL_FILE_NAME).unstripped $(KERNEL_STATIC_LINK_TARGETS)
89*2c2f96dcSApple OSS Distributions	@:
90*2c2f96dcSApple OSS Distributions
91*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_DSYM),1)
92*2c2f96dcSApple OSS Distributionsdo_build_all:: do_build_kernel_dSYM
93*2c2f96dcSApple OSS Distributionsendif
94*2c2f96dcSApple OSS Distributions
95*2c2f96dcSApple OSS Distributions.PHONY: do_build_kernel_dSYM
96*2c2f96dcSApple OSS Distributions
97*2c2f96dcSApple OSS Distributionsdo_build_kernel_dSYM: $(TARGET)/$(KERNEL_FILE_NAME).dSYM
98*2c2f96dcSApple OSS Distributions	@:
99*2c2f96dcSApple OSS Distributions
100*2c2f96dcSApple OSS Distributionsendif
101*2c2f96dcSApple OSS Distributions
102*2c2f96dcSApple OSS Distributionsdo_build_all:: do_build_compile_commands_json
103*2c2f96dcSApple OSS Distributions
104*2c2f96dcSApple OSS Distributions.PHONY: do_build_compile_commands_json
105*2c2f96dcSApple OSS Distributions
106*2c2f96dcSApple OSS Distributionsdo_build_compile_commands_json: $(TARGET)/compile_commands.json
107*2c2f96dcSApple OSS Distributions	@:
108*2c2f96dcSApple OSS Distributions
109*2c2f96dcSApple OSS Distributions.LDFLAGS: ALWAYS
110*2c2f96dcSApple OSS Distributions	$(_v)$(REPLACECONTENTS) $@ $(LD) $(LDFLAGS_KERNEL) $(LDFLAGS_KERNEL_ONLY) $(LD_KERNEL_LIBS)
111*2c2f96dcSApple OSS Distributions.CFLAGS: ALWAYS
112*2c2f96dcSApple OSS Distributions	$(_v)$(REPLACECONTENTS) $@ $(KCC) $(CFLAGS) $(INCFLAGS)
113*2c2f96dcSApple OSS Distributions
114*2c2f96dcSApple OSS Distributions
115*2c2f96dcSApple OSS Distributions#
116*2c2f96dcSApple OSS Distributions# CTF generation requires the following files:
117*2c2f96dcSApple OSS Distributions
118*2c2f96dcSApple OSS Distributions#     kernel.unstripped.noctf  Unstripped kernel with no CTF
119*2c2f96dcSApple OSS Distributions#     kernel.ctf               CTF from the dSYM associated with kernel.unstripped.noctf
120*2c2f96dcSApple OSS Distributions#     kernel.unstripped        kernel.unstripped.noctf merged with kernel.ctf (Debug Rich Executable)
121*2c2f96dcSApple OSS Distributions#     kernel                   Stripped kernel.unstripped.noctf merged with kernel.ctf (Final Kernel)
122*2c2f96dcSApple OSS Distributions
123*2c2f96dcSApple OSS Distributions# Note: "kernel" here is a placeholder for the actual name of the kernel which
124*2c2f96dcSApple OSS Distributions# varies.
125*2c2f96dcSApple OSS Distributions#
126*2c2f96dcSApple OSS Distributions
127*2c2f96dcSApple OSS Distributions
128*2c2f96dcSApple OSS Distributions# Convert DWARF to CTF
129*2c2f96dcSApple OSS Distributions$(TARGET)/$(KERNEL_FILE_NAME).ctf: $(TARGET)/$(KERNEL_FILE_NAME).dSYM $(TARGET)/$(KERNEL_FILE_NAME).unstripped.noctf
130*2c2f96dcSApple OSS Distributionsifeq ($(DO_CTFMERGE),1)
131*2c2f96dcSApple OSS Distributions	@$(LOG_CTFCONVERT) "$(@F)"
132*2c2f96dcSApple OSS Distributions	$(_v)$(CTFCONVERT) -c -l xnu -u xnu -o $@ $(TARGET)/$(KERNEL_FILE_NAME).dSYM/Contents/Resources/DWARF/$(KERNEL_FILE_NAME)
133*2c2f96dcSApple OSS Distributionsendif
134*2c2f96dcSApple OSS Distributions
135*2c2f96dcSApple OSS Distributions# Strip the kernel and merge in the CTF
136*2c2f96dcSApple OSS Distributions$(TARGET)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME).unstripped.noctf $(TARGET)/$(KERNEL_FILE_NAME).dSYM $(TARGET)/$(KERNEL_FILE_NAME).ctf
137*2c2f96dcSApple OSS Distributions	@$(LOG_STRIP) "$(@F)"
138*2c2f96dcSApple OSS Distributions	$(_v)$(STRIP) $(STRIP_FLAGS) $< -o $@
139*2c2f96dcSApple OSS Distributions	@echo "built kernel at $@"
140*2c2f96dcSApple OSS Distributions	$(_v)$(RM) [email protected]
141*2c2f96dcSApple OSS Distributionsifeq ($(DO_CTFMERGE),1)
142*2c2f96dcSApple OSS Distributions	@$(LOG_CTFMERGE) "$(@F)"
143*2c2f96dcSApple OSS Distributions	$(_v)$(CTFMERGE) -l xnu -o $@ -Z [email protected] [email protected]
144*2c2f96dcSApple OSS Distributions	$(_v)if [ -s [email protected] ]; then                          \
145*2c2f96dcSApple OSS Distributions		$(LOG_CTFINSERT) "$(@F)";                            \
146*2c2f96dcSApple OSS Distributions		$(CTFINSERT) $@	$(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
147*2c2f96dcSApple OSS Distributions			     [email protected] -o $@;                           \
148*2c2f96dcSApple OSS Distributions	else                                                     \
149*2c2f96dcSApple OSS Distributions	    exit 1;                                              \
150*2c2f96dcSApple OSS Distributions	fi;
151*2c2f96dcSApple OSS Distributions	-$(_v)$(CTFDUMP) -S $@ $(_vstdout) $(_vstderr)
152*2c2f96dcSApple OSS Distributionsendif
153*2c2f96dcSApple OSS Distributions	$(_v)$(LN) $(call function_convert_build_config_to_objdir,$(CURRENT_BUILD_CONFIG))/$(KERNEL_FILE_NAME) $(OBJROOT)/$(KERNEL_FILE_NAME)
154*2c2f96dcSApple OSS Distributions
155*2c2f96dcSApple OSS Distributions# Merge the CTF into the unstripped kernel (Debug Rich Executable)
156*2c2f96dcSApple OSS Distributions$(TARGET)/$(KERNEL_FILE_NAME).unstripped: $(TARGET)/$(KERNEL_FILE_NAME).ctf $(TARGET)/$(KERNEL_FILE_NAME).unstripped.noctf
157*2c2f96dcSApple OSS Distributions	$(_v)$(CP) $(TARGET)/$(KERNEL_FILE_NAME).unstripped.noctf $(TARGET)/$(KERNEL_FILE_NAME).unstripped
158*2c2f96dcSApple OSS Distributions	$(_v)$(RM) [email protected]
159*2c2f96dcSApple OSS Distributionsifeq ($(DO_CTFMERGE),1)
160*2c2f96dcSApple OSS Distributions	@$(LOG_CTFMERGE) "$(@F)"
161*2c2f96dcSApple OSS Distributions	$(_v)$(CTFMERGE) -l xnu -o $@ -Z [email protected] $(TARGET)/$(KERNEL_FILE_NAME).ctf
162*2c2f96dcSApple OSS Distributions	$(_v)if [ -s [email protected] ]; then                          \
163*2c2f96dcSApple OSS Distributions		$(LOG_CTFINSERT) "$(@F)";                            \
164*2c2f96dcSApple OSS Distributions		$(CTFINSERT) $@	$(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
165*2c2f96dcSApple OSS Distributions			     [email protected] -o $@;                           \
166*2c2f96dcSApple OSS Distributions	else                                                     \
167*2c2f96dcSApple OSS Distributions	    exit 1;                                              \
168*2c2f96dcSApple OSS Distributions	fi;
169*2c2f96dcSApple OSS Distributions	-$(_v)$(CTFDUMP) -S $@ $(_vstdout) $(_vstderr)
170*2c2f96dcSApple OSS Distributionsendif
171*2c2f96dcSApple OSS Distributions
172*2c2f96dcSApple OSS Distributions$(TARGET)/$(KERNEL_FILE_NAME).dSYM: $(TARGET)/$(KERNEL_FILE_NAME).unstripped.noctf
173*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_DSYM),1)
174*2c2f96dcSApple OSS Distributions	@$(LOG_DSYMUTIL) "$(@F)"
175*2c2f96dcSApple OSS Distributions	$(_v)$(BASH) -c "$(DSYMUTIL) $(DSYMUTIL_FLAGS) $< -o $@ $(_vstdout) 2> >(grep -v '^warning:.*could not find object file symbol for symbol' 1>&2)"
176*2c2f96dcSApple OSS Distributions	$(_v)$(MV) $@/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME).unstripped.noctf $@/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME)
177*2c2f96dcSApple OSS Distributionselse
178*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $@
179*2c2f96dcSApple OSS Distributionsendif
180*2c2f96dcSApple OSS Distributions	$(_v)$(TOUCH) $@
181*2c2f96dcSApple OSS Distributions
182*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_XNU_LIBRARY),1)
183*2c2f96dcSApple OSS Distributions$(TARGET)/lib$(KERNEL_FILE_NAME).a: $(addprefix $(TARGET)/,$(foreach component,$(COMPONENT_LIST),$(component)/$(CURRENT_KERNEL_CONFIG)/$(component).libfilelist)) nonlto.o version.o .LDFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
184*2c2f96dcSApple OSS Distributions	@$(LOG_LIBTOOL) "$(@F)"
185*2c2f96dcSApple OSS Distributions	$(_v)$(CAT) $(filter %.libfilelist,$+) < /dev/null > link.filelist
186*2c2f96dcSApple OSS Distributions	$(_v)$(LIBTOOL) -static -csD -filelist link.filelist -o $@
187*2c2f96dcSApple OSS Distributions	$(_v)$(LN) $(call function_convert_build_config_to_objdir,$(CURRENT_BUILD_CONFIG))/lib$(KERNEL_FILE_NAME).a $(OBJROOT)/lib$(KERNEL_FILE_NAME).a
188*2c2f96dcSApple OSS Distributionsendif
189*2c2f96dcSApple OSS Distributions
190*2c2f96dcSApple OSS Distributions$(TARGET)/$(KERNEL_FILE_NAME).unstripped.noctf: $(addprefix $(TARGET)/,$(foreach component,$(COMPONENT_LIST),$(component)/$(CURRENT_KERNEL_CONFIG)/$(component).filelist)) lastkerneldataconst.o lastkernelconstructor.o nonlto.o version.o $(LDFILES_KERNEL_ONLY) .LDFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
191*2c2f96dcSApple OSS Distributionsifeq ($(PRE_LTO),1)
192*2c2f96dcSApple OSS Distributions	@$(LOG_LTO) "$(@F)"
193*2c2f96dcSApple OSS Distributions	$(_v)$(RM) ltolink.filelist
194*2c2f96dcSApple OSS Distributions	$(_v)$(RM) nonltolink.filelist
195*2c2f96dcSApple OSS Distributions	$(_v)$(RM) -r $(TARGET)/justlto.o
196*2c2f96dcSApple OSS Distributions	$(_v)files="$$($(CAT) $(filter %.filelist,$+)) $(filter %.o,$+)"; \
197*2c2f96dcSApple OSS Distributions	for ofile in $$files; \
198*2c2f96dcSApple OSS Distributions	do \
199*2c2f96dcSApple OSS Distributions		hdr=$$(od -An -N 4 -t x4 $$ofile); \
200*2c2f96dcSApple OSS Distributions		if [ $$hdr = "0b17c0de" ]; \
201*2c2f96dcSApple OSS Distributions			then \
202*2c2f96dcSApple OSS Distributions				if [ -z "$$lto" ]; \
203*2c2f96dcSApple OSS Distributions					then \
204*2c2f96dcSApple OSS Distributions						lto="$$ofile"; \
205*2c2f96dcSApple OSS Distributions					else \
206*2c2f96dcSApple OSS Distributions						lto="$$(printf '%s\n%s' "$$lto" "$$ofile")"; \
207*2c2f96dcSApple OSS Distributions				fi; \
208*2c2f96dcSApple OSS Distributions			else \
209*2c2f96dcSApple OSS Distributions				if [ -z "$$nonlto" ]; \
210*2c2f96dcSApple OSS Distributions					then \
211*2c2f96dcSApple OSS Distributions						nonlto="$$ofile"; \
212*2c2f96dcSApple OSS Distributions					else \
213*2c2f96dcSApple OSS Distributions						nonlto="$$(printf '%s\n%s' "$$nonlto" "$$ofile")"; \
214*2c2f96dcSApple OSS Distributions				fi; \
215*2c2f96dcSApple OSS Distributions			fi; \
216*2c2f96dcSApple OSS Distributions	done; \
217*2c2f96dcSApple OSS Distributions	printf '%s\n' "$$lto" >ltolink.filelist; \
218*2c2f96dcSApple OSS Distributions	printf '%s\n' "$$nonlto" >nonltolink.filelist
219*2c2f96dcSApple OSS Distributions	@$(LOG_LD) "$(@F)"
220*2c2f96dcSApple OSS Distributions	$(_v)if [ -s ltolink.filelist ]; \
221*2c2f96dcSApple OSS Distributions	then \
222*2c2f96dcSApple OSS Distributions		$(LD) $($(addsuffix $(CURRENT_ARCH_CONFIG),ARCH_FLAGS_)) -r nonlto.o -filelist ltolink.filelist $(LDFLAGS_KERNEL_LTO) -Wl,-object_path_lto,$(TARGET)/justlto.o -o $(TARGET)/justlto.tmp.o && \
223*2c2f96dcSApple OSS Distributions		if test -d $(TARGET)/justlto.o; \
224*2c2f96dcSApple OSS Distributions		then \
225*2c2f96dcSApple OSS Distributions		    $(LD) $(LDFLAGS_KERNEL) $(LDFLAGS_KERNEL_ONLY) -filelist nonltolink.filelist $(TARGET)/justlto.o/*.o $(LDFLAGS_KERNEL_STRIP_LTO) -o $@ $(LD_KERNEL_LIBS) $(LD_KERNEL_ARCHIVES); \
226*2c2f96dcSApple OSS Distributions		else \
227*2c2f96dcSApple OSS Distributions		    $(LD) $(LDFLAGS_KERNEL) $(LDFLAGS_KERNEL_ONLY) -filelist nonltolink.filelist $(TARGET)/justlto.o $(LDFLAGS_KERNEL_STRIP_LTO) -o $@ $(LD_KERNEL_LIBS) $(LD_KERNEL_ARCHIVES); \
228*2c2f96dcSApple OSS Distributions		fi; \
229*2c2f96dcSApple OSS Distributions	else \
230*2c2f96dcSApple OSS Distributions		$(LD) $(LDFLAGS_KERNEL) $(LDFLAGS_KERNEL_ONLY) -filelist nonltolink.filelist -o $@ $(LD_KERNEL_LIBS) $(LD_KERNEL_ARCHIVES); \
231*2c2f96dcSApple OSS Distributions	fi
232*2c2f96dcSApple OSS Distributionselse
233*2c2f96dcSApple OSS Distributions	@$(LOG_LD) "$(@F)"
234*2c2f96dcSApple OSS Distributions	$(_v)$(CAT) $(filter %.filelist,$+) < /dev/null > link.filelist
235*2c2f96dcSApple OSS Distributions	$(_v)$(LD) $(LDFLAGS_KERNEL) $(LDFLAGS_KERNEL_ONLY) -filelist link.filelist $(filter %.o,$+) -o $@ $(LD_KERNEL_LIBS) $(LD_KERNEL_ARCHIVES)
236*2c2f96dcSApple OSS Distributionsendif
237*2c2f96dcSApple OSS Distributions
238*2c2f96dcSApple OSS Distributions$(TARGET)/compile_commands.json: $(addprefix $(TARGET)/,$(foreach component,$(COMPONENT_LIST),$(component)/$(CURRENT_KERNEL_CONFIG)/$(component).filelist))
239*2c2f96dcSApple OSS Distributions	$(_v)files="$$(sed -e 's/$$/.json/' $(filter %.filelist,$+))"; \
240*2c2f96dcSApple OSS Distributions	sed -e '1s/^/[\'$$'\n''/' -e '$$s/,$$/\'$$'\n'']/' $$files > compile_commands.json
241*2c2f96dcSApple OSS Distributions
242*2c2f96dcSApple OSS Distributions# for now, rename LASTDATA_CONST to LAST on static kernel cache builds
243*2c2f96dcSApple OSS DistributionsEXTRA_KC_LINKARGS = -Wl,-rename_segment,__LASTDATA_CONST,__LAST
244*2c2f96dcSApple OSS Distributions
245*2c2f96dcSApple OSS Distributions$(TARGET)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).a:   $(TARGET)/$(KERNEL_FILE_NAME).unstripped .LDFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
246*2c2f96dcSApple OSS Distributions	@$(LOG_LIBTOOL) "$(@F)"
247*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
248*2c2f96dcSApple OSS Distributionsifeq ($(PRE_LTO),1)
249*2c2f96dcSApple OSS Distributions	$(_v)if [ -d $(TARGET)/justlto.o ]; \
250*2c2f96dcSApple OSS Distributions	then \
251*2c2f96dcSApple OSS Distributions	    $(LIBTOOL) -ca $(TARGET)/justlto.o/*.o -filelist nonltolink.filelist -o $@; \
252*2c2f96dcSApple OSS Distributions	else \
253*2c2f96dcSApple OSS Distributions	    $(LIBTOOL) -ca $(TARGET)/justlto.o -filelist nonltolink.filelist -o $@; \
254*2c2f96dcSApple OSS Distributions	fi
255*2c2f96dcSApple OSS Distributionselse
256*2c2f96dcSApple OSS Distributions	$(_v)$(LIBTOOL) -ca -filelist link.filelist version.o lastkerneldataconst.o lastkernelconstructor.o -o $@
257*2c2f96dcSApple OSS Distributionsendif
258*2c2f96dcSApple OSS Distributions	$(_v)cp $(TARGET)/all-kpi.exp $(TARGET)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).exp
259*2c2f96dcSApple OSS Distributions	$(_v)cp $(TARGET)/all-alias.exp $(TARGET)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).alias.exp
260*2c2f96dcSApple OSS Distributions	$(_v)echo "$(LD_KERNEL_ARCHIVES)" >$(TARGET)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).linkarchives
261*2c2f96dcSApple OSS Distributions	$(_v)echo "$(LDFLAGS_KERNEL) $(LD_KERNEL_LIBS) $(EXTRA_KC_LINKARGS)" >$(TARGET)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).linkarguments
262*2c2f96dcSApple OSS Distributions	$(_v)$(LN) $(call function_convert_build_config_to_objdir,$(CURRENT_BUILD_CONFIG))/$(KERNEL_FILE_NAME).link $(OBJROOT)/$(KERNEL_FILE_NAME).link
263*2c2f96dcSApple OSS Distributions
264*2c2f96dcSApple OSS Distributionsnonlto.o: .CFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
265*2c2f96dcSApple OSS Distributionsnonlto.o:   $(SRCROOT)/libsa/nonlto.c
266*2c2f96dcSApple OSS Distributions	${C_RULE_0}
267*2c2f96dcSApple OSS Distributions	${C_RULE_1A}$< $(CFLAGS_NOLTO_FLAG)
268*2c2f96dcSApple OSS Distributions	${C_RULE_2}
269*2c2f96dcSApple OSS Distributions
270*2c2f96dcSApple OSS Distributions-include version.d
271*2c2f96dcSApple OSS Distributionsversion.o: .CFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
272*2c2f96dcSApple OSS Distributionsversion.o: $(OBJPATH)/version.c
273*2c2f96dcSApple OSS Distributions	${C_RULE_0}
274*2c2f96dcSApple OSS Distributions	${C_RULE_1A}$<
275*2c2f96dcSApple OSS Distributions	${C_RULE_2}
276*2c2f96dcSApple OSS Distributions	${C_RULE_4}
277*2c2f96dcSApple OSS Distributions
278*2c2f96dcSApple OSS Distributions$(OBJPATH)/version.c: $(SRCROOT)/config/version.c.template $(NEWVERS) $(XNU_VERSION)
279*2c2f96dcSApple OSS Distributions	$(_v)$(CP) $< $@
280*2c2f96dcSApple OSS Distributions	$(_v)$(NEWVERS) $@ > /dev/null;
281*2c2f96dcSApple OSS Distributions
282*2c2f96dcSApple OSS Distributions# Generate xnuVersion file from B&I env var or the System.kext/Info.plist
283*2c2f96dcSApple OSS Distributions# found in the SDK or KDK. Only update the file if the version number has
284*2c2f96dcSApple OSS Distributions# actually changed to avoid rebuilding dependent source files unnecessarily.
285*2c2f96dcSApple OSS Distributionsifeq ($(origin RC_DARWIN_KERNEL_VERSION), undefined)
286*2c2f96dcSApple OSS DistributionsSDK_SYSTEM_KEXT_INFO_PLIST := $(firstword $(wildcard $(addsuffix $(SYSTEM_KEXT_INFO_PLIST),$(SDKROOT_RESOLVED) $(KDKROOT))))
287*2c2f96dcSApple OSS Distributionsifneq ($(SDK_SYSTEM_KEXT_INFO_PLIST),)
288*2c2f96dcSApple OSS DistributionsRC_DARWIN_KERNEL_VERSION := $(strip $(shell $(PLUTIL) -extract CFBundleVersion raw -n $(SDK_SYSTEM_KEXT_INFO_PLIST)))
289*2c2f96dcSApple OSS Distributionsendif
290*2c2f96dcSApple OSS Distributionsendif
291*2c2f96dcSApple OSS Distributionsifeq ($(RC_DARWIN_KERNEL_VERSION),)
292*2c2f96dcSApple OSS Distributions$(error Could not determine xnu version from SDK or KDK! Set RC_DARWIN_KERNEL_VERSION environment variable.)
293*2c2f96dcSApple OSS Distributionsendif
294*2c2f96dcSApple OSS DistributionsEXISTING_KERNEL_VERSION := $(strip $(shell test -r $(XNU_VERSION) && head -1 $(XNU_VERSION)))
295*2c2f96dcSApple OSS Distributionsifneq ($(EXISTING_KERNEL_VERSION), $(RC_DARWIN_KERNEL_VERSION))
296*2c2f96dcSApple OSS Distributions$(XNU_VERSION): ALWAYS
297*2c2f96dcSApple OSS Distributions	@$(LOG_GENERATE) "$(notdir $@)$(Color0) with version \"$(ColorF)$(RC_DARWIN_KERNEL_VERSION)$(Color0)\""
298*2c2f96dcSApple OSS Distributions	$(_v)printf > $@ '%s\n' "$(RC_DARWIN_KERNEL_VERSION)"
299*2c2f96dcSApple OSS Distributionselse ifeq ($(VERBOSE),YES)
300*2c2f96dcSApple OSS Distributions$(XNU_VERSION): ALWAYS
301*2c2f96dcSApple OSS Distributions	@echo "xnuVersion unchanged: checked for \"$(RC_DARWIN_KERNEL_VERSION)\" in $@"
302*2c2f96dcSApple OSS Distributionsendif
303*2c2f96dcSApple OSS Distributions
304*2c2f96dcSApple OSS Distributions-include lastkerneldataconst.d
305*2c2f96dcSApple OSS Distributionslastkerneldataconst.o: .CFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
306*2c2f96dcSApple OSS Distributionslastkerneldataconst.o: $(SRCROOT)/libsa/lastkerneldataconst.c
307*2c2f96dcSApple OSS Distributions	${C_RULE_0}
308*2c2f96dcSApple OSS Distributions	${C_RULE_1A}$<
309*2c2f96dcSApple OSS Distributions	${C_RULE_2}
310*2c2f96dcSApple OSS Distributions
311*2c2f96dcSApple OSS Distributions
312*2c2f96dcSApple OSS Distributionslastkernelconstructor.o_CFLAGS_RM = -fprofile-instr-generate
313*2c2f96dcSApple OSS Distributions# the LAST segment is mapped read-only on arm, so if we include llvm profiling
314*2c2f96dcSApple OSS Distributions# here it will segfault the kernel.  (see arm_vm_init.c) We don't currently have
315*2c2f96dcSApple OSS Distributions# a way of retrieving these counters from LAST anyway, so there's no harm in just
316*2c2f96dcSApple OSS Distributions# disabling them.
317*2c2f96dcSApple OSS Distributions
318*2c2f96dcSApple OSS DistributionsLAST_FILES=lastkernelconstructor.o
319*2c2f96dcSApple OSS Distributions-include lastkernelconstructor.d
320*2c2f96dcSApple OSS Distributionslastkernelconstructor.o: .CFLAGS $(filter %/MakeInc.kernel,$(MAKEFILE_LIST))
321*2c2f96dcSApple OSS Distributionslastkernelconstructor.o: $(SRCROOT)/libsa/lastkernelconstructor.c
322*2c2f96dcSApple OSS Distributions	${C_RULE_0}
323*2c2f96dcSApple OSS Distributions	${C_RULE_1A}$< $(CFLAGS_NOLTO_FLAG)
324*2c2f96dcSApple OSS Distributions	${C_RULE_2}
325*2c2f96dcSApple OSS Distributions	${C_RULE_3}
326*2c2f96dcSApple OSS Distributions	${C_RULE_4}
327*2c2f96dcSApple OSS Distributions	$(_v)for last_file in ${LAST_FILES};				\
328*2c2f96dcSApple OSS Distributions	do							\
329*2c2f96dcSApple OSS Distributions		$(SEG_HACK) -s __DATA -n __LASTDATA_CONST -o $${last_file}__ $${last_file} || exit 1; \
330*2c2f96dcSApple OSS Distributions		mv $${last_file}__ $${last_file} || exit 1;		\
331*2c2f96dcSApple OSS Distributions	done
332*2c2f96dcSApple OSS DistributionsEXTRA_KC_LINKARGS = -Wl,-rename_segment,__LASTDATA_CONST,__LAST
333*2c2f96dcSApple OSS Distributions
334*2c2f96dcSApple OSS Distributions#
335*2c2f96dcSApple OSS Distributions# Install rules. Each build config is classified as "primary" (the first
336*2c2f96dcSApple OSS Distributions# config for an architecture) or "non-primary". Primary build configs
337*2c2f96dcSApple OSS Distributions# have the semantic of competing to *combine* single-architecture
338*2c2f96dcSApple OSS Distributions# files into a multi-architecture output in the DSTROOT, like
339*2c2f96dcSApple OSS Distributions# $(DSTROOT)/$(KERNEL_FILE_NAME), and consequently each primary build config
340*2c2f96dcSApple OSS Distributions# has its install target run serially with respect to other primary
341*2c2f96dcSApple OSS Distributions# build configs. Non-primary build configs will never compete for
342*2c2f96dcSApple OSS Distributions# files in the DSTROOT or SYMROOT, and can be installed in parallel
343*2c2f96dcSApple OSS Distributions# with other non-primary configs (and even primary configs)
344*2c2f96dcSApple OSS Distributions#
345*2c2f96dcSApple OSS Distributions
346*2c2f96dcSApple OSS Distributionsdo_build_install_primary:: do_install_machine_specific_kernel
347*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_DSYM),1)
348*2c2f96dcSApple OSS Distributionsdo_build_install_primary:: do_install_machine_specific_kernel_dSYM
349*2c2f96dcSApple OSS Distributionsendif
350*2c2f96dcSApple OSS Distributions
351*2c2f96dcSApple OSS Distributionsdo_build_install_non_primary:: do_install_machine_specific_kernel
352*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_DSYM),1)
353*2c2f96dcSApple OSS Distributionsdo_build_install_non_primary:: do_install_machine_specific_kernel_dSYM
354*2c2f96dcSApple OSS Distributionsendif
355*2c2f96dcSApple OSS Distributions
356*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_DSYM),1)
357*2c2f96dcSApple OSS Distributionsifeq ($(INSTALL_KERNEL_SYM_TO_KDK),1)
358*2c2f96dcSApple OSS Distributionsdo_build_install_primary:: do_install_machine_specific_KDK_dSYM
359*2c2f96dcSApple OSS Distributionsdo_build_install_non_primary:: do_install_machine_specific_KDK_dSYM
360*2c2f96dcSApple OSS Distributionsendif
361*2c2f96dcSApple OSS Distributionsendif
362*2c2f96dcSApple OSS Distributions
363*2c2f96dcSApple OSS Distributionsifneq ($(BUILD_XNU_LIBRARY),1)
364*2c2f96dcSApple OSS Distributionsifeq ($(INSTALL_XNU_DEBUG_FILES),1)
365*2c2f96dcSApple OSS Distributionsdo_build_install_primary:: do_install_xnu_debug_files
366*2c2f96dcSApple OSS Distributionsendif
367*2c2f96dcSApple OSS Distributions
368*2c2f96dcSApple OSS Distributions.PHONY: do_install_xnu_debug_files
369*2c2f96dcSApple OSS Distributions
370*2c2f96dcSApple OSS Distributionsdo_install_xnu_debug_files:	$(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)/README.DEBUG-kernel.txt
371*2c2f96dcSApple OSS Distributions	@:
372*2c2f96dcSApple OSS Distributionsendif
373*2c2f96dcSApple OSS Distributions
374*2c2f96dcSApple OSS Distributions#
375*2c2f96dcSApple OSS Distributions# If the timestamp indicates the DSTROOT kernel is out of
376*2c2f96dcSApple OSS Distributions# date, start over. Normal dependencies don't work because we can have
377*2c2f96dcSApple OSS Distributions# ( BUILDA, BUILDB, INSTALLB, INSTALLA ) in which case at INSTALLA time
378*2c2f96dcSApple OSS Distributions# the timestamps would $(DSTROOT)/$(KERNEL_FILE_NAME) is not out of date compared
379*2c2f96dcSApple OSS Distributions# to BUILDA. So we maintain a separate file at the time make(1)
380*2c2f96dcSApple OSS Distributions# was run and use it to determine what actions to take
381*2c2f96dcSApple OSS Distributions#
382*2c2f96dcSApple OSS Distributions
383*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME) ALWAYS
384*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
385*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALL) "$(@F)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
386*2c2f96dcSApple OSS Distributions    # -nt and -ot are evaluated differently by bash, dash, and zsh (and are not part of the POSIX specification).
387*2c2f96dcSApple OSS Distributions    # Explicitly specify what should happen when the right hand file doesn't exist.
388*2c2f96dcSApple OSS Distributions	$(_v)if [ $(OBJROOT)/.mach_kernel.timestamp -nt $@ -o \( -e $(OBJROOT)/.mach_kernel.timestamp -a \! -e $@ \) ]; then	\
389*2c2f96dcSApple OSS Distributions		$(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@;			\
390*2c2f96dcSApple OSS Distributions		cmdstatus=$$?;						\
391*2c2f96dcSApple OSS Distributions	else								\
392*2c2f96dcSApple OSS Distributions		$(LIPO) -create $@ $< -output $@;			\
393*2c2f96dcSApple OSS Distributions		cmdstatus=$$?;						\
394*2c2f96dcSApple OSS Distributions	fi;								\
395*2c2f96dcSApple OSS Distributions	exit $$cmdstatus
396*2c2f96dcSApple OSS Distributions
397*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_STATIC_LINK),1)
398*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_XNU_LIBRARY),1)
399*2c2f96dcSApple OSS Distributions
400*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_DIR)/lib$(KERNEL_FILE_NAME).a: $(TARGET)/lib$(KERNEL_FILE_NAME).a ALWAYS
401*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
402*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALL) "$(@F)"
403*2c2f96dcSApple OSS Distributions	$(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
404*2c2f96dcSApple OSS Distributions
405*2c2f96dcSApple OSS Distributionselse
406*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).a: $(TARGET)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).a ALWAYS
407*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
408*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALL) "$(@F)"
409*2c2f96dcSApple OSS Distributions	$(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
410*2c2f96dcSApple OSS Distributions
411*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).linkarguments: $(TARGET)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).linkarguments ALWAYS
412*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
413*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALL) "$(@F)"
414*2c2f96dcSApple OSS Distributions	$(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
415*2c2f96dcSApple OSS Distributions
416*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).linkarchives: $(TARGET)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).linkarchives ALWAYS
417*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
418*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALL) "$(@F)"
419*2c2f96dcSApple OSS Distributions	$(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
420*2c2f96dcSApple OSS Distributions
421*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).exp: $(TARGET)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).exp ALWAYS
422*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
423*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALL) "$(@F)"
424*2c2f96dcSApple OSS Distributions	$(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
425*2c2f96dcSApple OSS Distributions
426*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).alias.exp: $(TARGET)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).alias.exp ALWAYS
427*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
428*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALL) "$(@F)"
429*2c2f96dcSApple OSS Distributions	$(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
430*2c2f96dcSApple OSS Distributionsendif
431*2c2f96dcSApple OSS Distributions
432*2c2f96dcSApple OSS Distributions# BUILD_STATIC_LINK
433*2c2f96dcSApple OSS Distributionsendif
434*2c2f96dcSApple OSS Distributions
435*2c2f96dcSApple OSS Distributions$(SYMROOT)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME).unstripped ALWAYS
436*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
437*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALLSYM) "$(@F)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
438*2c2f96dcSApple OSS Distributions    # -nt and -ot are evaluated differently by bash, dash, and zsh (and are not part of the POSIX specification).
439*2c2f96dcSApple OSS Distributions    # Explicitly specify what should happen when the right hand file doesn't exist.
440*2c2f96dcSApple OSS Distributions	$(_v)if [ $(OBJROOT)/.mach_kernel.timestamp -nt $@ -o \( -e $(OBJROOT)/.mach_kernel.timestamp -a \! -e $@ \) ]; then		\
441*2c2f96dcSApple OSS Distributions		$(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@;				\
442*2c2f96dcSApple OSS Distributions		cmdstatus=$$?;							\
443*2c2f96dcSApple OSS Distributions	else									\
444*2c2f96dcSApple OSS Distributions		$(LIPO) -create $@ $< -output $@;				\
445*2c2f96dcSApple OSS Distributions		cmdstatus=$$?;							\
446*2c2f96dcSApple OSS Distributions	fi;									\
447*2c2f96dcSApple OSS Distributions	exit $$cmdstatus
448*2c2f96dcSApple OSS Distributions
449*2c2f96dcSApple OSS Distributions
450*2c2f96dcSApple OSS Distributions$(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros                                                                     \
451*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros                      \
452*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros:                                          \
453*2c2f96dcSApple OSS Distributions$(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros
454*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
455*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALLMACROS) "$(@F)$(Color0) $(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
456*2c2f96dcSApple OSS Distributions	$(_v)$(CP) -r $< $(dir $@)
457*2c2f96dcSApple OSS Distributions	$(_v)$(TOUCH) $@
458*2c2f96dcSApple OSS Distributions
459*2c2f96dcSApple OSS Distributions$(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME)                                                   \
460*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME).link/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME)    \
461*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME):                        \
462*2c2f96dcSApple OSS Distributions$(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME)
463*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
464*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALLMACROS) "$(@F)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
465*2c2f96dcSApple OSS Distributions	$(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
466*2c2f96dcSApple OSS Distributions
467*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(DEVELOPER_EXTRAS_DIR)/README.DEBUG-kernel.txt: $(SRCROOT)/config/README.DEBUG-kernel.txt
468*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
469*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALL) "$(@F)"
470*2c2f96dcSApple OSS Distributions	$(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
471*2c2f96dcSApple OSS Distributions
472*2c2f96dcSApple OSS Distributions$(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMINFODIR)/Info.plist $(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMINFODIR)/Info.plist: $(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMINFODIR)/Info.plist
473*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
474*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALLSYM) "$(ColorL)dSYM$(Color0) $(ColorF)$(@F)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
475*2c2f96dcSApple OSS Distributions	$(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
476*2c2f96dcSApple OSS Distributions
477*2c2f96dcSApple OSS Distributions$(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME) $(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME): $(TARGET)/$(KERNEL_FILE_NAME).dSYM/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME) ALWAYS
478*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(dir $@)
479*2c2f96dcSApple OSS Distributions	@$(LOG_INSTALLSYM) "$(ColorL)dSYM$(Color0) $(ColorF)$(@F).dSYM$(ColorF) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
480*2c2f96dcSApple OSS Distributions    # -nt and -ot are evaluated differently by bash, dash, and zsh (and are not part of the POSIX specification).
481*2c2f96dcSApple OSS Distributions    # Explicitly specify what should happen when the right hand file doesn't exist.
482*2c2f96dcSApple OSS Distributions	$(_v)if [ $(OBJROOT)/.mach_kernel.timestamp -nt $@ -o \( -e $(OBJROOT)/.mach_kernel.timestamp -a \! -e $@ \) ]; then			\
483*2c2f96dcSApple OSS Distributions		$(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@;					\
484*2c2f96dcSApple OSS Distributions		cmdstatus=$$?;								\
485*2c2f96dcSApple OSS Distributions	else										\
486*2c2f96dcSApple OSS Distributions		$(LIPO) -create $@ $< -output $@;					\
487*2c2f96dcSApple OSS Distributions		cmdstatus=$$?;								\
488*2c2f96dcSApple OSS Distributions	fi;										\
489*2c2f96dcSApple OSS Distributions	exit $$cmdstatus
490*2c2f96dcSApple OSS Distributions
491*2c2f96dcSApple OSS Distributions.PHONY: do_install_machine_specific_kernel do_install_machine_specific_kernel_dSYM
492*2c2f96dcSApple OSS Distributions.PHONY: do_install_machine_specific_KDK_dSYM
493*2c2f96dcSApple OSS Distributions
494*2c2f96dcSApple OSS Distributionsifeq ($(BUILD_XNU_LIBRARY),1)
495*2c2f96dcSApple OSS Distributions
496*2c2f96dcSApple OSS Distributionsdo_install_machine_specific_kernel: $(KERNEL_STATIC_LINK_DST)
497*2c2f96dcSApple OSS Distributions	@:
498*2c2f96dcSApple OSS Distributionsdo_install_machine_specific_kernel_dSYM:
499*2c2f96dcSApple OSS Distributions	@:
500*2c2f96dcSApple OSS Distributions
501*2c2f96dcSApple OSS Distributionselse
502*2c2f96dcSApple OSS Distributions
503*2c2f96dcSApple OSS Distributionsdo_install_machine_specific_kernel: $(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME)                \
504*2c2f96dcSApple OSS Distributions			$(SYMROOT)/$(KERNEL_FILE_NAME)                                                              \
505*2c2f96dcSApple OSS Distributions			$(KERNEL_STATIC_LINK_DST)
506*2c2f96dcSApple OSS Distributions	@:
507*2c2f96dcSApple OSS Distributions
508*2c2f96dcSApple OSS Distributionsdo_install_machine_specific_kernel_dSYM: \
509*2c2f96dcSApple OSS Distributions			$(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMINFODIR)/Info.plist \
510*2c2f96dcSApple OSS Distributions			$(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros \
511*2c2f96dcSApple OSS Distributions			$(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME) \
512*2c2f96dcSApple OSS Distributions			$(SYMROOT)/$(KERNEL_FILE_NAME).dSYM/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME)
513*2c2f96dcSApple OSS Distributions	@:
514*2c2f96dcSApple OSS Distributions
515*2c2f96dcSApple OSS Distributionsdo_install_machine_specific_KDK_dSYM: \
516*2c2f96dcSApple OSS Distributions			$(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMINFODIR)/Info.plist \
517*2c2f96dcSApple OSS Distributions			$(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/lldbmacros \
518*2c2f96dcSApple OSS Distributions			$(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMLLDBMACROSDIR)/$(KERNEL_LLDBBOOTSTRAP_NAME) \
519*2c2f96dcSApple OSS Distributions			$(DSTROOT)/$(INSTALL_KERNEL_SYM_DIR)/$(KERNEL_FILE_NAME).dSYM/$(DSYMDWARFDIR)/$(KERNEL_FILE_NAME)
520*2c2f96dcSApple OSS Distributions	@:
521*2c2f96dcSApple OSS Distributions
522*2c2f96dcSApple OSS Distributionsendif
523*2c2f96dcSApple OSS Distributions
524*2c2f96dcSApple OSS Distributions# The $(RM) is needed so that the $(LN) doesn't dereference an existing
525*2c2f96dcSApple OSS Distributions# symlink during incremental builds and create a new symlink inside
526*2c2f96dcSApple OSS Distributions# the target of the existing symlink
527*2c2f96dcSApple OSS Distributionsifneq ($(INSTALLHDRS_SKIP_HOST),YES)
528*2c2f96dcSApple OSS Distributionsdo_installhdrs_mi:: $(DSTROOT)/$(KRESDIR)/Info.plist
529*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(DSTROOT)/$(KINCFRAME)
530*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(DSTROOT)/$(KPINCDIR)
531*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(DSTROOT)/$(KRESDIR)
532*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(DSTROOT)/$(KLIBCXXINCDIR)
533*2c2f96dcSApple OSS Distributions	$(_v)$(RM) $(DSTROOT)/$(KINCFRAME)/Versions/Current
534*2c2f96dcSApple OSS Distributions	$(_v)$(LN) $(KINCVERS) $(DSTROOT)/$(KINCFRAME)/Versions/Current
535*2c2f96dcSApple OSS Distributions	$(_v)$(RM) $(DSTROOT)/$(KINCFRAME)/Headers
536*2c2f96dcSApple OSS Distributions	$(_v)$(LN) Versions/Current/Headers			\
537*2c2f96dcSApple OSS Distributions		   $(DSTROOT)/$(KINCFRAME)/Headers
538*2c2f96dcSApple OSS Distributions	$(_v)$(RM) $(DSTROOT)/$(KINCFRAME)/PrivateHeaders
539*2c2f96dcSApple OSS Distributions	$(_v)$(LN) Versions/Current/PrivateHeaders		\
540*2c2f96dcSApple OSS Distributions		   $(DSTROOT)/$(KINCFRAME)/PrivateHeaders
541*2c2f96dcSApple OSS Distributions	$(_v)$(RM) $(DSTROOT)/$(KINCFRAME)/Resources
542*2c2f96dcSApple OSS Distributions	$(_v)$(LN) Versions/Current/Resources			\
543*2c2f96dcSApple OSS Distributions		   $(DSTROOT)/$(KINCFRAME)/Resources
544*2c2f96dcSApple OSS Distributionsendif
545*2c2f96dcSApple OSS Distributions
546*2c2f96dcSApple OSS Distributionsifneq ($(INSTALLHDRS_SKIP_HOST),YES)
547*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(KRESDIR)/Info.plist: $(SOURCE)/EXTERNAL_HEADERS/Info.plist $(NEWVERS) $(XNU_VERSION)
548*2c2f96dcSApple OSS Distributions	$(_v)$(MKDIR) $(DSTROOT)/$(KRESDIR)
549*2c2f96dcSApple OSS Distributions	$(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
550*2c2f96dcSApple OSS Distributions	$(_v)$(NEWVERS) $@ $(_vstdout)
551*2c2f96dcSApple OSS Distributionsifeq ($(USE_BINARY_PLIST),1)
552*2c2f96dcSApple OSS Distributions	$(_v)$(PLUTIL) -convert binary1 -o $@ $@
553*2c2f96dcSApple OSS Distributionsendif
554*2c2f96dcSApple OSS Distributionsendif
555*2c2f96dcSApple OSS Distributions
556*2c2f96dcSApple OSS Distributions$(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(ALIAS_FILE_NAME): ALWAYS
557*2c2f96dcSApple OSS Distributions	@$(LOG_ALIAS) "$(@F)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0) $(ColorLF)$(CURRENT_MACHINE_CONFIG_LC)$(Color0) $(ColorLF)$(CURRENT_ALIAS_MACHINE_CONFIG_LC)$(Color0))"
558*2c2f96dcSApple OSS Distributions	$(_v)$(INSTALL) $(EXEC_INSTALL_FLAGS) $(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(KERNEL_FILE_NAME) $@
559*2c2f96dcSApple OSS Distributions
560*2c2f96dcSApple OSS Distributionsinstall_alias: $(DSTROOT)/$(INSTALL_KERNEL_DIR)/$(ALIAS_FILE_NAME)
561*2c2f96dcSApple OSS Distributions
562*2c2f96dcSApple OSS Distributionsprint_exports:
563*2c2f96dcSApple OSS Distributions	$(_v)printenv | sort
564*2c2f96dcSApple OSS Distributions
565*2c2f96dcSApple OSS Distributions# vim: set ft=make:
566