]> git.saurik.com Git - apple/xnu.git/blobdiff - config/Makefile
xnu-6153.61.1.tar.gz
[apple/xnu.git] / config / Makefile
index 36d0759dd62d61bd119b56edd054b6f88632b5fa..0f5f3ab63f0d078e931f034127e48dfeed353f98 100644 (file)
@@ -3,95 +3,157 @@ export MakeInc_def=${SRCROOT}/makedefs/MakeInc.def
 export MakeInc_rule=${SRCROOT}/makedefs/MakeInc.rule
 export MakeInc_dir=${SRCROOT}/makedefs/MakeInc.dir
 
-
 include $(MakeInc_cmd)
 include $(MakeInc_def)
 
-ALL_SUBDIRS = 
-
-INSTINC_SUBDIRS = 
-
-INSTINC_SUBDIRS_PPC = 
-
-INSTINC_SUBDIRS_I386 = 
-
-EXPINC_SUBDIRS = 
-
-EXPINC_SUBDIRS_PPC =  
+MD_SUPPORTED_KPI_FILENAME = SupportedKPIs-${CURRENT_ARCH_CONFIG_LC}.txt
+MI_SUPPORTED_KPI_FILENAME = SupportedKPIs-all-archs.txt
 
-EXPINC_SUBDIRS_I386 = 
+INSTALL_KEXT_DIR = $(DSTROOT)$(INSTALL_EXTENSIONS_DIR)
 
-COMP_SUBDIRS = 
-
-INST_SUBDIRS = 
-
-
-INSTALL_DATA_LIST= \
+KEXT_PLIST_LIST = \
        System.kext/Info.plist \
-       System.kext/PlugIns/Libkern.kext/Info.plist \
-       System.kext/PlugIns/Mach.kext/Info.plist \
-       System.kext/PlugIns/BSDKernel.kext/Info.plist \
-       System.kext/PlugIns/IOKit.kext/Info.plist \
+       System.kext/PlugIns/Kasan.kext/Info.plist \
        System.kext/PlugIns/AppleNMI.kext/Info.plist \
        System.kext/PlugIns/ApplePlatformFamily.kext/Info.plist \
        System.kext/PlugIns/IONVRAMFamily.kext/Info.plist \
-       System.kext/PlugIns/IOSystemManagement.kext/Info.plist \
-       \
-       System.kext/PlugIns/System6.0.kext/Info.plist \
-       System.kext/PlugIns/Libkern6.0.kext/Info.plist \
-       System.kext/PlugIns/Mach6.0.kext/Info.plist \
-       System.kext/PlugIns/BSDKernel6.0.kext/Info.plist \
-       System.kext/PlugIns/IOKit6.0.kext/Info.plist \
-       
-
-INSTALL_DATA_DIR= \
-       /System/Library/Extensions/
-
-INSTMAN_SUBDIRS = 
-
-#
-
-KEXT_CREATE_SYMBOL_SET = /usr/local/bin/kextsymboltool
+       System.kext/PlugIns/IOSystemManagement.kext/Info.plist
 
 SYMBOL_COMPONENT_LIST =        \
-        System6.0      \
         BSDKernel      \
         IOKit          \
