1*fdd8201dSApple OSS Distributionsexport MakeInc_cmd=${SRCROOT}/makedefs/MakeInc.cmd 2*fdd8201dSApple OSS Distributionsexport MakeInc_def=${SRCROOT}/makedefs/MakeInc.def 3*fdd8201dSApple OSS Distributionsexport MakeInc_rule=${SRCROOT}/makedefs/MakeInc.rule 4*fdd8201dSApple OSS Distributionsexport MakeInc_dir=${SRCROOT}/makedefs/MakeInc.dir 5*fdd8201dSApple OSS Distributions 6*fdd8201dSApple OSS Distributionsinclude $(MakeInc_cmd) 7*fdd8201dSApple OSS Distributionsinclude $(MakeInc_def) 8*fdd8201dSApple OSS Distributions 9*fdd8201dSApple OSS Distributions# config is not a COMPONENT but we still want to build most files in a TARGET subdir 10*fdd8201dSApple OSS Distributionsoverride TARGET := $(OBJPATH)/config 11*fdd8201dSApple OSS Distributions 12*fdd8201dSApple OSS DistributionsMD_SUPPORTED_KPI_FILENAME := SupportedKPIs-${CURRENT_ARCH_CONFIG_LC}.txt 13*fdd8201dSApple OSS DistributionsMI_SUPPORTED_KPI_FILENAME := SupportedKPIs-all-archs.txt 14*fdd8201dSApple OSS Distributions 15*fdd8201dSApple OSS DistributionsINSTALL_KEXT_DIR = $(DSTROOT)$(INSTALL_EXTENSIONS_DIR) 16*fdd8201dSApple OSS Distributions 17*fdd8201dSApple OSS DistributionsKEXT_PLIST_LIST := \ 18*fdd8201dSApple OSS Distributions System.kext/Info.plist \ 19*fdd8201dSApple OSS Distributions System.kext/PlugIns/Kasan.kext/Info.plist \ 20*fdd8201dSApple OSS Distributions System.kext/PlugIns/Kcov.kext/Info.plist \ 21*fdd8201dSApple OSS Distributions System.kext/PlugIns/AppleNMI.kext/Info.plist \ 22*fdd8201dSApple OSS Distributions System.kext/PlugIns/ApplePlatformFamily.kext/Info.plist \ 23*fdd8201dSApple OSS Distributions System.kext/PlugIns/IONVRAMFamily.kext/Info.plist \ 24*fdd8201dSApple OSS Distributions System.kext/PlugIns/IOSystemManagement.kext/Info.plist 25*fdd8201dSApple OSS Distributions 26*fdd8201dSApple OSS DistributionsSYMBOL_COMPONENT_LIST := \ 27*fdd8201dSApple OSS Distributions BSDKernel \ 28*fdd8201dSApple OSS Distributions IOKit \ 29*fdd8201dSApple OSS Distributions Libkern \ 30*fdd8201dSApple OSS Distributions Mach \ 31*fdd8201dSApple OSS Distributions MACFramework \ 32*fdd8201dSApple OSS Distributions Unsupported \ 33*fdd8201dSApple OSS Distributions Private 34*fdd8201dSApple OSS Distributions 35*fdd8201dSApple OSS DistributionsSYMBOL_SET_PLIST_COMPONENT_LIST := $(SYMBOL_COMPONENT_LIST) Kasan Kcov 36*fdd8201dSApple OSS Distributions 37*fdd8201dSApple OSS DistributionsKEXT_PLIST_LIST += $(foreach symbolset,$(SYMBOL_COMPONENT_LIST),System.kext/PlugIns/$(symbolset).kext/Info.plist) 38*fdd8201dSApple OSS Distributions 39*fdd8201dSApple OSS Distributions# In general you want it to be possible to have a CPU sub-type's symbol exports 40*fdd8201dSApple OSS Distributions# alias to the parent type's exports. This is a special-case way to handle it 41*fdd8201dSApple OSS Distributions# for now: 42*fdd8201dSApple OSS Distributionsifeq ($(CURRENT_ARCH_CONFIG_LC),x86_64h) 43*fdd8201dSApple OSS DistributionsEXPORT_SOURCE_ARCH_CONFIG_LC := x86_64 44*fdd8201dSApple OSS Distributionselse 45*fdd8201dSApple OSS DistributionsEXPORT_SOURCE_ARCH_CONFIG_LC := $(CURRENT_ARCH_CONFIG_LC) 46*fdd8201dSApple OSS Distributionsendif 47*fdd8201dSApple OSS Distributions 48*fdd8201dSApple OSS DistributionsEXPORTS_FILES := $(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(symbolset).exports \ 49*fdd8201dSApple OSS Distributions $(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports \ 50*fdd8201dSApple OSS Distributions $(notdir $(wildcard $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).$(PLATFORM).exports))) \ 51*fdd8201dSApple OSS Distributions Unused.exports 52*fdd8201dSApple OSS Distributions 53*fdd8201dSApple OSS DistributionsKasan_EXPORTS := $(SRCROOT)/config/Kasan_disabled.exports 54*fdd8201dSApple OSS DistributionsKcov_EXPORTS := $(SRCROOT)/config/Kcov_disabled.exports 55*fdd8201dSApple OSS Distributions 56*fdd8201dSApple OSS Distributionsifneq ($(filter $(CURRENT_KERNEL_CONFIG),$(KCOV_RUNTIME)),) 57*fdd8201dSApple OSS DistributionsKcov_EXPORTS := $(SRCROOT)/config/Kcov_enabled.exports 58*fdd8201dSApple OSS Distributionsendif 59*fdd8201dSApple OSS Distributions 60*fdd8201dSApple OSS Distributionsifeq ($(KASAN),1) 61*fdd8201dSApple OSS DistributionsKasan_EXPORTS := $(SRCROOT)/config/Kasan_enabled.exports 62*fdd8201dSApple OSS Distributionsendif 63*fdd8201dSApple OSS Distributions 64*fdd8201dSApple OSS Distributionsdefine symbol_set_template 65*fdd8201dSApple OSS Distributions$(1)_EXPORTS := $$(addprefix $$(SOURCE)/,$$(filter $(1)%,$$(EXPORTS_FILES))) 66*fdd8201dSApple OSS Distributions$$(TARGET)/$(1).symbolset: MY_EXPORTS_ARGS := $$(foreach file,$$($(1)_EXPORTS),-export $$(file)) 67*fdd8201dSApple OSS Distributions$$(TARGET)/$(1).symbolset: $$($(1)_EXPORTS) $$(TARGET)/allsymbols $$(KEXT_CREATE_SYMBOL_SET) 68*fdd8201dSApple OSS Distributions @$$(LOG_SYMBOLSET) "$(1)$$(Color0) ($$(ColorLF)$$(CURRENT_ARCH_CONFIG_LC)$$(Color0))" 69*fdd8201dSApple OSS Distributions $$(_v)$$(KEXT_CREATE_SYMBOL_SET) \ 70*fdd8201dSApple OSS Distributions $$(ARCH_FLAGS_$$(CURRENT_ARCH_CONFIG)) \ 71*fdd8201dSApple OSS Distributions -import $$(TARGET)/allsymbols \ 72*fdd8201dSApple OSS Distributions $$(MY_EXPORTS_ARGS) \ 73*fdd8201dSApple OSS Distributions -output $$@ $$(_vstdout) 74*fdd8201dSApple OSS Distributions 75*fdd8201dSApple OSS DistributionsSYMBOL_SET_BUILD += $$(TARGET)/$(1).symbolset 76*fdd8201dSApple OSS Distributionsendef 77*fdd8201dSApple OSS Distributions 78*fdd8201dSApple OSS Distributions# Each parallel invocation of this target must use a distinct location, as it is 79*fdd8201dSApple OSS Distributions# not safe to call multiple NEWVERS on the same file concurrently (rdar://66173684) 80*fdd8201dSApple OSS Distributionsdefine kext_plist_template 81*fdd8201dSApple OSS Distributions$$(TARGET)/$(1): $$(SOURCE)/$(1) $$(NEWVERS) $$(SRCROOT)/config/MasterVersion 82*fdd8201dSApple OSS Distributions @$$(LOG_GENERATE) "$(1)" 83*fdd8201dSApple OSS Distributions $$(_v)$$(MKDIR) $$(@D) 84*fdd8201dSApple OSS Distributions $$(_v)$$(CP) $$< $$@ 85*fdd8201dSApple OSS Distributions $$(_v)$$(NEWVERS) $$@ > /dev/null 86*fdd8201dSApple OSS Distributions 87*fdd8201dSApple OSS DistributionsKEXT_PLIST_BUILD += $$(TARGET)/$(1) 88*fdd8201dSApple OSS DistributionsSYMROOT_INSTALL_KEXT_PLISTS += $$(SYMROOT)/$(1) 89*fdd8201dSApple OSS DistributionsDSTROOT_INSTALL_KEXT_PLISTS += $$(INSTALL_KEXT_DIR)/$(1) 90*fdd8201dSApple OSS Distributionsendef 91*fdd8201dSApple OSS Distributions 92*fdd8201dSApple OSS Distributionsdefine symbol_set_plist_template 93*fdd8201dSApple OSS Distributions$(1)_KEXT_PLIST := $$(filter %/$(1).kext/Info.plist,$$(KEXT_PLIST_LIST)) 94*fdd8201dSApple OSS Distributions$$(TARGET)/$(1).symbolset.plist: $$(TARGET)/$$($(1)_KEXT_PLIST) $$($(1)_EXPORTS) 95*fdd8201dSApple OSS Distributions @$$(LOG_SYMBOLSETPLIST) "$(1)$$(Color0) ($$(ColorLF)$$(CURRENT_ARCH_CONFIG_LC)$$(Color0))" 96*fdd8201dSApple OSS Distributions $$(_v)$$(SOURCE)/generate_symbolset_plist.sh $$@ $$+ $$(_vstdout) 97*fdd8201dSApple OSS Distributions $$(_v)$$(PLUTIL) -lint -s $$@ 98*fdd8201dSApple OSS Distributions 99*fdd8201dSApple OSS DistributionsSYMBOL_SET_PLIST_BUILD += $$(TARGET)/$(1).symbolset.plist 100*fdd8201dSApple OSS Distributionsendef 101*fdd8201dSApple OSS Distributions 102*fdd8201dSApple OSS Distributions$(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(eval $(call symbol_set_template,$(symbolset)))) 103*fdd8201dSApple OSS Distributions$(foreach plist,$(KEXT_PLIST_LIST),$(eval $(call kext_plist_template,$(plist)))) 104*fdd8201dSApple OSS Distributions$(foreach symbolset,$(SYMBOL_SET_PLIST_COMPONENT_LIST),$(eval $(call symbol_set_plist_template,$(symbolset)))) 105*fdd8201dSApple OSS Distributions 106*fdd8201dSApple OSS Distributions$(OBJPATH)/symbolsets.plist: $(SYMBOL_SET_PLIST_BUILD) 107*fdd8201dSApple OSS Distributions $(_v)$(SOURCE)/generate_combined_symbolsets_plist.sh $@ $^ $(_vstdout) 108*fdd8201dSApple OSS Distributions $(_v)$(PLUTIL) -convert binary1 -s $@ 109*fdd8201dSApple OSS Distributions 110*fdd8201dSApple OSS Distributionsbuild_symbol_set_plists: $(KEXT_PLIST_BUILD) $(OBJPATH)/symbolsets.plist 111*fdd8201dSApple OSS Distributions 112*fdd8201dSApple OSS Distributions$(TARGET)/allsymbols: $(OBJPATH)/$(KERNEL_FILE_NAME) 113*fdd8201dSApple OSS Distributions $(_v)$(NM) -gj $< | sort -u > $@ 114*fdd8201dSApple OSS Distributions 115*fdd8201dSApple OSS Distributionscheck_all_exports: $(TARGET)/allsymbols $(KEXT_CREATE_SYMBOL_SET) 116*fdd8201dSApple OSS Distributions $(_v)$(KEXT_CREATE_SYMBOL_SET) \ 117*fdd8201dSApple OSS Distributions $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \ 118*fdd8201dSApple OSS Distributions -import $(TARGET)/allsymbols \ 119*fdd8201dSApple OSS Distributions $(foreach symbolset,$(filter-out Private,$(SYMBOL_COMPONENT_LIST)), \ 120*fdd8201dSApple OSS Distributions -export $(SOURCE)/$(symbolset).exports \ 121*fdd8201dSApple OSS Distributions -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \ 122*fdd8201dSApple OSS Distributions -output /dev/null $(_vstdout) 123*fdd8201dSApple OSS Distributions $(_v)$(KEXT_CREATE_SYMBOL_SET) \ 124*fdd8201dSApple OSS Distributions $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \ 125*fdd8201dSApple OSS Distributions -import $(TARGET)/allsymbols \ 126*fdd8201dSApple OSS Distributions $(foreach symbolset,$(filter-out Unsupported,$(SYMBOL_COMPONENT_LIST)), \ 127*fdd8201dSApple OSS Distributions -export $(SOURCE)/$(symbolset).exports \ 128*fdd8201dSApple OSS Distributions -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \ 129*fdd8201dSApple OSS Distributions -output /dev/null $(_vstdout) 130*fdd8201dSApple OSS Distributions 131*fdd8201dSApple OSS Distributions$(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES) 132*fdd8201dSApple OSS Distributions @$(LOG_SUPPORTED_KPI) "$(CURRENT_ARCH_CONFIG_LC)" 133*fdd8201dSApple OSS Distributions $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) $(EXPORT_SOURCE_ARCH_CONFIG_LC) $@ 134*fdd8201dSApple OSS Distributions 135*fdd8201dSApple OSS Distributions$(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES) 136*fdd8201dSApple OSS Distributions @$(LOG_SUPPORTED_KPI) "all" 137*fdd8201dSApple OSS Distributions $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) all $@ 138*fdd8201dSApple OSS Distributions 139*fdd8201dSApple OSS Distributionsbuild_symbol_sets: check_all_exports $(SYMBOL_SET_BUILD) $(TARGET)/allsymbols \ 140*fdd8201dSApple OSS Distributions $(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME) \ 141*fdd8201dSApple OSS Distributions $(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME) 142*fdd8201dSApple OSS Distributions 143*fdd8201dSApple OSS Distributions# Generate rules for symroot fat kexts with dependencies on every corresponding symbolset for each build config. 144*fdd8201dSApple OSS Distributions# This target must only run from do_config_install for a single build config after the do_config_all phases for 145*fdd8201dSApple OSS Distributions# all build configs have completed. This ensures every unique slice built by any config is pulled into the fat 146*fdd8201dSApple OSS Distributions# symbolset kext (note that not all slices are reflected as distinct xnu build config ARCHS!) (rdar://70703349) 147*fdd8201dSApple OSS Distributionsdefine symroot_symbol_set_template 148*fdd8201dSApple OSS Distributions$$(SYMROOT_SYSTEM_KEXT_PATH)/$(1).kext/$(1): $$(addsuffix /config/$(1).symbolset, \ 149*fdd8201dSApple OSS Distributions $$(addprefix $$(OBJROOT)/,$$(foreach bc,$(BUILD_CONFIGS),$$(call function_convert_build_config_to_objdir,$$(bc))))) 150*fdd8201dSApple OSS Distributions @$$(LOG_INSTALLSYM) "$$(Color0)symbolset $$(ColorF)$(1)" 151*fdd8201dSApple OSS Distributions $$(_v)$$(MKDIR) $$(@D) 152*fdd8201dSApple OSS Distributions $$(_v)$$(LIPO) -create `(echo $$^ | xargs -L 1 lipo -detailed_info) | \ 153*fdd8201dSApple OSS Distributions awk '/is architecture/ {s[$$$$6]=$$$$3} END {for (a in s) {print s[a]}}'` -output $$@ $$(_vstdout) 154*fdd8201dSApple OSS Distributions 155*fdd8201dSApple OSS DistributionsSYMROOT_INSTALL_KEXT_MACHO_FILES += $$(SYMROOT_SYSTEM_KEXT_PATH)/$(1).kext/$(1) 156*fdd8201dSApple OSS DistributionsDSTROOT_INSTALL_KEXT_MACHO_FILES += $$(DSTROOT_SYSTEM_KEXT_PATH)/$(1).kext/$(1) 157*fdd8201dSApple OSS Distributionsendef 158*fdd8201dSApple OSS Distributions$(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(eval $(call symroot_symbol_set_template,$(symbolset)))) 159*fdd8201dSApple OSS Distributions 160*fdd8201dSApple OSS Distributions$(SYMROOT_INSTALL_KEXT_PLISTS): $(SYMROOT)/% : $(TARGET)/% 161*fdd8201dSApple OSS Distributions $(_v)$(MKDIR) $(@D) 162*fdd8201dSApple OSS Distributions @$(LOG_INSTALLSYM) "$(Color0)kextplist $(ColorF)$*" 163*fdd8201dSApple OSS Distributions $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@ 164*fdd8201dSApple OSS Distributions 165*fdd8201dSApple OSS Distributions$(DSTROOT_INSTALL_KEXT_PLISTS): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/% 166*fdd8201dSApple OSS Distributions $(_v)$(MKDIR) $(@D) 167*fdd8201dSApple OSS Distributions @$(LOG_INSTALL) "$(Color0)kextplist $(ColorF)$*" 168*fdd8201dSApple OSS Distributions $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@ 169*fdd8201dSApple OSS Distributions 170*fdd8201dSApple OSS Distributions$(DSTROOT_INSTALL_KEXT_MACHO_FILES): $(DSTROOT_SYSTEM_KEXT_PATH)/% : $(SYMROOT_SYSTEM_KEXT_PATH)/% 171*fdd8201dSApple OSS Distributions $(_v)$(MKDIR) $(@D) 172*fdd8201dSApple OSS Distributions @$(LOG_INSTALL) "$(Color0)symbolset $(ColorF)$(@F)" 173*fdd8201dSApple OSS Distributions $(_v)$(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@ 174*fdd8201dSApple OSS Distributions 175*fdd8201dSApple OSS Distributions$(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME): $(DSTROOT)/$(KRESDIR)/% : $(OBJPATH)/% 176*fdd8201dSApple OSS Distributions $(_v)$(MKDIR) $(@D) 177*fdd8201dSApple OSS Distributions @$(LOG_INSTALL) "$*" 178*fdd8201dSApple OSS Distributions $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@ 179*fdd8201dSApple OSS Distributions 180*fdd8201dSApple OSS Distributionsifneq ($(RC_ProjectName),xnu_libraries) 181*fdd8201dSApple OSS Distributions 182*fdd8201dSApple OSS Distributionsdo_build_all:: build_symbol_set_plists 183*fdd8201dSApple OSS Distributionsdo_config_all:: build_symbol_sets 184*fdd8201dSApple OSS Distributions 185*fdd8201dSApple OSS Distributionsifneq ($(INSTALL_KASAN_ONLY),1) 186*fdd8201dSApple OSS Distributions 187*fdd8201dSApple OSS Distributionsdo_config_install_primary:: \ 188*fdd8201dSApple OSS Distributions $(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) 189*fdd8201dSApple OSS Distributions 190*fdd8201dSApple OSS Distributionsdo_config_install:: \ 191*fdd8201dSApple OSS Distributions $(SYMROOT_INSTALL_KEXT_MACHO_FILES) \ 192*fdd8201dSApple OSS Distributions $(SYMROOT_INSTALL_KEXT_PLISTS) \ 193*fdd8201dSApple OSS Distributions $(DSTROOT_INSTALL_KEXT_MACHO_FILES) \ 194*fdd8201dSApple OSS Distributions $(DSTROOT_INSTALL_KEXT_PLISTS) \ 195*fdd8201dSApple OSS Distributions $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME) 196*fdd8201dSApple OSS Distributionsendif 197*fdd8201dSApple OSS Distributions 198*fdd8201dSApple OSS Distributionselse 199*fdd8201dSApple OSS Distributions# We are building XNU as a static library - avoid creating symbol sets 200*fdd8201dSApple OSS Distributionsendif 201*fdd8201dSApple OSS Distributions 202*fdd8201dSApple OSS Distributions$(OBJPATH)/all-kpi.exp: $(EXPORTS_FILES) 203*fdd8201dSApple OSS Distributions $(_v)$(SOURCE)/generate_linker_exports.sh $@ $+ $(Kasan_EXPORTS) $(Kcov_EXPORTS) 204*fdd8201dSApple OSS Distributions 205*fdd8201dSApple OSS Distributions$(OBJPATH)/all-alias.exp: $(EXPORTS_FILES) 206*fdd8201dSApple OSS Distributions $(_v)$(SOURCE)/generate_linker_aliases.sh $@ $+ $(Kasan_EXPORTS) $(Kcov_EXPORTS) 207*fdd8201dSApple OSS Distributions 208*fdd8201dSApple OSS Distributionsdo_build_all:: $(OBJPATH)/all-kpi.exp $(OBJPATH)/all-alias.exp 209*fdd8201dSApple OSS Distributions 210*fdd8201dSApple OSS Distributionsinclude $(MakeInc_rule) 211*fdd8201dSApple OSS Distributionsinclude $(MakeInc_dir) 212*fdd8201dSApple OSS Distributions 213*fdd8201dSApple OSS Distributions.PHONY: build_symbol_set_plists build_symbol_sets check_all_exports 214