# SPDX-License-Identifier: GPL-2.0VERSION = 6PATCHLEVEL = 19SUBLEVEL = 0EXTRAVERSION =NAME = Baby Opossum Posse # *DOCUMENTATION*# To see a list of typical targets execute "make help"# More info can be located in ./README# Comments in this file are targeted only to the developer, do not# expect to learn how to build the kernel reading this file. ifeq ($(filter output-sync,$(.FEATURES)),)$(error GNU Make >= 4.0 is required. Your Make version is $(MAKE_VERSION))endif $(if $(filter __%, $(MAKECMDGOALS)), \ $(error targets prefixed with '__' are only for internal use)) # That's our default target when none is given on the command linePHONY := __all__all: # We are using a recursive build, so we need to do a little thinking# to get the ordering right.## Most importantly: sub-Makefiles should only ever modify files in# their own directory. If in some directory we have a dependency on# a file in another dir (which doesn't happen often, but it's often# unavoidable when linking the built-in.a targets which finally# turn into vmlinux), we will call a sub make in that other dir, and# after that we are sure that everything which is in that other dir# is now up to date.## The only cases where we need to modify files which have global# effects are thus separated out and done before the recursive# descending is started. They are now explicitly listed as the# prepare rule. this-makefile := $(lastword $(MAKEFILE_LIST))abs_srctree := $(realpath $(dir $(this-makefile)))abs_output := $(CURDIR) ifneq ($(sub_make_done),1) # Do not use make's built-in rules and variables# (this increases performance and avoids hard-to-debug behaviour)MAKEFLAGS += -rR # Avoid funny character set dependenciesunexport LC_ALLLC_COLLATE=CLC_NUMERIC=Cexport LC_COLLATE LC_NUMERIC # Avoid interference with shell env settingsunexport GREP_OPTIONS # Beautify output# ---------------------------------------------------------------------------## Most of build commands in Kbuild start with "cmd_". You can optionally define# "quiet_cmd_*". If defined, the short log is printed. Otherwise, no log from# that command is printed by default.## e.g.)# quiet_cmd_depmod = DEPMOD $(MODLIB)# cmd_depmod = $(srctree)/scripts/depmod.sh $(DEPMOD) $(KERNELRELEASE)## A simple variant is to prefix commands with $(Q) - that's useful# for commands that shall be hidden in non-verbose mode.## $(Q)$(MAKE) $(build)=scripts/basic## If KBUILD_VERBOSE contains 1, the whole command is echoed.# If KBUILD_VERBOSE contains 2, the reason for rebuilding is printed.## To put more focus on warnings, be less verbose as default# Use 'make V=1' to see the full commands ifeq ("$(origin V)", "command line") KBUILD_VERBOSE = $(V)endif quiet = quiet_Q = @ ifneq ($(findstring 1, $(KBUILD_VERBOSE)),) quiet = Q =endif # If the user is running make -s (silent mode), suppress echoing of# commandsifneq ($(findstring s,$(firstword -$(MAKEFLAGS))),)quiet=silent_override KBUILD_VERBOSE :=endif export quiet Q KBUILD_VERBOSE # Call a source code checker (by default, "sparse") as part of the# C compilation.## Use 'make C=1' to enable checking of only re-compiled files.# Use 'make C=2' to enable checking of *all* source files, regardless# of whether they are re-compiled or not.## See the file "Documentation/dev-tools/sparse.rst" for more details,# including where to get the "sparse" utility. ifeq ("$(origin C)", "command line") KBUILD_CHECKSRC = $(C)endififndef KBUILD_CHECKSRC KBUILD_CHECKSRC = 0endif export KBUILD_CHECKSRC # Enable "clippy" (a linter) as part of the Rust compilation.## Use 'make CLIPPY=1' to enable it.ifeq ("$(origin CLIPPY)", "command line") KBUILD_CLIPPY := $(CLIPPY)endif export KBUILD_CLIPPY # Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the# directory of external module to build. Setting M= takes precedence.ifeq ("$(origin M)", "command line") KBUILD_EXTMOD := $(M)endif ifeq ("$(origin MO)", "command line") KBUILD_EXTMOD_OUTPUT := $(MO)endif $(if $(word 2, $(KBUILD_EXTMOD)), \ $(error building multiple external modules is not supported)) $(foreach x, % :, $(if $(findstring $x, $(KBUILD_EXTMOD)), \ $(error module directory path cannot contain '$x'))) # Remove trailing slashesifneq ($(filter %/, $(KBUILD_EXTMOD)),)KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)endif export KBUILD_EXTMOD ifeq ("$(origin W)", "command line") KBUILD_EXTRA_WARN := $(W)endif export KBUILD_EXTRA_WARN # Kbuild will save output files in the current working directory.# This does not need to match to the root of the kernel source tree.## For example, you can do this:## cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile## If you want to save output files in a different location, there are# two syntaxes to specify it.## 1) O=# Use "make O=dir/to/store/output/files/"## 2) Set KBUILD_OUTPUT# Set the environment variable KBUILD_OUTPUT to point to the output directory.# export KBUILD_OUTPUT=dir/to/store/output/files/; make## The O= assignment takes precedence over the KBUILD_OUTPUT environment# variable. ifeq ("$(origin O)", "command line") KBUILD_OUTPUT := $(O)endif ifdef KBUILD_EXTMOD ifdef KBUILD_OUTPUT objtree := $(realpath $(KBUILD_OUTPUT)) $(if $(objtree),,$(error specified kernel directory "$(KBUILD_OUTPUT)" does not exist)) else objtree := $(abs_srctree) endif # If Make is invoked from the kernel directory (either kernel # source directory or kernel build directory), external modules # are built in $(KBUILD_EXTMOD) for backward compatibility, # otherwise, built in the current directory. output := $(or $(KBUILD_EXTMOD_OUTPUT),$(if $(filter $(CURDIR),$(objtree) $(abs_srctree)),$(KBUILD_EXTMOD))) # KBUILD_EXTMOD might be a relative path. Remember its absolute path before # Make changes the working directory. srcroot := $(realpath $(KBUILD_EXTMOD)) $(if $(srcroot),,$(error specified external module directory "$(KBUILD_EXTMOD)" does not exist))else objtree := . output := $(KBUILD_OUTPUT)endif export objtree srcroot # Do we want to change the working directory?ifneq ($(output),)# $(realpath ...) gets empty if the path does not exist. Run 'mkdir -p' first.$(shell mkdir -p "$(output)")# $(realpath ...) resolves symlinksabs_output := $(realpath $(output))$(if $(abs_output),,$(error failed to create output directory "$(output)"))endif ifneq ($(words $(subst :, ,$(abs_srctree))), 1)$(error source directory cannot contain spaces or colons)endif export sub_make_done := 1 endif # sub_make_done ifeq ($(abs_output),$(CURDIR))# Suppress "Entering directory ..." if we are at the final work directory.no-print-directory := --no-print-directoryelse# Recursion to show "Entering directory ..."need-sub-make := 1endif ifeq ($(filter --no-print-directory, $(MAKEFLAGS)),)# If --no-print-directory is unset, recurse once again to set it.# You may end up recursing into __sub-make twice. This is needed due to the# behavior change in GNU Make 4.4.1.need-sub-make := 1endif ifeq ($(need-sub-make),1) PHONY += $(MAKECMDGOALS) __sub-make $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make @: # Invoke a second make in the output directory, passing relevant variables__sub-make: $(Q)$(MAKE) $(no-print-directory) -C $(abs_output) \ -f $(abs_srctree)/Makefile $(MAKECMDGOALS) else # need-sub-make # We process the rest of the Makefile if this is the final invocation of make ifndef KBUILD_EXTMODsrcroot := $(abs_srctree)endif ifeq ($(srcroot),$(CURDIR))building_out_of_srctree :=elseexport building_out_of_srctree := 1endif ifdef KBUILD_ABS_SRCTREE # Do nothing. Use the absolute path.else ifeq ($(srcroot),$(CURDIR)) # Building in the source. srcroot := .else ifeq ($(srcroot)/,$(dir $(CURDIR))) # Building in a subdirectory of the source. srcroot := ..endif export srctree := $(if $(KBUILD_EXTMOD),$(abs_srctree),$(srcroot)) ifdef building_out_of_srctreeexport VPATH := $(srcroot)elseVPATH :=endif # To make sure we do not include .config for any of the *config targets# catch them early, and hand them over to scripts/kconfig/Makefile# It is allowed to specify more targets when calling make, including# mixing *config targets and build targets.# For example 'make oldconfig all'.# Detect when mixed targets is specified, and make a second invocation# of make so .config is not included in this case either (for *config). version_h := include/generated/uapi/linux/version.h clean-targets := %clean mrproper cleandocsno-dot-config-targets := $(clean-targets) \ cscope gtags TAGS tags help% %docs check% coccicheck \ $(version_h) headers headers_% archheaders archscripts \ %asm-generic kernelversion %src-pkg dt_binding_check \ outputmakefile rustavailable rustfmt rustfmtcheckno-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \ image_namesingle-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %/ config-build :=mixed-build :=need-config := 1may-sync-config := 1single-build := ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) need-config := endifendif ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) may-sync-config := endifendif need-compiler := $(may-sync-config) ifneq ($(KBUILD_EXTMOD),) may-sync-config :=endif ifeq ($(KBUILD_EXTMOD),) ifneq ($(filter %config,$(MAKECMDGOALS)),) config-build := 1 ifneq ($(words $(MAKECMDGOALS)),1) mixed-build := 1 endif endifendif # We cannot build single targets and the others at the same timeifneq ($(filter $(single-targets), $(MAKECMDGOALS)),) single-build := 1 ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),) mixed-build := 1 endifendif # For "make -j clean all", "make -j mrproper defconfig all", etc.ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),) ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),) mixed-build := 1 endifendif # install and modules_install need also be processed one by oneifneq ($(filter install,$(MAKECMDGOALS)),) ifneq ($(filter modules_install,$(MAKECMDGOALS)),) mixed-build := 1 endifendif ifdef mixed-build# ===========================================================================# We're called with mixed targets (*config and build targets).# Handle them one by one. PHONY += $(MAKECMDGOALS) __build_one_by_one $(MAKECMDGOALS): __build_one_by_one @: __build_one_by_one: $(Q)set -e; \ for i in $(MAKECMDGOALS); do \ $(MAKE) -f $(srctree)/Makefile $$i; \ done else # !mixed-build include $(srctree)/scripts/Kbuild.include # Read KERNELRELEASE from include/config/kernel.release (if it exists)KERNELRELEASE = $(call read-file, $(objtree)/include/config/kernel.release)KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION include $(srctree)/scripts/subarch.include # Cross compiling and selecting different set of gcc/bin-utils# ---------------------------------------------------------------------------## When performing cross compilation for other architectures ARCH shall be set# to the target architecture. (See arch/* for the possibilities).# ARCH can be set during invocation of make:# make ARCH=arm64# Another way is to have ARCH set in the environment.# The default ARCH is the host where make is executed. # CROSS_COMPILE specify the prefix used for all executables used# during compilation. Only gcc and related bin-utils executables# are prefixed with $(CROSS_COMPILE).# CROSS_COMPILE can be set on the command line# make CROSS_COMPILE=aarch64-linux-gnu-# Alternatively CROSS_COMPILE can be set in the environment.# Default value for CROSS_COMPILE is not to prefix executables# Note: Some architectures assign CROSS_COMPILE in their arch/*/MakefileARCH ?= $(SUBARCH) # Architecture as present in compile.hUTS_MACHINE := $(ARCH)SRCARCH := $(ARCH) # Additional ARCH settings for x86ifeq ($(ARCH),i386) SRCARCH := x86endififeq ($(ARCH),x86_64) SRCARCH := x86endif # Additional ARCH settings for sparcifeq ($(ARCH),sparc32) SRCARCH := sparcendififeq ($(ARCH),sparc64) SRCARCH := sparcendif # Additional ARCH settings for pariscifeq ($(ARCH),parisc64) SRCARCH := pariscendif export cross_compiling :=ifneq ($(SRCARCH),$(SUBARCH))cross_compiling := 1endif KCONFIG_CONFIG ?= .configexport KCONFIG_CONFIG # SHELL used by kbuildCONFIG_SHELL := sh HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null) ifneq ($(LLVM),)ifneq ($(filter %/,$(LLVM)),)LLVM_PREFIX := $(LLVM)else ifneq ($(filter -%,$(LLVM)),)LLVM_SUFFIX := $(LLVM)endif HOSTCC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)HOSTCXX = $(LLVM_PREFIX)clang++$(LLVM_SUFFIX)elseHOSTCC = gccHOSTCXX = g++endifHOSTRUSTC = rustcHOSTPKG_CONFIG = pkg-config # the KERNELDOC macro needs to be exported, as scripts/Makefile.build# has a logic to call itKERNELDOC = $(srctree)/scripts/kernel-doc.pyexport KERNELDOC KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ -O2 -fomit-frame-pointer -std=gnu11KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)KBUILD_USERLDFLAGS := $(USERLDFLAGS) # These flags apply to all Rust code in the tree, including the kernel and# host programs.export rust_common_flags := --edition=2021 \ -Zbinary_dep_depinfo=y \ -Astable_features \ -Dnon_ascii_idents \ -Dunsafe_op_in_unsafe_fn \ -Wmissing_docs \ -Wrust_2018_idioms \ -Wunreachable_pub \ -Wclippy::all \ -Wclippy::as_ptr_cast_mut \ -Wclippy::as_underscore \ -Wclippy::cast_lossless \ -Wclippy::ignored_unit_patterns \ -Wclippy::mut_mut \ -Wclippy::needless_bitwise_bool \ -Aclippy::needless_lifetimes \ -Wclippy::no_mangle_with_rust_abi \ -Wclippy::ptr_as_ptr \ -Wclippy::ptr_cast_constness \ -Wclippy::ref_as_ptr \ -Wclippy::undocumented_unsafe_blocks \ -Wclippy::unnecessary_safety_comment \ -Wclippy::unnecessary_safety_doc \ -Wrustdoc::missing_crate_level_docs \ -Wrustdoc::unescaped_backticks KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) \ $(HOSTCFLAGS) -I $(srctree)/scripts/includeLines 1–500 of 2203. Load more
# SPDX-License-Identifier: GPL-2.0 VERSION = 6 PATCHLEVEL = 19 SUBLEVEL = 0 EXTRAVERSION = NAME = Baby Opossum Posse # *DOCUMENTATION* # To see a list of typical targets execute "make help" # More info can be located in ./README # Comments in this file are targeted only to the developer, do not # expect to learn how to build the kernel reading this file. ifeq ($(filter output-sync,$(.FEATURES)),) $(error GNU Make >= 4.0 is required. Your Make version is $(MAKE_VERSION)) endif $(if $(filter __%, $(MAKECMDGOALS)), \ $(error targets prefixed with '__' are only for internal use)) # That's our default target when none is given on the command line PHONY := __all __all: # We are using a recursive build, so we need to do a little thinking # to get the ordering right. # # Most importantly: sub-Makefiles should only ever modify files in # their own directory. If in some directory we have a dependency on # a file in another dir (which doesn't happen often, but it's often # unavoidable when linking the built-in.a targets which finally # turn into vmlinux), we will call a sub make in that other dir, and # after that we are sure that everything which is in that other dir # is now up to date. # # The only cases where we need to modify files which have global # effects are thus separated out and done before the recursive # descending is started. They are now explicitly listed as the # prepare rule. this-makefile := $(lastword $(MAKEFILE_LIST)) abs_srctree := $(realpath $(dir $(this-makefile))) abs_output := $(CURDIR) ifneq ($(sub_make_done),1) # Do not use make's built-in rules and variables # (this increases performance and avoids hard-to-debug behaviour) MAKEFLAGS += -rR # Avoid funny character set dependencies unexport LC_ALL LC_COLLATE=C LC_NUMERIC=C export LC_COLLATE LC_NUMERIC # Avoid interference with shell env settings unexport GREP_OPTIONS # Beautify output # --------------------------------------------------------------------------- # # Most of build commands in Kbuild start with "cmd_". You can optionally define # "quiet_cmd_*". If defined, the short log is printed. Otherwise, no log from # that command is printed by default. # # e.g.) # quiet_cmd_depmod = DEPMOD $(MODLIB) # cmd_depmod = $(srctree)/scripts/depmod.sh $(DEPMOD) $(KERNELRELEASE) # # A simple variant is to prefix commands with $(Q) - that's useful # for commands that shall be hidden in non-verbose mode. # # $(Q)$(MAKE) $(build)=scripts/basic # # If KBUILD_VERBOSE contains 1, the whole command is echoed. # If KBUILD_VERBOSE contains 2, the reason for rebuilding is printed. # # To put more focus on warnings, be less verbose as default # Use 'make V=1' to see the full commands ifeq ("$(origin V)", "command line") KBUILD_VERBOSE = $(V) endif quiet = quiet_ Q = @ ifneq ($(findstring 1, $(KBUILD_VERBOSE)),) quiet = Q = endif # If the user is running make -s (silent mode), suppress echoing of # commands ifneq ($(findstring s,$(firstword -$(MAKEFLAGS))),) quiet=silent_ override KBUILD_VERBOSE := endif export quiet Q KBUILD_VERBOSE # Call a source code checker (by default, "sparse") as part of the # C compilation. # # Use 'make C=1' to enable checking of only re-compiled files. # Use 'make C=2' to enable checking of *all* source files, regardless # of whether they are re-compiled or not. # # See the file "Documentation/dev-tools/sparse.rst" for more details, # including where to get the "sparse" utility. ifeq ("$(origin C)", "command line") KBUILD_CHECKSRC = $(C) endif ifndef KBUILD_CHECKSRC KBUILD_CHECKSRC = 0 endif export KBUILD_CHECKSRC # Enable "clippy" (a linter) as part of the Rust compilation. # # Use 'make CLIPPY=1' to enable it. ifeq ("$(origin CLIPPY)", "command line") KBUILD_CLIPPY := $(CLIPPY) endif export KBUILD_CLIPPY # Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the # directory of external module to build. Setting M= takes precedence. ifeq ("$(origin M)", "command line") KBUILD_EXTMOD := $(M) endif ifeq ("$(origin MO)", "command line") KBUILD_EXTMOD_OUTPUT := $(MO) endif $(if $(word 2, $(KBUILD_EXTMOD)), \ $(error building multiple external modules is not supported)) $(foreach x, % :, $(if $(findstring $x, $(KBUILD_EXTMOD)), \ $(error module directory path cannot contain '$x'))) # Remove trailing slashes ifneq ($(filter %/, $(KBUILD_EXTMOD)),) KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).) endif export KBUILD_EXTMOD ifeq ("$(origin W)", "command line") KBUILD_EXTRA_WARN := $(W) endif export KBUILD_EXTRA_WARN # Kbuild will save output files in the current working directory. # This does not need to match to the root of the kernel source tree. # # For example, you can do this: # # cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile # # If you want to save output files in a different location, there are # two syntaxes to specify it. # # 1) O= # Use "make O=dir/to/store/output/files/" # # 2) Set KBUILD_OUTPUT # Set the environment variable KBUILD_OUTPUT to point to the output directory. # export KBUILD_OUTPUT=dir/to/store/output/files/; make # # The O= assignment takes precedence over the KBUILD_OUTPUT environment # variable. ifeq ("$(origin O)", "command line") KBUILD_OUTPUT := $(O) endif ifdef KBUILD_EXTMOD ifdef KBUILD_OUTPUT objtree := $(realpath $(KBUILD_OUTPUT)) $(if $(objtree),,$(error specified kernel directory "$(KBUILD_OUTPUT)" does not exist)) else objtree := $(abs_srctree) endif # If Make is invoked from the kernel directory (either kernel # source directory or kernel build directory), external modules # are built in $(KBUILD_EXTMOD) for backward compatibility, # otherwise, built in the current directory. output := $(or $(KBUILD_EXTMOD_OUTPUT),$(if $(filter $(CURDIR),$(objtree) $(abs_srctree)),$(KBUILD_EXTMOD))) # KBUILD_EXTMOD might be a relative path. Remember its absolute path before # Make changes the working directory. srcroot := $(realpath $(KBUILD_EXTMOD)) $(if $(srcroot),,$(error specified external module directory "$(KBUILD_EXTMOD)" does not exist)) else objtree := . output := $(KBUILD_OUTPUT) endif export objtree srcroot # Do we want to change the working directory? ifneq ($(output),) # $(realpath ...) gets empty if the path does not exist. Run 'mkdir -p' first. $(shell mkdir -p "$(output)") # $(realpath ...) resolves symlinks abs_output := $(realpath $(output)) $(if $(abs_output),,$(error failed to create output directory "$(output)")) endif ifneq ($(words $(subst :, ,$(abs_srctree))), 1) $(error source directory cannot contain spaces or colons) endif export sub_make_done := 1 endif # sub_make_done ifeq ($(abs_output),$(CURDIR)) # Suppress "Entering directory ..." if we are at the final work directory. no-print-directory := --no-print-directory else # Recursion to show "Entering directory ..." need-sub-make := 1 endif ifeq ($(filter --no-print-directory, $(MAKEFLAGS)),) # If --no-print-directory is unset, recurse once again to set it. # You may end up recursing into __sub-make twice. This is needed due to the # behavior change in GNU Make 4.4.1. need-sub-make := 1 endif ifeq ($(need-sub-make),1) PHONY += $(MAKECMDGOALS) __sub-make $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make @: # Invoke a second make in the output directory, passing relevant variables __sub-make: $(Q)$(MAKE) $(no-print-directory) -C $(abs_output) \ -f $(abs_srctree)/Makefile $(MAKECMDGOALS) else # need-sub-make # We process the rest of the Makefile if this is the final invocation of make ifndef KBUILD_EXTMOD srcroot := $(abs_srctree) endif ifeq ($(srcroot),$(CURDIR)) building_out_of_srctree := else export building_out_of_srctree := 1 endif ifdef KBUILD_ABS_SRCTREE # Do nothing. Use the absolute path. else ifeq ($(srcroot),$(CURDIR)) # Building in the source. srcroot := . else ifeq ($(srcroot)/,$(dir $(CURDIR))) # Building in a subdirectory of the source. srcroot := .. endif export srctree := $(if $(KBUILD_EXTMOD),$(abs_srctree),$(srcroot)) ifdef building_out_of_srctree export VPATH := $(srcroot) else VPATH := endif # To make sure we do not include .config for any of the *config targets # catch them early, and hand them over to scripts/kconfig/Makefile # It is allowed to specify more targets when calling make, including # mixing *config targets and build targets. # For example 'make oldconfig all'. # Detect when mixed targets is specified, and make a second invocation # of make so .config is not included in this case either (for *config). version_h := include/generated/uapi/linux/version.h clean-targets := %clean mrproper cleandocs no-dot-config-targets := $(clean-targets) \ cscope gtags TAGS tags help% %docs check% coccicheck \ $(version_h) headers headers_% archheaders archscripts \ %asm-generic kernelversion %src-pkg dt_binding_check \ outputmakefile rustavailable rustfmt rustfmtcheck no-sync-config-targets := $(no-dot-config-targets) %install modules_sign kernelrelease \ image_name single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.rsi %.s %/ config-build := mixed-build := need-config := 1 may-sync-config := 1 single-build := ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) need-config := endif endif ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) may-sync-config := endif endif need-compiler := $(may-sync-config) ifneq ($(KBUILD_EXTMOD),) may-sync-config := endif ifeq ($(KBUILD_EXTMOD),) ifneq ($(filter %config,$(MAKECMDGOALS)),) config-build := 1 ifneq ($(words $(MAKECMDGOALS)),1) mixed-build := 1 endif endif endif # We cannot build single targets and the others at the same time ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),) single-build := 1 ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),) mixed-build := 1 endif endif # For "make -j clean all", "make -j mrproper defconfig all", etc. ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),) ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),) mixed-build := 1 endif endif # install and modules_install need also be processed one by one ifneq ($(filter install,$(MAKECMDGOALS)),) ifneq ($(filter modules_install,$(MAKECMDGOALS)),) mixed-build := 1 endif endif ifdef mixed-build # =========================================================================== # We're called with mixed targets (*config and build targets). # Handle them one by one. PHONY += $(MAKECMDGOALS) __build_one_by_one $(MAKECMDGOALS): __build_one_by_one @: __build_one_by_one: $(Q)set -e; \ for i in $(MAKECMDGOALS); do \ $(MAKE) -f $(srctree)/Makefile $$i; \ done else # !mixed-build include $(srctree)/scripts/Kbuild.include # Read KERNELRELEASE from include/config/kernel.release (if it exists) KERNELRELEASE = $(call read-file, $(objtree)/include/config/kernel.release) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION include $(srctree)/scripts/subarch.include # Cross compiling and selecting different set of gcc/bin-utils # --------------------------------------------------------------------------- # # When performing cross compilation for other architectures ARCH shall be set # to the target architecture. (See arch/* for the possibilities). # ARCH can be set during invocation of make: # make ARCH=arm64 # Another way is to have ARCH set in the environment. # The default ARCH is the host where make is executed. # CROSS_COMPILE specify the prefix used for all executables used # during compilation. Only gcc and related bin-utils executables # are prefixed with $(CROSS_COMPILE). # CROSS_COMPILE can be set on the command line # make CROSS_COMPILE=aarch64-linux-gnu- # Alternatively CROSS_COMPILE can be set in the environment. # Default value for CROSS_COMPILE is not to prefix executables # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile ARCH ?= $(SUBARCH) # Architecture as present in compile.h UTS_MACHINE := $(ARCH) SRCARCH := $(ARCH) # Additional ARCH settings for x86 ifeq ($(ARCH),i386) SRCARCH := x86 endif ifeq ($(ARCH),x86_64) SRCARCH := x86 endif # Additional ARCH settings for sparc ifeq ($(ARCH),sparc32) SRCARCH := sparc endif ifeq ($(ARCH),sparc64) SRCARCH := sparc endif # Additional ARCH settings for parisc ifeq ($(ARCH),parisc64) SRCARCH := parisc endif export cross_compiling := ifneq ($(SRCARCH),$(SUBARCH)) cross_compiling := 1 endif KCONFIG_CONFIG ?= .config export KCONFIG_CONFIG # SHELL used by kbuild CONFIG_SHELL := sh HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null) HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null) HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null) ifneq ($(LLVM),) ifneq ($(filter %/,$(LLVM)),) LLVM_PREFIX := $(LLVM) else ifneq ($(filter -%,$(LLVM)),) LLVM_SUFFIX := $(LLVM) endif HOSTCC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX) HOSTCXX = $(LLVM_PREFIX)clang++$(LLVM_SUFFIX) else HOSTCC = gcc HOSTCXX = g++ endif HOSTRUSTC = rustc HOSTPKG_CONFIG = pkg-config # the KERNELDOC macro needs to be exported, as scripts/Makefile.build # has a logic to call it KERNELDOC = $(srctree)/scripts/kernel-doc.py export KERNELDOC KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ -O2 -fomit-frame-pointer -std=gnu11 KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS) KBUILD_USERLDFLAGS := $(USERLDFLAGS) # These flags apply to all Rust code in the tree, including the kernel and # host programs. export rust_common_flags := --edition=2021 \ -Zbinary_dep_depinfo=y \ -Astable_features \ -Dnon_ascii_idents \ -Dunsafe_op_in_unsafe_fn \ -Wmissing_docs \ -Wrust_2018_idioms \ -Wunreachable_pub \ -Wclippy::all \ -Wclippy::as_ptr_cast_mut \ -Wclippy::as_underscore \ -Wclippy::cast_lossless \ -Wclippy::ignored_unit_patterns \ -Wclippy::mut_mut \ -Wclippy::needless_bitwise_bool \ -Aclippy::needless_lifetimes \ -Wclippy::no_mangle_with_rust_abi \ -Wclippy::ptr_as_ptr \ -Wclippy::ptr_cast_constness \ -Wclippy::ref_as_ptr \ -Wclippy::undocumented_unsafe_blocks \ -Wclippy::unnecessary_safety_comment \ -Wclippy::unnecessary_safety_doc \ -Wrustdoc::missing_crate_level_docs \ -Wrustdoc::unescaped_backticks KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) \ $(HOSTCFLAGS) -I $(srctree)/scripts/include