]> git.saurik.com Git - apple/xnu.git/blame_incremental - config/Makefile
xnu-7195.101.1.tar.gz
[apple/xnu.git] / config / Makefile
... / ...
CommitLineData
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
6include $(MakeInc_cmd)
7include $(MakeInc_def)
8
9MD_SUPPORTED_KPI_FILENAME = SupportedKPIs-${CURRENT_ARCH_CONFIG_LC}.txt
10MI_SUPPORTED_KPI_FILENAME = SupportedKPIs-all-archs.txt
11
12INSTALL_KEXT_DIR = $(DSTROOT)$(INSTALL_EXTENSIONS_DIR)
13
14KEXT_PLIST_LIST = \
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
21
22SYMBOL_COMPONENT_LIST = \
23 BSDKernel \
24 IOKit \
25 Libkern \
26 Mach \
27 MACFramework \
28 Unsupported \
29 Private
30
31SYMBOL_SET_PLIST_COMPONENT_LIST := $(SYMBOL_COMPONENT_LIST) Kasan
32
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
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))
50
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
52
53Kasan_EXPORTS := $(SRCROOT)/san/Kasan.exports
54ifeq ($(KASAN),1)
55Kasan_EXPORTS := $(SRCROOT)/san/Kasan_kasan.exports
56endif
57
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)
60
61define symbol_set_rule
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))"
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
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
81$(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(eval $(call symbol_set_rule,$(symbolset))))
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
88ifneq ($(RC_ProjectName),xnu_libraries)
89$(OBJPATH)/allsymbols: $(OBJPATH)/$(KERNEL_FILE_NAME)
90 $(_v)$(NM) -gj $< | sort -u > $@
91
92.PHONY: check_all_exports
93
94check_all_exports: $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET)
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 \
100 -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
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 \
107 -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
108 -output /dev/null $(_vstdout)
109
110$(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
111 @$(LOG_SUPPORTED_KPI) "$(CURRENT_ARCH_CONFIG_LC)"
112 $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) $(EXPORT_SOURCE_ARCH_CONFIG_LC) $@
113
114$(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
115 @$(LOG_SUPPORTED_KPI) "all"
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
123else
124# We are building XNU as a static library - avoid creating symbol sets
125endif
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 $@)
130 @$(LOG_INSTALLSYM) "symbolset $(notdir $@)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
131 $(_v)if [ $(OBJROOT)/.symbolset.timestamp -nt $@ ]; then \
132 $(INSTALL) $(EXEC_INSTALL_FLAGS) $(OBJPATH)/$(@F).symbolset $@; \
133 cmdstatus=$$?; \
134 else \
135 $(LIPO) -create $@ $(OBJPATH)/$(@F).symbolset -output $@ 2>/dev/null || true; \
136 cmdstatus=$$?; \
137 fi; \
138 exit $$cmdstatus
139
140$(SYMROOT_INSTALL_KEXT_PLISTS): $(SYMROOT)/% : $(SOURCE)/%
141 $(_v)$(MKDIR) $(dir $@)
142 @$(LOG_INSTALLSYM) "kextplist$(Color0) $(ColorF)$*"
143 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
144 $(_v)$(NEWVERS) $@ $(_vstdout)
145
146$(DSTROOT_INSTALL_KEXT_PLISTS): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/%
147 $(_v)$(MKDIR) $(dir $@)
148 @$(LOG_INSTALLSYM) "kextplist$(Color0) $(ColorF)$*"
149 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
150
151$(DSTROOT_INSTALL_KEXT_MACHO_FILES): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/% ALWAYS
152 $(_v)$(MKDIR) $(dir $@)
153 @$(LOG_INSTALL) "$(notdir $@)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
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 $@)
158 @$(LOG_INSTALL) "$*"
159 $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
160
161ifneq ($(INSTALL_KASAN_ONLY),1)
162ifneq ($(BUILD_XNU_LIBRARY),1)
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)
169endif
170endif
171
172$(OBJPATH)/all-kpi.exp: $(EXPORTS_FILES)
173 $(_v)$(SOURCE)/generate_linker_exports.sh $@ $+ $(Kasan_EXPORTS)
174
175$(OBJPATH)/all-alias.exp: $(EXPORTS_FILES)
176 $(_v)$(SOURCE)/generate_linker_aliases.sh $@ $+ $(Kasan_EXPORTS)
177
178do_build_all:: $(OBJPATH)/all-kpi.exp $(OBJPATH)/all-alias.exp $(OBJPATH)/symbolsets.plist
179
180include $(MakeInc_rule)
181include $(MakeInc_dir)