^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) VERSION = 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) PATCHLEVEL = 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) SUBLEVEL = 110
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) EXTRAVERSION =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) NAME = Dare mighty things
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # *DOCUMENTATION*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) # To see a list of typical targets execute "make help"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # More info can be located in ./README
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # Comments in this file are targeted only to the developer, do not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # expect to learn how to build the kernel reading this file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) $(if $(filter __%, $(MAKECMDGOALS)), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) $(error targets prefixed with '__' are only for internal use))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) # That's our default target when none is given on the command line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) PHONY := __all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) __all:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) # We are using a recursive build, so we need to do a little thinking
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) # to get the ordering right.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) # Most importantly: sub-Makefiles should only ever modify files in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) # their own directory. If in some directory we have a dependency on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) # a file in another dir (which doesn't happen often, but it's often
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) # unavoidable when linking the built-in.a targets which finally
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) # turn into vmlinux), we will call a sub make in that other dir, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) # after that we are sure that everything which is in that other dir
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) # is now up to date.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) # The only cases where we need to modify files which have global
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) # effects are thus separated out and done before the recursive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) # descending is started. They are now explicitly listed as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) # prepare rule.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) ifneq ($(sub_make_done),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) # Do not use make's built-in rules and variables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) # (this increases performance and avoids hard-to-debug behaviour)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) MAKEFLAGS += -rR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) # Avoid funny character set dependencies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) unexport LC_ALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) LC_COLLATE=C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) LC_NUMERIC=C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) export LC_COLLATE LC_NUMERIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) # Avoid interference with shell env settings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) unexport GREP_OPTIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) # Beautify output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) # Normally, we echo the whole command before executing it. By making
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) # that echo $($(quiet)$(cmd)), we now have the possibility to set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) # $(quiet) to choose other forms of output instead, e.g.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) # If $(quiet) is empty, the whole command will be printed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) # If it is set to "quiet_", only the short version will be printed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) # If it is set to "silent_", nothing will be printed at all, since
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) # the variable $(silent_cmd_cc_o_c) doesn't exist.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) # A simple variant is to prefix commands with $(Q) - that's useful
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) # for commands that shall be hidden in non-verbose mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) # $(Q)ln $@ :<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) # If KBUILD_VERBOSE equals 1 then the above command is displayed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) # If KBUILD_VERBOSE equals 2 then give the reason why each target is rebuilt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) # To put more focus on warnings, be less verbose as default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) # Use 'make V=1' to see the full commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) ifeq ("$(origin V)", "command line")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) KBUILD_VERBOSE = $(V)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ifndef KBUILD_VERBOSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) KBUILD_VERBOSE = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) ifeq ($(KBUILD_VERBOSE),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) quiet =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) Q =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) quiet=quiet_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) Q = @
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) # If the user is running make -s (silent mode), suppress echoing of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) # commands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) quiet=silent_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) export quiet Q KBUILD_VERBOSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) # Kbuild will save output files in the current working directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) # This does not need to match to the root of the kernel source tree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) # For example, you can do this:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) # cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) # If you want to save output files in a different location, there are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) # two syntaxes to specify it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) # 1) O=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) # Use "make O=dir/to/store/output/files/"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) # 2) Set KBUILD_OUTPUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) # Set the environment variable KBUILD_OUTPUT to point to the output directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) # export KBUILD_OUTPUT=dir/to/store/output/files/; make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) # The O= assignment takes precedence over the KBUILD_OUTPUT environment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) # variable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) # Do we want to change the working directory?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) ifeq ("$(origin O)", "command line")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) KBUILD_OUTPUT := $(O)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) ifneq ($(KBUILD_OUTPUT),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) # expand a shell special character '~'. We use a somewhat tedious way here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) $(if $(abs_objtree),, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) $(error failed to create output directory "$(KBUILD_OUTPUT)"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) # $(realpath ...) resolves symlinks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) abs_objtree := $(realpath $(abs_objtree))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) abs_objtree := $(CURDIR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) endif # ifneq ($(KBUILD_OUTPUT),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) ifeq ($(abs_objtree),$(CURDIR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) # Suppress "Entering directory ..." unless we are changing the work directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) MAKEFLAGS += --no-print-directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) need-sub-make := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) abs_srctree := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) ifneq ($(words $(subst :, ,$(abs_srctree))), 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) $(error source directory cannot contain spaces or colons)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) ifneq ($(abs_srctree),$(abs_objtree))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) # Look for make include files relative to root of kernel src
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) # This does not become effective immediately because MAKEFLAGS is re-parsed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) # once after the Makefile is read. We need to invoke sub-make.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) MAKEFLAGS += --include-dir=$(abs_srctree)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) need-sub-make := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) this-makefile := $(lastword $(MAKEFILE_LIST))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) ifneq ($(filter 3.%,$(MAKE_VERSION)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) # We need to invoke sub-make to avoid implicit rules in the top Makefile.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) need-sub-make := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) # Cancel implicit rules for this Makefile.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) $(this-makefile): ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) export abs_srctree abs_objtree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) export sub_make_done := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) ifeq ($(need-sub-make),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) PHONY += $(MAKECMDGOALS) __sub-make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) @:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) # Invoke a second make in the output directory, passing relevant variables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) __sub-make:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) endif # need-sub-make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) endif # sub_make_done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) # We process the rest of the Makefile if this is the final invocation of make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) ifeq ($(need-sub-make),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) # Do not print "Entering directory ...",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) # but we want to display it when entering to the output directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) # so that IDEs/editors are able to understand relative filenames.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) MAKEFLAGS += --no-print-directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) # Call a source code checker (by default, "sparse") as part of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) # C compilation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) # Use 'make C=1' to enable checking of only re-compiled files.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) # Use 'make C=2' to enable checking of *all* source files, regardless
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) # of whether they are re-compiled or not.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) # See the file "Documentation/dev-tools/sparse.rst" for more details,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) # including where to get the "sparse" utility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) ifeq ("$(origin C)", "command line")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) KBUILD_CHECKSRC = $(C)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) ifndef KBUILD_CHECKSRC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) KBUILD_CHECKSRC = 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) # Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) # directory of external module to build. Setting M= takes precedence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) ifeq ("$(origin M)", "command line")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) KBUILD_EXTMOD := $(M)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) $(if $(word 2, $(KBUILD_EXTMOD)), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) $(error building multiple external modules is not supported))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) export KBUILD_CHECKSRC KBUILD_EXTMOD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) # ANDROID: set up mixed-build support. mixed-build allows device kernel modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) # to be compiled against a GKI kernel. This approach still uses the headers and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) # Kbuild from device kernel, so care must be taken to ensure that those headers match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) ifdef KBUILD_MIXED_TREE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) # Need vmlinux.symvers for modpost and System.map for depmod, check whether they exist in KBUILD_MIXED_TREE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) required_mixed_files=vmlinux.symvers System.map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) $(if $(filter-out $(words $(required_mixed_files)), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) $(words $(wildcard $(add-prefix $(KBUILD_MIXED_TREE)/,$(required_mixed_files))))),,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) $(error KBUILD_MIXED_TREE=$(KBUILD_MIXED_TREE) doesn't contain $(required_mixed_files)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) mixed-build-prefix = $(if $(KBUILD_MIXED_TREE),$(KBUILD_MIXED_TREE)/)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) export KBUILD_MIXED_TREE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) ifeq ($(abs_srctree),$(abs_objtree))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) # building in the source tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) srctree := .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) building_out_of_srctree :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) # building in a subdirectory of the source tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) srctree := ..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) srctree := $(abs_srctree)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) building_out_of_srctree := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) ifneq ($(KBUILD_ABS_SRCTREE),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) srctree := $(abs_srctree)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) objtree := .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) VPATH := $(srctree)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) export building_out_of_srctree srctree objtree VPATH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) # To make sure we do not include .config for any of the *config targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) # catch them early, and hand them over to scripts/kconfig/Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) # It is allowed to specify more targets when calling make, including
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) # mixing *config targets and build targets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) # For example 'make oldconfig all'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) # Detect when mixed targets is specified, and make a second invocation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) # of make so .config is not included in this case either (for *config).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) version_h := include/generated/uapi/linux/version.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) old_version_h := include/linux/version.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) clean-targets := %clean mrproper cleandocs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) no-dot-config-targets := $(clean-targets) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) cscope gtags TAGS tags help% %docs check% coccicheck \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) $(version_h) headers headers_% archheaders archscripts \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) %asm-generic kernelversion %src-pkg dt_binding_check \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) outputmakefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) image_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) config-build :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) mixed-build :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) need-config := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) may-sync-config := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) single-build :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) need-config :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) may-sync-config :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) ifneq ($(KBUILD_EXTMOD),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) may-sync-config :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) ifeq ($(KBUILD_EXTMOD),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) ifneq ($(filter %config,$(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) config-build := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) ifneq ($(words $(MAKECMDGOALS)),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) mixed-build := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) # We cannot build single targets and the others at the same time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) single-build := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) mixed-build := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) # For "make -j clean all", "make -j mrproper defconfig all", etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) mixed-build := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) # install and modules_install need also be processed one by one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) ifneq ($(filter install,$(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) mixed-build := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) ifdef mixed-build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) # ===========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) # We're called with mixed targets (*config and build targets).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) # Handle them one by one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) PHONY += $(MAKECMDGOALS) __build_one_by_one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) $(MAKECMDGOALS): __build_one_by_one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) @:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) __build_one_by_one:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) $(Q)set -e; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) for i in $(MAKECMDGOALS); do \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) $(MAKE) -f $(srctree)/Makefile $$i; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) else # !mixed-build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) include scripts/Kbuild.include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) # Read KERNELRELEASE from include/config/kernel.release (if it exists)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) include scripts/subarch.include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) # Cross compiling and selecting different set of gcc/bin-utils
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) # When performing cross compilation for other architectures ARCH shall be set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) # to the target architecture. (See arch/* for the possibilities).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) # ARCH can be set during invocation of make:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) # make ARCH=ia64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) # Another way is to have ARCH set in the environment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) # The default ARCH is the host where make is executed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) # CROSS_COMPILE specify the prefix used for all executables used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) # during compilation. Only gcc and related bin-utils executables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) # are prefixed with $(CROSS_COMPILE).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) # CROSS_COMPILE can be set on the command line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) # make CROSS_COMPILE=ia64-linux-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) # Alternatively CROSS_COMPILE can be set in the environment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) # Default value for CROSS_COMPILE is not to prefix executables
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) ARCH ?= $(SUBARCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) # Architecture as present in compile.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) UTS_MACHINE := $(ARCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) SRCARCH := $(ARCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) # Additional ARCH settings for x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) ifeq ($(ARCH),i386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) SRCARCH := x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) ifeq ($(ARCH),x86_64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) SRCARCH := x86
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) # Additional ARCH settings for sparc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) ifeq ($(ARCH),sparc32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) SRCARCH := sparc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) ifeq ($(ARCH),sparc64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) SRCARCH := sparc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) # Additional ARCH settings for sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) ifeq ($(ARCH),sh64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) SRCARCH := sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) KCONFIG_CONFIG ?= .config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) export KCONFIG_CONFIG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) # Default file for 'make defconfig'. This may be overridden by arch-Makefile.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) export KBUILD_DEFCONFIG := defconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) # SHELL used by kbuild
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) CONFIG_SHELL := sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) ifneq ($(LLVM),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) HOSTCC = clang
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) HOSTCXX = clang++
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) HOSTCC = gcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) HOSTCXX = g++
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) -O2 -fomit-frame-pointer -std=gnu89
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) KBUILD_USERLDFLAGS := $(USERLDFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) # Make variables (CC, etc...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) CPP = $(CC) -E
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) ifneq ($(LLVM),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) CC = clang
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) LD = ld.lld
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) AR = llvm-ar
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) NM = llvm-nm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) OBJCOPY = llvm-objcopy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) OBJDUMP = llvm-objdump
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) READELF = llvm-readelf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) STRIP = llvm-strip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) CC = $(CROSS_COMPILE)gcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) LD = $(CROSS_COMPILE)ld
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) AR = $(CROSS_COMPILE)ar
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) NM = $(CROSS_COMPILE)nm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) OBJCOPY = $(CROSS_COMPILE)objcopy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) OBJDUMP = $(CROSS_COMPILE)objdump
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) READELF = $(CROSS_COMPILE)readelf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) STRIP = $(CROSS_COMPILE)strip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) PAHOLE = pahole
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) RESOLVE_BTFIDS = $(objtree)/tools/bpf/resolve_btfids/resolve_btfids
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) LEX = flex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) YACC = bison
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) AWK = awk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) INSTALLKERNEL := installkernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) DEPMOD = depmod
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) PERL = perl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) PYTHON = python
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) PYTHON3 = python3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) CHECK = sparse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) BASH = bash
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) KGZIP = gzip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) KBZIP2 = bzip2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) KLZOP = lzop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) LZMA = lzma
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) LZ4 = lz4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) XZ = xz
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) ZSTD = zstd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) # Use the wrapper for the compiler. This wrapper scans for new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) # warnings and causes the build to stop upon encountering them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) ifeq ($(CC),$(CROSS_COMPILE)gcc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) ifneq ($(wildcard $(srctree)/scripts/gcc-wrapper.py),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) CC = $(abspath $(srctree)/scripts/gcc-wrapper.py) $(CROSS_COMPILE)gcc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) NOSTDINC_FLAGS :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) CFLAGS_MODULE =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) AFLAGS_MODULE =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) LDFLAGS_MODULE =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) CFLAGS_KERNEL =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) AFLAGS_KERNEL =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) LDFLAGS_vmlinux =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) # Use USERINCLUDE when you must reference the UAPI directories only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) USERINCLUDE := \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) -I$(srctree)/arch/$(SRCARCH)/include/uapi \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) -I$(srctree)/include/uapi \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) -I$(objtree)/include/generated/uapi \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) -include $(srctree)/include/linux/kconfig.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) # Use LINUXINCLUDE when you must reference the include/ directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) # Needed to be compatible with the O= option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) LINUXINCLUDE := \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) -I$(srctree)/arch/$(SRCARCH)/include \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) -I$(objtree)/arch/$(SRCARCH)/include/generated \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) $(if $(building_out_of_srctree),-I$(srctree)/include) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) -I$(objtree)/include \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) $(USERINCLUDE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) -Werror=implicit-function-declaration -Werror=implicit-int \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) -Werror=return-type -Wno-format-security \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) -std=gnu89
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) KBUILD_CPPFLAGS := -D__KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) KBUILD_AFLAGS_KERNEL :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) KBUILD_CFLAGS_KERNEL :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) KBUILD_AFLAGS_MODULE := -DMODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) KBUILD_CFLAGS_MODULE := -DMODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) KBUILD_LDFLAGS_MODULE :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) KBUILD_LDFLAGS :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) CLANG_FLAGS :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) export KBUILD_USERCFLAGS KBUILD_USERLDFLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) # Files to ignore in find ... statements
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) -name CVS -o -name .pc -o -name .hg -o -name .git \) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) -prune -o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) --exclude CVS --exclude .pc --exclude .hg --exclude .git
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) # ===========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) # Rules shared between *config targets and build targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) # Basic helpers built in scripts/basic/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) PHONY += scripts_basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) scripts_basic:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) $(Q)$(MAKE) $(build)=scripts/basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) $(Q)rm -f .tmp_quiet_recordmcount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) PHONY += outputmakefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) # Before starting out-of-tree build, make sure the source tree is clean.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) # outputmakefile generates a Makefile in the output directory, if using a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) # separate output directory. This allows convenient use of make in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) # output directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) # At the same time when output Makefile generated, generate .gitignore to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) # ignore whole output directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) outputmakefile:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) ifdef building_out_of_srctree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) $(Q)if [ -f $(srctree)/.config -o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) -d $(srctree)/include/config -o \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) echo >&2 "***"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) echo >&2 "*** The source tree is not clean, please run 'make$(if $(findstring command line, $(origin ARCH)), ARCH=$(ARCH)) mrproper'"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) echo >&2 "*** in $(abs_srctree)";\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) echo >&2 "***"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) false; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) $(Q)ln -fsn $(srctree) source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) $(Q)test -e .gitignore || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) ifneq ($(CROSS_COMPILE),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) ifneq ($(GCC_TOOLCHAIN),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) ifneq ($(LLVM_IAS),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) CLANG_FLAGS += -no-integrated-as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) CLANG_FLAGS += -Werror=unknown-warning-option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) KBUILD_CFLAGS += $(CLANG_FLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) KBUILD_AFLAGS += $(CLANG_FLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) export CLANG_FLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) # The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) # Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) # CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) # and from include/config/auto.conf.cmd to detect the compiler upgrade.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) ifdef config-build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) # ===========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) # *config targets only - make sure prerequisites are updated, and descend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) # in scripts/kconfig to make the *config target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) # KBUILD_DEFCONFIG may point out an alternative default configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) # used for 'make defconfig'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) include arch/$(SRCARCH)/Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) config: outputmakefile scripts_basic FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) $(Q)$(MAKE) $(build)=scripts/kconfig $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) %config: outputmakefile scripts_basic FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) $(Q)$(MAKE) $(build)=scripts/kconfig $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) else #!config-build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) # ===========================================================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) # Build targets only - this includes vmlinux, arch specific targets, clean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) # targets and others. In general all targets except *config targets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) # If building an external module we do not care about the all: rule
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) # but instead __all depend on modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) PHONY += all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) ifeq ($(KBUILD_EXTMOD),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) __all: all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) __all: modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) # Decide whether to build built-in, modular, or both.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) # Normally, just do built-in.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) KBUILD_MODULES :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) KBUILD_BUILTIN := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) # If we have only "make modules", don't compile built-in objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) ifeq ($(MAKECMDGOALS),modules)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) KBUILD_BUILTIN :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) # If we have "make <whatever> modules", compile modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) # in addition to whatever we do anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) # Just "make" or "make all" shall build modules as well
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) ifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) KBUILD_MODULES := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) ifeq ($(MAKECMDGOALS),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) KBUILD_MODULES := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) export KBUILD_MODULES KBUILD_BUILTIN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) ifdef need-config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) include include/config/auto.conf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) ifeq ($(KBUILD_EXTMOD),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) # Objects we will link into vmlinux / subdirs we need to visit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) core-y := init/ usr/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) drivers-y := drivers/ sound/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) drivers-$(CONFIG_SAMPLES) += samples/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) drivers-y += net/ virt/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) libs-y := lib/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) endif # KBUILD_EXTMOD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) ifndef KBUILD_MIXED_TREE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) # The all: target is the default when no target is given on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) # command line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) # This allow a user to issue only 'make' to build a kernel including modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) # Defaults to vmlinux, but the arch makefile usually adds further targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) all: vmlinux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) CFLAGS_GCOV := -fprofile-arcs -ftest-coverage \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) $(call cc-option,-fno-tree-loop-im) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) $(call cc-disable-warning,maybe-uninitialized,)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) export CFLAGS_GCOV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) # The arch Makefiles can override CC_FLAGS_FTRACE. We may also append it later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) ifdef CONFIG_FUNCTION_TRACER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) CC_FLAGS_FTRACE := -pg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) RETPOLINE_VDSO_CFLAGS_GCC := -mindirect-branch=thunk-inline -mindirect-branch-register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) RETPOLINE_VDSO_CFLAGS_CLANG := -mretpoline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_VDSO_CFLAGS_CLANG)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) export RETPOLINE_CFLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) export RETPOLINE_VDSO_CFLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) include arch/$(SRCARCH)/Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) ifdef need-config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) ifdef may-sync-config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) # changes are detected. This should be included after arch/$(SRCARCH)/Makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) # because some architectures define CROSS_COMPILE there.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) include include/config/auto.conf.cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) $(KCONFIG_CONFIG):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) @echo >&2 '***'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) @echo >&2 '*** Configuration file "$@" not found!'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) @echo >&2 '***'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) @echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) @echo >&2 '*** "make menuconfig" or "make xconfig").'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) @echo >&2 '***'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) @/bin/false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) # The actual configuration files used during the build are stored in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) # include/generated/ and include/config/. Update them if .config is newer than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) # include/config/auto.conf (which mirrors .config).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) # This exploits the 'multi-target pattern rule' trick.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) # The syncconfig should be executed only once to make all the targets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) # (Note: use the grouped target '&:' when we bump to GNU Make 4.3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) # Do not use $(call cmd,...) here. That would suppress prompts from syncconfig,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) # so you cannot notice that Kconfig is waiting for the user input.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) %/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h: $(KCONFIG_CONFIG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) $(Q)$(kecho) " SYNC $@"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) else # !may-sync-config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) # External modules and some install targets need include/generated/autoconf.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) # and include/config/auto.conf but do not care if they are up-to-date.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) # Use auto.conf to trigger the test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) PHONY += include/config/auto.conf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) include/config/auto.conf:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) echo >&2; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) echo >&2 " ERROR: Kernel configuration is invalid."; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) echo >&2 " include/generated/autoconf.h or $@ are missing.";\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) echo >&2 ; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) /bin/false)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) endif # may-sync-config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) endif # need-config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) KBUILD_CFLAGS += -O2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) KBUILD_CFLAGS += -O3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) KBUILD_CFLAGS += -Os
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) # Tell gcc to never replace conditional load with a non-conditional one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) ifdef CONFIG_READABLE_ASM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) # Disable optimizations that make assembler listings hard to read.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) # reorder blocks reorders the control in the function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) # ipa clone creates specialized cloned functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) # partial inlining inlines only parts of functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) $(call cc-option,-fno-ipa-cp-clone,) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) $(call cc-option,-fno-partial-inlining)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) ifneq ($(CONFIG_FRAME_WARN),0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) stackp-flags-y := -fno-stack-protector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) KBUILD_CFLAGS += $(stackp-flags-y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) ifdef CONFIG_CC_IS_CLANG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) KBUILD_CPPFLAGS += -Qunused-arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) KBUILD_CFLAGS += -Wno-format-invalid-specifier
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) KBUILD_CFLAGS += -Wno-gnu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) # source of a reference will be _MergedGlobals and not on of the whitelisted names.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) # See modpost pattern 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) KBUILD_CFLAGS += -mno-global-merge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) # Warn about unmarked fall-throughs in switch statement.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) # Disabled for clang while comment to attribute conversion happens and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) # https://github.com/ClangBuiltLinux/linux/issues/636 is discussed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) # These warnings generated too much noise in a regular build.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) # Use make W=1 to enable them (see scripts/Makefile.extrawarn)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) # These result in bogus false positives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) ifdef CONFIG_FRAME_POINTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) # Some targets (ARM with Thumb2, for example), can't be built with frame
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) # pointers. For those, we don't have FUNCTION_TRACER automatically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) # incompatible with -fomit-frame-pointer with current GCC, so we don't use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) # -fomit-frame-pointer with FUNCTION_TRACER.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) ifndef CONFIG_FUNCTION_TRACER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) KBUILD_CFLAGS += -fomit-frame-pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) # Initialize all stack variables with a 0xAA pattern.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) ifdef CONFIG_INIT_STACK_ALL_PATTERN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) # Initialize all stack variables with a zero value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) ifdef CONFIG_INIT_STACK_ALL_ZERO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) # Future support for zero initialization is still being debated, see
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) # https://bugs.llvm.org/show_bug.cgi?id=45497. These flags are subject to being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) # renamed or dropped.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) DEBUG_CFLAGS :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) # Workaround for GCC versions < 5.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) ifdef CONFIG_CC_IS_GCC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) DEBUG_CFLAGS += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) ifdef CONFIG_DEBUG_INFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) ifdef CONFIG_DEBUG_INFO_SPLIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) DEBUG_CFLAGS += -gsplit-dwarf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) DEBUG_CFLAGS += -g
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) ifneq ($(LLVM_IAS),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) KBUILD_AFLAGS += -Wa,-gdwarf-2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) ifdef CONFIG_DEBUG_INFO_DWARF4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) DEBUG_CFLAGS += -gdwarf-4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) ifdef CONFIG_DEBUG_INFO_REDUCED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) $(call cc-option,-fno-var-tracking)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) ifdef CONFIG_DEBUG_INFO_COMPRESSED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) DEBUG_CFLAGS += -gz=zlib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) KBUILD_AFLAGS += -gz=zlib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) KBUILD_LDFLAGS += --compress-debug-sections=zlib
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) endif # CONFIG_DEBUG_INFO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) KBUILD_CFLAGS += $(DEBUG_CFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) export DEBUG_CFLAGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) ifdef CONFIG_FUNCTION_TRACER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) ifdef CONFIG_FTRACE_MCOUNT_USE_CC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) CC_FLAGS_FTRACE += -mrecord-mcount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) ifdef CONFIG_HAVE_NOP_MCOUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) ifeq ($(call cc-option-yn, -mnop-mcount),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) CC_FLAGS_FTRACE += -mnop-mcount
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) ifdef CONFIG_HAVE_C_RECORDMCOUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) BUILD_C_RECORDMCOUNT := y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) export BUILD_C_RECORDMCOUNT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) ifdef CONFIG_HAVE_FENTRY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) ifeq ($(call cc-option-yn, -mfentry),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) CC_FLAGS_FTRACE += -mfentry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) CC_FLAGS_USING += -DCC_USING_FENTRY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) export CC_FLAGS_FTRACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) KBUILD_AFLAGS += $(CC_FLAGS_USING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) # We trigger additional mismatches with less inlining
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) ifdef CONFIG_DEBUG_SECTION_MISMATCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) LDFLAGS_vmlinux += --gc-sections
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) ifdef CONFIG_SHADOW_CALL_STACK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) CC_FLAGS_SCS := -fsanitize=shadow-call-stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) KBUILD_CFLAGS += $(CC_FLAGS_SCS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) export CC_FLAGS_SCS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) ifdef CONFIG_LTO_CLANG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) ifdef CONFIG_LTO_CLANG_THIN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) CC_FLAGS_LTO := -flto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) ifeq ($(SRCARCH),x86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) # TODO(b/182572011): Revert workaround for compiler / linker bug.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) CC_FLAGS_LTO += -fvisibility=hidden
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) CC_FLAGS_LTO += -fvisibility=default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) # Limit inlining across translation units to reduce binary size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) ifdef CONFIG_LTO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) KBUILD_CFLAGS += $(CC_FLAGS_LTO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) export CC_FLAGS_LTO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) ifdef CONFIG_CFI_CLANG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) CC_FLAGS_CFI := -fsanitize=cfi \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) -fsanitize-cfi-cross-dso \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) -fno-sanitize-cfi-canonical-jump-tables \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) -fno-sanitize-blacklist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) ifdef CONFIG_CFI_PERMISSIVE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) CC_FLAGS_CFI += -fsanitize-recover=cfi \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) -fno-sanitize-trap=cfi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) ifndef CONFIG_UBSAN_TRAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) CC_FLAGS_CFI += -ftrap-function=__ubsan_handle_cfi_check_fail_abort
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) # If LTO flags are filtered out, we must also filter out CFI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) CC_FLAGS_LTO += $(CC_FLAGS_CFI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) KBUILD_CFLAGS += $(CC_FLAGS_CFI)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) export CC_FLAGS_CFI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) ifdef CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_32B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) KBUILD_CFLAGS += -falign-functions=32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) # arch Makefile may override CC so keep this after arch Makefile is included
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) # warn about C99 declaration after statement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) KBUILD_CFLAGS += -Wdeclaration-after-statement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) # Variable Length Arrays (VLAs) should not be used anywhere in the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) KBUILD_CFLAGS += -Wvla
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) # disable pointer signed / unsigned warnings in gcc 4.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) KBUILD_CFLAGS += -Wno-pointer-sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) # disable stringop warnings in gcc 8+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) # We'll want to enable this eventually, but it's not going away for 5.7 at least
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) # Another good warning that we'll want to enable eventually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) # Enabled with W=2, disabled by default as noisy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) # disable invalid "can't wrap" optimizations for signed / pointers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) KBUILD_CFLAGS += -fno-strict-overflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) # Make sure -fstack-check isn't enabled (like gentoo apparently did)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) KBUILD_CFLAGS += -fno-stack-check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) # conserve stack if available
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) # Prohibit date/time macros, which would make the build non-deterministic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) KBUILD_CFLAGS += -Werror=date-time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) # enforce correct pointer usage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) # Require designated initializers for all marked structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) # change __FILE__ to the relative path from the srctree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) # include additional Makefiles when needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) include-y := scripts/Makefile.extrawarn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) include-$(CONFIG_KASAN) += scripts/Makefile.kasan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) include-$(CONFIG_KCOV) += scripts/Makefile.kcov
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) include $(addprefix $(srctree)/, $(include-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) # scripts/Makefile.gcc-plugins is intentionally included last.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) # Do not add $(call cc-option,...) below this line. When you build the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) # from the clean source tree, the GCC plugins do not exist at this point.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) KBUILD_CPPFLAGS += $(KCPPFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) KBUILD_AFLAGS += $(KAFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) KBUILD_CFLAGS += $(KCFLAGS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) KBUILD_LDFLAGS_MODULE += --build-id=sha1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) LDFLAGS_vmlinux += --build-id=sha1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) LDFLAGS_vmlinux += $(call ld-option, -X,)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) ifeq ($(CONFIG_RELR),y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) # We never want expected sections to be placed heuristically by the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) # linker. All sections should be explicitly named in the linker script.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) ifdef CONFIG_LD_ORPHAN_WARN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) LDFLAGS_vmlinux += --orphan-handling=warn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) # Align the bit size of userspace programs with the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) # make the checker run with the right architecture
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) CHECKFLAGS += --arch=$(ARCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) # insure the checker run with the right endianness
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) # the checker needs the correct machine size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) # Default kernel image to build when no specific target is given.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) # KBUILD_IMAGE may be overruled on the command line or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) # set in the environment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) # Also any assignments in arch/$(ARCH)/Makefile take precedence over
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) # this default value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) export KBUILD_IMAGE ?= vmlinux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) # INSTALL_PATH specifies where to place the updated kernel and system map
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) # images. Default is /boot, but you can set it to other values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) export INSTALL_PATH ?= /boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) # INSTALL_DTBS_PATH specifies a prefix for relocations required by build roots.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) # Like INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) # an argument if needed. Otherwise it defaults to the kernel install path
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) # relocations required by build roots. This is not defined in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) # makefile but the argument can be passed to make if needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) export MODLIB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) # INSTALL_MOD_STRIP, if defined, will cause modules to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) # stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) # the default option --strip-debug will be used. Otherwise,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) # INSTALL_MOD_STRIP value will be used as the options to the strip command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) ifdef INSTALL_MOD_STRIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) ifeq ($(INSTALL_MOD_STRIP),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) mod_strip_cmd = $(STRIP) --strip-debug
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) endif # INSTALL_MOD_STRIP=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) mod_strip_cmd = true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) endif # INSTALL_MOD_STRIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) export mod_strip_cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) # CONFIG_MODULE_COMPRESS, if defined, will cause module to be compressed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) # after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) # or CONFIG_MODULE_COMPRESS_XZ.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) mod_compress_cmd = true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) ifdef CONFIG_MODULE_COMPRESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) ifdef CONFIG_MODULE_COMPRESS_GZIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) mod_compress_cmd = $(KGZIP) -n -f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) endif # CONFIG_MODULE_COMPRESS_GZIP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) ifdef CONFIG_MODULE_COMPRESS_XZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) mod_compress_cmd = $(XZ) -f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) endif # CONFIG_MODULE_COMPRESS_XZ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) endif # CONFIG_MODULE_COMPRESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) export mod_compress_cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) ifdef CONFIG_MODULE_SIG_ALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) $(eval $(call config_filename,MODULE_SIG_KEY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) mod_sign_cmd = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY) certs/signing_key.x509
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) mod_sign_cmd = true
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) export mod_sign_cmd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) has_libelf := $(call try-run,\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) echo "int main() {}" | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) $(HOSTCC) $(KBUILD_HOSTCFLAGS) -xc -o /dev/null $(KBUILD_HOSTLDFLAGS) $(HOST_LIBELF_LIBS) -,1,0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) ifdef CONFIG_STACK_VALIDATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) ifeq ($(has_libelf),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) objtool_target := tools/objtool FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) SKIP_STACK_VALIDATION := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) export SKIP_STACK_VALIDATION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) PHONY += resolve_btfids_clean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) resolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) # tools/bpf/resolve_btfids directory might not exist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) # in output directory, skip its clean in that case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) resolve_btfids_clean:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) ifneq ($(wildcard $(resolve_btfids_O)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) ifdef CONFIG_BPF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) ifdef CONFIG_DEBUG_INFO_BTF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) ifeq ($(has_libelf),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) resolve_btfids_target := tools/bpf/resolve_btfids FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) ERROR_RESOLVE_BTFIDS := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) endif # CONFIG_DEBUG_INFO_BTF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) endif # CONFIG_BPF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) PHONY += prepare0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) export MODORDER := $(extmod-prefix)modules.order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) # Kernel headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) PHONY += headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) #Default location for installed headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) ifeq ($(KBUILD_EXTMOD),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) PHONY += archheaders archscripts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) hdr-prefix = $(KBUILD_EXTMOD)/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) hdr-inst := -f $(srctree)/scripts/Makefile.headersinst dst=$(KBUILD_EXTMOD)/usr/include objtree=$(objtree)/$(KBUILD_EXTMOD) obj
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) export INSTALL_HDR_PATH = $(objtree)/$(hdr-prefix)usr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) quiet_cmd_headers_install = INSTALL $(INSTALL_HDR_PATH)/include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) cmd_headers_install = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) mkdir -p $(INSTALL_HDR_PATH); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) $(hdr-prefix)usr/include $(INSTALL_HDR_PATH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) PHONY += headers_install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) headers_install: headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) $(call cmd,headers_install)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) headers:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) ifeq ($(KBUILD_EXTMOD),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) $(if $(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/Kbuild),, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) $(error Headers not exportable for the $(SRCARCH) architecture))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)include/uapi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)arch/$(SRCARCH)/include/uapi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) ifeq ($(KBUILD_EXTMOD),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) vmlinux-dirs := $(patsubst %/,%,$(filter %/, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) $(libs-y) $(libs-m)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) $(patsubst %/,%,$(filter %/, $(core-) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) $(drivers-) $(libs-))))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) subdir-modorder := $(addsuffix modules.order,$(filter %/, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) $(core-y) $(core-m) $(libs-y) $(libs-m) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) $(drivers-y) $(drivers-m)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) build-dirs := $(vmlinux-dirs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) clean-dirs := $(vmlinux-alldirs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) # Externally visible symbols (used by link-vmlinux.sh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) ifdef CONFIG_MODULES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) # used by scripts/Makefile.package
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) # Recurse until adjust_autoksyms.sh is satisfied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) PHONY += autoksyms_recursive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) ifdef CONFIG_TRIM_UNUSED_KSYMS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) # For the kernel to actually contain only the needed exported symbols,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) # we have to build modules as well to determine what those symbols are.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) # (this can be evaluated only once include/config/auto.conf has been included)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) KBUILD_MODULES := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) autoksyms_recursive: descend modules.order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) "$(MAKE) -f $(srctree)/Makefile vmlinux"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) quiet_cmd_autoksyms_h = GEN $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) cmd_autoksyms_h = mkdir -p $(dir $@); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) $(CONFIG_SHELL) $(srctree)/scripts/gen_autoksyms.sh $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) $(autoksyms_h):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) $(call cmd,autoksyms_h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) # Final link of vmlinux with optional arch pass after final link
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) cmd_link-vmlinux = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) $(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) ifndef KBUILD_MIXED_TREE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) +$(call if_changed,link-vmlinux)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) targets := vmlinux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) # The actual objects are generated when descending,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) # make sure no implicit rule kicks in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) $(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) filechk_kernel.release = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) $(srctree) $(BRANCH) $(KMI_GENERATION))"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) # Store (new) KERNELRELEASE string in include/config/kernel.release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) include/config/kernel.release: FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) $(call filechk,kernel.release)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) # Additional helpers built in scripts/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) # Carefully list dependencies so we do not try to build scripts twice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) # in parallel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) PHONY += scripts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) scripts: scripts_basic scripts_dtc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) $(Q)$(MAKE) $(build)=$(@)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) # Things we need to do before we recursively start building the kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) # or the modules are listed in "prepare".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) # A multi level approach is used. prepareN is processed before prepareN-1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) # archprepare is used in arch Makefiles and when processed asm symlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) # version.h and scripts_basic is processed / created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) PHONY += prepare archprepare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) include/generated/autoconf.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) prepare0: archprepare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) $(Q)$(MAKE) $(build)=scripts/mod
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) $(Q)$(MAKE) $(build)=.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) # All the preparing..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) prepare: prepare0 prepare-objtool prepare-resolve_btfids
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) # Support for using generic headers in asm-generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) PHONY += asm-generic uapi-asm-generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) asm-generic: uapi-asm-generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) generic=include/asm-generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) uapi-asm-generic:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) generic=include/uapi/asm-generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) PHONY += prepare-objtool prepare-resolve_btfids
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) prepare-objtool: $(objtool_target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) ifeq ($(SKIP_STACK_VALIDATION),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) @echo "error: Cannot generate __mcount_loc for CONFIG_DYNAMIC_FTRACE=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) @false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) ifdef CONFIG_UNWINDER_ORC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) @echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) @false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) @echo "warning: Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) prepare-resolve_btfids: $(resolve_btfids_target)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) ifeq ($(ERROR_RESOLVE_BTFIDS),1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) @echo "error: Cannot resolve BTF IDs for CONFIG_DEBUG_INFO_BTF, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) @false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) # Generate some files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) # KERNELRELEASE can change from a few different places, meaning version.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) # needs to be updated, so this check is forced on all builds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) uts_len := 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) ifneq (,$(BUILD_NUMBER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) UTS_RELEASE=$(KERNELRELEASE)-ab$(BUILD_NUMBER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) UTS_RELEASE=$(KERNELRELEASE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) define filechk_utsrelease.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) if [ `echo -n "$(UTS_RELEASE)" | wc -c ` -gt $(uts_len) ]; then \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) echo '"$(UTS_RELEASE)" exceeds $(uts_len) characters' >&2; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) exit 1; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) fi; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) echo \#define UTS_RELEASE \"$(UTS_RELEASE)\"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) define filechk_version.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) if [ $(SUBLEVEL) -gt 255 ]; then \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) echo \#define LINUX_VERSION_CODE $(shell \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + 255); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) else \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) echo \#define LINUX_VERSION_CODE $(shell \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) fi; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) ((c) > 255 ? 255 : (c)))'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) endef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) $(version_h): PATCHLEVEL := $(if $(PATCHLEVEL), $(PATCHLEVEL), 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) $(version_h): SUBLEVEL := $(if $(SUBLEVEL), $(SUBLEVEL), 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) $(version_h): FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) $(call filechk,version.h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) $(Q)rm -f $(old_version_h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) include/generated/utsrelease.h: include/config/kernel.release FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) $(call filechk,utsrelease.h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) PHONY += headerdep
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) headerdep:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) $(srctree)/scripts/headerdep.pl -I$(srctree)/include
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) # Deprecated. It is no-op now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) PHONY += headers_check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) headers_check:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) @:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) ifdef CONFIG_HEADERS_INSTALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) prepare: headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) PHONY += scripts_unifdef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) scripts_unifdef: scripts_basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) $(Q)$(MAKE) $(build)=scripts scripts/unifdef
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) # Kernel selftest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) PHONY += kselftest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) kselftest:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) kselftest-%: FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) PHONY += kselftest-merge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) kselftest-merge:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) $(Q)find $(srctree)/tools/testing/selftests -name config | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) # Devicetree files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) dtstree := arch/$(SRCARCH)/boot/dts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) ifneq ($(dtstree),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) %.dtb: include/config/kernel.release scripts_dtc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) %.dtbo: include/config/kernel.release scripts_dtc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) PHONY += dtbs dtbs_install dtbs_check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) dtbs: include/config/kernel.release scripts_dtc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) $(Q)$(MAKE) $(build)=$(dtstree)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) export CHECK_DTBS=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) dtbs: dt_binding_check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) dtbs_check: dtbs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) dtbs_install:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) $(Q)$(MAKE) $(dtbinst)=$(dtstree) dst=$(INSTALL_DTBS_PATH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) ifdef CONFIG_OF_EARLY_FLATTREE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) all: dtbs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) PHONY += scripts_dtc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) scripts_dtc: scripts_basic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) $(Q)$(MAKE) $(build)=scripts/dtc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) ifneq ($(filter dt_binding_check, $(MAKECMDGOALS)),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) export CHECK_DT_BINDING=y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) PHONY += dt_binding_check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) dt_binding_check: scripts_dtc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) # Modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) ifdef CONFIG_MODULES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) # By default, build modules as well
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) all: modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) # When we're building modules with modversions, we need to consider
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) # the built-in objects during the descend as well, in order to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) # make sure the checksums are up to date before we record them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) ifdef CONFIG_MODVERSIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) KBUILD_BUILTIN := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) # Build modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) # A module can be listed more than once in obj-m resulting in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) # duplicate lines in modules.order files. Those are removed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) # using awk while concatenating to the final file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) PHONY += modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) # if KBUILD_BUILTIN && !KBUILD_MIXED_TREE, depend on vmlinux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) modules: $(if $(KBUILD_BUILTIN), $(if $(KBUILD_MIXED_TREE),,vmlinux))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) modules: modules_check modules_prepare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) PHONY += modules_check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) modules_check: modules.order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) modules.order: $(subdir-modorder) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) $(call if_changed,modules_order)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) targets += modules.order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) # Target to prepare building external modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) PHONY += modules_prepare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) modules_prepare: prepare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) $(Q)$(MAKE) $(build)=scripts scripts/module.lds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) # Target to install modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) PHONY += modules_install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) modules_install: _modinst_ _modinst_post
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) PHONY += _modinst_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) _modinst_:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) @rm -rf $(MODLIB)/kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) @rm -f $(MODLIB)/source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) @mkdir -p $(MODLIB)/kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) @ln -s $(abspath $(srctree)) $(MODLIB)/source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) rm -f $(MODLIB)/build ; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) ln -s $(CURDIR) $(MODLIB)/build ; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) @cp -f $(mixed-build-prefix)modules.builtin $(MODLIB)/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) @cp -f $(or $(mixed-build-prefix),$(objtree)/)modules.builtin.modinfo $(MODLIB)/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) # This depmod is only for convenience to give the initial
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) # boot a modules.dep even before / is mounted read-write. However the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) # boot script depmod is the master version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) PHONY += _modinst_post
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) _modinst_post: _modinst_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) $(call cmd,depmod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) ifeq ($(CONFIG_MODULE_SIG), y)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) PHONY += modules_sign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) modules_sign:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) else # CONFIG_MODULES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) # Modules not configured
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) PHONY += modules modules_install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) modules modules_install:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) @echo >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) @echo >&2 "The present kernel configuration has modules disabled."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) @echo >&2 "Type 'make config' and enable loadable module support."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) @echo >&2 "Then build a kernel with module support enabled."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) @echo >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) @exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) endif # CONFIG_MODULES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) ###
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) # Cleaning is done on three levels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) # make clean Delete most generated files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) # Leave enough to build external modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) # make mrproper Delete the current configuration, and all generated files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) # make distclean Remove editor backup files, patch leftover files and the like
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) # Directories & files removed with 'make clean'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) modules.builtin modules.builtin.modinfo modules.nsdeps \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) compile_commands.json .thinlto-cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) # Directories & files removed with 'make mrproper'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) MRPROPER_FILES += include/config include/generated \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) arch/$(SRCARCH)/include/generated .tmp_objdiff \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) debian snap tar-install \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) .config .config.old .version \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) Module.symvers \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) signing_key.pem signing_key.priv signing_key.x509 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) x509.genkey extra_certificates signing_key.x509.keyid \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) signing_key.x509.signer vmlinux-gdb.py \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) *.spec
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) # Directories & files removed with 'make distclean'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) # clean - Delete most, but leave enough to build external modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) clean: rm-files := $(CLEAN_FILES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) PHONY += archclean vmlinuxclean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) vmlinuxclean:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) clean: archclean vmlinuxclean resolve_btfids_clean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) # mrproper - Delete all generated files, including .config
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) mrproper-dirs := $(addprefix _mrproper_,scripts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) PHONY += $(mrproper-dirs) mrproper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) $(mrproper-dirs):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) mrproper: clean $(mrproper-dirs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) $(call cmd,rmfiles)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) # distclean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) distclean: rm-files := $(wildcard $(DISTCLEAN_FILES))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) PHONY += distclean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) distclean: mrproper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) $(call cmd,rmfiles)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) @find $(srctree) $(RCS_FIND_IGNORE) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) -o -name '*.bak' -o -name '#*#' -o -name '*%' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) -o -name 'core' \) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) -type f -print | xargs rm -f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) # Packaging of the kernel to various formats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) %src-pkg: FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) %pkg: include/config/kernel.release FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) # Brief documentation of the typical targets used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) boards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) boards := $(sort $(notdir $(boards)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) board-dirs := $(sort $(notdir $(board-dirs:/=)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) PHONY += help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) help:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) @echo 'Cleaning targets:'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) @echo ' clean - Remove most generated files but keep the config and'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) @echo ' enough build support to build external modules'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) @echo ' mrproper - Remove all generated files + config + various backup files'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) @echo ' distclean - mrproper + remove editor backup and patch files'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) @echo 'Configuration targets:'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) @echo 'Other generic targets:'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) @echo ' all - Build all targets marked with [*]'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) @echo '* vmlinux - Build the bare kernel'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) @echo '* modules - Build all modules'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) @echo ' dir/ - Build all files in dir and below'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) @echo ' dir/file.[ois] - Build specified target only'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) @echo ' dir/file.ll - Build the LLVM assembly file'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) @echo ' (requires compiler support for LLVM assembly generation)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) @echo ' dir/file.lst - Build specified mixed source/assembly target only'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) @echo ' (requires a recent binutils and recent build (System.map))'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) @echo ' dir/file.ko - Build module including final link'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) @echo ' modules_prepare - Set up for building external modules'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) @echo ' tags/TAGS - Generate tags file for editors'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) @echo ' cscope - Generate cscope index'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) @echo ' gtags - Generate GNU GLOBAL index'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) @echo ' kernelrelease - Output the release version string (use with make -s)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) @echo ' image_name - Output the image name (use with make -s)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) echo ' (default: $(INSTALL_HDR_PATH))'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691) echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) @echo 'Static analysers:'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) @echo ' checkstack - Generate a list of stack hogs'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) @echo ' versioncheck - Sanity check on version.h usage'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) @echo ' includecheck - Check for duplicate included header files'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) @echo ' export_report - List the usages of all exported symbols'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) @echo ' headerdep - Detect inclusion cycles in headers'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) @echo ' coccicheck - Check with Coccinelle'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) @echo ' clang-analyzer - Check with clang static analyzer'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) @echo ' clang-tidy - Check with clang-tidy'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) @echo 'Tools:'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) @echo ' nsdeps - Generate missing symbol namespace dependencies'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) @echo 'Kernel selftest:'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) @echo ' kselftest - Build and run kernel selftest'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) @echo ' Build, install, and boot kernel before'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) @echo ' running kselftest on it'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) @echo ' Run as root for full coverage'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) @echo ' kselftest-all - Build kernel selftest'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) @echo ' kselftest-install - Build and install kernel selftest'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) @echo ' kselftest-clean - Remove all generated kselftest files'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) @echo ' kselftest-merge - Merge all the config dependencies of'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) @echo ' kselftest to existing .config.'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) @$(if $(dtstree), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) echo 'Devicetree:'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) echo '* dtbs - Build device tree blobs for enabled boards'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) echo ' dt_binding_check - Validate device tree binding documents'; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) echo ' dtbs_check - Validate device tree source files';\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) echo '')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) @echo 'Userspace tools targets:'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) @echo ' use "make tools/help"'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) @echo ' or "cd tools; make help"'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) @echo 'Kernel packaging:'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) @$(MAKE) -f $(srctree)/scripts/Makefile.package help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) @echo 'Documentation targets:'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) @echo 'Architecture specific targets ($(SRCARCH)):'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) @$(if $(archhelp),$(archhelp),\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) echo ' No architecture specific help defined for $(SRCARCH)')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) @$(if $(boards), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) $(foreach b, $(boards), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) echo '')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) @$(if $(board-dirs), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) $(foreach b, $(board-dirs), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) printf " %-16s - Show all of the above\\n" help-boards; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) echo '')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) @echo ' (sparse by default)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) @echo ' make W=n [targets] Enable extra build checks, n=1,2,3 where'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) @echo ' 1: warnings which may be relevant and do not occur too often'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) @echo ' 2: warnings which occur quite often but may still be relevant'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) @echo ' 3: more obscure warnings, can most likely be ignored'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) @echo ' Multiple levels can be combined with W=12 or W=123'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) @echo 'Execute "make" or "make all" to build all targets marked with [*] '
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) @echo 'For further info see the ./README file'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) help-board-dirs := $(addprefix help-,$(board-dirs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) help-boards: $(help-board-dirs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) $(help-board-dirs): help-%:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) @echo 'Architecture specific targets ($(SRCARCH) $*):'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) @$(if $(boards-per-dir), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) $(foreach b, $(boards-per-dir), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) echo '')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) # Documentation targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) linkcheckdocs dochelp refcheckdocs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) PHONY += $(DOC_TARGETS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) $(DOC_TARGETS):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) $(Q)$(MAKE) $(build)=Documentation $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) # Misc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) PHONY += scripts_gdb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) scripts_gdb: prepare0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) $(Q)$(MAKE) $(build)=scripts/gdb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) ifdef CONFIG_GDB_SCRIPTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) all: scripts_gdb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) else # KBUILD_EXTMOD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) ###
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) # External module support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) # When building external modules the kernel used as basis is considered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) # read-only, and no consistency checks are made and the make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) # system is not used on the basis kernel. If updates are required
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) # in the basis kernel ordinary make commands (without M=...) must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) # be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) # The following are the only valid targets when building external
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) # modules.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) # make M=dir clean Delete all automatically generated files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) # make M=dir modules Make all modules in specified dir
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) # make M=dir Same as 'make M=dir modules'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) # make M=dir modules_install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) # Install the modules built in the module directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) # Assumes install directory is already created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) # We are always building only modules.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) KBUILD_BUILTIN :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) KBUILD_MODULES := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) build-dirs := $(KBUILD_EXTMOD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) PHONY += modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) modules: $(MODORDER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) $(MODORDER): descend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) @:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) PHONY += modules_install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) modules_install: _emodinst_ _emodinst_post
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) PHONY += _emodinst_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) _emodinst_:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) $(Q)mkdir -p $(MODLIB)/$(install-dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) PHONY += _emodinst_post
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) _emodinst_post: _emodinst_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) $(call cmd,depmod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) compile_commands.json: $(extmod-prefix)compile_commands.json
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) PHONY += compile_commands.json
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) clean-dirs := $(KBUILD_EXTMOD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) $(KBUILD_EXTMOD)/compile_commands.json $(KBUILD_EXTMOD)/.thinlto-cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) PHONY += help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) help:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) @echo ' Building external modules.'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) @echo ' modules - default target, build the module(s)'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) @echo ' modules_install - install the module'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) @echo ' (default: $(abspath $(INSTALL_HDR_PATH)))'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) @echo ' clean - remove generated files in module directory only'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) @echo ''
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) # no-op for external module builds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) PHONY += prepare modules_prepare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) endif # KBUILD_EXTMOD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) # Single targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) # To build individual files in subdirectories, you can do like this:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) # make foo/bar/baz.s
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) # The supported suffixes for single-target are listed in 'single-targets'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) # To build only under specific subdirectories, you can do like this:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) # make foo/bar/baz/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) ifdef single-build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) # .ko is special because modpost is needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) single-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) $(single-ko): single_modpost
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) @:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) $(single-no-ko): descend
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) @:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) ifeq ($(KBUILD_EXTMOD),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) # For the single build of in-tree modules, use a temporary file to avoid
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) # the situation of modules_install installing an invalid modules.order.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) MODORDER := .modules.tmp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) PHONY += single_modpost
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) single_modpost: $(single-no-ko) modules_prepare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) KBUILD_MODULES := 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) # trim unrelated directories
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) build-dirs := $(foreach d, $(build-dirs), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) $(if $(filter $(d)/%, $(KBUILD_SINGLE_TARGETS)), $(d)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) ifndef CONFIG_MODULES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) KBUILD_MODULES :=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) # Handle descending into subdirectories listed in $(build-dirs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) # Preset locale variables to speed up the build process. Limit locale
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) # tweaks to this spot to avoid wrong language settings when running
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) # make menuconfig etc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) # Error messages still appears in the original language
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) PHONY += descend $(build-dirs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) descend: $(build-dirs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) $(build-dirs): prepare
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) $(Q)$(MAKE) $(build)=$@ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) $(if $(KBUILD_MIXED_TREE),,need-builtin=1) need-modorder=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927) clean-dirs := $(addprefix _clean_, $(clean-dirs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) PHONY += $(clean-dirs) clean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) $(clean-dirs):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) clean: $(clean-dirs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) $(call cmd,rmfiles)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) -o -name '*.ko.*' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) -o -name '*.dtb' -o -name '*.dtbo' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) -o -name '*.dwo' -o -name '*.lst' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) -o -name '*.su' -o -name '*.mod' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) -o -name '*.lex.c' -o -name '*.tab.[ch]' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) -o -name '*.asn1.[ch]' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) -o -name '*.symtypes' -o -name 'modules.order' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) -o -name '.tmp_*.o.*' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) -o -name '*.c.[012]*.*' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) -o -name '*.ll' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) -o -name '*.gcno' \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) -o -name '*.*.symversions' \) -type f -print | xargs rm -f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) # Generate tags for editors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) quiet_cmd_tags = GEN $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) cmd_tags = $(BASH) $(srctree)/scripts/tags.sh $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) tags TAGS cscope gtags: FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) $(call cmd,tags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) # Script to generate missing namespace dependencies
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) PHONY += nsdeps
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) nsdeps: export KBUILD_NSDEPS=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) nsdeps: modules
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/nsdeps
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) # Clang Tooling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) quiet_cmd_gen_compile_commands = GEN $@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970) cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) $(extmod-prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) $(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) $(if $(CONFIG_MODULES), $(MODORDER)) FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) $(call if_changed,gen_compile_commands)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) targets += $(extmod-prefix)compile_commands.json
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) PHONY += clang-tidy clang-analyzer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) ifdef CONFIG_CC_IS_CLANG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) quiet_cmd_clang_tools = CHECK $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983) cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) clang-tidy clang-analyzer: $(extmod-prefix)compile_commands.json
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) $(call cmd,clang_tools)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) clang-tidy clang-analyzer:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) @echo "$@ requires CC=clang" >&2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) @false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) # Scripts to check various things for consistency
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) # ---------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) PHONY += includecheck versioncheck coccicheck export_report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) includecheck:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) find $(srctree)/* $(RCS_FIND_IGNORE) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) -name '*.[hcS]' -type f -print | sort \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) versioncheck:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) find $(srctree)/* $(RCS_FIND_IGNORE) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005) -name '*.[hcS]' -type f -print | sort \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) coccicheck:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) $(Q)$(BASH) $(srctree)/scripts/$@
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) export_report:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) $(PERL) $(srctree)/scripts/export_report.pl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) PHONY += checkstack kernelrelease kernelversion image_name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) # UML needs a little special treatment here. It wants to use the host
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) # toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) # else wants $(ARCH), including people doing cross-builds, which means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) # that $(SUBARCH) doesn't work here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) ifeq ($(ARCH), um)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) CHECKSTACK_ARCH := $(SUBARCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) CHECKSTACK_ARCH := $(ARCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025) checkstack:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) $(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) kernelrelease:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) $(srctree) $(BRANCH) $(KMI_GENERATION))"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) kernelversion:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) @echo $(KERNELVERSION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) image_name:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) @echo $(KBUILD_IMAGE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) # Clear a bunch of variables before executing the submake
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) ifeq ($(quiet),silent_)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) tools_silent=s
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) tools/: FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) $(Q)mkdir -p $(objtree)/tools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) tools/%: FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) $(Q)mkdir -p $(objtree)/tools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) cmd_rmfiles = rm -rf $(rm-files)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) # Run depmod only if we have System.map and depmod is executable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) $(KERNELRELEASE) $(mixed-build-prefix)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) # read saved command lines for existing targets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062) existing-targets := $(wildcard $(sort $(targets)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) endif # config-build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) endif # mixed-build
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068) endif # need-sub-make
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) PHONY += FORCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) FORCE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) # Declare the contents of the PHONY variable as phony. We keep that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) # information in a variable so we can use it in if_changed and friends.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) .PHONY: $(PHONY)