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