]> git.saurik.com Git - apple/xnu.git/blame - config/Makefile
xnu-7195.101.1.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
f427ee49
A
31SYMBOL_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:
36ifeq ($(CURRENT_ARCH_CONFIG_LC),x86_64h)
37EXPORT_SOURCE_ARCH_CONFIG_LC = x86_64
38else
39EXPORT_SOURCE_ARCH_CONFIG_LC = $(CURRENT_ARCH_CONFIG_LC)
40endif
41
39236c6e
A
42KEXT_MACHO_LIST = $(foreach symbolset,$(filter-out Dummy,$(SYMBOL_COMPONENT_LIST)),System.kext/PlugIns/$(symbolset).kext/$(symbolset))
43KEXT_PLIST_LIST += $(foreach symbolset,$(filter-out Dummy,$(SYMBOL_COMPONENT_LIST)),System.kext/PlugIns/$(symbolset).kext/Info.plist)
44
45SYMROOT_INSTALL_KEXT_MACHO_FILES = $(addprefix $(SYMROOT)/,$(KEXT_MACHO_LIST))
46DSTROOT_INSTALL_KEXT_MACHO_FILES = $(addprefix $(INSTALL_KEXT_DIR)/,$(KEXT_MACHO_LIST))
47
48SYMROOT_INSTALL_KEXT_PLISTS = $(addprefix $(SYMROOT)/,$(KEXT_PLIST_LIST))
49DSTROOT_INSTALL_KEXT_PLISTS = $(addprefix $(INSTALL_KEXT_DIR)/,$(KEXT_PLIST_LIST))
55e303ae 50
f427ee49 51EXPORTS_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 53Kasan_EXPORTS := $(SRCROOT)/san/Kasan.exports
d9a64523 54ifeq ($(KASAN),1)
f427ee49 55Kasan_EXPORTS := $(SRCROOT)/san/Kasan_kasan.exports
d9a64523
A
56endif
57
f427ee49
A
58SYMBOL_SET_BUILD = $(foreach symbolset, $(SYMBOL_COMPONENT_LIST), $(OBJPATH)/$(symbolset).symbolset)
59SYMBOL_SET_PLIST_BUILD = $(foreach symbolset, $(SYMBOL_SET_PLIST_COMPONENT_LIST), $(OBJPATH)/$(symbolset).symbolset.plist)
55e303ae 60
cb323159 61define 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)
71endef
72
f427ee49
A
73define 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 $$@
79endef
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
a991bd8d 88ifneq ($(RC_ProjectName),xnu_libraries)
f427ee49
A
89$(OBJPATH)/allsymbols: $(OBJPATH)/$(KERNEL_FILE_NAME)
90 $(_v)$(NM) -gj $< | sort -u > $@
39236c6e
A
91
92.PHONY: check_all_exports
93
fe8ab488 94check_all_exports: $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET)
39236c6e
A
95 $(_v)$(KEXT_CREATE_SYMBOL_SET) \
96 $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
97 -import $(OBJPATH)/allsymbols \
98 $(foreach symbolset,$(filter-out Private,$(SYMBOL_COMPONENT_LIST)), \
99 -export $(SOURCE)/$(symbolset).exports \
fe8ab488 100 -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
39236c6e
A
101 -output /dev/null $(_vstdout)
102 $(_v)$(KEXT_CREATE_SYMBOL_SET) \
103 $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG)) \
104 -import $(OBJPATH)/allsymbols \
105 $(foreach symbolset,$(filter-out Unsupported,$(SYMBOL_COMPONENT_LIST)), \
106 -export $(SOURCE)/$(symbolset).exports \
fe8ab488 107 -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
39236c6e
A
108 -output /dev/null $(_vstdout)
109
110$(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
f427ee49 111 @$(LOG_SUPPORTED_KPI) "$(CURRENT_ARCH_CONFIG_LC)"
fe8ab488 112 $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) $(EXPORT_SOURCE_ARCH_CONFIG_LC) $@
39236c6e
A
113
114$(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
f427ee49 115 @$(LOG_SUPPORTED_KPI) "all"
39236c6e
A
116 $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) all $@
117
118build_symbol_sets: check_all_exports $(SYMBOL_SET_BUILD) $(OBJPATH)/allsymbols \
119 $(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME) \
120 $(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME)
121
122do_config_all:: build_symbol_sets
a991bd8d
A
123else
124# We are building XNU as a static library - avoid creating symbol sets
125endif
39236c6e
A
126
127# There's no simple static pattern rule for these paths, so hardcode dependencies in the command list
128$(SYMROOT_INSTALL_KEXT_MACHO_FILES): ALWAYS
129 $(_v)$(MKDIR) $(dir $@)
f427ee49 130 @$(LOG_INSTALLSYM) "symbolset $(notdir $@)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
39236c6e 131 $(_v)if [ $(OBJROOT)/.symbolset.timestamp -nt $@ ]; then \
39236c6e
A
132 $(INSTALL) $(EXEC_INSTALL_FLAGS) $(OBJPATH)/$(@F).symbolset $@; \
133 cmdstatus=$$?; \
134 else \
39236c6e
A
135 $(LIPO) -create $@ $(OBJPATH)/$(@F).symbolset -output $@ 2>/dev/null || true; \
136 cmdstatus=$$?; \
137 fi; \
138 exit $$cmdstatus
139
39236c6e
A
140$(SYMROOT_INSTALL_KEXT_PLISTS): $(SYMROOT)/% : $(SOURCE)/%
141 $(_v)$(MKDIR) $(dir $@)
f427ee49 142 @$(LOG_INSTALLSYM) "kextplist$(Color0) $(ColorF)$*"
39236c6e
A
143 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
144 $(_v)$(NEWVERS) $@ $(_vstdout)
145
39236c6e
A
146$(DSTROOT_INSTALL_KEXT_PLISTS): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/%
147 $(_v)$(MKDIR) $(dir $@)
f427ee49 148 @$(LOG_INSTALLSYM) "kextplist$(Color0) $(ColorF)$*"
39236c6e
A
149 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
150
fe8ab488 151$(DSTROOT_INSTALL_KEXT_MACHO_FILES): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/% ALWAYS
39236c6e 152 $(_v)$(MKDIR) $(dir $@)
f427ee49 153 @$(LOG_INSTALL) "$(notdir $@)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
39236c6e
A
154 $(_v)$(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@
155
156$(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME): $(DSTROOT)/$(KRESDIR)/% : $(OBJPATH)/%
157 $(_v)$(MKDIR) $(dir $@)
f427ee49 158 @$(LOG_INSTALL) "$*"
39236c6e
A
159 $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
160
5ba3f43e 161ifneq ($(INSTALL_KASAN_ONLY),1)
a991bd8d 162ifneq ($(BUILD_XNU_LIBRARY),1)
fe8ab488
A
163do_config_install:: $(SYMROOT_INSTALL_KEXT_MACHO_FILES) \
164 $(SYMROOT_INSTALL_KEXT_PLISTS) \
165 $(DSTROOT_INSTALL_KEXT_MACHO_FILES) \
166 $(DSTROOT_INSTALL_KEXT_PLISTS) \
167 $(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) \
168 $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME)
5ba3f43e 169endif
a991bd8d 170endif
5ba3f43e 171
fe8ab488 172$(OBJPATH)/all-kpi.exp: $(EXPORTS_FILES)
f427ee49 173 $(_v)$(SOURCE)/generate_linker_exports.sh $@ $+ $(Kasan_EXPORTS)
d9a64523
A
174
175$(OBJPATH)/all-alias.exp: $(EXPORTS_FILES)
f427ee49 176 $(_v)$(SOURCE)/generate_linker_aliases.sh $@ $+ $(Kasan_EXPORTS)
39236c6e 177
f427ee49 178do_build_all:: $(OBJPATH)/all-kpi.exp $(OBJPATH)/all-alias.exp $(OBJPATH)/symbolsets.plist
b7266188 179
d7e50217
A
180include $(MakeInc_rule)
181include $(MakeInc_dir)