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