-        Libkern        \
-        Mach
-
-SYMBOL_SET_BUILD = $(foreach set, $(SYMBOL_COMPONENT_LIST), $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/$(set).symbolset)
-SYMBOL_SET_FAT = $(foreach set, $(SYMBOL_COMPONENT_LIST), $(OBJROOT)/$(set).symbolset)
-
-## .SUFFIXES: .symbolset .symbollist
-
-$(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/allsymbols: $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/mach_kernel
-       nm -gj $< > $@
-
-$(SYMBOL_SET_BUILD): $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/%.symbolset :  %.exports %.$(ARCH_CONFIG_LC).exports $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/allsymbols
-       $(KEXT_CREATE_SYMBOL_SET) \
-               -arch $(ARCH_CONFIG_LC) \
-               -import $(OBJROOT)/$(KERNEL_CONFIG)_$(ARCH_CONFIG)/allsymbols \
-               -export $*.exports \
-               -export $*.$(ARCH_CONFIG_LC).exports \
-               -output $@;
-
-$(SYMBOL_SET_FAT): $(OBJROOT)/%.symbolset : $(foreach arch, $(INSTALL_ARCHS), $(OBJROOT)/$(KERNEL_CONFIG)_$(arch)/%.symbolset)
-       $(LIPO) $(foreach arch, $(INSTALL_ARCHS), $(OBJROOT)/$(KERNEL_CONFIG)_$(arch)/$*.symbolset) -create -output $@;
-
-
-build_symbol_sets:     $(SYMBOL_SET_BUILD)
-
-install_symbol_sets:   $(SYMBOL_SET_FAT)
-       install $(INSTALL_FLAGS) $(OBJROOT)/System6.0.symbolset $(DSTROOT)/$(INSTALL_DATA_DIR)/System.kext/PlugIns/System6.0.kext/kernel.6.0;
-       install $(INSTALL_FLAGS) $(OBJROOT)/BSDKernel.symbolset $(DSTROOT)/$(INSTALL_DATA_DIR)/System.kext/PlugIns/BSDKernel.kext/BSDKernel;
-       install $(INSTALL_FLAGS) $(OBJROOT)/IOKit.symbolset     $(DSTROOT)/$(INSTALL_DATA_DIR)/System.kext/PlugIns/IOKit.kext/IOKit;
-       install $(INSTALL_FLAGS) $(OBJROOT)/Libkern.symbolset   $(DSTROOT)/$(INSTALL_DATA_DIR)/System.kext/PlugIns/Libkern.kext/Libkern;
-       install $(INSTALL_FLAGS) $(OBJROOT)/Mach.symbolset      $(DSTROOT)/$(INSTALL_DATA_DIR)/System.kext/PlugIns/Mach.kext/Mach;
-
-do_build_all:  build_symbol_sets
-
-do_build_install:      install_symbol_sets
+        Libkern                \
+        Mach           \
+        MACFramework   \
+        Unsupported    \
+        Private
+
+# In general you want it to be possible to have a CPU sub-type's symbol exports
+# alias to the parent type's exports. This is a special-case way to handle it
+# for now:
+ifeq ($(CURRENT_ARCH_CONFIG_LC),x86_64h)
+EXPORT_SOURCE_ARCH_CONFIG_LC = x86_64
+else
+EXPORT_SOURCE_ARCH_CONFIG_LC = $(CURRENT_ARCH_CONFIG_LC)
+endif
+
+KEXT_MACHO_LIST = $(foreach symbolset,$(filter-out Dummy,$(SYMBOL_COMPONENT_LIST)),System.kext/PlugIns/$(symbolset).kext/$(symbolset))
+KEXT_PLIST_LIST += $(foreach symbolset,$(filter-out Dummy,$(SYMBOL_COMPONENT_LIST)),System.kext/PlugIns/$(symbolset).kext/Info.plist)
+
+SYMROOT_INSTALL_KEXT_MACHO_FILES = $(addprefix $(SYMROOT)/,$(KEXT_MACHO_LIST))
+DSTROOT_INSTALL_KEXT_MACHO_FILES = $(addprefix $(INSTALL_KEXT_DIR)/,$(KEXT_MACHO_LIST))
+
+SYMROOT_INSTALL_KEXT_PLISTS = $(addprefix $(SYMROOT)/,$(KEXT_PLIST_LIST))
+DSTROOT_INSTALL_KEXT_PLISTS = $(addprefix $(INSTALL_KEXT_DIR)/,$(KEXT_PLIST_LIST))
+
+EXPORTS_FILES = $(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(symbolset).exports $(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) Unused.exports
+
+SYMBOL_SET_BUILD = $(foreach symbolset, $(SYMBOL_COMPONENT_LIST), $(OBJPATH)/$(symbolset).symbolset)
+
+ifeq ($(KASAN),1)
+KASAN_EXPORTS = $(SRCROOT)/san/Kasan_kasan.exports
+endif
+
+$(OBJPATH)/allsymbols: $(OBJPATH)/$(KERNEL_FILE_NAME)
+       $(_v)$(NM) -gj $< > $@
+
+define symbol_set_rule
+$(OBJPATH)/$(1).symbolset: MY_EXPORTS := $(filter $(1)%,$(EXPORTS_FILES))
+$(OBJPATH)/$(1).symbolset: MY_EXPORTS_ARGS := $$(foreach file,$$(MY_EXPORTS),-export $(SOURCE)/$$(file))
+$(OBJPATH)/$(1).symbolset: $$(MY_EXPORTS) $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET)
+       $$(call makelog,$(ColorH)SYMBOLSET$(Color0)     $(ColorF)$(1)$(Color0) "($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))")
+       $(_v)$(KEXT_CREATE_SYMBOL_SET)                  \
+               $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG))    \
+               -import $(OBJPATH)/allsymbols           \
+               $$(MY_EXPORTS_ARGS)                     \
+               -output $$@ $(_vstdout)
+endef
+
+$(foreach symbolset,$(SYMBOL_COMPONENT_LIST),$(eval $(call symbol_set_rule,$(symbolset))))
+
+.PHONY: check_all_exports
+
+check_all_exports: $(OBJPATH)/allsymbols $(KEXT_CREATE_SYMBOL_SET)
+       $(_v)$(KEXT_CREATE_SYMBOL_SET)                                  \
+               $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG))                    \
+               -import $(OBJPATH)/allsymbols                           \
+               $(foreach symbolset,$(filter-out Private,$(SYMBOL_COMPONENT_LIST)),     \
+                       -export $(SOURCE)/$(symbolset).exports          \
+                       -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
+               -output /dev/null $(_vstdout)
+       $(_v)$(KEXT_CREATE_SYMBOL_SET)                                  \
+               $(ARCH_FLAGS_$(CURRENT_ARCH_CONFIG))                    \
+               -import $(OBJPATH)/allsymbols                           \
+               $(foreach symbolset,$(filter-out Unsupported,$(SYMBOL_COMPONENT_LIST)), \
+                       -export $(SOURCE)/$(symbolset).exports          \
+                       -export $(SOURCE)/$(symbolset).$(EXPORT_SOURCE_ARCH_CONFIG_LC).exports) \
+               -output /dev/null $(_vstdout)
+
+$(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
+       $(call makelog,$(ColorH)SUPPORTED_KPI$(Color0) "($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))")
+       $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) $(EXPORT_SOURCE_ARCH_CONFIG_LC) $@
+
+$(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME): $(EXPORTS_FILES)
+       $(call makelog,$(ColorH)SUPPORTED_KPI$(Color0) "($(ColorLF)all$(Color0))")
+       $(_v)$(SRCROOT)/config/list_supported.sh $(SOURCE) all $@
+
+build_symbol_sets: check_all_exports $(SYMBOL_SET_BUILD) $(OBJPATH)/allsymbols \
+                       $(OBJPATH)/$(MD_SUPPORTED_KPI_FILENAME) \
+                       $(OBJPATH)/$(MI_SUPPORTED_KPI_FILENAME)
+
+do_config_all::        build_symbol_sets
+
+# There's no simple static pattern rule for these paths, so hardcode dependencies in the command list
+$(SYMROOT_INSTALL_KEXT_MACHO_FILES): ALWAYS
+       $(_v)$(MKDIR) $(dir $@)
+       $(call makelog,$(ColorH)INSTALLSYM$(Color0)    $(ColorF)symbolset $(notdir $@)$(Color0) "($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))")
+       $(_v)if [ $(OBJROOT)/.symbolset.timestamp -nt $@ ]; then                \
+               $(INSTALL) $(EXEC_INSTALL_FLAGS) $(OBJPATH)/$(@F).symbolset $@; \
+               cmdstatus=$$?;                                                  \
+       else                                                                    \
+               $(LIPO) -create $@ $(OBJPATH)/$(@F).symbolset -output $@ 2>/dev/null || true;   \
+               cmdstatus=$$?;                                                  \
+       fi;                                                                     \
+       exit $$cmdstatus
+
+$(SYMROOT_INSTALL_KEXT_PLISTS): $(SYMROOT)/% : $(SOURCE)/%
+       $(_v)$(MKDIR) $(dir $@)
+       $(call makelog,$(ColorH)INSTALLSYM$(Coloro)    $(ColorLF)kextplist$(Color0) $(ColorF)$*$(Color0))
+       $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
+       $(_v)$(NEWVERS) $@ $(_vstdout)
+
+$(DSTROOT_INSTALL_KEXT_PLISTS): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/%
+       $(_v)$(MKDIR) $(dir $@)
+       $(call makelog,$(ColorH)INSTALL$(Color0)       $(ColorLF)kextplist$(Color0) $(ColorF)$*$(Color0))
+       $(_v)$(INSTALL) $(DATA_INSTALL_FLAGS) $< $@
+
+$(DSTROOT_INSTALL_KEXT_MACHO_FILES): $(INSTALL_KEXT_DIR)/% : $(SYMROOT)/% ALWAYS
+       $(_v)$(MKDIR) $(dir $@)
+       $(call makelog,$(ColorF)INSTALL$(Color0)       $(ColorF)$(notdir $@)$(Color0) "($(ColorLF)$(CURRENT_ARCH_CONFIG_LC)$(Color0))")
+       $(_v)$(INSTALL) $(EXEC_INSTALL_FLAGS) $< $@
+
+$(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME): $(DSTROOT)/$(KRESDIR)/% : $(OBJPATH)/%
+       $(_v)$(MKDIR) $(dir $@)
+       $(call makelog,$(ColorH)INSTALL$(Color0)       $(ColorF)$*$(Color0))
+       $(_v)$(INSTALL) $(INSTALL_FLAGS) $< $@
+
+ifneq ($(INSTALL_KASAN_ONLY),1)
+do_config_install::    $(SYMROOT_INSTALL_KEXT_MACHO_FILES) \
+                               $(SYMROOT_INSTALL_KEXT_PLISTS) \
+                               $(DSTROOT_INSTALL_KEXT_MACHO_FILES) \
+                               $(DSTROOT_INSTALL_KEXT_PLISTS) \
+                               $(DSTROOT)/$(KRESDIR)/$(MD_SUPPORTED_KPI_FILENAME) \
+                               $(DSTROOT)/$(KRESDIR)/$(MI_SUPPORTED_KPI_FILENAME)
+endif
+
+
+$(OBJPATH)/all-kpi.exp: $(EXPORTS_FILES)
+       $(_v)$(SOURCE)/generate_linker_exports.sh $@ $+ $(KASAN_EXPORTS)
+
+$(OBJPATH)/all-alias.exp: $(EXPORTS_FILES)
+       $(_v)$(SOURCE)/generate_linker_aliases.sh $@ $+ $(KASAN_EXPORTS)
+
+do_build_all:: $(OBJPATH)/all-kpi.exp $(OBJPATH)/all-alias.exp
 
 include $(MakeInc_rule)
 include $(MakeInc_dir)