# SPDX-License-Identifier: GPL-2.0VERSION = 6PATCHLEVEL = 0SUBLEVEL = 0EXTRAVERSION =NAME = Hurr durr I'ma ninja sloth # *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. $(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. 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# ---------------------------------------------------------------------------## Normally, we echo the whole command before executing it. By making# that echo $($(quiet)$(cmd)), we now have the possibility to set# $(quiet) to choose other forms of output instead, e.g.## quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<## If $(quiet) is empty, the whole command will be printed.# If it is set to "quiet_", only the short version will be printed.# If it is set to "silent_", nothing will be printed at all, since# the variable $(silent_cmd_cc_o_c) doesn't exist.## A simple variant is to prefix commands with $(Q) - that's useful# for commands that shall be hidden in non-verbose mode.## $(Q)ln $@ :<## If KBUILD_VERBOSE equals 0 then the above command will be hidden.# If KBUILD_VERBOSE equals 1 then the above command is displayed.# If KBUILD_VERBOSE equals 2 then give the reason why each target is rebuilt.## 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)endififndef KBUILD_VERBOSE KBUILD_VERBOSE = 0endif ifeq ($(KBUILD_VERBOSE),1) quiet = Q =else quiet=quiet_ Q = @endif # If the user is running make -s (silent mode), suppress echoing of# commands ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) quiet=silent_ KBUILD_VERBOSE = 0endif 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 # 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 $(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 # 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. # Do we want to change the working directory?ifeq ("$(origin O)", "command line") KBUILD_OUTPUT := $(O)endif ifneq ($(KBUILD_OUTPUT),)# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot# expand a shell special character '~'. We use a somewhat tedious way here.abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)$(if $(abs_objtree),, \ $(error failed to create output directory "$(KBUILD_OUTPUT)")) # $(realpath ...) resolves symlinksabs_objtree := $(realpath $(abs_objtree))elseabs_objtree := $(CURDIR)endif # ifneq ($(KBUILD_OUTPUT),) ifeq ($(abs_objtree),$(CURDIR))# Suppress "Entering directory ..." unless we are changing the work directory.MAKEFLAGS += --no-print-directoryelseneed-sub-make := 1endif this-makefile := $(lastword $(MAKEFILE_LIST))abs_srctree := $(realpath $(dir $(this-makefile))) ifneq ($(words $(subst :, ,$(abs_srctree))), 1)$(error source directory cannot contain spaces or colons)endif ifneq ($(abs_srctree),$(abs_objtree))# Look for make include files relative to root of kernel src## --included-dir is added for backward compatibility, but you should not rely on# it. Please add $(srctree)/ prefix to include Makefiles in the source tree.MAKEFLAGS += --include-dir=$(abs_srctree)endif ifneq ($(filter 3.%,$(MAKE_VERSION)),)# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x# We need to invoke sub-make to avoid implicit rules in the top Makefile.need-sub-make := 1# Cancel implicit rules for this Makefile.$(this-makefile): ;endif export abs_srctree abs_objtreeexport sub_make_done := 1 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) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS) endif # need-sub-makeendif # sub_make_done # We process the rest of the Makefile if this is the final invocation of makeifeq ($(need-sub-make),) # Do not print "Entering directory ...",# but we want to display it when entering to the output directory# so that IDEs/editors are able to understand relative filenames.MAKEFLAGS += --no-print-directory ifeq ($(abs_srctree),$(abs_objtree)) # building in the source tree srctree := . building_out_of_srctree :=else ifeq ($(abs_srctree)/,$(dir $(abs_objtree))) # building in a subdirectory of the source tree srctree := .. else srctree := $(abs_srctree) endif building_out_of_srctree := 1endif ifneq ($(KBUILD_ABS_SRCTREE),)srctree := $(abs_srctree)endif objtree := .VPATH := $(srctree) export building_out_of_srctree srctree objtree VPATH # 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# Installation targets should not require compiler. Unfortunately, vdso_install# is an exception where build artifacts may be updated. This must be fixed.no-compiler-targets := $(no-dot-config-targets) install dtbs_install \ headers_install modules_install kernelrelease image_nameno-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \ image_namesingle-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/ config-build :=mixed-build :=need-config := 1need-compiler := 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-compiler-targets), $(MAKECMDGOALS)),) ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),) need-compiler := endifendif ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) may-sync-config := endifendif 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 = $(shell cat include/config/kernel.release 2> /dev/null)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=ia64# 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=ia64-linux-# 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++endifHOSTPKG_CONFIG = pkg-config KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ -O2 -fomit-frame-pointer -std=gnu11 \ -Wdeclaration-after-statementKBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)KBUILD_USERLDFLAGS := $(USERLDFLAGS) KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) # Make variables (CC, etc...)CPP = $(CC) -Eifneq ($(LLVM),)CC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX)LD = $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX)AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX)NM = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX)OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)OBJDUMP = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)READELF = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)STRIP = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)elseCC = $(CROSS_COMPILE)gccLD = $(CROSS_COMPILE)ldAR = $(CROSS_COMPILE)arNM = $(CROSS_COMPILE)nmOBJCOPY = $(CROSS_COMPILE)objcopyOBJDUMP = $(CROSS_COMPILE)objdumpREADELF = $(CROSS_COMPILE)readelfSTRIP = $(CROSS_COMPILE)stripendifPAHOLE = paholeRESOLVE_BTFIDS = $(objtree)/tools/bpf/resolve_btfids/resolve_btfidsLEX = flexYACC = bisonAWK = awkINSTALLKERNEL := installkernelDEPMOD = depmodPERL = perlPYTHON3 = python3CHECK = sparseBASH = bashKGZIP = gzipKBZIP2 = bzip2KLZOP = lzopLZMA = lzmaLZ4 = lz4cXZ = xzZSTD = zstd PAHOLE_FLAGS = $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh) CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)NOSTDINC_FLAGS :=CFLAGS_MODULE =Lines 1–500 of 1984. Load more
# SPDX-License-Identifier: GPL-2.0 VERSION = 6 PATCHLEVEL = 0 SUBLEVEL = 0 EXTRAVERSION = NAME = Hurr durr I'ma ninja sloth # *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. $(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. 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 # --------------------------------------------------------------------------- # # Normally, we echo the whole command before executing it. By making # that echo $($(quiet)$(cmd)), we now have the possibility to set # $(quiet) to choose other forms of output instead, e.g. # # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< # # If $(quiet) is empty, the whole command will be printed. # If it is set to "quiet_", only the short version will be printed. # If it is set to "silent_", nothing will be printed at all, since # the variable $(silent_cmd_cc_o_c) doesn't exist. # # A simple variant is to prefix commands with $(Q) - that's useful # for commands that shall be hidden in non-verbose mode. # # $(Q)ln $@ :< # # If KBUILD_VERBOSE equals 0 then the above command will be hidden. # If KBUILD_VERBOSE equals 1 then the above command is displayed. # If KBUILD_VERBOSE equals 2 then give the reason why each target is rebuilt. # # 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 ifndef KBUILD_VERBOSE KBUILD_VERBOSE = 0 endif ifeq ($(KBUILD_VERBOSE),1) quiet = Q = else quiet=quiet_ Q = @ endif # If the user is running make -s (silent mode), suppress echoing of # commands ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) quiet=silent_ KBUILD_VERBOSE = 0 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 # 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 $(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 # 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. # Do we want to change the working directory? ifeq ("$(origin O)", "command line") KBUILD_OUTPUT := $(O) endif ifneq ($(KBUILD_OUTPUT),) # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot # expand a shell special character '~'. We use a somewhat tedious way here. abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd) $(if $(abs_objtree),, \ $(error failed to create output directory "$(KBUILD_OUTPUT)")) # $(realpath ...) resolves symlinks abs_objtree := $(realpath $(abs_objtree)) else abs_objtree := $(CURDIR) endif # ifneq ($(KBUILD_OUTPUT),) ifeq ($(abs_objtree),$(CURDIR)) # Suppress "Entering directory ..." unless we are changing the work directory. MAKEFLAGS += --no-print-directory else need-sub-make := 1 endif this-makefile := $(lastword $(MAKEFILE_LIST)) abs_srctree := $(realpath $(dir $(this-makefile))) ifneq ($(words $(subst :, ,$(abs_srctree))), 1) $(error source directory cannot contain spaces or colons) endif ifneq ($(abs_srctree),$(abs_objtree)) # Look for make include files relative to root of kernel src # # --included-dir is added for backward compatibility, but you should not rely on # it. Please add $(srctree)/ prefix to include Makefiles in the source tree. MAKEFLAGS += --include-dir=$(abs_srctree) endif ifneq ($(filter 3.%,$(MAKE_VERSION)),) # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x # We need to invoke sub-make to avoid implicit rules in the top Makefile. need-sub-make := 1 # Cancel implicit rules for this Makefile. $(this-makefile): ; endif export abs_srctree abs_objtree export sub_make_done := 1 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) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS) endif # need-sub-make endif # sub_make_done # We process the rest of the Makefile if this is the final invocation of make ifeq ($(need-sub-make),) # Do not print "Entering directory ...", # but we want to display it when entering to the output directory # so that IDEs/editors are able to understand relative filenames. MAKEFLAGS += --no-print-directory ifeq ($(abs_srctree),$(abs_objtree)) # building in the source tree srctree := . building_out_of_srctree := else ifeq ($(abs_srctree)/,$(dir $(abs_objtree))) # building in a subdirectory of the source tree srctree := .. else srctree := $(abs_srctree) endif building_out_of_srctree := 1 endif ifneq ($(KBUILD_ABS_SRCTREE),) srctree := $(abs_srctree) endif objtree := . VPATH := $(srctree) export building_out_of_srctree srctree objtree VPATH # 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 # Installation targets should not require compiler. Unfortunately, vdso_install # is an exception where build artifacts may be updated. This must be fixed. no-compiler-targets := $(no-dot-config-targets) install dtbs_install \ headers_install modules_install kernelrelease image_name no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \ image_name single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/ config-build := mixed-build := need-config := 1 need-compiler := 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-compiler-targets), $(MAKECMDGOALS)),) ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),) need-compiler := endif endif ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) may-sync-config := endif endif 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 = $(shell cat include/config/kernel.release 2> /dev/null) 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=ia64 # 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=ia64-linux- # 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 HOSTPKG_CONFIG = pkg-config KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ -O2 -fomit-frame-pointer -std=gnu11 \ -Wdeclaration-after-statement KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS) KBUILD_USERLDFLAGS := $(USERLDFLAGS) KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) # Make variables (CC, etc...) CPP = $(CC) -E ifneq ($(LLVM),) CC = $(LLVM_PREFIX)clang$(LLVM_SUFFIX) LD = $(LLVM_PREFIX)ld.lld$(LLVM_SUFFIX) AR = $(LLVM_PREFIX)llvm-ar$(LLVM_SUFFIX) NM = $(LLVM_PREFIX)llvm-nm$(LLVM_SUFFIX) OBJCOPY = $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX) OBJDUMP = $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX) READELF = $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX) STRIP = $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX) else CC = $(CROSS_COMPILE)gcc LD = $(CROSS_COMPILE)ld AR = $(CROSS_COMPILE)ar NM = $(CROSS_COMPILE)nm OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump READELF = $(CROSS_COMPILE)readelf STRIP = $(CROSS_COMPILE)strip endif PAHOLE = pahole RESOLVE_BTFIDS = $(objtree)/tools/bpf/resolve_btfids/resolve_btfids LEX = flex YACC = bison AWK = awk INSTALLKERNEL := installkernel DEPMOD = depmod PERL = perl PYTHON3 = python3 CHECK = sparse BASH = bash KGZIP = gzip KBZIP2 = bzip2 KLZOP = lzop LZMA = lzma LZ4 = lz4c XZ = xz ZSTD = zstd PAHOLE_FLAGS = $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh) CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF) NOSTDINC_FLAGS := CFLAGS_MODULE =