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