]> git.saurik.com Git - apple/xnu.git/blame - config/Makefile
xnu-6153.81.5.tar.gz
[apple/xnu.git] / config / Makefile
CommitLineData
d7e50217
A
1export MakeInc_cmd=${SRCROOT}/makedefs/MakeInc.cmd
2export MakeInc_def=${SRCROOT}/makedefs/MakeInc.def
3export MakeInc_rule=${SRCROOT}/makedefs/MakeInc.rule
4export MakeInc_dir=${SRCROOT}/makedefs/MakeInc.dir
5
d7e50217
A
6include $(MakeInc_cmd)
7include $(MakeInc_def)
8
39236c6e
A
9MD_SUPPORTED_KPI_FILENAME = SupportedKPIs-${CURRENT_ARCH_CONFIG_LC}.txt
10MI_SUPPORTED_KPI_FILENAME = SupportedKPIs-all-archs.txt
d7e50217 11
39236c6e 12INSTALL_KEXT_DIR = $(DSTROOT)$(INSTALL_EXTENSIONS_DIR)
d7e50217 13
39236c6e 14KEXT_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 22SYMBOL_COMPONENT_LIST = \
55e303ae
A
23 BSDKernel \
24 IOKit \
6d2010ae
A
25 Libkern \
26 Mach \
27 MACFramework \
28 Unsupported \
29 Private
2d21ac55 30
fe8ab488
A
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
33# for now:
34ifeq ($(CURRENT_ARCH_CONFIG_LC),x86_64h)
35EXPORT_SOURCE_ARCH_CONFIG_LC = x86_64
36else
37EXPORT_SOURCE_ARCH_CONFIG_LC = $(CURRENT_ARCH_CONFIG_LC)
38endif
39
39236c6e
A
40KEXT_MACHO_LIST = $(foreach symbolset,$(filter-out Dummy,$(SYMBOL_COMPONENT_LIST)),System.kext/PlugIns/$(symbolset).kext/$(symbolset))
41KEXT_PLIST_LIST += $(foreach symbolset,$(filter-out Dummy,$(SYMBOL_COMPONENT_LIST)),System.kext/PlugIns/$(symbolset).kext/Info.plist)
42
43SYMROOT_INSTALL_KEXT_MACHO_FILES = $(addprefix $(SYMROOT)/,$(KEXT_MACHO_LIST))
44DSTROOT_INSTALL_KEXT_MACHO_FILES = $(addprefix $(INSTALL_KEXT_DIR)/,$(KEXT_MACHO_LIST))
45
46SYMROOT_INSTALL_KEXT_PLISTS = $(addprefix $(SYMROOT)/,$(KEXT_PLIST_LIST))
47DSTROOT_INSTALL_KEXT_PLISTS = $(addprefix $(INSTALL_KEXT_DIR)/,$(KEXT_PLIST_LIST))
55e303ae 48
fe8ab488 49EXPORTS_FILES = $(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(symbolset).exports $(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) Unused.exports
6d2010ae 50
39236c6e 51SYMBOL_SET_BUILD = $(foreach symbolset, $(SYMBOL_COMPONENT_LIST), $(OBJPATH)/$(symbolset).symbolset)
55e303ae 52
d9a64523
A
53ifeq ($(KASAN),1)
54KASAN_EXPORTS = $(SRCROOT)/san/Kasan_kasan.exports
55endif
56
fe8ab488 57$(OBJPATH)/allsymbols: $(OBJPATH)/$(KERNEL_FILE_NAME)
b0d623f7 58 $(_v)$(NM) -gj $< > $@
55e303ae 59
cb323159
A
60define symbol_set_rule
61$(OBJPATH)/$(1).symbolset: MY_EXPORTS := $(filter $(1)%,$(EXPORTS_FILES))
62$(OBJPATH)/$(1).symbolset: MY_EXPORTS_ARGS := $$(foreach file,$$(MY_EXPORTS),-export $(SOURCE)/$$(file))
63$(OBJPATH)/$(1).symbolset: $$(MY_EXPORTS) $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET)
64 $$(call makelog,$(ColorH)SYMBOLSET$(Color0) $(ColorF)$(1)$(Color0) "($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))")
65 $(_v)$(KEXT_CREATE_SYMBOL_SET) \
66 $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
67 -import $(OBJPATH)/allsymbols \
68 $$(MY_EXPORTS_ARGS) \
69 -output $$@ $(_vstdout)
70endef
71
72$(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(eval $(call symbol_set_rule,$(symbolset))))
39236c6e
A
73
74.PHONY: check_all_exports
75
fe8ab488 76check_all_exports: $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET)
39236c6e
A
77 $(_v)$(KEXT_CREATE_SYMBOL_SET) \
78 $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
79 -import $(OBJPATH)/allsymbols \
80 $(foreach symbolset,$(filter-out Private,$(SYMBOL_COMPONENT_LIST)), \
81 -export $(SOURCE)/$(symbolset).exports \
fe8ab488 82 -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
39236c6e
A
83 -output /dev/null $(_vstdout)
84 $(_v)$(KEXT_CREATE_SYMBOL_SET) \
85 $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
86 -import $(OBJPATH)/allsymbols \
87 $(foreach symbolset,$(filter-out Unsupported,$(SYMBOL_COMPONENT_LIST)), \
88 -export $(SOURCE)/$(symbolset).exports \
fe8ab488 89 -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
39236c6e
A
90 -output /dev/null $(_vstdout)
91
92$(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
cb323159 93 $(call makelog,$(ColorH)SUPPORTED_KPI$(Color0) "($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))")
fe8ab488 94 $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) $(EXPORT_SOURCE_ARCH_CONFIG_LC) $@
39236c6e
A
95
96$(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
cb323159 97 $(call makelog,$(ColorH)SUPPORTED_KPI$(Color0) "($(ColorLF)all$(Color0))")
39236c6e
A
98 $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) all $@
99
100build_symbol_sets: check_all_exports $(SYMBOL_SET_BUILD) $(OBJPATH)/allsymbols \
101 $(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME) \
102 $(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME)
103
104do_config_all:: build_symbol_sets
105
106# There's no simple static pattern rule for these paths, so hardcode dependencies in the command list
107$(SYMROOT_INSTALL_KEXT_MACHO_FILES): ALWAYS
108 $(_v)$(MKDIR) $(dir $@)
cb323159 109 $(call makelog,$(ColorH)INSTALLSYM$(Color0) $(ColorF)symbolset $(notdir $@)$(Color0) "($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))")
39236c6e 110 $(_v)if [ $(OBJROOT)/.symbolset.timestamp -nt $@ ]; then \
39236c6e
A
111 $(INSTALL) $(EXEC_INSTALL_FLAGS) $(OBJPATH)/$(@F).symbolset $@; \
112 cmdstatus=$$?; \
113 else \
39236c6e
A
114 $(LIPO) -create $@ $(OBJPATH)/$(@F).symbolset -output $@ 2>/dev/null || true; \
115 cmdstatus=$$?; \
116 fi; \
117 exit $$cmdstatus
118
39236c6e
A
119$(SYMROOT_INSTALL_KEXT_PLISTS): $(SYMROOT)/% : $(SOURCE)/%
120 $(_v)$(MKDIR) $(dir $@)
cb323159 121 $(call makelog,$(ColorH)INSTALLSYM$(Coloro) $(ColorLF)kextplist$(Color0) $(ColorF)$*$(Color0))
39236c6e
A
122 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
123 $(_v)$(NEWVERS) $@ $(_vstdout)
124
39236c6e
A
125$(DSTROOT_INSTALL_KEXT_PLISTS): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/%
126 $(_v)$(MKDIR) $(dir $@)
cb323159 127 $(call makelog,$(ColorH)INSTALL$(Color0) $(ColorLF)kextplist$(Color0) $(ColorF)$*$(Color0))
39236c6e
A
128 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
129
fe8ab488 130$(DSTROOT_INSTALL_KEXT_MACHO_FILES): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/% ALWAYS
39236c6e 131 $(_v)$(MKDIR) $(dir $@)
cb323159 132 $(call makelog,$(ColorF)INSTALL$(Color0) $(ColorF)$(notdir $@)$(Color0) "($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))")
39236c6e
A
133 $(_v)$(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@
134
135$(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME): $(DSTROOT)/$(KRESDIR)/% : $(OBJPATH)/%
136 $(_v)$(MKDIR) $(dir $@)
cb323159 137 $(call makelog,$(ColorH)INSTALL$(Color0) $(ColorF)$*$(Color0))
39236c6e
A
138 $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
139
5ba3f43e 140ifneq ($(INSTALL_KASAN_ONLY),1)
fe8ab488
A
141do_config_install:: $(SYMROOT_INSTALL_KEXT_MACHO_FILES) \
142 $(SYMROOT_INSTALL_KEXT_PLISTS) \
143 $(DSTROOT_INSTALL_KEXT_MACHO_FILES) \
144 $(DSTROOT_INSTALL_KEXT_PLISTS) \
145 $(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) \
146 $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME)
5ba3f43e
A
147endif
148
39236c6e 149
fe8ab488 150$(OBJPATH)/all-kpi.exp: $(EXPORTS_FILES)
d9a64523
A
151 $(_v)$(SOURCE)/generate_linker_exports.sh $@ $+ $(KASAN_EXPORTS)
152
153$(OBJPATH)/all-alias.exp: $(EXPORTS_FILES)
154 $(_v)$(SOURCE)/generate_linker_aliases.sh $@ $+ $(KASAN_EXPORTS)
39236c6e 155
d9a64523 156do_build_all:: $(OBJPATH)/all-kpi.exp $(OBJPATH)/all-alias.exp
b7266188 157
d7e50217
A
158include $(MakeInc_rule)
159include $(MakeInc_dir)