-build_symbol_sets: $(SYMBOL_SET_BUILD)
- $(_v)$(KEXT_CREATE_SYMBOL_SET) \
- $($(addsuffix $(ARCH_CONFIG),ARCH_FLAGS_)) \
- -import $(OBJPATH)/allsymbols \
- -export $(SRCROOT)/$(COMPONENT)/Libkern.exports \
- -export $(SRCROOT)/$(COMPONENT)/Libkern.$(ARCH_CONFIG_LC).exports \
- -export $(SRCROOT)/$(COMPONENT)/Mach.exports \
- -export $(SRCROOT)/$(COMPONENT)/Mach.$(ARCH_CONFIG_LC).exports \
- -export $(SRCROOT)/$(COMPONENT)/IOKit.exports \
- -export $(SRCROOT)/$(COMPONENT)/IOKit.$(ARCH_CONFIG_LC).exports \
- -export $(SRCROOT)/$(COMPONENT)/BSDKernel.exports \
- -export $(SRCROOT)/$(COMPONENT)/BSDKernel.$(ARCH_CONFIG_LC).exports \
- $(MACFRAMEWORKEXPORTS) \
- -export $(SRCROOT)/$(COMPONENT)/Unsupported.exports \
- -export $(SRCROOT)/$(COMPONENT)/Unsupported.$(ARCH_CONFIG_LC).exports \
- -output /dev/null;
-
-install_symbol_sets: $(SYMBOL_SET_FAT) $(SRCROOT)/config/MasterVersion
- $(_v)install $(INSTALL_FLAGS) $(OBJROOT)/System6.0.symbolset $(DSTROOT)/$(INSTALL_DATA_DIR)/System.kext/PlugIns/System6.0.kext/kernel.6.0;
- $(_v)install $(INSTALL_FLAGS) $(OBJROOT)/BSDKernel.symbolset $(DSTROOT)/$(INSTALL_DATA_DIR)/System.kext/PlugIns/BSDKernel.kext/BSDKernel;
-ifdef MAC
- $(_v)install $(INSTALL_FLAGS) $(OBJROOT)/MACFramework.symbolset $(DSTROOT)/$(INSTALL_DATA_DIR)/System.kext/PlugIns/MACFramework.kext/MACFramework;
+SYMBOL_SET_BUILD = $(foreach symbolset, $(SYMBOL_COMPONENT_LIST), $(OBJPATH)/$(symbolset).symbolset)
+SYMBOL_SET_PLIST_BUILD = $(foreach symbolset, $(SYMBOL_SET_PLIST_COMPONENT_LIST), $(OBJPATH)/$(symbolset).symbolset.plist)
+
+define symbol_set_rule
+$(1)_EXPORTS := $(addprefix $(SOURCE)/,$(filter $(1)%,$(EXPORTS_FILES)))
+$(OBJPATH)/$(1).symbolset: MY_EXPORTS_ARGS := $$(foreach file,$$($(1)_EXPORTS),-export $$(file))
+$(OBJPATH)/$(1).symbolset: $$($(1)_EXPORTS) $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET)
+ @$$(LOG_SYMBOLSET) "$(ColorF)$(1)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
+ $(_v)$(KEXT_CREATE_SYMBOL_SET) \
+ $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
+ -import $(OBJPATH)/allsymbols \
+ $$(MY_EXPORTS_ARGS) \
+ -output $$@ $(_vstdout)
+endef
+
+define symbol_set_plist_rule
+$(1)_KEXT_PLIST := $$(filter %/$(1).kext/Info.plist,$$(SYMROOT_INSTALL_KEXT_PLISTS))
+$(OBJPATH)/$(1).symbolset.plist: $$($(1)_KEXT_PLIST) $$($(1)_EXPORTS)
+ @$$(LOG_SYMBOLSETPLIST) "$(ColorF)$(1)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
+ $(_v)$(SOURCE)/generate_symbolset_plist.sh $$@ $$+ $(_vstdout)
+ $(_v)$(PLUTIL) -lint -s $$@
+endef
+
+$(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(eval $(call symbol_set_rule,$(symbolset))))
+$(foreach symbolset,$(SYMBOL_SET_PLIST_COMPONENT_LIST),$(eval $(call symbol_set_plist_rule,$(symbolset))))
+
+$(OBJPATH)/symbolsets.plist: $(SYMBOL_SET_PLIST_BUILD)
+ $(_v)$(SOURCE)/generate_combined_symbolsets_plist.sh $@ $^ $(_vstdout)
+ $(_v)$(PLUTIL) -convert binary1 -s $@
+
+$(OBJPATH)/allsymbols: $(OBJPATH)/$(KERNEL_FILE_NAME)
+ $(_v)$(NM) -gj $< | sort -u > $@
+
+.PHONY: check_all_exports
+
+check_all_exports: $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET)
+ $(_v)$(KEXT_CREATE_SYMBOL_SET) \
+ $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
+ -import $(OBJPATH)/allsymbols \
+ $(foreach symbolset,$(filter-out Private,$(SYMBOL_COMPONENT_LIST)), \
+ -export $(SOURCE)/$(symbolset).exports \
+ -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
+ -output /dev/null $(_vstdout)
+ $(_v)$(KEXT_CREATE_SYMBOL_SET) \
+ $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
+ -import $(OBJPATH)/allsymbols \
+ $(foreach symbolset,$(filter-out Unsupported,$(SYMBOL_COMPONENT_LIST)), \
+ -export $(SOURCE)/$(symbolset).exports \
+ -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
+ -output /dev/null $(_vstdout)
+
+$(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
+ @$(LOG_SUPPORTED_KPI) "$(CURRENT_ARCH_CONFIG_LC)"
+ $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) $(EXPORT_SOURCE_ARCH_CONFIG_LC) $@
+
+$(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
+ @$(LOG_SUPPORTED_KPI) "all"
+ $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) all $@
+
+build_symbol_sets: check_all_exports $(SYMBOL_SET_BUILD) $(OBJPATH)/allsymbols \
+ $(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME) \
+ $(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME)
+
+do_config_all:: build_symbol_sets
+
+# There's no simple static pattern rule for these paths, so hardcode dependencies in the command list
+$(SYMROOT_INSTALL_KEXT_MACHO_FILES): ALWAYS
+ $(_v)$(MKDIR) $(dir $@)
+ @$(LOG_INSTALLSYM) "symbolset $(notdir $@)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
+ $(_v)if [ $(OBJROOT)/.symbolset.timestamp -nt $@ ]; then \
+ $(INSTALL) $(EXEC_INSTALL_FLAGS) $(OBJPATH)/$(@F).symbolset $@; \
+ cmdstatus=$$?; \
+ else \
+ $(LIPO) -create $@ $(OBJPATH)/$(@F).symbolset -output $@ 2>/dev/null || true; \
+ cmdstatus=$$?; \
+ fi; \
+ exit $$cmdstatus
+
+$(SYMROOT_INSTALL_KEXT_PLISTS): $(SYMROOT)/% : $(SOURCE)/%
+ $(_v)$(MKDIR) $(dir $@)
+ @$(LOG_INSTALLSYM) "kextplist$(Color0) $(ColorF)$*"
+ $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
+ $(_v)$(NEWVERS) $@ $(_vstdout)
+
+$(DSTROOT_INSTALL_KEXT_PLISTS): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/%
+ $(_v)$(MKDIR) $(dir $@)
+ @$(LOG_INSTALLSYM) "kextplist$(Color0) $(ColorF)$*"
+ $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
+
+$(DSTROOT_INSTALL_KEXT_MACHO_FILES): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/% ALWAYS
+ $(_v)$(MKDIR) $(dir $@)
+ @$(LOG_INSTALL) "$(notdir $@)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
+ $(_v)$(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@
+
+$(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME): $(DSTROOT)/$(KRESDIR)/% : $(OBJPATH)/%
+ $(_v)$(MKDIR) $(dir $@)
+ @$(LOG_INSTALL) "$*"
+ $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
+
+ifneq ($(INSTALL_KASAN_ONLY),1)
+do_config_install:: $(SYMROOT_INSTALL_KEXT_MACHO_FILES) \
+ $(SYMROOT_INSTALL_KEXT_PLISTS) \
+ $(DSTROOT_INSTALL_KEXT_MACHO_FILES) \
+ $(DSTROOT_INSTALL_KEXT_PLISTS) \
+ $(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) \
+ $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME)