]> git.saurik.com Git - apple/xnu.git/blobdiff - makedefs/MakeInc.top
xnu-7195.101.1.tar.gz
[apple/xnu.git] / makedefs / MakeInc.top
index c552c108a3d44a9a95268daae1e57c04c3f435d4..c5a98999c50b9043f6743fd0780ed6fb14e49f45 100644 (file)
@@ -1,6 +1,6 @@
 # -*- mode: makefile;-*-
 #
-# Copyright (C) 2010-2016 Apple Inc. All rights reserved.
+# Copyright (C) 2010-2020 Apple Inc. All rights reserved.
 #
 # MakeInc.top is the top-level makefile for the xnu
 # build system. All the main XBS targets
@@ -58,9 +58,9 @@ endif
 
 DEFAULT_PRODUCT_CONFIGS :=
 
-ifeq ($(RC_ProjectName),xnu_debug)
+ifneq ($(filter $(RC_ProjectName),xnu_debug),)
 override DEFAULT_KERNEL_CONFIG := DEBUG
-else ifeq ($(RC_ProjectName),xnu_kasan)
+else ifneq ($(filter $(RC_ProjectName),xnu_kasan),)
 override KERNEL_CONFIGS := KASAN
 else ifneq ($(filter $(SUPPORTED_EMBEDDED_PLATFORMS),$(PLATFORM)),)
 override DEFAULT_KERNEL_CONFIG := DEVELOPMENT
@@ -88,6 +88,16 @@ override DEFAULT_I386_MACHINE_CONFIG := NONE
 override DEFAULT_X86_64_MACHINE_CONFIG := NONE
 override DEFAULT_X86_64H_MACHINE_CONFIG := NONE
 
+ifneq ($(findstring _Sim,$(RC_ProjectName)),)
+override DEFAULT_ARM_MACHINE_CONFIG    := NONE
+override DEFAULT_ARM64_MACHINE_CONFIG  := NONE
+else ifneq ($(findstring _host,$(RC_ProjectName)),)
+override DEFAULT_ARM_MACHINE_CONFIG    := NONE
+override DEFAULT_ARM64_MACHINE_CONFIG  := NONE
+else
+override DEFAULT_ARM_MACHINE_CONFIG    := T8002
+override DEFAULT_ARM64_MACHINE_CONFIG  := T7000
+endif
 
 # This is typically never specified (TARGET_CONFIGS is used)
 ifndef MACHINE_CONFIGS
@@ -114,6 +124,95 @@ endif
 # default kernel configuration = DEFAULT_KERNEL_CONFIG
 # default architecture configuration = system architecture where you are running make.
 
