]>
Commit | Line | Data |
---|---|---|
d7e50217 A |
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 | |
5 | ||
d7e50217 A |
6 | include $(MakeInc_cmd) |
7 | include $(MakeInc_def) | |
8 | ||
39236c6e A |
9 | MD_SUPPORTED_KPI_FILENAME = SupportedKPIs-${CURRENT_ARCH_CONFIG_LC}.txt |
10 | MI_SUPPORTED_KPI_FILENAME = SupportedKPIs-all-archs.txt | |
d7e50217 | 11 | |
39236c6e | 12 | INSTALL_KEXT_DIR = $(DSTROOT)$(INSTALL_EXTENSIONS_DIR) |
d7e50217 | 13 | |
39236c6e | 14 | KEXT_PLIST_LIST = \ |
55e303ae | 15 | System.kext/Info.plist \ |
5ba3f43e | 16 | System.kext/PlugIns/Kasan.kext/Info.plist \ |
55e303ae A |
17 | System.kext/PlugIns/AppleNMI.kext/Info.plist \ |
18 | System.kext/PlugIns/ApplePlatformFamily.kext/Info.plist \ | |
19 | System.kext/PlugIns/IONVRAMFamily.kext/Info.plist \ | |
39236c6e | 20 | System.kext/PlugIns/IOSystemManagement.kext/Info.plist |
6d2010ae | 21 | |
55e303ae | 22 | SYMBOL_COMPONENT_LIST = \ |
55e303ae A |
23 | BSDKernel \ |
24 | IOKit \ | |
6d2010ae A |
25 | Libkern \ |
26 | Mach \ | |
27 | MACFramework \ | |
28 | Unsupported \ | |
29 | Private | |
2d21ac55 | 30 | |
f427ee49 A |
31 | SYMBOL_SET_PLIST_COMPONENT_LIST := $(SYMBOL_COMPONENT_LIST) Kasan |
32 | ||
fe8ab488 A |
33 | # In general you want it to be possible to have a CPU sub-type's symbol exports |
34 | # alias to the parent type's exports. This is a special-case way to handle it | |
35 | # for now: | |
36 | ifeq ($(CURRENT_ARCH_CONFIG_LC),x86_64h) | |
37 | EXPORT_SOURCE_ARCH_CONFIG_LC = x86_64 | |
38 | else | |
39 | EXPORT_SOURCE_ARCH_CONFIG_LC = $(CURRENT_ARCH_CONFIG_LC) | |
40 | endif | |
41 | ||
39236c6e A |
42 | KEXT_MACHO_LIST = $(foreach symbolset,$(filter-out Dummy,$(SYMBOL_COMPONENT_LIST)),System.kext/PlugIns/$(symbolset).kext/$(symbolset)) |
43 | KEXT_PLIST_LIST += $(foreach symbolset,$(filter-out Dummy,$(SYMBOL_COMPONENT_LIST)),System.kext/PlugIns/$(symbolset).kext/Info.plist) | |
44 | ||
45 | SYMROOT_INSTALL_KEXT_MACHO_FILES = $(addprefix $(SYMROOT)/,$(KEXT_MACHO_LIST)) | |
46 | DSTROOT_INSTALL_KEXT_MACHO_FILES = $(addprefix $(INSTALL_KEXT_DIR)/,$(KEXT_MACHO_LIST)) | |
47 | ||
48 | SYMROOT_INSTALL_KEXT_PLISTS = $(addprefix $(SYMROOT)/,$(KEXT_PLIST_LIST)) | |
49 | DSTROOT_INSTALL_KEXT_PLISTS = $(addprefix $(INSTALL_KEXT_DIR)/,$(KEXT_PLIST_LIST)) | |
55e303ae | 50 | |
f427ee49 | 51 | EXPORTS_FILES = $(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(symbolset).exports $(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports $(notdir $(wildcard $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).$(PLATFORM).exports))) Unused.exports |
55e303ae | 52 | |
f427ee49 | 53 | Kasan_EXPORTS := $(SRCROOT)/san/Kasan.exports |
d9a64523 | 54 | ifeq ($(KASAN),1) |
f427ee49 | 55 | Kasan_EXPORTS := $(SRCROOT)/san/Kasan_kasan.exports |
d9a64523 A |
56 | endif |
57 | ||
f427ee49 A |
58 | SYMBOL_SET_BUILD = $(foreach symbolset, $(SYMBOL_COMPONENT_LIST), $(OBJPATH)/$(symbolset).symbolset) |
59 | SYMBOL_SET_PLIST_BUILD = $(foreach symbolset, $(SYMBOL_SET_PLIST_COMPONENT_LIST), $(OBJPATH)/$(symbolset).symbolset.plist) | |
55e303ae | 60 | |
cb323159 | 61 | define symbol_set_rule |
f427ee49 A |
62 | $(1)_EXPORTS := $(addprefix $(SOURCE)/,$(filter $(1)%,$(EXPORTS_FILES))) |
63 | $(OBJPATH)/$(1).symbolset: MY_EXPORTS_ARGS := $$(foreach file,$$($(1)_EXPORTS),-export $$(file)) | |
64 | $(OBJPATH)/$(1).symbolset: $$($(1)_EXPORTS) $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET) | |
65 | @$$(LOG_SYMBOLSET) "$(ColorF)$(1)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))" | |
cb323159 A |
66 | $(_v)$(KEXT_CREATE_SYMBOL_SET) \ |
67 | $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \ | |
68 | -import $(OBJPATH)/allsymbols \ | |
69 | $$(MY_EXPORTS_ARGS) \ | |
70 | -output $$@ $(_vstdout) | |
71 | endef | |
72 | ||
f427ee49 A |
73 | define symbol_set_plist_rule |
74 | $(1)_KEXT_PLIST := $$(filter %/$(1).kext/Info.plist,$$(SYMROOT_INSTALL_KEXT_PLISTS)) | |
75 | $(OBJPATH)/$(1).symbolset.plist: $$($(1)_KEXT_PLIST) $$($(1)_EXPORTS) | |
76 | @$$(LOG_SYMBOLSETPLIST) "$(ColorF)$(1)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))" | |
77 | $(_v)$(SOURCE)/generate_symbolset_plist.sh $$@ $$+ $(_vstdout) | |
78 | $(_v)$(PLUTIL) -lint -s $$@ | |
79 | endef | |
80 | ||
cb323159 | 81 | $(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(eval $(call symbol_set_rule,$(symbolset)))) |
f427ee49 A |
82 | $(foreach symbolset,$(SYMBOL_SET_PLIST_COMPONENT_LIST),$(eval $(call symbol_set_plist_rule,$(symbolset)))) |
83 | ||
84 | $(OBJPATH)/symbolsets.plist: $(SYMBOL_SET_PLIST_BUILD) | |
85 | $(_v)$(SOURCE)/generate_combined_symbolsets_plist.sh $@ $^ $(_vstdout) | |
86 | $(_v)$(PLUTIL) -convert binary1 -s $@ | |
87 | ||
88 | $(OBJPATH)/allsymbols: $(OBJPATH)/$(KERNEL_FILE_NAME) | |
89 | $(_v)$(NM) -gj $< | sort -u > $@ | |
39236c6e A |
90 | |
91 | .PHONY: check_all_exports | |
92 | ||
fe8ab488 | 93 | check_all_exports: $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET) |
39236c6e A |
94 | $(_v)$(KEXT_CREATE_SYMBOL_SET) \ |
95 | $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \ | |
96 | -import $(OBJPATH)/allsymbols \ | |
97 | $(foreach symbolset,$(filter-out Private,$(SYMBOL_COMPONENT_LIST)), \ | |
98 | -export $(SOURCE)/$(symbolset).exports \ | |
fe8ab488 | 99 | -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \ |
39236c6e A |
100 | -output /dev/null $(_vstdout) |
101 | $(_v)$(KEXT_CREATE_SYMBOL_SET) \ | |
102 | $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \ | |
103 | -import $(OBJPATH)/allsymbols \ | |
104 | $(foreach symbolset,$(filter-out Unsupported,$(SYMBOL_COMPONENT_LIST)), \ | |
105 | -export $(SOURCE)/$(symbolset).exports \ | |
fe8ab488 | 106 | -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \ |
39236c6e A |
107 | -output /dev/null $(_vstdout) |
108 | ||
109 | $(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES) | |
f427ee49 | 110 | @$(LOG_SUPPORTED_KPI) "$(CURRENT_ARCH_CONFIG_LC)" |
fe8ab488 | 111 | $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) $(EXPORT_SOURCE_ARCH_CONFIG_LC) $@ |
39236c6e A |
112 | |
113 | $(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES) | |
f427ee49 | 114 | @$(LOG_SUPPORTED_KPI) "all" |
39236c6e A |
115 | $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) all $@ |
116 | ||
117 | build_symbol_sets: check_all_exports $(SYMBOL_SET_BUILD) $(OBJPATH)/allsymbols \ | |
118 | $(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME) \ | |
119 | $(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME) | |
120 | ||
121 | do_config_all:: build_symbol_sets | |
122 | ||
123 | # There's no simple static pattern rule for these paths, so hardcode dependencies in the command list | |
124 | $(SYMROOT_INSTALL_KEXT_MACHO_FILES): ALWAYS | |
125 | $(_v)$(MKDIR) $(dir $@) | |
f427ee49 | 126 | @$(LOG_INSTALLSYM) "symbolset $(notdir $@)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))" |
39236c6e | 127 | $(_v)if [ $(OBJROOT)/.symbolset.timestamp -nt $@ ]; then \ |
39236c6e A |
128 | $(INSTALL) $(EXEC_INSTALL_FLAGS) $(OBJPATH)/$(@F).symbolset $@; \ |
129 | cmdstatus=$$?; \ | |
130 | else \ | |
39236c6e A |
131 | $(LIPO) -create $@ $(OBJPATH)/$(@F).symbolset -output $@ 2>/dev/null || true; \ |
132 | cmdstatus=$$?; \ | |
133 | fi; \ | |
134 | exit $$cmdstatus | |
135 | ||
39236c6e A |
136 | $(SYMROOT_INSTALL_KEXT_PLISTS): $(SYMROOT)/% : $(SOURCE)/% |
137 | $(_v)$(MKDIR) $(dir $@) | |
f427ee49 | 138 | @$(LOG_INSTALLSYM) "kextplist$(Color0) $(ColorF)$*" |
39236c6e A |
139 | $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@ |
140 | $(_v)$(NEWVERS) $@ $(_vstdout) | |
141 | ||
39236c6e A |
142 | $(DSTROOT_INSTALL_KEXT_PLISTS): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/% |
143 | $(_v)$(MKDIR) $(dir $@) | |
f427ee49 | 144 | @$(LOG_INSTALLSYM) "kextplist$(Color0) $(ColorF)$*" |
39236c6e A |
145 | $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@ |
146 | ||
fe8ab488 | 147 | $(DSTROOT_INSTALL_KEXT_MACHO_FILES): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/% ALWAYS |
39236c6e | 148 | $(_v)$(MKDIR) $(dir $@) |
f427ee49 | 149 | @$(LOG_INSTALL) "$(notdir $@)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))" |
39236c6e A |
150 | $(_v)$(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@ |
151 | ||
152 | $(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME): $(DSTROOT)/$(KRESDIR)/% : $(OBJPATH)/% | |
153 | $(_v)$(MKDIR) $(dir $@) | |
f427ee49 | 154 | @$(LOG_INSTALL) "$*" |
39236c6e A |
155 | $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@ |
156 | ||
5ba3f43e | 157 | ifneq ($(INSTALL_KASAN_ONLY),1) |
fe8ab488 A |
158 | do_config_install:: $(SYMROOT_INSTALL_KEXT_MACHO_FILES) \ |
159 | $(SYMROOT_INSTALL_KEXT_PLISTS) \ | |
160 | $(DSTROOT_INSTALL_KEXT_MACHO_FILES) \ | |
161 | $(DSTROOT_INSTALL_KEXT_PLISTS) \ | |
162 | $(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) \ | |
163 | $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME) | |
5ba3f43e A |
164 | endif |
165 | ||
fe8ab488 | 166 | $(OBJPATH)/all-kpi.exp: $(EXPORTS_FILES) |
f427ee49 | 167 | $(_v)$(SOURCE)/generate_linker_exports.sh $@ $+ $(Kasan_EXPORTS) |
d9a64523 A |
168 | |
169 | $(OBJPATH)/all-alias.exp: $(EXPORTS_FILES) | |
f427ee49 | 170 | $(_v)$(SOURCE)/generate_linker_aliases.sh $@ $+ $(Kasan_EXPORTS) |
39236c6e | 171 | |
f427ee49 | 172 | do_build_all:: $(OBJPATH)/all-kpi.exp $(OBJPATH)/all-alias.exp $(OBJPATH)/symbolsets.plist |
b7266188 | 173 | |
d7e50217 A |
174 | include $(MakeInc_rule) |
175 | include $(MakeInc_dir) |