]> git.saurik.com Git - apple/xnu.git/blob - config/Makefile
xnu-7195.60.75.tar.gz
[apple/xnu.git] / config / Makefile
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
6 include $(MakeInc_cmd)
7 include $(MakeInc_def)
8
9 MD_SUPPORTED_KPI_FILENAME = SupportedKPIs-${CURRENT_ARCH_CONFIG_LC}.txt
10 MI_SUPPORTED_KPI_FILENAME = SupportedKPIs-all-archs.txt
11
12 INSTALL_KEXT_DIR = $(DSTROOT)$(INSTALL_EXTENSIONS_DIR)
13
14 KEXT_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
22 SYMBOL_COMPONENT_LIST = \
23 BSDKernel \
24 IOKit \
25 Libkern \
26 Mach \
27 MACFramework \
28 Unsupported \
29 Private
30
31 SYMBOL_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:
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
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))
50
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
52
53 Kasan_EXPORTS := $(SRCROOT)/san/Kasan.exports
54 ifeq ($(KASAN),1)
55 Kasan_EXPORTS := $(SRCROOT)/san/Kasan_kasan.exports
56 endif
57
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)
60
61 define 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)
71 endef
72
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
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
88 $(OBJPATH)/allsymbols: $(OBJPATH)/$(KERNEL_FILE_NAME)
89 $(_v)$(NM) -gj $< | sort -u > $@
90
91 .PHONY: check_all_exports
92
93 check_all_exports: $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET)
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 \
99 -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
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 \
106 -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
107 -output /dev/null $(_vstdout)
108
109 $(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
110 @$(LOG_SUPPORTED_KPI) "$(CURRENT_ARCH_CONFIG_LC)"
111 $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) $(EXPORT_SOURCE_ARCH_CONFIG_LC) $@
112
113 $(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
114 @$(LOG_SUPPORTED_KPI) "all"
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 $@)
126 @$(LOG_INSTALLSYM) "symbolset $(notdir $@)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
127 $(_v)if [ $(OBJROOT)/.symbolset.timestamp -nt $@ ]; then \
128 $(INSTALL) $(EXEC_INSTALL_FLAGS) $(OBJPATH)/$(@F).symbolset $@; \
129 cmdstatus=$$?; \
130 else \
131 $(LIPO) -create $@ $(OBJPATH)/$(@F).symbolset -output $@ 2>/dev/null || true; \
132 cmdstatus=$$?; \
133 fi; \
134 exit $$cmdstatus
135
136 $(SYMROOT_INSTALL_KEXT_PLISTS): $(SYMROOT)/% : $(SOURCE)/%
137 $(_v)$(MKDIR) $(dir $@)
138 @$(LOG_INSTALLSYM) "kextplist$(Color0) $(ColorF)$*"
139 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
140 $(_v)$(NEWVERS) $@ $(_vstdout)
141
142 $(DSTROOT_INSTALL_KEXT_PLISTS): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/%
143 $(_v)$(MKDIR) $(dir $@)
144 @$(LOG_INSTALLSYM) "kextplist$(Color0) $(ColorF)$*"
145 $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
146
147 $(DSTROOT_INSTALL_KEXT_MACHO_FILES): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/% ALWAYS
148 $(_v)$(MKDIR) $(dir $@)
149 @$(LOG_INSTALL) "$(notdir $@)$(Color0) ($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))"
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 $@)
154 @$(LOG_INSTALL) "$*"
155 $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
156
157 ifneq ($(INSTALL_KASAN_ONLY),1)
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)
164 endif
165
166 $(OBJPATH)/all-kpi.exp: $(EXPORTS_FILES)
167 $(_v)$(SOURCE)/generate_linker_exports.sh $@ $+ $(Kasan_EXPORTS)
168
169 $(OBJPATH)/all-alias.exp: $(EXPORTS_FILES)
170 $(_v)$(SOURCE)/generate_linker_aliases.sh $@ $+ $(Kasan_EXPORTS)
171
172 do_build_all:: $(OBJPATH)/all-kpi.exp $(OBJPATH)/all-alias.exp $(OBJPATH)/symbolsets.plist
173
174 include $(MakeInc_rule)
175 include $(MakeInc_dir)