+ifneq ($(filter $(SUPPORTED_PLATFORMS),$(PLATFORM)),)
+
+# Defaults for "make all_embedded"
+ifeq ($(KERNEL_CONFIGS),DEFAULT)
+KERNEL_CONFIGS_EMBEDDED := RELEASE DEVELOPMENT
+else
+KERNEL_CONFIGS_EMBEDDED := $(KERNEL_CONFIGS)
+endif
+
+ifeq ($(ARCH_CONFIGS),DEFAULT)
+ARCH_CONFIGS_EMBEDDED := ARM ARM64
+ARCH_CONFIGS_DESKTOP := X86_64
+else
+ARCH_CONFIGS_EMBEDDED := $(strip $(shell echo $(filter-out X86_64, $(ARCH_CONFIGS)) | $(TR) a-z A-Z))
+ARCH_CONFIGS_DESKTOP := $(strip $(shell echo $(filter X86_64, $(ARCH_CONFIGS)) | $(TR) a-z A-Z))
+endif
+
+# Find supported products from the device map
+ifneq ($(EMBEDDED_DEVICE_MAP),)
+DEVICEMAP_PRODUCTS_ARMV7  := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH)          \
+                               -query 'SELECT DISTINCT TargetType                      \
+                                       FROM Files                                      \
+                                         INNER JOIN Manifests USING (manifestID)       \
+                                         INNER JOIN Targets USING (Target)             \
+                                       WHERE (KernelMachOArchitecture LIKE "armv7"     \
+                                          AND fileType in ("KernelCache", "RestoreKernelCache"))')
+DEVICEMAP_PRODUCTS_ARMV7S := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH)          \
+                               -query 'SELECT DISTINCT TargetType                      \
+                                       FROM Files                                      \
+                                         INNER JOIN Manifests USING (manifestID)       \
+                                         INNER JOIN Targets USING (Target)             \
+                                       WHERE (KernelMachOArchitecture LIKE "armv7s"    \
+                                          AND fileType in ("KernelCache", "RestoreKernelCache"))')
+DEVICEMAP_PRODUCTS_ARMV7K := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH)          \
+                               -query 'SELECT DISTINCT TargetType                      \
+                                       FROM Files                                      \
+                                         INNER JOIN Manifests USING (manifestID)       \
+                                         INNER JOIN Targets USING (Target)             \
+                                       WHERE (KernelMachOArchitecture LIKE "armv7k"    \
+                                          AND fileType in ("KernelCache", "RestoreKernelCache"))')
+DEVICEMAP_PRODUCTS_ARM := $(DEVICEMAP_PRODUCTS_ARMV7) $(DEVICEMAP_PRODUCTS_ARMV7S) $(DEVICEMAP_PRODUCTS_ARMV7K)
+
+
+DEVICEMAP_PRODUCTS_ARM64 := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH)           \
+                               -query 'SELECT DISTINCT TargetType                      \
+                                       FROM Files                                      \
+                                         INNER JOIN Manifests USING (manifestID)       \
+                                         INNER JOIN Targets USING (Target)             \
+                                       WHERE (KernelMachOArchitecture LIKE "arm64"     \
+                                          AND fileType in ("KernelCache", "RestoreKernelCache"))')
+DEVICEMAP_PRODUCTS_OSX_ARM64 := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH)               \
+                                       -query 'SELECT DISTINCT TargetType                      \
+                                               FROM Files                                      \
+                                                 INNER JOIN Manifests USING (manifestID)       \
+                                                 INNER JOIN Targets USING (Target)             \
+                                               WHERE (KernelMachOArchitecture LIKE "arm64"     \
+                                                 AND fileType in ("KernelCache", "RestoreKernelCache") \
+                                                 AND SDKPlatform == "macosx")')
+
+
+# Generate a list of mappings of the form "n75:arm;t8002" based on the device map
+DEVICEMAP_PRODUCT_SOC_MAPPINGS := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH) -query SELECT DISTINCT TargetType, KernelMachOArchitecture, KernelPlatform FROM Targets | awk -F\| '{ if ($$2 ~ /armv[0-9][a-z]?/) { print $$1 ":arm;" $$3 } else if ($$2 ~ /arm64[a-z]?/) { print $$1 ":arm64;" $$3 ";" $$4} else { print $$1 ":" $$2 ";" $$3 ";" $$4} }' )
+
+# use embedded_device_map
+endif
+
+# Map a product like "n75" to "arm;t8002"
+# $(1) is a product name in lower case
+function_lookup_product = $(call function_substitute_word_with_replacement,    \
+                                $(1),                                          \
+                                $(DEVICEMAP_PRODUCT_SOC_MAPPINGS),             \
+                                unknown_arch_for_$(1);unknown_platform_for_$(1) \
+                          )
+
+ifneq ($(PLATFORM),MacOSX)
+ifneq ($(EMBEDDED_DEVICE_MAP),)
+# Generate a list of mappings for products that use a different platform for their kernel configuration than their true platform
+# of the form "n71m:arm64;s8000;s8003". The 4th element is the true SoC platform, which will get an on-disk copy, while the
+# kernel's recursive build system will build the 3rd element as the KernelPlatform
+DEVICEMAP_PRODUCT_SOC_ALIASES := $(shell $(EMBEDDED_DEVICE_MAP) -db $(EDM_DBPATH) -query SELECT DISTINCT TargetType, KernelMachOArchitecture, KernelPlatform, Platform FROM Targets WHERE KernelPlatform "!=" Platform | awk -F\| '{ if ($$2 ~ /armv[0-9][a-z]?/) { print $$1 ":arm;" $$3 ";" $$4} else if ($$2 ~ /arm64[a-z]?/) { print $$1 ":arm64;" $$3 ";" $$4} else { print $$1 ":" $$2 ";" $$3 ";" $$4} }' )
+
+endif
+endif
+
+function_lookup_product_alias = $(call function_substitute_word_with_replacement,      \
+                                       $(1),                                           \
+                                       $(DEVICEMAP_PRODUCT_SOC_ALIASES),               \
+                                )
+endif
 
 ifeq ($(PLATFORM),MacOSX)
 
