1 export MakeInc_cmd=${SRCROOT}/makedefs/MakeInc.cmd
2 export MakeInc_def=${SRCROOT}/makedefs/MakeInc.def
3 export MakeInc_rule=${SRCROOT}/makedefs/MakeInc.rule
4 export MakeInc_dir=${SRCROOT}/makedefs/MakeInc.dir
9 MD_SUPPORTED_KPI_FILENAME = SupportedKPIs-${CURRENT_ARCH_CONFIG_LC}.txt
10 MI_SUPPORTED_KPI_FILENAME = SupportedKPIs-all-archs.txt
12 INSTALL_KEXT_DIR = $(DSTROOT)$(INSTALL_EXTENSIONS_DIR)
15 System.kext/Info.plist \
16 System.kext/PlugIns/Kasan.kext/Info.plist \
17 System.kext/PlugIns/AppleNMI.kext/Info.plist \
18 System.kext/PlugIns/ApplePlatformFamily.kext/Info.plist \
19 System.kext/PlugIns/IONVRAMFamily.kext/Info.plist \
20 System.kext/PlugIns/IOSystemManagement.kext/Info.plist
22 SYMBOL_COMPONENT_LIST = \
31 # In general you want it to be possible to have a CPU sub-type's symbol exports
32 # alias to the parent type's exports. This is a special-case way to handle it
34 ifeq ($(CURRENT_ARCH_CONFIG_LC),x86_64h)
35 EXPORT_SOURCE_ARCH_CONFIG_LC = x86_64
37 EXPORT_SOURCE_ARCH_CONFIG_LC = $(CURRENT_ARCH_CONFIG_LC)
40 KEXT_MACHO_LIST = $(foreach symbolset,$(filter-out Dummy,$(SYMBOL_COMPONENT_LIST)),System.kext/PlugIns/$(symbolset).kext/$(symbolset))
41 KEXT_PLIST_LIST += $(foreach symbolset,$(filter-out Dummy,$(SYMBOL_COMPONENT_LIST)),System.kext/PlugIns/$(symbolset).kext/Info.plist)
43 SYMROOT_INSTALL_KEXT_MACHO_FILES = $(addprefix $(SYMROOT)/,$(KEXT_MACHO_LIST))
44 DSTROOT_INSTALL_KEXT_MACHO_FILES = $(addprefix $(INSTALL_KEXT_DIR)/,$(KEXT_MACHO_LIST))
46 SYMROOT_INSTALL_KEXT_PLISTS = $(addprefix $(SYMROOT)/,$(KEXT_PLIST_LIST))
47 DSTROOT_INSTALL_KEXT_PLISTS = $(addprefix $(INSTALL_KEXT_DIR)/,$(KEXT_PLIST_LIST))
49 EXPORTS_FILES = $(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(symbolset).exports $(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) Unused.exports
51 SYMBOL_SET_BUILD = $(foreach symbolset, $(SYMBOL_COMPONENT_LIST), $(OBJPATH)/$(symbolset).symbolset)
54 KASAN_EXPORTS = $(SRCROOT)/san/Kasan_kasan.exports
57 $(OBJPATH)/allsymbols: $(OBJPATH)/$(KERNEL_FILE_NAME)
58 $(_v)$(NM) -gj $< > $@
60 $(SYMBOL_SET_BUILD): $(OBJPATH)/%.symbolset : %.exports %.$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET)
61 @echo "$(ColorH)SYMBOLSET$(Color0) $(ColorF)$*$(Color0) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))\""
62 $(_v)$(KEXT_CREATE_SYMBOL_SET) \
63 $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
64 -import $(OBJPATH)/allsymbols \
65 -export $(SOURCE)/$*.exports \
66 -export $(SOURCE)/$*.$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports \
67 -output $@ $(_vstdout)
69 .PHONY: check_all_exports
71 check_all_exports: $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET)
72 $(_v)$(KEXT_CREATE_SYMBOL_SET) \
73 $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
74 -import $(OBJPATH)/allsymbols \
75 $(foreach symbolset,$(filter-out Private,$(SYMBOL_COMPONENT_LIST)), \
76 -export $(SOURCE)/$(symbolset).exports \
77 -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
78 -output /dev/null $(_vstdout)
79 $(_v)$(KEXT_CREATE_SYMBOL_SET) \
80 $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
81 -import $(OBJPATH)/allsymbols \
82 $(foreach symbolset,$(filter-out Unsupported,$(SYMBOL_COMPONENT_LIST)), \
83 -export $(SOURCE)/$(symbolset).exports \
84 -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
85 -output /dev/null $(_vstdout)
87 $(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
88 @echo "$(ColorH)SUPPORTED_KPI$(Color0) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))\""
89 $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) $(EXPORT_SOURCE_ARCH_CONFIG_LC) $@
91 $(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
92 @echo "$(ColorH)SUPPORTED_KPI$(Color0) \"($(ColorLF)all$(Color0))\""
93 $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) all $@
95 build_symbol_sets: check_all_exports $(SYMBOL_SET_BUILD) $(OBJPATH)/allsymbols \
96 $(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME) \
97 $(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME)
99 do_config_all:: build_symbol_sets
101 # There's no simple static pattern rule for these paths, so hardcode dependencies in the command list
102 $(SYMROOT_INSTALL_KEXT_MACHO_FILES): ALWAYS
103 $(_v)$(MKDIR) $(dir $@)
104 $(_v)if [ $(OBJROOT)/.symbolset.timestamp -nt $@ ]; then \
105 echo INSTALLSYM symbolset $(notdir $@) "($(CURRENT_ARCH_CONFIG_LC))"; \
106 $(INSTALL) $(EXEC_INSTALL_FLAGS) $(OBJPATH)/$(@F).symbolset $@; \
109 echo INSTALLSYM symbolset $(notdir $@) "($(CURRENT_ARCH_CONFIG_LC))"; \
110 $(LIPO) -create $@ $(OBJPATH)/$(@F).symbolset -output $@ 2>/dev/null || true; \
115 $(SYMROOT_INSTALL_KEXT_PLISTS): $(SYMROOT)/% : $(SOURCE)/%
116 $(_v)$(MKDIR) $(dir $@)
117 @echo "$(ColorH)INSTALLSYM$(ColorH) $(ColorLF)kextplist$(Color0) $(ColorF)$*$(Color0)"
118 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
119 $(_v)$(NEWVERS) $@ $(_vstdout)
121 $(DSTROOT_INSTALL_KEXT_PLISTS): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/%
122 $(_v)$(MKDIR) $(dir $@)
123 @echo "$(ColorH)INSTALL$(ColorH) $(ColorLF)kextplist$(Color0) $(ColorF)$*$(Color0)"
124 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
126 $(DSTROOT_INSTALL_KEXT_MACHO_FILES): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/% ALWAYS
127 $(_v)$(MKDIR) $(dir $@)
128 @echo "$(ColorF)INSTALL$(Color0) $(ColorF)$(notdir $@)$(Color0) \"($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))\""
129 $(_v)$(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@
131 $(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME): $(DSTROOT)/$(KRESDIR)/% : $(OBJPATH)/%
132 $(_v)$(MKDIR) $(dir $@)
133 @echo "$(ColorH)INSTALL$(Color0) $(ColorF)$*$(Color0)"
134 $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
136 ifneq ($(INSTALL_KASAN_ONLY),1)
137 do_config_install:: $(SYMROOT_INSTALL_KEXT_MACHO_FILES) \
138 $(SYMROOT_INSTALL_KEXT_PLISTS) \
139 $(DSTROOT_INSTALL_KEXT_MACHO_FILES) \
140 $(DSTROOT_INSTALL_KEXT_PLISTS) \
141 $(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) \
142 $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME)
146 $(OBJPATH)/all-kpi.exp: $(EXPORTS_FILES)
147 $(_v)$(SOURCE)/generate_linker_exports.sh $@ $+ $(KASAN_EXPORTS)
149 $(OBJPATH)/all-alias.exp: $(EXPORTS_FILES)
150 $(_v)$(SOURCE)/generate_linker_aliases.sh $@ $+ $(KASAN_EXPORTS)
152 do_build_all:: $(OBJPATH)/all-kpi.exp $(OBJPATH)/all-alias.exp
154 include $(MakeInc_rule)
155 include $(MakeInc_dir)