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