@@ -145,8 +244,9 @@ TARGET_CONFIGS := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_
 TARGET_CONFIGS_ALIASES := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_$(my_arch_config)),$(call function_lookup_product_alias,$(my_product_config)))),$(foreach my_kernel_config,$(KERNEL_CONFIGS_EMBEDDED),$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
 else ifneq ($(filter %_desktop,$(MAKECMDGOALS)),)
 # generate TARGET_CONFIGS for all kernel configs for B&I
-TARGET_CONFIGS := $(foreach my_kern_config, $(KERNEL_CONFIGS_DESKTOP), $(foreach my_arch_config, $(ARCH_CONFIGS), $(foreach my_machine_config, $(MACHINE_CONFIGS), $(my_kern_config) $(my_arch_config) $(my_machine_config))))
-TARGET_CONFIGS_ALIASES :=
+TARGET_CONFIGS := $(foreach my_kern_config, $(KERNEL_CONFIGS_DESKTOP), $(foreach my_arch_config, $(ARCH_CONFIGS_DESKTOP), $(foreach my_machine_config, $(MACHINE_CONFIGS), $(my_kern_config) $(my_arch_config) $(my_machine_config))))
+TARGET_CONFIGS += $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_OSX_$(my_arch_config)),$(call function_lookup_product,$(my_product_config)))),$(foreach my_kernel_config,$(KERNEL_CONFIGS_EMBEDDED),$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
+TARGET_CONFIGS_ALIASES := $(foreach my_devicemap_config,$(foreach my_arch_config,$(ARCH_CONFIGS_EMBEDDED),$(foreach my_product_config,$(DEVICEMAP_PRODUCTS_OSX_$(my_arch_config)),$(call function_lookup_product_alias,$(my_product_config)))),$(foreach my_kernel_config,$(KERNEL_CONFIGS_EMBEDDED),$(my_kernel_config) $(subst ;, ,$(my_devicemap_config))))
 else
 # generate TARGET_CONFIGS using KERNEL_CONFIGS and ARCH_CONFIGS and MACHINE_CONFIGS (which defaults to "DEFAULT")
 TARGET_CONFIGS := $(foreach my_kern_config, $(KERNEL_CONFIGS), $(foreach my_arch_config, $(ARCH_CONFIGS), $(foreach my_machine_config, $(MACHINE_CONFIGS), $(my_kern_config) $(my_arch_config) $(my_machine_config))))
@@ -348,10 +448,10 @@ exporthdrs_md: build_exporthdrs_md_bootstrap
 
 .PHONY: installhdrs installhdrs_mi installhdrs_md
 
-ifeq ($(RC_ProjectName),xnu_debug)
+ifneq ($(filter $(RC_ProjectName),xnu_debug),)
 installhdrs:
        @:
-else ifeq ($(RC_ProjectName),xnu_kasan)
+else ifneq ($(filter $(RC_ProjectName),xnu_kasan),)
 installhdrs:
        @:
 else
@@ -389,19 +489,33 @@ $(eval $(generated_top_level_build_installhdrs_md))
 
 installhdrs_md: build_installhdrs_md_bootstrap
 
+.PHONY: install_textfiles install_textfiles_mi install_textfiles_md
+
+install_textfiles: install_textfiles_mi install_textfiles_md
+
 #
-#  Install text files (man pages, dtrace scripts, etc.)
+#  Install machine independent text files (man pages, dtrace scripts, etc.)
 #
 
-generated_top_level_textfiles_install = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install,,setup,,1,$(FIRST_BUILD_CONFIG))
+generated_top_level_textfiles_install_mi = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install_mi,,setup,,1,$(FIRST_BUILD_CONFIG))
 ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
-$(warning Generate makefile fragment: $(generated_top_level_textfiles_install))
+$(warning Generate makefile fragment: $(generated_top_level_textfiles_install_mi))
 endif
-$(eval $(generated_top_level_textfiles_install))
+$(eval $(generated_top_level_textfiles_install_mi))
 
-.PHONY: install_textfiles
+install_textfiles_mi: textfiles_install_mi_bootstrap
 
-install_textfiles: textfiles_install_bootstrap
+#
+#  Install machine dependent text files (man pages, dtrace scripts, etc.)
+#
+
+generated_top_level_textfiles_install_md = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,textfiles_install_md,,setup,,$(KERNEL_BUILDS_IN_PARALLEL),$(PRIMARY_BUILD_CONFIGS))
+ifeq ($(VERBOSE_GENERATED_MAKE_FRAGMENTS),YES)
+$(warning Generate makefile fragment: $(generated_top_level_textfiles_install_md))
+endif
+$(eval $(generated_top_level_textfiles_install_md))
+
+install_textfiles_md: textfiles_install_md_bootstrap
 
 #
 # Build all architectures for all Configuration/Architecture options
@@ -479,12 +593,17 @@ final_touch_config_timestamps: config_install_bootstrap
 
 .PHONY: install
 
-ifeq ($(RC_ProjectName),xnu_debug)
+ifneq ($(filter $(RC_ProjectName),xnu_debug),)
 install: install_kernels
-else ifeq ($(RC_ProjectName),xnu_kasan)
+else ifneq ($(filter $(RC_ProjectName),xnu_kasan),)
 install: install_config install_kernels
-else ifeq ($(RC_ProjectName),xnu_headers_Sim)
+else ifneq ($(filter $(RC_ProjectName),xnu_headers_Sim),)
 install: installhdrs
+else ifneq ($(filter $(RC_ProjectName),xnu_headers_host),)
+install: installhdrs
+export INSTALLHDRS_SKIP_HOST=YES
+else ifneq ($(filter $(RC_ProjectName),xnu_headers_driverkit),)
+install: installhdrs_desktop
 else
 
 install: installhdrs install_textfiles install_config install_kernels install_aliases
@@ -505,6 +624,7 @@ install_kernels: build_install_primary_bootstrap build_install_non_primary_boots
 # Tell the next build the latest timestamp of any potential file in DSTROOT/SYMROOT
 final_touch_kernel_timestamps: build_install_primary_bootstrap build_install_non_primary_bootstrap
        $(_v)$(TOUCH) $(OBJROOT)/.mach_kernel.timestamp
+       @echo "done building xnu"
 
 # Copy kernels that are aliases of another configuration
 generated_top_level_install_alias = $(call TOP_LEVEL_EACH_BUILD_CONFIG_BOOTSTRAP_template,install_alias,,install_kernels,,$(KERNEL_BUILDS_IN_PARALLEL),$(ALIAS_CONFIGS))
@@ -545,7 +665,6 @@ CLEAN_RM_DIRS= $(OBJROOT) $(SYMROOT) $(DSTROOT) \
 CLEAN_ACTION_DIRS= $(SRCROOT)/tools/tests/MPMMTest \
                $(SRCROOT)/tools/tests/TLBcoherency \
                $(SRCROOT)/tools/tests/kqueue_tests \
-               $(SRCROOT)/tools/tests/libMicro \
                $(SRCROOT)/tools/tests/mktimer \
                $(SRCROOT)/tools/tests/zero-to-n \
                $(SRCROOT)/tools/tests/personas
@@ -605,13 +724,6 @@ TAGS: cscope.files
        @-cat cscope.files | etags -l auto -S - 2> /dev/null
        @rm -f cscope.files 2> /dev/null
 
-#
-# Re-indent source code using xnu clang-format style
-#
-.PHONY: reindent
-
-reindent:
-       $(_v)$(SRCROOT)/tools/reindent.sh
 
 .PHONY: help
 
@@ -632,3 +744,5 @@ $(eval $(generated_top_level_print_exports))
 .PHONY: print_exports_first_build_config
 
 print_exports_first_build_config: print_exports_bootstrap
+
+# vim: set ft=make: