b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100 1) # SPDX-License-Identifier: GPL-2.0
bfeffd1552837 (Linus Torvalds 2019-01-06 17:08:20 -0800 2) VERSION = 5
6880fa6c56601 (Linus Torvalds 2021-09-12 16:28:37 -0700 3) PATCHLEVEL = 15
55922c9d1b84b (Linus Torvalds 2011-05-29 17:43:36 -0700 4) SUBLEVEL = 0
8bb7eca972ad5 (Linus Torvalds 2021-10-31 13:53:10 -0700 5) EXTRAVERSION =
8bb7eca972ad5 (Linus Torvalds 2021-10-31 13:53:10 -0700 6) NAME = Trick or Treat
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 7)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 8) # *DOCUMENTATION*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 9) # To see a list of typical targets execute "make help"
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 10) # More info can be located in ./README
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 11) # Comments in this file are targeted only to the developer, do not
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 12) # expect to learn how to build the kernel reading this file.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 13)
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 14) $(if $(filter __%, $(MAKECMDGOALS)), \
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 15) $(error targets prefixed with '__' are only for internal use))
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 16)
ba634eceb535d (Masahiro Yamada 2017-10-04 12:56:05 +0900 17) # That's our default target when none is given on the command line
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 18) PHONY := __all
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 19) __all:
ba634eceb535d (Masahiro Yamada 2017-10-04 12:56:05 +0900 20)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 21) # We are using a recursive build, so we need to do a little thinking
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 22) # to get the ordering right.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 23) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 24) # Most importantly: sub-Makefiles should only ever modify files in
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 25) # their own directory. If in some directory we have a dependency on
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 26) # a file in another dir (which doesn't happen often, but it's often
f49821ee32b76 (Nicholas Piggin 2018-02-11 00:25:04 +1000 27) # unavoidable when linking the built-in.a targets which finally
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 28) # turn into vmlinux), we will call a sub make in that other dir, and
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 29) # after that we are sure that everything which is in that other dir
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 30) # is now up to date.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 31) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 32) # The only cases where we need to modify files which have global
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 33) # effects are thus separated out and done before the recursive
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 34) # descending is started. They are now explicitly listed as the
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 35) # prepare rule.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 36)
221cc2d27ddc4 (Masahiro Yamada 2019-03-26 13:02:19 +0900 37) ifneq ($(sub_make_done),1)
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 38)
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 39) # Do not use make's built-in rules and variables
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 40) # (this increases performance and avoids hard-to-debug behaviour)
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 41) MAKEFLAGS += -rR
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 42)
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 43) # Avoid funny character set dependencies
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 44) unexport LC_ALL
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 45) LC_COLLATE=C
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 46) LC_NUMERIC=C
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 47) export LC_COLLATE LC_NUMERIC
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 48)
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 49) # Avoid interference with shell env settings
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 50) unexport GREP_OPTIONS
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 51)
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 52) # Beautify output
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 53) # ---------------------------------------------------------------------------
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 54) #
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 55) # Normally, we echo the whole command before executing it. By making
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 56) # that echo $($(quiet)$(cmd)), we now have the possibility to set
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 57) # $(quiet) to choose other forms of output instead, e.g.
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 58) #
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 59) # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 60) # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 61) #
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 62) # If $(quiet) is empty, the whole command will be printed.
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 63) # If it is set to "quiet_", only the short version will be printed.
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 64) # If it is set to "silent_", nothing will be printed at all, since
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 65) # the variable $(silent_cmd_cc_o_c) doesn't exist.
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 66) #
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 67) # A simple variant is to prefix commands with $(Q) - that's useful
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 68) # for commands that shall be hidden in non-verbose mode.
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 69) #
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 70) # $(Q)ln $@ :<
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 71) #
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 72) # If KBUILD_VERBOSE equals 0 then the above command will be hidden.
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 73) # If KBUILD_VERBOSE equals 1 then the above command is displayed.
505b12b3861bc (Randy Dunlap 2020-02-12 20:40:57 -0800 74) # If KBUILD_VERBOSE equals 2 then give the reason why each target is rebuilt.
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 75) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 76) # To put more focus on warnings, be less verbose as default
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 77) # Use 'make V=1' to see the full commands
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 78)
b8b0618cf6fab (Cheng Renquan 2009-05-26 16:03:07 +0800 79) ifeq ("$(origin V)", "command line")
b8b0618cf6fab (Cheng Renquan 2009-05-26 16:03:07 +0800 80) KBUILD_VERBOSE = $(V)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 81) endif
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 82) ifndef KBUILD_VERBOSE
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 83) KBUILD_VERBOSE = 0
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 84) endif
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 85)
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 86) ifeq ($(KBUILD_VERBOSE),1)
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 87) quiet =
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 88) Q =
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 89) else
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 90) quiet=quiet_
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 91) Q = @
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 92) endif
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 93)
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 94) # If the user is running make -s (silent mode), suppress echoing of
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 95) # commands
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 96)
6f0fa58e45964 (Masahiro Yamada 2017-05-19 20:42:30 +0900 97) ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 98) quiet=silent_
2214945422c14 (Masahiro Yamada 2021-02-27 15:26:20 +0900 99) KBUILD_VERBOSE = 0
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 100) endif
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 101)
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 102) export quiet Q KBUILD_VERBOSE
066b7ed955808 (Michal Marek 2014-07-04 14:29:30 +0200 103)
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 104) # Call a source code checker (by default, "sparse") as part of the
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 105) # C compilation.
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 106) #
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 107) # Use 'make C=1' to enable checking of only re-compiled files.
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 108) # Use 'make C=2' to enable checking of *all* source files, regardless
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 109) # of whether they are re-compiled or not.
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 110) #
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 111) # See the file "Documentation/dev-tools/sparse.rst" for more details,
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 112) # including where to get the "sparse" utility.
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 113)
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 114) ifeq ("$(origin C)", "command line")
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 115) KBUILD_CHECKSRC = $(C)
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 116) endif
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 117) ifndef KBUILD_CHECKSRC
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 118) KBUILD_CHECKSRC = 0
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 119) endif
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 120)
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 121) export KBUILD_CHECKSRC
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 122)
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 123) # Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 124) # directory of external module to build. Setting M= takes precedence.
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 125) ifeq ("$(origin M)", "command line")
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 126) KBUILD_EXTMOD := $(M)
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 127) endif
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 128)
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 129) $(if $(word 2, $(KBUILD_EXTMOD)), \
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 130) $(error building multiple external modules is not supported))
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 131)
74ee585b7eecd (Masahiro Yamada 2021-06-02 23:02:13 +0900 132) # Remove trailing slashes
74ee585b7eecd (Masahiro Yamada 2021-06-02 23:02:13 +0900 133) ifneq ($(filter %/, $(KBUILD_EXTMOD)),)
74ee585b7eecd (Masahiro Yamada 2021-06-02 23:02:13 +0900 134) KBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)
74ee585b7eecd (Masahiro Yamada 2021-06-02 23:02:13 +0900 135) endif
74ee585b7eecd (Masahiro Yamada 2021-06-02 23:02:13 +0900 136)
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 137) export KBUILD_EXTMOD
bcf637f54f6d2 (Masahiro Yamada 2021-02-22 01:53:06 +0900 138)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 139) # Kbuild will save output files in the current working directory.
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 140) # This does not need to match to the root of the kernel source tree.
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 141) #
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 142) # For example, you can do this:
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 143) #
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 144) # cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 145) #
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 146) # If you want to save output files in a different location, there are
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 147) # two syntaxes to specify it.
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 148) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 149) # 1) O=
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 150) # Use "make O=dir/to/store/output/files/"
070b98bfda3d2 (Sam Ravnborg 2006-06-25 00:07:55 +0200 151) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 152) # 2) Set KBUILD_OUTPUT
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 153) # Set the environment variable KBUILD_OUTPUT to point to the output directory.
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 154) # export KBUILD_OUTPUT=dir/to/store/output/files/; make
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 155) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 156) # The O= assignment takes precedence over the KBUILD_OUTPUT environment
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 157) # variable.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 158)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 159) # Do we want to change the working directory?
b8b0618cf6fab (Cheng Renquan 2009-05-26 16:03:07 +0800 160) ifeq ("$(origin O)", "command line")
b8b0618cf6fab (Cheng Renquan 2009-05-26 16:03:07 +0800 161) KBUILD_OUTPUT := $(O)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 162) endif
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 163)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 164) ifneq ($(KBUILD_OUTPUT),)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 165) # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 166) # expand a shell special character '~'. We use a somewhat tedious way here.
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 167) abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 168) $(if $(abs_objtree),, \
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 169) $(error failed to create output directory "$(KBUILD_OUTPUT)"))
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 170)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 171) # $(realpath ...) resolves symlinks
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 172) abs_objtree := $(realpath $(abs_objtree))
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 173) else
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 174) abs_objtree := $(CURDIR)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 175) endif # ifneq ($(KBUILD_OUTPUT),)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 176)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 177) ifeq ($(abs_objtree),$(CURDIR))
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 178) # Suppress "Entering directory ..." unless we are changing the work directory.
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 179) MAKEFLAGS += --no-print-directory
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 180) else
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 181) need-sub-make := 1
51193b76bfff5 (Robert Jarzmik 2016-04-02 21:38:53 +0200 182) endif
51193b76bfff5 (Robert Jarzmik 2016-04-02 21:38:53 +0200 183)
30cef68d2d19e (Masahiro Yamada 2021-02-22 01:50:19 +0900 184) this-makefile := $(lastword $(MAKEFILE_LIST))
30cef68d2d19e (Masahiro Yamada 2021-02-22 01:50:19 +0900 185) abs_srctree := $(realpath $(dir $(this-makefile)))
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 186)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 187) ifneq ($(words $(subst :, ,$(abs_srctree))), 1)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 188) $(error source directory cannot contain spaces or colons)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 189) endif
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 190)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 191) ifneq ($(abs_srctree),$(abs_objtree))
80463f1b7bf9f (Masahiro Yamada 2018-09-14 15:33:23 +0900 192) # Look for make include files relative to root of kernel src
80463f1b7bf9f (Masahiro Yamada 2018-09-14 15:33:23 +0900 193) #
d828563955057 (Masahiro Yamada 2021-07-25 03:35:56 +0900 194) # --included-dir is added for backward compatibility, but you should not rely on
d828563955057 (Masahiro Yamada 2021-07-25 03:35:56 +0900 195) # it. Please add $(srctree)/ prefix to include Makefiles in the source tree.
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 196) MAKEFLAGS += --include-dir=$(abs_srctree)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 197) endif
3812b8c5c5d52 (Masahiro Yamada 2019-02-22 16:40:07 +0900 198)
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 199) ifneq ($(filter 3.%,$(MAKE_VERSION)),)
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 200) # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 201) # We need to invoke sub-make to avoid implicit rules in the top Makefile.
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 202) need-sub-make := 1
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 203) # Cancel implicit rules for this Makefile.
93fdddfefc831 (Masahiro Yamada 2020-05-11 12:50:12 +0900 204) $(this-makefile): ;
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 205) endif
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 206)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 207) export abs_srctree abs_objtree
221cc2d27ddc4 (Masahiro Yamada 2019-03-26 13:02:19 +0900 208) export sub_make_done := 1
221cc2d27ddc4 (Masahiro Yamada 2019-03-26 13:02:19 +0900 209)
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 210) ifeq ($(need-sub-make),1)
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 211)
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 212) PHONY += $(MAKECMDGOALS) __sub-make
0b35786d77ba4 (Milton Miller 2007-09-21 18:09:02 -0500 213)
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 214) $(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
16f890988114a (Charles Keepax 2012-10-15 13:49:12 +0100 215) @:
0b35786d77ba4 (Milton Miller 2007-09-21 18:09:02 -0500 216)
c4e6fff1ae572 (Cao jin 2017-06-30 10:45:43 +0800 217) # Invoke a second make in the output directory, passing relevant variables
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 218) __sub-make:
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 219) $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 220)
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 221) endif # need-sub-make
221cc2d27ddc4 (Masahiro Yamada 2019-03-26 13:02:19 +0900 222) endif # sub_make_done
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 223)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 224) # We process the rest of the Makefile if this is the final invocation of make
688931a5ad4e5 (Masahiro Yamada 2019-03-19 13:02:36 +0900 225) ifeq ($(need-sub-make),)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 226)
7ff525712acf9 (Masahiro Yamada 2014-09-09 20:02:22 +0900 227) # Do not print "Entering directory ...",
7ff525712acf9 (Masahiro Yamada 2014-09-09 20:02:22 +0900 228) # but we want to display it when entering to the output directory
7ff525712acf9 (Masahiro Yamada 2014-09-09 20:02:22 +0900 229) # so that IDEs/editors are able to understand relative filenames.
7ff525712acf9 (Masahiro Yamada 2014-09-09 20:02:22 +0900 230) MAKEFLAGS += --no-print-directory
7ff525712acf9 (Masahiro Yamada 2014-09-09 20:02:22 +0900 231)
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 232) ifeq ($(abs_srctree),$(abs_objtree))
9da0763bdd825 (Michal Marek 2014-04-25 23:25:18 +0200 233) # building in the source tree
9da0763bdd825 (Michal Marek 2014-04-25 23:25:18 +0200 234) srctree := .
051f278e9d81b (Masahiro Yamada 2019-07-06 12:07:12 +0900 235) building_out_of_srctree :=
9da0763bdd825 (Michal Marek 2014-04-25 23:25:18 +0200 236) else
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 237) ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
9da0763bdd825 (Michal Marek 2014-04-25 23:25:18 +0200 238) # building in a subdirectory of the source tree
9da0763bdd825 (Michal Marek 2014-04-25 23:25:18 +0200 239) srctree := ..
9da0763bdd825 (Michal Marek 2014-04-25 23:25:18 +0200 240) else
25b146c5b8cee (Masahiro Yamada 2019-03-30 21:04:14 +0900 241) srctree := $(abs_srctree)
9da0763bdd825 (Michal Marek 2014-04-25 23:25:18 +0200 242) endif
051f278e9d81b (Masahiro Yamada 2019-07-06 12:07:12 +0900 243) building_out_of_srctree := 1
9da0763bdd825 (Michal Marek 2014-04-25 23:25:18 +0200 244) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 245)
95fd3f87bfbe8 (Masahiro Yamada 2019-07-06 12:07:13 +0900 246) ifneq ($(KBUILD_ABS_SRCTREE),)
95fd3f87bfbe8 (Masahiro Yamada 2019-07-06 12:07:13 +0900 247) srctree := $(abs_srctree)
95fd3f87bfbe8 (Masahiro Yamada 2019-07-06 12:07:13 +0900 248) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 249)
7e1c04779efd5 (Michal Marek 2014-04-25 17:29:45 +0200 250) objtree := .
6b12de69ad82c (Masahiro Yamada 2019-02-22 16:40:09 +0900 251) VPATH := $(srctree)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 252)
051f278e9d81b (Masahiro Yamada 2019-07-06 12:07:12 +0900 253) export building_out_of_srctree srctree objtree VPATH
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 254)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 255) # To make sure we do not include .config for any of the *config targets
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 256) # catch them early, and hand them over to scripts/kconfig/Makefile
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 257) # It is allowed to specify more targets when calling make, including
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 258) # mixing *config targets and build targets.
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 259) # For example 'make oldconfig all'.
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 260) # Detect when mixed targets is specified, and make a second invocation
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 261) # of make so .config is not included in this case either (for *config).
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 262)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 263) version_h := include/generated/uapi/linux/version.h
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 264)
22340a06534a1 (Masahiro Yamada 2018-02-11 17:40:29 +0900 265) clean-targets := %clean mrproper cleandocs
22340a06534a1 (Masahiro Yamada 2018-02-11 17:40:29 +0900 266) no-dot-config-targets := $(clean-targets) \
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 267) cscope gtags TAGS tags help% %docs check% coccicheck \
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 268) $(version_h) headers headers_% archheaders archscripts \
4623980dea7c6 (David Engraf 2020-03-26 20:29:33 +0100 269) %asm-generic kernelversion %src-pkg dt_binding_check \
4623980dea7c6 (David Engraf 2020-03-26 20:29:33 +0100 270) outputmakefile
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 271) # Installation targets should not require compiler. Unfortunately, vdso_install
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 272) # is an exception where build artifacts may be updated. This must be fixed.
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 273) no-compiler-targets := $(no-dot-config-targets) install dtbs_install \
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 274) headers_install modules_install kernelrelease image_name
993bdde945478 (Masahiro Yamada 2021-02-28 15:10:25 +0900 275) no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
993bdde945478 (Masahiro Yamada 2021-02-28 15:10:25 +0900 276) image_name
394053f4a4b3e (Masahiro Yamada 2019-08-15 00:19:18 +0900 277) single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 278)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 279) config-build :=
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 280) mixed-build :=
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 281) need-config := 1
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 282) need-compiler := 1
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 283) may-sync-config := 1
394053f4a4b3e (Masahiro Yamada 2019-08-15 00:19:18 +0900 284) single-build :=
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 285)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 286) ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 287) ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 288) need-config :=
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 289) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 290) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 291)
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 292) ifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),)
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 293) ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),)
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 294) need-compiler :=
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 295) endif
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 296) endif
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 297)
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 298) ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 299) ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 300) may-sync-config :=
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 301) endif
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 302) endif
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 303)
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 304) ifneq ($(KBUILD_EXTMOD),)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 305) may-sync-config :=
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 306) endif
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 307)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 308) ifeq ($(KBUILD_EXTMOD),)
efbf97265f9fc (Masahiro Yamada 2020-08-12 23:49:23 +0900 309) ifneq ($(filter %config,$(MAKECMDGOALS)),)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 310) config-build := 1
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 311) ifneq ($(words $(MAKECMDGOALS)),1)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 312) mixed-build := 1
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 313) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 314) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 315) endif
22340a06534a1 (Masahiro Yamada 2018-02-11 17:40:29 +0900 316)
394053f4a4b3e (Masahiro Yamada 2019-08-15 00:19:18 +0900 317) # We cannot build single targets and the others at the same time
394053f4a4b3e (Masahiro Yamada 2019-08-15 00:19:18 +0900 318) ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
394053f4a4b3e (Masahiro Yamada 2019-08-15 00:19:18 +0900 319) single-build := 1
394053f4a4b3e (Masahiro Yamada 2019-08-15 00:19:18 +0900 320) ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
394053f4a4b3e (Masahiro Yamada 2019-08-15 00:19:18 +0900 321) mixed-build := 1
394053f4a4b3e (Masahiro Yamada 2019-08-15 00:19:18 +0900 322) endif
394053f4a4b3e (Masahiro Yamada 2019-08-15 00:19:18 +0900 323) endif
394053f4a4b3e (Masahiro Yamada 2019-08-15 00:19:18 +0900 324)
22340a06534a1 (Masahiro Yamada 2018-02-11 17:40:29 +0900 325) # For "make -j clean all", "make -j mrproper defconfig all", etc.
22340a06534a1 (Masahiro Yamada 2018-02-11 17:40:29 +0900 326) ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
22340a06534a1 (Masahiro Yamada 2018-02-11 17:40:29 +0900 327) ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 328) mixed-build := 1
22340a06534a1 (Masahiro Yamada 2018-02-11 17:40:29 +0900 329) endif
22340a06534a1 (Masahiro Yamada 2018-02-11 17:40:29 +0900 330) endif
22340a06534a1 (Masahiro Yamada 2018-02-11 17:40:29 +0900 331)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 332) # install and modules_install need also be processed one by one
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 333) ifneq ($(filter install,$(MAKECMDGOALS)),)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 334) ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 335) mixed-build := 1
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 336) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 337) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 338)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 339) ifdef mixed-build
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 340) # ===========================================================================
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 341) # We're called with mixed targets (*config and build targets).
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 342) # Handle them one by one.
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 343)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 344) PHONY += $(MAKECMDGOALS) __build_one_by_one
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 345)
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 346) $(MAKECMDGOALS): __build_one_by_one
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 347) @:
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 348)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 349) __build_one_by_one:
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 350) $(Q)set -e; \
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 351) for i in $(MAKECMDGOALS); do \
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 352) $(MAKE) -f $(srctree)/Makefile $$i; \
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 353) done
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 354)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 355) else # !mixed-build
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 356)
3204a7fb98a3b (Masahiro Yamada 2021-02-28 15:10:26 +0900 357) include $(srctree)/scripts/Kbuild.include
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 358)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 359) # Read KERNELRELEASE from include/config/kernel.release (if it exists)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 360) KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 361) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 362) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 363)
3204a7fb98a3b (Masahiro Yamada 2021-02-28 15:10:26 +0900 364) include $(srctree)/scripts/subarch.include
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 365)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 366) # Cross compiling and selecting different set of gcc/bin-utils
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 367) # ---------------------------------------------------------------------------
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 368) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 369) # When performing cross compilation for other architectures ARCH shall be set
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 370) # to the target architecture. (See arch/* for the possibilities).
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 371) # ARCH can be set during invocation of make:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 372) # make ARCH=ia64
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 373) # Another way is to have ARCH set in the environment.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 374) # The default ARCH is the host where make is executed.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 375)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 376) # CROSS_COMPILE specify the prefix used for all executables used
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 377) # during compilation. Only gcc and related bin-utils executables
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 378) # are prefixed with $(CROSS_COMPILE).
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 379) # CROSS_COMPILE can be set on the command line
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 380) # make CROSS_COMPILE=ia64-linux-
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 381) # Alternatively CROSS_COMPILE can be set in the environment.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 382) # Default value for CROSS_COMPILE is not to prefix executables
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 383) # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
2331d1a6cd3d6 (Sam Ravnborg 2009-10-11 23:22:58 +0200 384) ARCH ?= $(SUBARCH)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 385)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 386) # Architecture as present in compile.h
6752ed90da032 (Thomas Gleixner 2007-10-11 11:11:36 +0200 387) UTS_MACHINE := $(ARCH)
6752ed90da032 (Thomas Gleixner 2007-10-11 11:11:36 +0200 388) SRCARCH := $(ARCH)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 389)
d746d647f31bd (Sam Ravnborg 2007-11-12 20:14:19 +0100 390) # Additional ARCH settings for x86
d746d647f31bd (Sam Ravnborg 2007-11-12 20:14:19 +0100 391) ifeq ($(ARCH),i386)
d746d647f31bd (Sam Ravnborg 2007-11-12 20:14:19 +0100 392) SRCARCH := x86
d746d647f31bd (Sam Ravnborg 2007-11-12 20:14:19 +0100 393) endif
d746d647f31bd (Sam Ravnborg 2007-11-12 20:14:19 +0100 394) ifeq ($(ARCH),x86_64)
d746d647f31bd (Sam Ravnborg 2007-11-12 20:14:19 +0100 395) SRCARCH := x86
d746d647f31bd (Sam Ravnborg 2007-11-12 20:14:19 +0100 396) endif
74b469f2e6b15 (Sam Ravnborg 2007-10-25 19:42:04 +0200 397)
5e53879008b9a (Sam Ravnborg 2008-12-02 23:17:12 -0800 398) # Additional ARCH settings for sparc
e69f58c037ab5 (Namhyung Kim 2010-10-25 05:48:23 +0000 399) ifeq ($(ARCH),sparc32)
e69f58c037ab5 (Namhyung Kim 2010-10-25 05:48:23 +0000 400) SRCARCH := sparc
e69f58c037ab5 (Namhyung Kim 2010-10-25 05:48:23 +0000 401) endif
a439fe51a1f8e (Sam Ravnborg 2008-07-27 23:00:59 +0200 402) ifeq ($(ARCH),sparc64)
5e53879008b9a (Sam Ravnborg 2008-12-02 23:17:12 -0800 403) SRCARCH := sparc
a439fe51a1f8e (Sam Ravnborg 2008-07-27 23:00:59 +0200 404) endif
2fb9b1bd9dd7f (Sam Ravnborg 2008-06-21 00:24:17 +0200 405)
5f6e0fe01b6b3 (Masahiro Yamada 2021-06-10 11:03:31 +0900 406) # Additional ARCH settings for parisc
5f6e0fe01b6b3 (Masahiro Yamada 2021-06-10 11:03:31 +0900 407) ifeq ($(ARCH),parisc64)
5f6e0fe01b6b3 (Masahiro Yamada 2021-06-10 11:03:31 +0900 408) SRCARCH := parisc
5f6e0fe01b6b3 (Masahiro Yamada 2021-06-10 11:03:31 +0900 409) endif
5f6e0fe01b6b3 (Masahiro Yamada 2021-06-10 11:03:31 +0900 410)
f02aa48dde8b9 (Masahiro Yamada 2021-04-10 23:31:58 +0900 411) export cross_compiling :=
f02aa48dde8b9 (Masahiro Yamada 2021-04-10 23:31:58 +0900 412) ifneq ($(SRCARCH),$(SUBARCH))
f02aa48dde8b9 (Masahiro Yamada 2021-04-10 23:31:58 +0900 413) cross_compiling := 1
f02aa48dde8b9 (Masahiro Yamada 2021-04-10 23:31:58 +0900 414) endif
f02aa48dde8b9 (Masahiro Yamada 2021-04-10 23:31:58 +0900 415)
14cdd3c402bf7 (Roman Zippel 2006-06-08 22:12:51 -0700 416) KCONFIG_CONFIG ?= .config
41263fc6716de (Ben Gardiner 2010-12-14 11:39:44 -0500 417) export KCONFIG_CONFIG
14cdd3c402bf7 (Roman Zippel 2006-06-08 22:12:51 -0700 418)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 419) # SHELL used by kbuild
858805b336be1 (Masahiro Yamada 2019-08-25 22:28:37 +0900 420) CONFIG_SHELL := sh
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 421)
6d79a7b424a56 (Masahiro Yamada 2018-07-12 19:38:36 +0900 422) HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
6d79a7b424a56 (Masahiro Yamada 2018-07-12 19:38:36 +0900 423) HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
6d79a7b424a56 (Masahiro Yamada 2018-07-12 19:38:36 +0900 424) HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
d7f14c66c273b (Uwe Kleine-König 2017-07-09 20:02:36 +0200 425)
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 426) ifneq ($(LLVM),)
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 427) HOSTCC = clang
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 428) HOSTCXX = clang++
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 429) else
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 430) HOSTCC = gcc
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 431) HOSTCXX = g++
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 432) endif
7f3a59db274c3 (Masahiro Yamada 2020-04-29 12:45:14 +0900 433)
7f3a59db274c3 (Masahiro Yamada 2020-04-29 12:45:14 +0900 434) export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
7f3a59db274c3 (Masahiro Yamada 2020-04-29 12:45:14 +0900 435) -O2 -fomit-frame-pointer -std=gnu89
7f3a59db274c3 (Masahiro Yamada 2020-04-29 12:45:14 +0900 436) export KBUILD_USERLDFLAGS :=
7f3a59db274c3 (Masahiro Yamada 2020-04-29 12:45:14 +0900 437)
7f3a59db274c3 (Masahiro Yamada 2020-04-29 12:45:14 +0900 438) KBUILD_HOSTCFLAGS := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
735aab1e008b6 (Masahiro Yamada 2020-03-25 12:14:32 +0900 439) KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
f92d19e0ef9bb (Laura Abbott 2018-07-09 17:46:02 -0700 440) KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
f92d19e0ef9bb (Laura Abbott 2018-07-09 17:46:02 -0700 441) KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 442)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 443) # Make variables (CC, etc...)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 444) CPP = $(CC) -E
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 445) ifneq ($(LLVM),)
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 446) CC = clang
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 447) LD = ld.lld
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 448) AR = llvm-ar
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 449) NM = llvm-nm
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 450) OBJCOPY = llvm-objcopy
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 451) OBJDUMP = llvm-objdump
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 452) READELF = llvm-readelf
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 453) STRIP = llvm-strip
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 454) else
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 455) CC = $(CROSS_COMPILE)gcc
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 456) LD = $(CROSS_COMPILE)ld
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 457) AR = $(CROSS_COMPILE)ar
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 458) NM = $(CROSS_COMPILE)nm
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 459) OBJCOPY = $(CROSS_COMPILE)objcopy
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 460) OBJDUMP = $(CROSS_COMPILE)objdump
eefb8c124fd96 (Dmitry Golovin 2019-12-05 00:54:41 +0200 461) READELF = $(CROSS_COMPILE)readelf
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 462) STRIP = $(CROSS_COMPILE)strip
a0d1c951ef08e (Masahiro Yamada 2020-04-08 10:36:23 +0900 463) endif
e83b9f55448af (Andrii Nakryiko 2019-04-02 09:49:50 -0700 464) PAHOLE = pahole
c9a0f3b85e09d (Jiri Olsa 2020-07-11 23:53:24 +0200 465) RESOLVE_BTFIDS = $(objtree)/tools/bpf/resolve_btfids/resolve_btfids
73a4f6dbe70a1 (Masahiro Yamada 2017-12-10 01:02:28 +0900 466) LEX = flex
73a4f6dbe70a1 (Masahiro Yamada 2017-12-10 01:02:28 +0900 467) YACC = bison
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 468) AWK = awk
caa27b66bd718 (Sam Ravnborg 2009-07-20 21:37:11 +0200 469) INSTALLKERNEL := installkernel
436e980e2ed52 (Dominique Martinet 2020-12-01 14:17:30 +0100 470) DEPMOD = depmod
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 471) PERL = perl
e9781b52d4e0e (Masahiro Yamada 2018-03-13 18:12:02 +0900 472) PYTHON3 = python3
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 473) CHECK = sparse
858805b336be1 (Masahiro Yamada 2019-08-25 22:28:37 +0900 474) BASH = bash
e4a42c82e943b (Denis Efremov 2020-06-08 12:59:44 +0300 475) KGZIP = gzip
e4a42c82e943b (Denis Efremov 2020-06-08 12:59:44 +0300 476) KBZIP2 = bzip2
e4a42c82e943b (Denis Efremov 2020-06-08 12:59:44 +0300 477) KLZOP = lzop
8dfb61dcbaceb (Denis Efremov 2020-06-05 10:39:55 +0300 478) LZMA = lzma
8dfb61dcbaceb (Denis Efremov 2020-06-05 10:39:55 +0300 479) LZ4 = lz4c
8dfb61dcbaceb (Denis Efremov 2020-06-05 10:39:55 +0300 480) XZ = xz
48f7ddf785af2 (Nick Terrell 2020-07-30 12:08:36 -0700 481) ZSTD = zstd
8dfb61dcbaceb (Denis Efremov 2020-06-05 10:39:55 +0300 482)
80a7d1d991e35 (Hannes Eder 2008-12-27 22:38:44 +0100 483) CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
6c49f359ca14f (Luc Van Oostenryck 2018-02-15 22:07:50 +0100 484) -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
0c22be0712b87 (Douglas Anderson 2019-03-14 16:41:59 -0700 485) NOSTDINC_FLAGS :=
6588169d51656 (Sam Ravnborg 2010-07-28 17:33:09 +0200 486) CFLAGS_MODULE =
6588169d51656 (Sam Ravnborg 2010-07-28 17:33:09 +0200 487) AFLAGS_MODULE =
6588169d51656 (Sam Ravnborg 2010-07-28 17:33:09 +0200 488) LDFLAGS_MODULE =
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 489) CFLAGS_KERNEL =
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 490) AFLAGS_KERNEL =
b36fad65d61ff (Michal Marek 2016-06-07 11:57:02 +0200 491) LDFLAGS_vmlinux =
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 492)
abbf1590de22a (David Howells 2012-10-02 18:01:26 +0100 493) # Use USERINCLUDE when you must reference the UAPI directories only.
abbf1590de22a (David Howells 2012-10-02 18:01:26 +0100 494) USERINCLUDE := \
9d022c540606a (Masahiro Yamada 2017-10-04 12:56:04 +0900 495) -I$(srctree)/arch/$(SRCARCH)/include/uapi \
9d022c540606a (Masahiro Yamada 2017-10-04 12:56:04 +0900 496) -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
abbf1590de22a (David Howells 2012-10-02 18:01:26 +0100 497) -I$(srctree)/include/uapi \
3308b28569ba3 (Arnd Bergmann 2016-06-15 17:45:45 +0200 498) -I$(objtree)/include/generated/uapi \
ce6ed1c4c9876 (Masahiro Yamada 2021-03-04 20:37:08 +0900 499) -include $(srctree)/include/linux/compiler-version.h \
abbf1590de22a (David Howells 2012-10-02 18:01:26 +0100 500) -include $(srctree)/include/linux/kconfig.h
abbf1590de22a (David Howells 2012-10-02 18:01:26 +0100 501)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 502) # Use LINUXINCLUDE when you must reference the include/ directory.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 503) # Needed to be compatible with the O= option
abbf1590de22a (David Howells 2012-10-02 18:01:26 +0100 504) LINUXINCLUDE := \
9d022c540606a (Masahiro Yamada 2017-10-04 12:56:04 +0900 505) -I$(srctree)/arch/$(SRCARCH)/include \
9d022c540606a (Masahiro Yamada 2017-10-04 12:56:04 +0900 506) -I$(objtree)/arch/$(SRCARCH)/include/generated \
051f278e9d81b (Masahiro Yamada 2019-07-06 12:07:12 +0900 507) $(if $(building_out_of_srctree),-I$(srctree)/include) \
f8224f7f48017 (Masahiro Yamada 2017-06-06 16:15:28 +0900 508) -I$(objtree)/include \
f8224f7f48017 (Masahiro Yamada 2017-06-06 16:15:28 +0900 509) $(USERINCLUDE)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 510)
42a92bccd213c (Masahiro Yamada 2018-12-14 17:05:37 +0900 511) KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
eeb5687a71396 (Masahiro Yamada 2018-12-14 17:05:38 +0900 512) KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
42a92bccd213c (Masahiro Yamada 2018-12-14 17:05:37 +0900 513) -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
b89f25ea78920 (Luc Van Oostenryck 2019-03-04 13:55:20 +0100 514) -Werror=implicit-function-declaration -Werror=implicit-int \
172aad81a8824 (Olaf Hering 2020-10-11 20:54:31 +0200 515) -Werror=return-type -Wno-format-security \
433dc2ebe7d17 (Masahiro Yamada 2017-10-12 18:22:25 +0900 516) -std=gnu89
433dc2ebe7d17 (Masahiro Yamada 2017-10-12 18:22:25 +0900 517) KBUILD_CPPFLAGS := -D__KERNEL__
80c00ba942ee3 (Sam Ravnborg 2010-07-28 19:11:27 +0200 518) KBUILD_AFLAGS_KERNEL :=
80c00ba942ee3 (Sam Ravnborg 2010-07-28 19:11:27 +0200 519) KBUILD_CFLAGS_KERNEL :=
6588169d51656 (Sam Ravnborg 2010-07-28 17:33:09 +0200 520) KBUILD_AFLAGS_MODULE := -DMODULE
6588169d51656 (Sam Ravnborg 2010-07-28 17:33:09 +0200 521) KBUILD_CFLAGS_MODULE := -DMODULE
10df063855822 (Masahiro Yamada 2019-08-15 01:06:22 +0900 522) KBUILD_LDFLAGS_MODULE :=
d503ac531a524 (Masahiro Yamada 2018-08-24 08:20:39 +0900 523) KBUILD_LDFLAGS :=
5241ab4cf42d3 (Masahiro Yamada 2019-07-29 18:15:17 +0900 524) CLANG_FLAGS :=
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 525)
aa824e0c962b5 (Masahiro Yamada 2020-03-26 14:57:18 +0900 526) export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
d9b5665fb3c82 (Vasily Gorbik 2020-10-23 13:57:32 +0200 527) export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
d8d2d38275c1b (Masahiro Yamada 2021-02-01 10:00:24 +0900 528) export PERL PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
48f7ddf785af2 (Nick Terrell 2020-07-30 12:08:36 -0700 529) export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
7bac98707f65b (Vasily Gorbik 2019-01-21 13:54:39 +0100 530) export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 531)
d503ac531a524 (Masahiro Yamada 2018-08-24 08:20:39 +0900 532) export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
0e410e158e5ba (Andrey Konovalov 2018-02-06 15:36:00 -0800 533) export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
222d394d30e74 (Sam Ravnborg 2007-10-15 21:59:31 +0200 534) export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
6588169d51656 (Sam Ravnborg 2010-07-28 17:33:09 +0200 535) export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
80c00ba942ee3 (Sam Ravnborg 2010-07-28 19:11:27 +0200 536) export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 537)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 538) # Files to ignore in find ... statements
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 539)
ae63b2d7bdd9b (Prarit Bhargava 2014-02-06 07:51:42 -0500 540) export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
ae63b2d7bdd9b (Prarit Bhargava 2014-02-06 07:51:42 -0500 541) -name CVS -o -name .pc -o -name .hg -o -name .git \) \
ae63b2d7bdd9b (Prarit Bhargava 2014-02-06 07:51:42 -0500 542) -prune -o
450c6076a79eb (Jesper Juhl 2012-02-16 22:49:15 +0100 543) export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
450c6076a79eb (Jesper Juhl 2012-02-16 22:49:15 +0100 544) --exclude CVS --exclude .pc --exclude .hg --exclude .git
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 545)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 546) # ===========================================================================
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 547) # Rules shared between *config targets and build targets
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 548)
312a3d0918bb7 (Cao jin 2017-08-02 10:31:06 +0800 549) # Basic helpers built in scripts/basic/
4f1933620f571 (Paul Smith 2006-03-05 17:14:10 -0500 550) PHONY += scripts_basic
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 551) scripts_basic:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 552) $(Q)$(MAKE) $(build)=scripts/basic
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 553)
4f1933620f571 (Paul Smith 2006-03-05 17:14:10 -0500 554) PHONY += outputmakefile
2728fcfa4fcc0 (Masahiro Yamada 2021-05-17 16:03:11 +0900 555) ifdef building_out_of_srctree
e8e83a236d36d (Masahiro Yamada 2019-08-22 13:46:11 +0900 556) # Before starting out-of-tree build, make sure the source tree is clean.
fd5f0cd6b0cef (Jan Beulich 2006-05-02 12:33:20 +0200 557) # outputmakefile generates a Makefile in the output directory, if using a
fd5f0cd6b0cef (Jan Beulich 2006-05-02 12:33:20 +0200 558) # separate output directory. This allows convenient use of make in the
fd5f0cd6b0cef (Jan Beulich 2006-05-02 12:33:20 +0200 559) # output directory.
3a51ff344204e (Vladimir Kondratiev 2019-02-03 10:48:40 +0200 560) # At the same time when output Makefile generated, generate .gitignore to
3a51ff344204e (Vladimir Kondratiev 2019-02-03 10:48:40 +0200 561) # ignore whole output directory
2728fcfa4fcc0 (Masahiro Yamada 2021-05-17 16:03:11 +0900 562)
2728fcfa4fcc0 (Masahiro Yamada 2021-05-17 16:03:11 +0900 563) quiet_cmd_makefile = GEN Makefile
2728fcfa4fcc0 (Masahiro Yamada 2021-05-17 16:03:11 +0900 564) cmd_makefile = { \
2728fcfa4fcc0 (Masahiro Yamada 2021-05-17 16:03:11 +0900 565) echo "\# Automatically generated by $(srctree)/Makefile: don't edit"; \
2728fcfa4fcc0 (Masahiro Yamada 2021-05-17 16:03:11 +0900 566) echo "include $(srctree)/Makefile"; \
2728fcfa4fcc0 (Masahiro Yamada 2021-05-17 16:03:11 +0900 567) } > Makefile
2728fcfa4fcc0 (Masahiro Yamada 2021-05-17 16:03:11 +0900 568)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 569) outputmakefile:
e8e83a236d36d (Masahiro Yamada 2019-08-22 13:46:11 +0900 570) $(Q)if [ -f $(srctree)/.config -o \
e8e83a236d36d (Masahiro Yamada 2019-08-22 13:46:11 +0900 571) -d $(srctree)/include/config -o \
e8e83a236d36d (Masahiro Yamada 2019-08-22 13:46:11 +0900 572) -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
e8e83a236d36d (Masahiro Yamada 2019-08-22 13:46:11 +0900 573) echo >&2 "***"; \
e8e83a236d36d (Masahiro Yamada 2019-08-22 13:46:11 +0900 574) echo >&2 "*** The source tree is not clean, please run 'make$(if $(findstring command line, $(origin ARCH)), ARCH=$(ARCH)) mrproper'"; \
e8e83a236d36d (Masahiro Yamada 2019-08-22 13:46:11 +0900 575) echo >&2 "*** in $(abs_srctree)";\
e8e83a236d36d (Masahiro Yamada 2019-08-22 13:46:11 +0900 576) echo >&2 "***"; \
e8e83a236d36d (Masahiro Yamada 2019-08-22 13:46:11 +0900 577) false; \
e8e83a236d36d (Masahiro Yamada 2019-08-22 13:46:11 +0900 578) fi
929799973ba4a (Andi Kleen 2009-01-10 04:56:13 +0100 579) $(Q)ln -fsn $(srctree) source
2728fcfa4fcc0 (Masahiro Yamada 2021-05-17 16:03:11 +0900 580) $(call cmd,makefile)
156e7cbb3ef50 (Masahiro Yamada 2019-03-26 13:26:58 +0900 581) $(Q)test -e .gitignore || \
156e7cbb3ef50 (Masahiro Yamada 2019-03-26 13:26:58 +0900 582) { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
fd5f0cd6b0cef (Jan Beulich 2006-05-02 12:33:20 +0200 583) endif
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 584)
db07562aeac77 (Nick Desaulniers 2021-02-05 14:01:25 -0800 585) # The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
db07562aeac77 (Nick Desaulniers 2021-02-05 14:01:25 -0800 586) # Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
db07562aeac77 (Nick Desaulniers 2021-02-05 14:01:25 -0800 587) # CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
db07562aeac77 (Nick Desaulniers 2021-02-05 14:01:25 -0800 588) # and from include/config/auto.conf.cmd to detect the compiler upgrade.
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 589) CC_VERSION_TEXT = $(subst $(pound),,$(shell LC_ALL=C $(CC) --version 2>/dev/null | head -n 1))
db07562aeac77 (Nick Desaulniers 2021-02-05 14:01:25 -0800 590)
db07562aeac77 (Nick Desaulniers 2021-02-05 14:01:25 -0800 591) ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
6f5b41a2f5a63 (Nick Desaulniers 2021-08-02 11:39:08 -0700 592) include $(srctree)/scripts/Makefile.clang
ae6b289a37890 (Chris Fries 2017-11-07 11:46:13 -0800 593) endif
ae6b289a37890 (Chris Fries 2017-11-07 11:46:13 -0800 594)
57fd251c78964 (Masahiro Yamada 2021-02-28 15:10:27 +0900 595) # Include this also for config targets because some architectures need
57fd251c78964 (Masahiro Yamada 2021-02-28 15:10:27 +0900 596) # cc-cross-prefix to determine CROSS_COMPILE.
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 597) ifdef need-compiler
57fd251c78964 (Masahiro Yamada 2021-02-28 15:10:27 +0900 598) include $(srctree)/scripts/Makefile.compiler
805b2e1d427aa (Masahiro Yamada 2021-02-28 15:10:28 +0900 599) endif
57fd251c78964 (Masahiro Yamada 2021-02-28 15:10:27 +0900 600)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 601) ifdef config-build
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 602) # ===========================================================================
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 603) # *config targets only - make sure prerequisites are updated, and descend
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 604) # in scripts/kconfig to make the *config target
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 605)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 606) # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 607) # KBUILD_DEFCONFIG may point out an alternative default configuration
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 608) # used for 'make defconfig'
3204a7fb98a3b (Masahiro Yamada 2021-02-28 15:10:26 +0900 609) include $(srctree)/arch/$(SRCARCH)/Makefile
315bab4e972d9 (Masahiro Yamada 2018-06-08 09:21:43 +0900 610) export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 611)
36de077b20d05 (Masahiro Yamada 2019-08-22 13:46:13 +0900 612) config: outputmakefile scripts_basic FORCE
31110ebbec868 (Sam Ravnborg 2008-12-13 23:00:45 +0100 613) $(Q)$(MAKE) $(build)=scripts/kconfig $@
31110ebbec868 (Sam Ravnborg 2008-12-13 23:00:45 +0100 614)
36de077b20d05 (Masahiro Yamada 2019-08-22 13:46:13 +0900 615) %config: outputmakefile scripts_basic FORCE
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 616) $(Q)$(MAKE) $(build)=scripts/kconfig $@
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 617)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 618) else #!config-build
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 619) # ===========================================================================
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 620) # Build targets only - this includes vmlinux, arch specific targets, clean
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 621) # targets and others. In general all targets except *config targets.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 622)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 623) # If building an external module we do not care about the all: rule
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 624) # but instead __all depend on modules
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 625) PHONY += all
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 626) ifeq ($(KBUILD_EXTMOD),)
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 627) __all: all
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 628) else
121c2a137767d (Masahiro Yamada 2020-05-11 12:50:13 +0900 629) __all: modules
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 630) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 631)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 632) # Decide whether to build built-in, modular, or both.
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 633) # Normally, just do built-in.
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 634)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 635) KBUILD_MODULES :=
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 636) KBUILD_BUILTIN := 1
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 637)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 638) # If we have only "make modules", don't compile built-in objects.
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 639) ifeq ($(MAKECMDGOALS),modules)
4b50c8c4eaf06 (Masahiro Yamada 2020-05-31 17:47:06 +0900 640) KBUILD_BUILTIN :=
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 641) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 642)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 643) # If we have "make <whatever> modules", compile modules
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 644) # in addition to whatever we do anyway.
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 645) # Just "make" or "make all" shall build modules as well
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 646)
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 647) ifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECMDGOALS)),)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 648) KBUILD_MODULES := 1
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 649) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 650)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 651) ifeq ($(MAKECMDGOALS),)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 652) KBUILD_MODULES := 1
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 653) endif
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 654)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 655) export KBUILD_MODULES KBUILD_BUILTIN
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 656)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 657) ifdef need-config
d93a18f27e370 (Masahiro Yamada 2019-04-27 12:33:36 +0900 658) include include/config/auto.conf
d93a18f27e370 (Masahiro Yamada 2019-04-27 12:33:36 +0900 659) endif
d93a18f27e370 (Masahiro Yamada 2019-04-27 12:33:36 +0900 660)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 661) ifeq ($(KBUILD_EXTMOD),)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 662) # Objects we will link into vmlinux / subdirs we need to visit
d92cc4d516439 (Masahiro Yamada 2021-05-12 16:57:25 +0900 663) core-y := init/ usr/ arch/$(SRCARCH)/
f96182e959a41 (Masahiro Yamada 2019-01-11 18:52:00 +0900 664) drivers-y := drivers/ sound/
d93a18f27e370 (Masahiro Yamada 2019-04-27 12:33:36 +0900 665) drivers-$(CONFIG_SAMPLES) += samples/
8b5f4eb3ab700 (Masahiro Yamada 2021-01-26 08:16:55 +0900 666) drivers-$(CONFIG_NET) += net/
8b5f4eb3ab700 (Masahiro Yamada 2021-01-26 08:16:55 +0900 667) drivers-y += virt/
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 668) libs-y := lib/
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 669) endif # KBUILD_EXTMOD
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 670)
315bab4e972d9 (Masahiro Yamada 2018-06-08 09:21:43 +0900 671) # The all: target is the default when no target is given on the
315bab4e972d9 (Masahiro Yamada 2018-06-08 09:21:43 +0900 672) # command line.
315bab4e972d9 (Masahiro Yamada 2018-06-08 09:21:43 +0900 673) # This allow a user to issue only 'make' to build a kernel including modules
315bab4e972d9 (Masahiro Yamada 2018-06-08 09:21:43 +0900 674) # Defaults to vmlinux, but the arch makefile usually adds further targets
315bab4e972d9 (Masahiro Yamada 2018-06-08 09:21:43 +0900 675) all: vmlinux
315bab4e972d9 (Masahiro Yamada 2018-06-08 09:21:43 +0900 676)
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 677) CFLAGS_GCOV := -fprofile-arcs -ftest-coverage
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 678) ifdef CONFIG_CC_IS_GCC
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 679) CFLAGS_GCOV += -fno-tree-loop-im
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 680) endif
5aadfdeb8de00 (Masahiro Yamada 2018-05-28 18:22:04 +0900 681) export CFLAGS_GCOV
315bab4e972d9 (Masahiro Yamada 2018-06-08 09:21:43 +0900 682)
b1f4ff74fcb0e (Paulo Zanoni 2018-09-10 10:59:56 -0700 683) # The arch Makefiles can override CC_FLAGS_FTRACE. We may also append it later.
b1f4ff74fcb0e (Paulo Zanoni 2018-09-10 10:59:56 -0700 684) ifdef CONFIG_FUNCTION_TRACER
b1f4ff74fcb0e (Paulo Zanoni 2018-09-10 10:59:56 -0700 685) CC_FLAGS_FTRACE := -pg
b1f4ff74fcb0e (Paulo Zanoni 2018-09-10 10:59:56 -0700 686) endif
b1f4ff74fcb0e (Paulo Zanoni 2018-09-10 10:59:56 -0700 687)
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 688) ifdef CONFIG_CC_IS_GCC
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 689) RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register)
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 690) RETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register)
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 691) endif
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 692) ifdef CONFIG_CC_IS_CLANG
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 693) RETPOLINE_CFLAGS := -mretpoline-external-thunk
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 694) RETPOLINE_VDSO_CFLAGS := -mretpoline
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 695) endif
669e06b19de8f (Masahiro Yamada 2019-03-26 15:11:12 +0900 696) export RETPOLINE_CFLAGS
669e06b19de8f (Masahiro Yamada 2019-03-26 15:11:12 +0900 697) export RETPOLINE_VDSO_CFLAGS
669e06b19de8f (Masahiro Yamada 2019-03-26 15:11:12 +0900 698)
3204a7fb98a3b (Masahiro Yamada 2021-02-28 15:10:26 +0900 699) include $(srctree)/arch/$(SRCARCH)/Makefile
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 700)
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 701) ifdef need-config
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 702) ifdef may-sync-config
315bab4e972d9 (Masahiro Yamada 2018-06-08 09:21:43 +0900 703) # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
315bab4e972d9 (Masahiro Yamada 2018-06-08 09:21:43 +0900 704) # changes are detected. This should be included after arch/$(SRCARCH)/Makefile
315bab4e972d9 (Masahiro Yamada 2018-06-08 09:21:43 +0900 705) # because some architectures define CROSS_COMPILE there.
d2f8ae0e4c5c7 (Masahiro Yamada 2019-05-12 11:13:48 +0900 706) include include/config/auto.conf.cmd
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 707)
058507195b534 (Masahiro Yamada 2019-02-22 16:40:11 +0900 708) $(KCONFIG_CONFIG):
058507195b534 (Masahiro Yamada 2019-02-22 16:40:11 +0900 709) @echo >&2 '***'
058507195b534 (Masahiro Yamada 2019-02-22 16:40:11 +0900 710) @echo >&2 '*** Configuration file "$@" not found!'
058507195b534 (Masahiro Yamada 2019-02-22 16:40:11 +0900 711) @echo >&2 '***'
058507195b534 (Masahiro Yamada 2019-02-22 16:40:11 +0900 712) @echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or'
058507195b534 (Masahiro Yamada 2019-02-22 16:40:11 +0900 713) @echo >&2 '*** "make menuconfig" or "make xconfig").'
058507195b534 (Masahiro Yamada 2019-02-22 16:40:11 +0900 714) @echo >&2 '***'
058507195b534 (Masahiro Yamada 2019-02-22 16:40:11 +0900 715) @/bin/false
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 716)
61277981dd535 (Ulf Magnusson 2018-02-13 08:58:20 +0100 717) # The actual configuration files used during the build are stored in
61277981dd535 (Ulf Magnusson 2018-02-13 08:58:20 +0100 718) # include/generated/ and include/config/. Update them if .config is newer than
61277981dd535 (Ulf Magnusson 2018-02-13 08:58:20 +0100 719) # include/config/auto.conf (which mirrors .config).
9390dff66a52d (Masahiro Yamada 2019-02-22 16:40:10 +0900 720) #
9390dff66a52d (Masahiro Yamada 2019-02-22 16:40:10 +0900 721) # This exploits the 'multi-target pattern rule' trick.
9390dff66a52d (Masahiro Yamada 2019-02-22 16:40:10 +0900 722) # The syncconfig should be executed only once to make all the targets.
f463c3510d44a (Masahiro Yamada 2020-03-25 12:16:30 +0900 723) # (Note: use the grouped target '&:' when we bump to GNU Make 4.3)
d952cfaf0cffd (Masahiro Yamada 2021-07-14 13:23:49 +0900 724) #
d952cfaf0cffd (Masahiro Yamada 2021-07-14 13:23:49 +0900 725) # Do not use $(call cmd,...) here. That would suppress prompts from syncconfig,
d952cfaf0cffd (Masahiro Yamada 2021-07-14 13:23:49 +0900 726) # so you cannot notice that Kconfig is waiting for the user input.
3044dd05289d6 (Masahiro Yamada 2020-05-01 15:01:41 +0900 727) %/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h: $(KCONFIG_CONFIG)
d952cfaf0cffd (Masahiro Yamada 2021-07-14 13:23:49 +0900 728) $(Q)$(kecho) " SYNC $@"
d952cfaf0cffd (Masahiro Yamada 2021-07-14 13:23:49 +0900 729) $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 730) else # !may-sync-config
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 731) # External modules and some install targets need include/generated/autoconf.h
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 732) # and include/config/auto.conf but do not care if they are up-to-date.
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 733) # Use auto.conf to trigger the test
9ee4e3365dd0d (Sam Ravnborg 2006-08-07 21:01:36 +0200 734) PHONY += include/config/auto.conf
9ee4e3365dd0d (Sam Ravnborg 2006-08-07 21:01:36 +0200 735)
9ee4e3365dd0d (Sam Ravnborg 2006-08-07 21:01:36 +0200 736) include/config/auto.conf:
264a26838056f (Sam Ravnborg 2009-10-18 00:49:24 +0200 737) $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \
5369f55021feb (Michal Marek 2012-07-07 23:04:40 +0200 738) echo >&2; \
5369f55021feb (Michal Marek 2012-07-07 23:04:40 +0200 739) echo >&2 " ERROR: Kernel configuration is invalid."; \
5369f55021feb (Michal Marek 2012-07-07 23:04:40 +0200 740) echo >&2 " include/generated/autoconf.h or $@ are missing.";\
5369f55021feb (Michal Marek 2012-07-07 23:04:40 +0200 741) echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
5369f55021feb (Michal Marek 2012-07-07 23:04:40 +0200 742) echo >&2 ; \
9ee4e3365dd0d (Sam Ravnborg 2006-08-07 21:01:36 +0200 743) /bin/false)
9ee4e3365dd0d (Sam Ravnborg 2006-08-07 21:01:36 +0200 744)
d79424137a731 (Masahiro Yamada 2018-07-20 16:46:34 +0900 745) endif # may-sync-config
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 746) endif # need-config
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 747)
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 748) KBUILD_CFLAGS += -fno-delete-null-pointer-checks
ef6000b4c6706 (Linus Torvalds 2016-10-12 10:23:41 -0700 749) KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
bd664f6b3e376 (Linus Torvalds 2017-07-12 19:25:47 -0700 750) KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
bd664f6b3e376 (Linus Torvalds 2017-07-12 19:25:47 -0700 751) KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
6f303d60534c4 (Linus Torvalds 2019-05-01 11:05:41 -0700 752) KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
a1c48bb160f83 (Geert Uytterhoeven 2014-05-27 09:54:12 +0200 753)
15f5db60a1374 (Masahiro Yamada 2019-08-21 02:09:40 +0900 754) ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
15f5db60a1374 (Masahiro Yamada 2019-08-21 02:09:40 +0900 755) KBUILD_CFLAGS += -O2
15f5db60a1374 (Masahiro Yamada 2019-08-21 02:09:40 +0900 756) else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
15f5db60a1374 (Masahiro Yamada 2019-08-21 02:09:40 +0900 757) KBUILD_CFLAGS += -O3
15f5db60a1374 (Masahiro Yamada 2019-08-21 02:09:40 +0900 758) else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
15f5db60a1374 (Masahiro Yamada 2019-08-21 02:09:40 +0900 759) KBUILD_CFLAGS += -Os
815eb71e7149e (Arnd Bergmann 2016-04-25 17:35:28 +0200 760) endif
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 761)
69102311a57d1 (Jiri Kosina 2014-08-06 16:08:43 -0700 762) # Tell gcc to never replace conditional load with a non-conditional one
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 763) ifdef CONFIG_CC_IS_GCC
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 764) # gcc-10 renamed --param=allow-store-data-races=0 to
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 765) # -fno-allow-store-data-races.
69102311a57d1 (Jiri Kosina 2014-08-06 16:08:43 -0700 766) KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
b1112139a103b (Sergei Trofimovich 2020-03-17 00:07:18 +0000 767) KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 768) endif
69102311a57d1 (Jiri Kosina 2014-08-06 16:08:43 -0700 769)
1873e870fd63e (Andi Kleen 2012-03-28 11:51:18 -0700 770) ifdef CONFIG_READABLE_ASM
1873e870fd63e (Andi Kleen 2012-03-28 11:51:18 -0700 771) # Disable optimizations that make assembler listings hard to read.
1873e870fd63e (Andi Kleen 2012-03-28 11:51:18 -0700 772) # reorder blocks reorders the control in the function
1873e870fd63e (Andi Kleen 2012-03-28 11:51:18 -0700 773) # ipa clone creates specialized cloned functions
1873e870fd63e (Andi Kleen 2012-03-28 11:51:18 -0700 774) # partial inlining inlines only parts of functions
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 775) KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
1873e870fd63e (Andi Kleen 2012-03-28 11:51:18 -0700 776) endif
1873e870fd63e (Andi Kleen 2012-03-28 11:51:18 -0700 777)
08f67461c609a (Mike Frysinger 2009-06-04 16:29:08 -0700 778) ifneq ($(CONFIG_FRAME_WARN),0)
a83e4ca26af8f (Masahiro Yamada 2020-02-17 00:19:36 +0900 779) KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
35bb5b1e0e84c (Andi Kleen 2008-02-22 15:15:03 +0100 780) endif
35bb5b1e0e84c (Andi Kleen 2008-02-22 15:15:03 +0100 781)
893ab00439a45 (Masahiro Yamada 2020-06-27 03:59:12 +0900 782) stackp-flags-y := -fno-stack-protector
050e9baa9dc9f (Linus Torvalds 2018-06-14 12:21:18 +0900 783) stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
050e9baa9dc9f (Linus Torvalds 2018-06-14 12:21:18 +0900 784) stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
2a61f4747eeaa (Masahiro Yamada 2018-05-28 18:22:00 +0900 785)
2a61f4747eeaa (Masahiro Yamada 2018-05-28 18:22:00 +0900 786) KBUILD_CFLAGS += $(stackp-flags-y)
e06b8b98da071 (Sam Ravnborg 2008-02-13 22:43:28 +0100 787)
3fe617ccafd6f (Linus Torvalds 2021-09-05 11:24:05 -0700 788) KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror
3fe617ccafd6f (Linus Torvalds 2021-09-05 11:24:05 -0700 789) KBUILD_CFLAGS += $(KBUILD_CFLAGS-y)
3fe617ccafd6f (Linus Torvalds 2021-09-05 11:24:05 -0700 790)
076f421da5d45 (Masahiro Yamada 2018-10-30 22:26:33 +0900 791) ifdef CONFIG_CC_IS_CLANG
a1494304346a3 (Masahiro Yamada 2019-05-10 23:10:09 +0900 792) KBUILD_CPPFLAGS += -Qunused-arguments
5c6ae0efca8d7 (Nathan Chancellor 2021-08-16 13:20:55 -0700 793) # The kernel builds with '-std=gnu89' so use of GNU extensions is acceptable.
a1494304346a3 (Masahiro Yamada 2019-05-10 23:10:09 +0900 794) KBUILD_CFLAGS += -Wno-gnu
cfe17c9bbe6a6 (Masahiro Yamada 2017-11-27 21:15:13 +0900 795) # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
cfe17c9bbe6a6 (Masahiro Yamada 2017-11-27 21:15:13 +0900 796) # source of a reference will be _MergedGlobals and not on of the whitelisted names.
cfe17c9bbe6a6 (Masahiro Yamada 2017-11-27 21:15:13 +0900 797) # See modpost pattern 2
a1494304346a3 (Masahiro Yamada 2019-05-10 23:10:09 +0900 798) KBUILD_CFLAGS += -mno-global-merge
d936eb2387443 (Linus Torvalds 2021-07-15 18:05:31 -0700 799) else
d936eb2387443 (Linus Torvalds 2021-07-15 18:05:31 -0700 800)
d936eb2387443 (Linus Torvalds 2021-07-15 18:05:31 -0700 801) # Warn about unmarked fall-throughs in switch statement.
d936eb2387443 (Linus Torvalds 2021-07-15 18:05:31 -0700 802) # Disabled for clang while comment to attribute conversion happens and
d936eb2387443 (Linus Torvalds 2021-07-15 18:05:31 -0700 803) # https://github.com/ClangBuiltLinux/linux/issues/636 is discussed.
d936eb2387443 (Linus Torvalds 2021-07-15 18:05:31 -0700 804) KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough=5,)
49832c819ab85 (Randy Dunlap 2021-09-07 15:42:02 -0700 805) # gcc inanely warns about local variables called 'main'
49832c819ab85 (Randy Dunlap 2021-09-07 15:42:02 -0700 806) KBUILD_CFLAGS += -Wno-main
cfe17c9bbe6a6 (Masahiro Yamada 2017-11-27 21:15:13 +0900 807) endif
cfe17c9bbe6a6 (Masahiro Yamada 2017-11-27 21:15:13 +0900 808)
885480b084696 (Nathan Chancellor 2021-04-28 18:23:50 -0700 809) # These warnings generated too much noise in a regular build.
885480b084696 (Nathan Chancellor 2021-04-28 18:23:50 -0700 810) # Use make W=1 to enable them (see scripts/Makefile.extrawarn)
885480b084696 (Nathan Chancellor 2021-04-28 18:23:50 -0700 811) KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
0a5f41767444c (Prasad Sodagudi 2018-02-06 15:46:51 -0800 812) KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
6272cc389fec7 (Nathan Chancellor 2021-08-16 13:20:56 -0700 813)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 814) ifdef CONFIG_FRAME_POINTER
a0f97e06a43cf (Sam Ravnborg 2007-10-14 22:21:35 +0200 815) KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 816) else
7e9501fdecdee (Rabin Vincent 2010-08-10 19:20:53 +0100 817) # Some targets (ARM with Thumb2, for example), can't be built with frame
7e9501fdecdee (Rabin Vincent 2010-08-10 19:20:53 +0100 818) # pointers. For those, we don't have FUNCTION_TRACER automatically
7e9501fdecdee (Rabin Vincent 2010-08-10 19:20:53 +0100 819) # select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is
7e9501fdecdee (Rabin Vincent 2010-08-10 19:20:53 +0100 820) # incompatible with -fomit-frame-pointer with current GCC, so we don't use
7e9501fdecdee (Rabin Vincent 2010-08-10 19:20:53 +0100 821) # -fomit-frame-pointer with FUNCTION_TRACER.
7e9501fdecdee (Rabin Vincent 2010-08-10 19:20:53 +0100 822) ifndef CONFIG_FUNCTION_TRACER
a0f97e06a43cf (Sam Ravnborg 2007-10-14 22:21:35 +0200 823) KBUILD_CFLAGS += -fomit-frame-pointer
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 824) endif
7e9501fdecdee (Rabin Vincent 2010-08-10 19:20:53 +0100 825) endif
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 826)
f0fe00d4972a8 (glider@google.com 2020-06-16 10:34:35 +0200 827) # Initialize all stack variables with a 0xAA pattern.
f0fe00d4972a8 (glider@google.com 2020-06-16 10:34:35 +0200 828) ifdef CONFIG_INIT_STACK_ALL_PATTERN
709a972efb01e (Kees Cook 2019-04-10 08:48:31 -0700 829) KBUILD_CFLAGS += -ftrivial-auto-var-init=pattern
709a972efb01e (Kees Cook 2019-04-10 08:48:31 -0700 830) endif
709a972efb01e (Kees Cook 2019-04-10 08:48:31 -0700 831)
f0fe00d4972a8 (glider@google.com 2020-06-16 10:34:35 +0200 832) # Initialize all stack variables with a zero value.
f0fe00d4972a8 (glider@google.com 2020-06-16 10:34:35 +0200 833) ifdef CONFIG_INIT_STACK_ALL_ZERO
f0fe00d4972a8 (glider@google.com 2020-06-16 10:34:35 +0200 834) # Future support for zero initialization is still being debated, see
f0fe00d4972a8 (glider@google.com 2020-06-16 10:34:35 +0200 835) # https://bugs.llvm.org/show_bug.cgi?id=45497. These flags are subject to being
f0fe00d4972a8 (glider@google.com 2020-06-16 10:34:35 +0200 836) # renamed or dropped.
f0fe00d4972a8 (glider@google.com 2020-06-16 10:34:35 +0200 837) KBUILD_CFLAGS += -ftrivial-auto-var-init=zero
f0fe00d4972a8 (glider@google.com 2020-06-16 10:34:35 +0200 838) KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
f0fe00d4972a8 (glider@google.com 2020-06-16 10:34:35 +0200 839) endif
f0fe00d4972a8 (glider@google.com 2020-06-16 10:34:35 +0200 840)
39218ff4c625d (Kees Cook 2021-04-01 16:23:44 -0700 841) # While VLAs have been removed, GCC produces unreachable stack probes
39218ff4c625d (Kees Cook 2021-04-01 16:23:44 -0700 842) # for the randomize_kstack_offset feature. Disable it for all compilers.
39218ff4c625d (Kees Cook 2021-04-01 16:23:44 -0700 843) KBUILD_CFLAGS += $(call cc-option, -fno-stack-clash-protection)
39218ff4c625d (Kees Cook 2021-04-01 16:23:44 -0700 844)
a82adfd5c7cb4 (Kees Cook 2021-04-12 19:56:54 -0700 845) # Clear used registers at func exit (to reduce data lifetime and ROP gadgets).
a82adfd5c7cb4 (Kees Cook 2021-04-12 19:56:54 -0700 846) ifdef CONFIG_ZERO_CALL_USED_REGS
a82adfd5c7cb4 (Kees Cook 2021-04-12 19:56:54 -0700 847) KBUILD_CFLAGS += -fzero-call-used-regs=used-gpr
a82adfd5c7cb4 (Kees Cook 2021-04-12 19:56:54 -0700 848) endif
a82adfd5c7cb4 (Kees Cook 2021-04-12 19:56:54 -0700 849)
315da87c0f99a (Masahiro Yamada 2021-02-03 16:52:39 +0900 850) DEBUG_CFLAGS :=
315da87c0f99a (Masahiro Yamada 2021-02-03 16:52:39 +0900 851)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 852) ifdef CONFIG_DEBUG_INFO
695afd3d7d58e (Sedat Dilek 2020-08-16 14:32:44 +0200 853)
866ced950bcd5 (Andi Kleen 2014-07-30 20:50:18 +0200 854) ifdef CONFIG_DEBUG_INFO_SPLIT
9d9374440072e (Masahiro Yamada 2019-02-22 16:56:09 +0900 855) DEBUG_CFLAGS += -gsplit-dwarf
866ced950bcd5 (Andi Kleen 2014-07-30 20:50:18 +0200 856) else
1e88e415ebccb (Masahiro Yamada 2019-02-10 15:51:00 +0900 857) DEBUG_CFLAGS += -g
866ced950bcd5 (Andi Kleen 2014-07-30 20:50:18 +0200 858) endif
695afd3d7d58e (Sedat Dilek 2020-08-16 14:32:44 +0200 859)
52cc02b910284 (Masahiro Yamada 2021-08-06 00:01:02 +0900 860) ifndef CONFIG_AS_IS_LLVM
2288328ce9700 (Behan Webster 2014-02-14 15:19:17 -0800 861) KBUILD_AFLAGS += -Wa,-gdwarf-2
b8a9092330da2 (Nick Desaulniers 2020-11-09 10:35:28 -0800 862) endif
695afd3d7d58e (Sedat Dilek 2020-08-16 14:32:44 +0200 863)
a66049e2cf0ef (Nick Desaulniers 2021-02-05 12:22:19 -0800 864) ifndef CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
a66049e2cf0ef (Nick Desaulniers 2021-02-05 12:22:19 -0800 865) dwarf-version-$(CONFIG_DEBUG_INFO_DWARF4) := 4
98cd6f521f101 (Nick Desaulniers 2021-02-05 12:22:20 -0800 866) dwarf-version-$(CONFIG_DEBUG_INFO_DWARF5) := 5
a66049e2cf0ef (Nick Desaulniers 2021-02-05 12:22:19 -0800 867) DEBUG_CFLAGS += -gdwarf-$(dwarf-version-y)
bfaf2dd3509bc (Andi Kleen 2014-07-30 20:50:19 +0200 868) endif
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 869)
d6f4ceb796ebf (Andi Kleen 2010-07-14 15:43:52 +0200 870) ifdef CONFIG_DEBUG_INFO_REDUCED
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 871) DEBUG_CFLAGS += -fno-var-tracking
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 872) ifdef CONFIG_CC_IS_GCC
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 873) DEBUG_CFLAGS += -femit-struct-debug-baseonly
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 874) endif
d6f4ceb796ebf (Andi Kleen 2010-07-14 15:43:52 +0200 875) endif
d6f4ceb796ebf (Andi Kleen 2010-07-14 15:43:52 +0200 876)
10e68b02c861c (Nick Desaulniers 2020-05-26 10:18:29 -0700 877) ifdef CONFIG_DEBUG_INFO_COMPRESSED
10e68b02c861c (Nick Desaulniers 2020-05-26 10:18:29 -0700 878) DEBUG_CFLAGS += -gz=zlib
7b16994437c73 (Arvind Sankar 2020-06-11 18:03:39 -0400 879) KBUILD_AFLAGS += -gz=zlib
10e68b02c861c (Nick Desaulniers 2020-05-26 10:18:29 -0700 880) KBUILD_LDFLAGS += --compress-debug-sections=zlib
10e68b02c861c (Nick Desaulniers 2020-05-26 10:18:29 -0700 881) endif
10e68b02c861c (Nick Desaulniers 2020-05-26 10:18:29 -0700 882)
695afd3d7d58e (Sedat Dilek 2020-08-16 14:32:44 +0200 883) endif # CONFIG_DEBUG_INFO
695afd3d7d58e (Sedat Dilek 2020-08-16 14:32:44 +0200 884)
1e88e415ebccb (Masahiro Yamada 2019-02-10 15:51:00 +0900 885) KBUILD_CFLAGS += $(DEBUG_CFLAGS)
1e88e415ebccb (Masahiro Yamada 2019-02-10 15:51:00 +0900 886) export DEBUG_CFLAGS
1e88e415ebccb (Masahiro Yamada 2019-02-10 15:51:00 +0900 887)
606576ce81660 (Steven Rostedt 2008-10-06 19:06:12 -0400 888) ifdef CONFIG_FUNCTION_TRACER
3b15cdc159566 (Sami Tolvanen 2020-12-11 10:46:18 -0800 889) ifdef CONFIG_FTRACE_MCOUNT_USE_CC
3b15cdc159566 (Sami Tolvanen 2020-12-11 10:46:18 -0800 890) CC_FLAGS_FTRACE += -mrecord-mcount
2f4df0017baed (Vasily Gorbik 2018-08-06 15:17:46 +0200 891) ifdef CONFIG_HAVE_NOP_MCOUNT
2f4df0017baed (Vasily Gorbik 2018-08-06 15:17:46 +0200 892) ifeq ($(call cc-option-yn, -mnop-mcount),y)
2f4df0017baed (Vasily Gorbik 2018-08-06 15:17:46 +0200 893) CC_FLAGS_FTRACE += -mnop-mcount
2f4df0017baed (Vasily Gorbik 2018-08-06 15:17:46 +0200 894) CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
2f4df0017baed (Vasily Gorbik 2018-08-06 15:17:46 +0200 895) endif
2f4df0017baed (Vasily Gorbik 2018-08-06 15:17:46 +0200 896) endif
07d0408120216 (Vasily Gorbik 2018-08-06 15:17:44 +0200 897) endif
22c8542d7b220 (Sami Tolvanen 2020-09-25 16:43:53 -0700 898) ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL
22c8542d7b220 (Sami Tolvanen 2020-09-25 16:43:53 -0700 899) CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT
22c8542d7b220 (Sami Tolvanen 2020-09-25 16:43:53 -0700 900) endif
3b15cdc159566 (Sami Tolvanen 2020-12-11 10:46:18 -0800 901) ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
3b15cdc159566 (Sami Tolvanen 2020-12-11 10:46:18 -0800 902) ifdef CONFIG_HAVE_C_RECORDMCOUNT
3b15cdc159566 (Sami Tolvanen 2020-12-11 10:46:18 -0800 903) BUILD_C_RECORDMCOUNT := y
3b15cdc159566 (Sami Tolvanen 2020-12-11 10:46:18 -0800 904) export BUILD_C_RECORDMCOUNT
3b15cdc159566 (Sami Tolvanen 2020-12-11 10:46:18 -0800 905) endif
3b15cdc159566 (Sami Tolvanen 2020-12-11 10:46:18 -0800 906) endif
a2546fae01124 (Steven Rostedt 2011-02-09 13:15:59 -0500 907) ifdef CONFIG_HAVE_FENTRY
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 908) # s390-linux-gnu-gcc did not support -mfentry until gcc-9.
f28bc3c32c059 (Vasily Gorbik 2018-08-06 15:17:42 +0200 909) ifeq ($(call cc-option-yn, -mfentry),y)
f28bc3c32c059 (Vasily Gorbik 2018-08-06 15:17:42 +0200 910) CC_FLAGS_FTRACE += -mfentry
f28bc3c32c059 (Vasily Gorbik 2018-08-06 15:17:42 +0200 911) CC_FLAGS_USING += -DCC_USING_FENTRY
f28bc3c32c059 (Vasily Gorbik 2018-08-06 15:17:42 +0200 912) endif
a2546fae01124 (Steven Rostedt 2011-02-09 13:15:59 -0500 913) endif
f28bc3c32c059 (Vasily Gorbik 2018-08-06 15:17:42 +0200 914) export CC_FLAGS_FTRACE
f28bc3c32c059 (Vasily Gorbik 2018-08-06 15:17:42 +0200 915) KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING)
f28bc3c32c059 (Vasily Gorbik 2018-08-06 15:17:42 +0200 916) KBUILD_AFLAGS += $(CC_FLAGS_USING)
16444a8a40d4c (Arnaldo Carvalho de Melo 2008-05-12 21:20:42 +0200 917) endif
16444a8a40d4c (Arnaldo Carvalho de Melo 2008-05-12 21:20:42 +0200 918)
91341d4b2c196 (Sam Ravnborg 2008-01-21 21:31:44 +0100 919) # We trigger additional mismatches with less inlining
91341d4b2c196 (Sam Ravnborg 2008-01-21 21:31:44 +0100 920) ifdef CONFIG_DEBUG_SECTION_MISMATCH
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 921) KBUILD_CFLAGS += -fno-inline-functions-called-once
91341d4b2c196 (Sam Ravnborg 2008-01-21 21:31:44 +0100 922) endif
91341d4b2c196 (Sam Ravnborg 2008-01-21 21:31:44 +0100 923)
90ad4052e85ce (Masahiro Yamada 2017-04-14 15:17:26 +0900 924) ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
e85d1d65cd8a9 (Masahiro Yamada 2018-08-22 22:51:09 +0900 925) KBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
e85d1d65cd8a9 (Masahiro Yamada 2018-08-22 22:51:09 +0900 926) LDFLAGS_vmlinux += --gc-sections
90ad4052e85ce (Masahiro Yamada 2017-04-14 15:17:26 +0900 927) endif
90ad4052e85ce (Masahiro Yamada 2017-04-14 15:17:26 +0900 928)
d08b9f0ca6605 (Sami Tolvanen 2020-04-27 09:00:07 -0700 929) ifdef CONFIG_SHADOW_CALL_STACK
d08b9f0ca6605 (Sami Tolvanen 2020-04-27 09:00:07 -0700 930) CC_FLAGS_SCS := -fsanitize=shadow-call-stack
d08b9f0ca6605 (Sami Tolvanen 2020-04-27 09:00:07 -0700 931) KBUILD_CFLAGS += $(CC_FLAGS_SCS)
d08b9f0ca6605 (Sami Tolvanen 2020-04-27 09:00:07 -0700 932) export CC_FLAGS_SCS
d08b9f0ca6605 (Sami Tolvanen 2020-04-27 09:00:07 -0700 933) endif
d08b9f0ca6605 (Sami Tolvanen 2020-04-27 09:00:07 -0700 934)
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 935) ifdef CONFIG_LTO_CLANG
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 936) ifdef CONFIG_LTO_CLANG_THIN
2b86895205201 (Alexander Lobakin 2021-01-21 18:45:55 +0000 937) CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
7f69180b8e905 (Masahiro Yamada 2021-03-31 22:38:06 +0900 938) KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod_prefix).thinlto-cache
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 939) else
2b86895205201 (Alexander Lobakin 2021-01-21 18:45:55 +0000 940) CC_FLAGS_LTO := -flto
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 941) endif
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 942) CC_FLAGS_LTO += -fvisibility=hidden
22d429e75f24d (Sami Tolvanen 2020-12-11 10:46:21 -0800 943)
22d429e75f24d (Sami Tolvanen 2020-12-11 10:46:21 -0800 944) # Limit inlining across translation units to reduce binary size
22d429e75f24d (Sami Tolvanen 2020-12-11 10:46:21 -0800 945) KBUILD_LDFLAGS += -mllvm -import-instr-limit=5
24845dcb170e1 (Nick Desaulniers 2021-03-11 17:09:41 -0800 946)
0236526d76b87 (Tor Vic 2021-06-13 13:07:49 +0000 947) # Check for frame size exceeding threshold during prolog/epilog insertion
0236526d76b87 (Tor Vic 2021-06-13 13:07:49 +0000 948) # when using lld < 13.0.0.
24845dcb170e1 (Nick Desaulniers 2021-03-11 17:09:41 -0800 949) ifneq ($(CONFIG_FRAME_WARN),0)
0236526d76b87 (Tor Vic 2021-06-13 13:07:49 +0000 950) ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0)
24845dcb170e1 (Nick Desaulniers 2021-03-11 17:09:41 -0800 951) KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN)
24845dcb170e1 (Nick Desaulniers 2021-03-11 17:09:41 -0800 952) endif
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 953) endif
0236526d76b87 (Tor Vic 2021-06-13 13:07:49 +0000 954) endif
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 955)
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 956) ifdef CONFIG_LTO
5e95325fbbbde (Sami Tolvanen 2021-02-23 13:59:52 -0800 957) KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO)
5e95325fbbbde (Sami Tolvanen 2021-02-23 13:59:52 -0800 958) KBUILD_AFLAGS += -fno-lto
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 959) export CC_FLAGS_LTO
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 960) endif
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 961)
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 962) ifdef CONFIG_CFI_CLANG
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 963) CC_FLAGS_CFI := -fsanitize=cfi \
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 964) -fsanitize-cfi-cross-dso \
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 965) -fno-sanitize-cfi-canonical-jump-tables \
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 966) -fno-sanitize-trap=cfi \
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 967) -fno-sanitize-blacklist
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 968)
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 969) ifdef CONFIG_CFI_PERMISSIVE
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 970) CC_FLAGS_CFI += -fsanitize-recover=cfi
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 971) endif
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 972)
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 973) # If LTO flags are filtered out, we must also filter out CFI.
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 974) CC_FLAGS_LTO += $(CC_FLAGS_CFI)
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 975) KBUILD_CFLAGS += $(CC_FLAGS_CFI)
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 976) export CC_FLAGS_CFI
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 977) endif
cf68fffb66d60 (Sami Tolvanen 2021-04-08 11:28:26 -0700 978)
cf536e185869d (Feng Tang 2021-05-06 15:34:59 +0800 979) ifdef CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B
cf536e185869d (Feng Tang 2021-05-06 15:34:59 +0800 980) KBUILD_CFLAGS += -falign-functions=64
09c60546f04f7 (Feng Tang 2020-08-11 18:34:13 -0700 981) endif
09c60546f04f7 (Feng Tang 2020-08-11 18:34:13 -0700 982)
e8e6993178344 (Sam Ravnborg 2005-04-30 16:51:42 -0700 983) # arch Makefile may override CC so keep this after arch Makefile is included
e08d6de4e5321 (Masahiro Yamada 2018-05-28 18:21:38 +0900 984) NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
e8e6993178344 (Sam Ravnborg 2005-04-30 16:51:42 -0700 985)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 986) # warn about C99 declaration after statement
a33e7ae295d5b (Masahiro Yamada 2018-10-01 18:44:37 +0900 987) KBUILD_CFLAGS += -Wdeclaration-after-statement
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 988)
0bb95f80a38f8 (Kees Cook 2018-06-25 15:59:34 -0700 989) # Variable Length Arrays (VLAs) should not be used anywhere in the kernel
8289f913fe126 (Masahiro Yamada 2019-05-09 15:45:49 +0900 990) KBUILD_CFLAGS += -Wvla
0bb95f80a38f8 (Kees Cook 2018-06-25 15:59:34 -0700 991)
070b98bfda3d2 (Sam Ravnborg 2006-06-25 00:07:55 +0200 992) # disable pointer signed / unsigned warnings in gcc 4.0
fb073a4b473e5 (Masahiro Yamada 2018-10-01 18:44:36 +0900 993) KBUILD_CFLAGS += -Wno-pointer-sign
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 994)
217c3e0196758 (Stephen Rothwell 2018-08-31 07:47:28 +1000 995) # disable stringop warnings in gcc 8+
217c3e0196758 (Stephen Rothwell 2018-08-31 07:47:28 +1000 996) KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
217c3e0196758 (Stephen Rothwell 2018-08-31 07:47:28 +1000 997)
5c45de21a2223 (Linus Torvalds 2020-05-09 14:30:29 -0700 998) # We'll want to enable this eventually, but it's not going away for 5.7 at least
5c45de21a2223 (Linus Torvalds 2020-05-09 14:30:29 -0700 999) KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds)
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 1000) KBUILD_CFLAGS += -Wno-array-bounds
5a76021c2eff7 (Linus Torvalds 2020-05-09 15:40:52 -0700 1001) KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
5c45de21a2223 (Linus Torvalds 2020-05-09 14:30:29 -0700 1002)
adc7192096987 (Linus Torvalds 2020-05-09 15:45:21 -0700 1003) # Another good warning that we'll want to enable eventually
adc7192096987 (Linus Torvalds 2020-05-09 15:45:21 -0700 1004) KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
adc7192096987 (Linus Torvalds 2020-05-09 15:45:21 -0700 1005)
78a5255ffb6a1 (Linus Torvalds 2020-05-09 13:57:10 -0700 1006) # Enabled with W=2, disabled by default as noisy
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 1007) ifdef CONFIG_CC_IS_GCC
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 1008) KBUILD_CFLAGS += -Wno-maybe-uninitialized
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 1009) endif
78a5255ffb6a1 (Linus Torvalds 2020-05-09 13:57:10 -0700 1010)
fe8d0a41081d6 (Kirill Smelkov 2009-04-09 15:34:34 +0400 1011) # disable invalid "can't wrap" optimizations for signed / pointers
8b42cf2fde0ee (Masahiro Yamada 2020-09-10 22:51:17 +0900 1012) KBUILD_CFLAGS += -fno-strict-overflow
d0115552cdb0b (Linus Torvalds 2009-03-19 15:53:19 -0700 1013)
3ce120b16cc54 (Linus Torvalds 2017-12-29 17:34:43 -0800 1014) # Make sure -fstack-check isn't enabled (like gentoo apparently did)
7d4eb0d8e229f (Masahiro Yamada 2020-09-10 22:51:19 +0900 1015) KBUILD_CFLAGS += -fno-stack-check
3ce120b16cc54 (Linus Torvalds 2017-12-29 17:34:43 -0800 1016)
8f7f5c9fc2966 (Andi Kleen 2009-09-18 12:49:37 -0700 1017) # conserve stack if available
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 1018) ifdef CONFIG_CC_IS_GCC
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 1019) KBUILD_CFLAGS += -fconserve-stack
7d73c3e9c5140 (Nick Desaulniers 2021-08-16 13:25:01 -0700 1020) endif
8f7f5c9fc2966 (Andi Kleen 2009-09-18 12:49:37 -0700 1021)
fe7c36c7bde12 (Josh Triplett 2013-12-23 13:56:06 -0800 1022) # Prohibit date/time macros, which would make the build non-deterministic
87de84c9140e1 (Masahiro Yamada 2020-09-10 22:51:20 +0900 1023) KBUILD_CFLAGS += -Werror=date-time
fe7c36c7bde12 (Josh Triplett 2013-12-23 13:56:06 -0800 1024)
ea8daa7b97842 (Daniel Wagner 2016-03-08 09:29:09 +0100 1025) # enforce correct pointer usage
ea8daa7b97842 (Daniel Wagner 2016-03-08 09:29:09 +0100 1026) KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
ea8daa7b97842 (Daniel Wagner 2016-03-08 09:29:09 +0100 1027)
c834f0e8a8bb3 (Kees Cook 2017-03-20 17:14:11 -0700 1028) # Require designated initializers for all marked structures
c834f0e8a8bb3 (Kees Cook 2017-03-20 17:14:11 -0700 1029) KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
c834f0e8a8bb3 (Kees Cook 2017-03-20 17:14:11 -0700 1030)
a73619a845d56 (Masahiro Yamada 2018-03-30 13:15:26 +0900 1031) # change __FILE__ to the relative path from the srctree
a716bd7432106 (Denys Zagorui 2020-11-02 04:08:53 -0800 1032) KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
a73619a845d56 (Masahiro Yamada 2018-03-30 13:15:26 +0900 1033)
e0fe0bbe57b8d (Masahiro Yamada 2020-08-02 00:00:49 +0900 1034) # include additional Makefiles when needed
e0fe0bbe57b8d (Masahiro Yamada 2020-08-02 00:00:49 +0900 1035) include-y := scripts/Makefile.extrawarn
e0fe0bbe57b8d (Masahiro Yamada 2020-08-02 00:00:49 +0900 1036) include-$(CONFIG_KASAN) += scripts/Makefile.kasan
e0fe0bbe57b8d (Masahiro Yamada 2020-08-02 00:00:49 +0900 1037) include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
e0fe0bbe57b8d (Masahiro Yamada 2020-08-02 00:00:49 +0900 1038) include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
e0fe0bbe57b8d (Masahiro Yamada 2020-08-02 00:00:49 +0900 1039) include-$(CONFIG_KCOV) += scripts/Makefile.kcov
e0fe0bbe57b8d (Masahiro Yamada 2020-08-02 00:00:49 +0900 1040) include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
e0fe0bbe57b8d (Masahiro Yamada 2020-08-02 00:00:49 +0900 1041)
e0fe0bbe57b8d (Masahiro Yamada 2020-08-02 00:00:49 +0900 1042) include $(addprefix $(srctree)/, $(include-y))
a86fe35373506 (Masahiro Yamada 2014-04-14 18:27:10 +0900 1043)
132305b3b474a (Masahiro Yamada 2020-08-02 00:00:50 +0900 1044) # scripts/Makefile.gcc-plugins is intentionally included last.
132305b3b474a (Masahiro Yamada 2020-08-02 00:00:50 +0900 1045) # Do not add $(call cc-option,...) below this line. When you build the kernel
132305b3b474a (Masahiro Yamada 2020-08-02 00:00:50 +0900 1046) # from the clean source tree, the GCC plugins do not exist at this point.
a86fe35373506 (Masahiro Yamada 2014-04-14 18:27:10 +0900 1047)
8cc7af751443f (Masahiro Yamada 2019-08-21 02:09:41 +0900 1048) # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
8cc7af751443f (Masahiro Yamada 2019-08-21 02:09:41 +0900 1049) KBUILD_CPPFLAGS += $(KCPPFLAGS)
8cc7af751443f (Masahiro Yamada 2019-08-21 02:09:41 +0900 1050) KBUILD_AFLAGS += $(KAFLAGS)
8cc7af751443f (Masahiro Yamada 2019-08-21 02:09:41 +0900 1051) KBUILD_CFLAGS += $(KCFLAGS)
52bcc3308ae33 (Sam Ravnborg 2007-10-15 22:03:58 +0200 1052)
a968433723310 (Bill Wendling 2020-09-22 16:21:40 -0700 1053) KBUILD_LDFLAGS_MODULE += --build-id=sha1
a968433723310 (Bill Wendling 2020-09-22 16:21:40 -0700 1054) LDFLAGS_vmlinux += --build-id=sha1
18991197b4b58 (Roland McGrath 2007-07-19 01:48:40 -0700 1055)
5d7d18f5bc507 (David Howells 2009-03-04 11:59:07 -0800 1056) ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
d79a27195a33f (Andi Kleen 2009-09-16 22:36:55 +0200 1057) LDFLAGS_vmlinux += $(call ld-option, -X,)
5d7d18f5bc507 (David Howells 2009-03-04 11:59:07 -0800 1058) endif
5d7d18f5bc507 (David Howells 2009-03-04 11:59:07 -0800 1059)
5cf896fb6be3e (Peter Collingbourne 2019-07-31 18:18:42 -0700 1060) ifeq ($(CONFIG_RELR),y)
27f2a4db76e8d (Nick Desaulniers 2021-05-21 18:26:24 -0700 1061) LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags
5cf896fb6be3e (Peter Collingbourne 2019-07-31 18:18:42 -0700 1062) endif
5cf896fb6be3e (Peter Collingbourne 2019-07-31 18:18:42 -0700 1063)
59612b24f78a0 (Nathan Chancellor 2020-11-19 13:46:56 -0700 1064) # We never want expected sections to be placed heuristically by the
59612b24f78a0 (Nathan Chancellor 2020-11-19 13:46:56 -0700 1065) # linker. All sections should be explicitly named in the linker script.
59612b24f78a0 (Nathan Chancellor 2020-11-19 13:46:56 -0700 1066) ifdef CONFIG_LD_ORPHAN_WARN
59612b24f78a0 (Nathan Chancellor 2020-11-19 13:46:56 -0700 1067) LDFLAGS_vmlinux += --orphan-handling=warn
59612b24f78a0 (Nathan Chancellor 2020-11-19 13:46:56 -0700 1068) endif
59612b24f78a0 (Nathan Chancellor 2020-11-19 13:46:56 -0700 1069)
7f3a59db274c3 (Masahiro Yamada 2020-04-29 12:45:14 +0900 1070) # Align the bit size of userspace programs with the kernel
7f58b487e9ff3 (Masahiro Yamada 2020-07-01 00:06:25 +0900 1071) KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
7f58b487e9ff3 (Masahiro Yamada 2020-07-01 00:06:25 +0900 1072) KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
7f3a59db274c3 (Masahiro Yamada 2020-04-29 12:45:14 +0900 1073)
80591e61a0f7e (Luc Van Oostenryck 2019-11-09 13:12:16 +0100 1074) # make the checker run with the right architecture
80591e61a0f7e (Luc Van Oostenryck 2019-11-09 13:12:16 +0100 1075) CHECKFLAGS += --arch=$(ARCH)
80591e61a0f7e (Luc Van Oostenryck 2019-11-09 13:12:16 +0100 1076)
145167650b969 (Luc Van Oostenryck 2018-05-28 20:27:35 +0200 1077) # insure the checker run with the right endianness
145167650b969 (Luc Van Oostenryck 2018-05-28 20:27:35 +0200 1078) CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
145167650b969 (Luc Van Oostenryck 2018-05-28 20:27:35 +0200 1079)
1f2f01b122d7c (Luc Van Oostenryck 2018-05-30 22:48:38 +0200 1080) # the checker needs the correct machine size
1f2f01b122d7c (Luc Van Oostenryck 2018-05-30 22:48:38 +0200 1081) CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
1f2f01b122d7c (Luc Van Oostenryck 2018-05-30 22:48:38 +0200 1082)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1083) # Default kernel image to build when no specific target is given.
070b98bfda3d2 (Sam Ravnborg 2006-06-25 00:07:55 +0200 1084) # KBUILD_IMAGE may be overruled on the command line or
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1085) # set in the environment
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1086) # Also any assignments in arch/$(ARCH)/Makefile take precedence over
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1087) # this default value
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1088) export KBUILD_IMAGE ?= vmlinux
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1089)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1090) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1091) # INSTALL_PATH specifies where to place the updated kernel and system map
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1092) # images. Default is /boot, but you can set it to other values
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1093) export INSTALL_PATH ?= /boot
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1094)
f4d4ffc03efc8 (Jason Cooper 2013-12-01 23:56:28 +0000 1095) #
f4d4ffc03efc8 (Jason Cooper 2013-12-01 23:56:28 +0000 1096) # INSTALL_DTBS_PATH specifies a prefix for relocations required by build roots.
f4d4ffc03efc8 (Jason Cooper 2013-12-01 23:56:28 +0000 1097) # Like INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed as
f4d4ffc03efc8 (Jason Cooper 2013-12-01 23:56:28 +0000 1098) # an argument if needed. Otherwise it defaults to the kernel install path
f4d4ffc03efc8 (Jason Cooper 2013-12-01 23:56:28 +0000 1099) #
f4d4ffc03efc8 (Jason Cooper 2013-12-01 23:56:28 +0000 1100) export INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE)
f4d4ffc03efc8 (Jason Cooper 2013-12-01 23:56:28 +0000 1101)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1102) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1103) # INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1104) # relocations required by build roots. This is not defined in the
070b98bfda3d2 (Sam Ravnborg 2006-06-25 00:07:55 +0200 1105) # makefile but the argument can be passed to make if needed.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1106) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1107)
df9df036d3560 (Sam Ravnborg 2006-01-16 12:46:07 +0100 1108) MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1109) export MODLIB
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1110)
e00d888048149 (Masahiro Yamada 2019-01-15 16:19:00 +0900 1111) PHONY += prepare0
e2a666d52b482 (Rusty Russell 2012-10-19 11:53:15 +1030 1112)
ccae4cfa7bfbe (Masahiro Yamada 2021-03-31 22:38:07 +0900 1113) export extmod_prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
7f69180b8e905 (Masahiro Yamada 2021-03-31 22:38:06 +0900 1114) export MODORDER := $(extmod_prefix)modules.order
7f69180b8e905 (Masahiro Yamada 2021-03-31 22:38:06 +0900 1115) export MODULES_NSDEPS := $(extmod_prefix)modules.nsdeps
47801c97deb71 (Masahiro Yamada 2019-08-02 19:23:58 +0900 1116)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1117) ifeq ($(KBUILD_EXTMOD),)
cfc411e7fff3e (David Howells 2015-08-14 15:20:41 +0100 1118) core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1119)
23febe375d94d (Masahiro Yamada 2020-06-01 14:56:57 +0900 1120) vmlinux-dirs := $(patsubst %/,%,$(filter %/, \
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1121) $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
95fb6317b3ab8 (Masahiro Yamada 2020-06-01 14:56:58 +0900 1122) $(libs-y) $(libs-m)))
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1123)
1eaca4b982806 (Masahiro Yamada 2019-04-27 12:33:37 +0900 1124) vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \
23febe375d94d (Masahiro Yamada 2020-06-01 14:56:57 +0900 1125) $(patsubst %/,%,$(filter %/, $(core-) \
95fb6317b3ab8 (Masahiro Yamada 2020-06-01 14:56:58 +0900 1126) $(drivers-) $(libs-))))
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1127)
b2c8855491226 (Masahiro Yamada 2020-06-01 14:57:00 +0900 1128) subdir-modorder := $(addsuffix modules.order,$(filter %/, \
b2c8855491226 (Masahiro Yamada 2020-06-01 14:57:00 +0900 1129) $(core-y) $(core-m) $(libs-y) $(libs-m) \
b2c8855491226 (Masahiro Yamada 2020-06-01 14:57:00 +0900 1130) $(drivers-y) $(drivers-m)))
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1131)
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1132) build-dirs := $(vmlinux-dirs)
76cd306d79792 (Masahiro Yamada 2019-08-11 00:53:05 +0900 1133) clean-dirs := $(vmlinux-alldirs)
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1134)
f0d50ca045e44 (Masahiro Yamada 2020-06-01 14:56:59 +0900 1135) # Externally visible symbols (used by link-vmlinux.sh)
f0d50ca045e44 (Masahiro Yamada 2020-06-01 14:56:59 +0900 1136) KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
f0d50ca045e44 (Masahiro Yamada 2020-06-01 14:56:59 +0900 1137) KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
7273ad2b08f8a (Masahiro Yamada 2020-03-12 07:37:25 +0900 1138) ifdef CONFIG_MODULES
f0d50ca045e44 (Masahiro Yamada 2020-06-01 14:56:59 +0900 1139) KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
f0d50ca045e44 (Masahiro Yamada 2020-06-01 14:56:59 +0900 1140) KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
7273ad2b08f8a (Masahiro Yamada 2020-03-12 07:37:25 +0900 1141) else
f0d50ca045e44 (Masahiro Yamada 2020-06-01 14:56:59 +0900 1142) KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
7273ad2b08f8a (Masahiro Yamada 2020-03-12 07:37:25 +0900 1143) endif
f0d50ca045e44 (Masahiro Yamada 2020-06-01 14:56:59 +0900 1144) KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1145)
f0d50ca045e44 (Masahiro Yamada 2020-06-01 14:56:59 +0900 1146) export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
95698570510b7 (Sam Ravnborg 2012-05-05 10:18:40 +0200 1147) export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
85f0ae7e435af (Masahiro Yamada 2019-09-21 22:18:46 +0900 1148) # used by scripts/Makefile.package
233c741dcbb13 (Masahiro Yamada 2019-05-16 01:18:54 +0900 1149) export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools)
9bb482476c6c9 (Jan Beulich 2008-12-16 11:30:08 +0000 1150)
d151e9719f184 (Masahiro Yamada 2019-01-17 09:10:04 +0900 1151) vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1152)
3fdc7d3fe4c04 (Masahiro Yamada 2018-03-16 16:37:15 +0900 1153) # Recurse until adjust_autoksyms.sh is satisfied
3fdc7d3fe4c04 (Masahiro Yamada 2018-03-16 16:37:15 +0900 1154) PHONY += autoksyms_recursive
2441e78b19192 (Nicolas Pitre 2016-04-22 15:25:00 -0400 1155) ifdef CONFIG_TRIM_UNUSED_KSYMS
1f50b80a09383 (Masahiro Yamada 2018-03-16 16:37:13 +0900 1156) # For the kernel to actually contain only the needed exported symbols,
1f50b80a09383 (Masahiro Yamada 2018-03-16 16:37:13 +0900 1157) # we have to build modules as well to determine what those symbols are.
1f50b80a09383 (Masahiro Yamada 2018-03-16 16:37:13 +0900 1158) # (this can be evaluated only once include/config/auto.conf has been included)
fb2d99be8919d (Masahiro Yamada 2020-05-31 19:11:39 +0900 1159) KBUILD_MODULES := 1
fb2d99be8919d (Masahiro Yamada 2020-05-31 19:11:39 +0900 1160)
fb2d99be8919d (Masahiro Yamada 2020-05-31 19:11:39 +0900 1161) autoksyms_recursive: descend modules.order
fb2d99be8919d (Masahiro Yamada 2020-05-31 19:11:39 +0900 1162) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
fb2d99be8919d (Masahiro Yamada 2020-05-31 19:11:39 +0900 1163) "$(MAKE) -f $(srctree)/Makefile vmlinux"
1f50b80a09383 (Masahiro Yamada 2018-03-16 16:37:13 +0900 1164) endif
1f50b80a09383 (Masahiro Yamada 2018-03-16 16:37:13 +0900 1165)
07a422bb213ad (Masahiro Yamada 2018-03-16 16:37:12 +0900 1166) autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h)
07a422bb213ad (Masahiro Yamada 2018-03-16 16:37:12 +0900 1167)
88694cff4952d (Quentin Perret 2020-02-28 17:20:15 +0000 1168) quiet_cmd_autoksyms_h = GEN $@
88694cff4952d (Quentin Perret 2020-02-28 17:20:15 +0000 1169) cmd_autoksyms_h = mkdir -p $(dir $@); \
88694cff4952d (Quentin Perret 2020-02-28 17:20:15 +0000 1170) $(CONFIG_SHELL) $(srctree)/scripts/gen_autoksyms.sh $@
88694cff4952d (Quentin Perret 2020-02-28 17:20:15 +0000 1171)
07a422bb213ad (Masahiro Yamada 2018-03-16 16:37:12 +0900 1172) $(autoksyms_h):
88694cff4952d (Quentin Perret 2020-02-28 17:20:15 +0000 1173) $(call cmd,autoksyms_h)
23121ca2b56b5 (Nicolas Pitre 2016-01-26 21:50:18 -0500 1174)
fbe6e37dab974 (Nicholas Piggin 2016-08-24 22:29:21 +1000 1175) ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
fbe6e37dab974 (Nicholas Piggin 2016-08-24 22:29:21 +1000 1176)
fbe6e37dab974 (Nicholas Piggin 2016-08-24 22:29:21 +1000 1177) # Final link of vmlinux with optional arch pass after final link
312a3d0918bb7 (Cao jin 2017-08-02 10:31:06 +0800 1178) cmd_link-vmlinux = \
3ec8a5b33deac (Masahiro Yamada 2020-07-02 04:29:36 +0900 1179) $(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \
fbe6e37dab974 (Nicholas Piggin 2016-08-24 22:29:21 +1000 1180) $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
2441e78b19192 (Nicolas Pitre 2016-04-22 15:25:00 -0400 1181)
3fdc7d3fe4c04 (Masahiro Yamada 2018-03-16 16:37:15 +0900 1182) vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
0b956e204132c (Rasmus Villemoes 2021-03-05 11:02:12 +0100 1183) +$(call if_changed_dep,link-vmlinux)
741f98fe298a7 (Sam Ravnborg 2007-07-17 10:54:06 +0200 1184)
392885ee82d35 (Masahiro Yamada 2018-11-30 10:05:22 +0900 1185) targets := vmlinux
392885ee82d35 (Masahiro Yamada 2018-11-30 10:05:22 +0900 1186)
38385f8f01803 (Masahiro Yamada 2014-04-28 16:26:18 +0900 1187) # The actual objects are generated when descending,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1188) # make sure no implicit rule kicks in
b2c8855491226 (Masahiro Yamada 2020-06-01 14:57:00 +0900 1189) $(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1190)
ba97df45581f0 (Masahiro Yamada 2019-01-03 10:16:54 +0900 1191) filechk_kernel.release = \
0d0e7718a9da7 (Michal Marek 2013-07-11 15:34:51 +0200 1192) echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
0d0e7718a9da7 (Michal Marek 2013-07-11 15:34:51 +0200 1193)
83a35e360433b (Geert Uytterhoeven 2013-06-28 11:27:31 +0200 1194) # Store (new) KERNELRELEASE string in include/config/kernel.release
24512795df090 (Masahiro Yamada 2019-04-07 19:03:18 +0900 1195) include/config/kernel.release: FORCE
0d0e7718a9da7 (Michal Marek 2013-07-11 15:34:51 +0200 1196) $(call filechk,kernel.release)
cb58455c48dc4 (Sam Ravnborg 2006-01-09 21:20:34 +0100 1197)
d8821622c889d (Masahiro Yamada 2018-03-16 16:37:11 +0900 1198) # Additional helpers built in scripts/
d8821622c889d (Masahiro Yamada 2018-03-16 16:37:11 +0900 1199) # Carefully list dependencies so we do not try to build scripts twice
d8821622c889d (Masahiro Yamada 2018-03-16 16:37:11 +0900 1200) # in parallel
d8821622c889d (Masahiro Yamada 2018-03-16 16:37:11 +0900 1201) PHONY += scripts
60df1aee2aecb (Masahiro Yamada 2018-11-29 12:13:24 +0900 1202) scripts: scripts_basic scripts_dtc
d8821622c889d (Masahiro Yamada 2018-03-16 16:37:11 +0900 1203) $(Q)$(MAKE) $(build)=$(@)
cb58455c48dc4 (Sam Ravnborg 2006-01-09 21:20:34 +0100 1204)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1205) # Things we need to do before we recursively start building the kernel
5bb78269000cf (Sam Ravnborg 2005-09-11 22:30:22 +0200 1206) # or the modules are listed in "prepare".
5bb78269000cf (Sam Ravnborg 2005-09-11 22:30:22 +0200 1207) # A multi level approach is used. prepareN is processed before prepareN-1.
5bb78269000cf (Sam Ravnborg 2005-09-11 22:30:22 +0200 1208) # archprepare is used in arch Makefiles and when processed asm symlink,
5bb78269000cf (Sam Ravnborg 2005-09-11 22:30:22 +0200 1209) # version.h and scripts_basic is processed / created.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1210)
a5139fb368d26 (Masahiro Yamada 2019-08-22 13:46:12 +0900 1211) PHONY += prepare archprepare
5bb78269000cf (Sam Ravnborg 2005-09-11 22:30:22 +0200 1212)
36de077b20d05 (Masahiro Yamada 2019-08-22 13:46:13 +0900 1213) archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
3044dd05289d6 (Masahiro Yamada 2020-05-01 15:01:41 +0900 1214) asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
1476fee5c53e2 (Masahiro Yamada 2021-04-25 16:07:12 +0900 1215) include/generated/autoconf.h remove-stale-files
5bb78269000cf (Sam Ravnborg 2005-09-11 22:30:22 +0200 1216)
65bba0423ecf8 (Masahiro Yamada 2018-11-29 11:58:50 +0900 1217) prepare0: archprepare
60df1aee2aecb (Masahiro Yamada 2018-11-29 12:13:24 +0900 1218) $(Q)$(MAKE) $(build)=scripts/mod
8d36a62364b6b (Sam Ravnborg 2005-09-10 21:05:36 +0200 1219) $(Q)$(MAKE) $(build)=.
86feeaa8120bb (Sam Ravnborg 2005-09-09 19:28:28 +0200 1220)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1221) # All the preparing..
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1222) prepare: prepare0
b9ab5ebb14ec3 (Josh Poimboeuf 2016-02-28 22:22:42 -0600 1223)
1476fee5c53e2 (Masahiro Yamada 2021-04-25 16:07:12 +0900 1224) PHONY += remove-stale-files
1476fee5c53e2 (Masahiro Yamada 2021-04-25 16:07:12 +0900 1225) remove-stale-files:
1476fee5c53e2 (Masahiro Yamada 2021-04-25 16:07:12 +0900 1226) $(Q)$(srctree)/scripts/remove-stale-files
1476fee5c53e2 (Masahiro Yamada 2021-04-25 16:07:12 +0900 1227)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 1228) # Support for using generic headers in asm-generic
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 1229) asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
7d0e5c2056c70 (Masahiro Yamada 2018-12-05 20:28:04 +0900 1230)
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 1231) PHONY += asm-generic uapi-asm-generic
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 1232) asm-generic: uapi-asm-generic
037fc3368be46 (Masahiro Yamada 2019-03-17 11:01:09 +0900 1233) $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
037fc3368be46 (Masahiro Yamada 2019-03-17 11:01:09 +0900 1234) generic=include/asm-generic
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 1235) uapi-asm-generic:
037fc3368be46 (Masahiro Yamada 2019-03-17 11:01:09 +0900 1236) $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
037fc3368be46 (Masahiro Yamada 2019-03-17 11:01:09 +0900 1237) generic=include/uapi/asm-generic
2c1f4f125159f (Masahiro Yamada 2017-10-04 12:56:06 +0900 1238)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1239) # Generate some files
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1240) # ---------------------------------------------------------------------------
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1241)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1242) # KERNELRELEASE can change from a few different places, meaning version.h
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1243) # needs to be updated, so this check is forced on all builds
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1244)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1245) uts_len := 64
63104eec234bd (Sam Ravnborg 2006-07-03 23:30:54 +0200 1246) define filechk_utsrelease.h
63104eec234bd (Sam Ravnborg 2006-07-03 23:30:54 +0200 1247) if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
63104eec234bd (Sam Ravnborg 2006-07-03 23:30:54 +0200 1248) echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
63104eec234bd (Sam Ravnborg 2006-07-03 23:30:54 +0200 1249) exit 1; \
63104eec234bd (Sam Ravnborg 2006-07-03 23:30:54 +0200 1250) fi; \
ad774086356da (Masahiro Yamada 2018-12-31 17:24:09 +0900 1251) echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"
63104eec234bd (Sam Ravnborg 2006-07-03 23:30:54 +0200 1252) endef
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1253)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1254) define filechk_version.h
9b82f13e7ef31 (Sasha Levin 2021-02-05 22:50:32 -0500 1255) if [ $(SUBLEVEL) -gt 255 ]; then \
9b82f13e7ef31 (Sasha Levin 2021-02-05 22:50:32 -0500 1256) echo \#define LINUX_VERSION_CODE $(shell \
207da4c82ade9 (Masahiro Yamada 2021-02-27 23:20:23 +0900 1257) expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + 255); \
9b82f13e7ef31 (Sasha Levin 2021-02-05 22:50:32 -0500 1258) else \
9b82f13e7ef31 (Sasha Levin 2021-02-05 22:50:32 -0500 1259) echo \#define LINUX_VERSION_CODE $(shell \
207da4c82ade9 (Masahiro Yamada 2021-02-27 23:20:23 +0900 1260) expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
9b82f13e7ef31 (Sasha Levin 2021-02-05 22:50:32 -0500 1261) fi; \
9b82f13e7ef31 (Sasha Levin 2021-02-05 22:50:32 -0500 1262) echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + \
88a686728b373 (Sasha Levin 2021-02-12 11:29:24 -0500 1263) ((c) > 255 ? 255 : (c)))'; \
88a686728b373 (Sasha Levin 2021-02-12 11:29:24 -0500 1264) echo \#define LINUX_VERSION_MAJOR $(VERSION); \
88a686728b373 (Sasha Levin 2021-02-12 11:29:24 -0500 1265) echo \#define LINUX_VERSION_PATCHLEVEL $(PATCHLEVEL); \
88a686728b373 (Sasha Levin 2021-02-12 11:29:24 -0500 1266) echo \#define LINUX_VERSION_SUBLEVEL $(SUBLEVEL)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1267) endef
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1268)
207da4c82ade9 (Masahiro Yamada 2021-02-27 23:20:23 +0900 1269) $(version_h): PATCHLEVEL := $(if $(PATCHLEVEL), $(PATCHLEVEL), 0)
207da4c82ade9 (Masahiro Yamada 2021-02-27 23:20:23 +0900 1270) $(version_h): SUBLEVEL := $(if $(SUBLEVEL), $(SUBLEVEL), 0)
43fee2b238959 (Masahiro Yamada 2018-07-25 14:16:11 +0900 1271) $(version_h): FORCE
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1272) $(call filechk,version.h)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1273)
273b281fa22c2 (Sam Ravnborg 2009-10-18 00:52:28 +0200 1274) include/generated/utsrelease.h: include/config/kernel.release FORCE
63104eec234bd (Sam Ravnborg 2006-07-03 23:30:54 +0200 1275) $(call filechk,utsrelease.h)
63104eec234bd (Sam Ravnborg 2006-07-03 23:30:54 +0200 1276)
179efcb47d5a5 (Vegard Nossum 2008-12-16 12:33:43 +0100 1277) PHONY += headerdep
179efcb47d5a5 (Vegard Nossum 2008-12-16 12:33:43 +0100 1278) headerdep:
9663d9890d804 (Peter Foley 2011-04-26 17:17:11 -0400 1279) $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
9663d9890d804 (Peter Foley 2011-04-26 17:17:11 -0400 1280) $(srctree)/scripts/headerdep.pl -I$(srctree)/include
179efcb47d5a5 (Vegard Nossum 2008-12-16 12:33:43 +0100 1281)
8d730cfb50cc7 (David Woodhouse 2006-06-18 11:58:39 +0100 1282) # ---------------------------------------------------------------------------
8d730cfb50cc7 (David Woodhouse 2006-06-18 11:58:39 +0100 1283) # Kernel headers
8d730cfb50cc7 (David Woodhouse 2006-06-18 11:58:39 +0100 1284)
e6883b187920e (Sam Ravnborg 2008-06-05 16:43:46 +0200 1285) #Default location for installed headers
e6883b187920e (Sam Ravnborg 2008-06-05 16:43:46 +0200 1286) export INSTALL_HDR_PATH = $(objtree)/usr
6d71627581e96 (David Woodhouse 2006-09-24 22:16:03 +0100 1287)
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 1288) quiet_cmd_headers_install = INSTALL $(INSTALL_HDR_PATH)/include
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 1289) cmd_headers_install = \
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 1290) mkdir -p $(INSTALL_HDR_PATH); \
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 1291) rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 1292) usr/include $(INSTALL_HDR_PATH)
e6883b187920e (Sam Ravnborg 2008-06-05 16:43:46 +0200 1293)
8d730cfb50cc7 (David Woodhouse 2006-06-18 11:58:39 +0100 1294) PHONY += headers_install
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 1295) headers_install: headers
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 1296) $(call cmd,headers_install)
6520fe5564acf (H. Peter Anvin 2012-05-08 21:22:24 +0300 1297)
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 1298) PHONY += archheaders archscripts
e6883b187920e (Sam Ravnborg 2008-06-05 16:43:46 +0200 1299)
a5bae54c106db (Masahiro Yamada 2019-06-04 19:14:04 +0900 1300) hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
6d71627581e96 (David Woodhouse 2006-09-24 22:16:03 +0100 1301)
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 1302) PHONY += headers
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 1303) headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
9d022c540606a (Masahiro Yamada 2017-10-04 12:56:04 +0900 1304) $(if $(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/Kbuild),, \
10b63956fce7f (David Howells 2012-10-02 18:01:57 +0100 1305) $(error Headers not exportable for the $(SRCARCH) architecture))
d5470d14431e9 (Masahiro Yamada 2019-06-04 19:14:03 +0900 1306) $(Q)$(MAKE) $(hdr-inst)=include/uapi
d5470d14431e9 (Masahiro Yamada 2019-06-04 19:14:03 +0900 1307) $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
1f85712e6e1f2 (Mike Frysinger 2007-02-14 00:33:02 -0800 1308)
7ecaf069da52e (Masahiro Yamada 2019-11-07 16:14:41 +0900 1309) # Deprecated. It is no-op now.
684753599afc7 (David Woodhouse 2006-06-18 12:02:10 +0100 1310) PHONY += headers_check
7ecaf069da52e (Masahiro Yamada 2019-11-07 16:14:41 +0900 1311) headers_check:
609bbb4de4f85 (Masahiro Yamada 2021-03-02 23:26:14 +0900 1312) @echo >&2 "=================== WARNING ==================="
609bbb4de4f85 (Masahiro Yamada 2021-03-02 23:26:14 +0900 1313) @echo >&2 "Since Linux 5.5, 'make headers_check' is no-op,"
609bbb4de4f85 (Masahiro Yamada 2021-03-02 23:26:14 +0900 1314) @echo >&2 "and will be removed after Linux 5.15 release."
609bbb4de4f85 (Masahiro Yamada 2021-03-02 23:26:14 +0900 1315) @echo >&2 "Please remove headers_check from your scripts."
609bbb4de4f85 (Masahiro Yamada 2021-03-02 23:26:14 +0900 1316) @echo >&2 "==============================================="
684753599afc7 (David Woodhouse 2006-06-18 12:02:10 +0100 1317)
e949f4c2d6a3d (Masahiro Yamada 2019-06-04 19:13:59 +0900 1318) ifdef CONFIG_HEADERS_INSTALL
59b2bd05f5f4d (Masahiro Yamada 2019-06-04 19:14:02 +0900 1319) prepare: headers
e949f4c2d6a3d (Masahiro Yamada 2019-06-04 19:13:59 +0900 1320) endif
684753599afc7 (David Woodhouse 2006-06-18 12:02:10 +0100 1321)
bdd7714b6f4cc (Masahiro Yamada 2019-06-04 19:14:01 +0900 1322) PHONY += scripts_unifdef
bdd7714b6f4cc (Masahiro Yamada 2019-06-04 19:14:01 +0900 1323) scripts_unifdef: scripts_basic
bdd7714b6f4cc (Masahiro Yamada 2019-06-04 19:14:01 +0900 1324) $(Q)$(MAKE) $(build)=scripts scripts/unifdef
bdd7714b6f4cc (Masahiro Yamada 2019-06-04 19:14:01 +0900 1325)
14ccc638b02f9 (Masahiro Yamada 2021-07-29 09:12:54 +0900 1326) # ---------------------------------------------------------------------------
14ccc638b02f9 (Masahiro Yamada 2021-07-29 09:12:54 +0900 1327) # Install
14ccc638b02f9 (Masahiro Yamada 2021-07-29 09:12:54 +0900 1328)
14ccc638b02f9 (Masahiro Yamada 2021-07-29 09:12:54 +0900 1329) # Many distributions have the custom install script, /sbin/installkernel.
14ccc638b02f9 (Masahiro Yamada 2021-07-29 09:12:54 +0900 1330) # If DKMS is installed, 'make install' will eventually recuses back
14ccc638b02f9 (Masahiro Yamada 2021-07-29 09:12:54 +0900 1331) # to the this Makefile to build and install external modules.
14ccc638b02f9 (Masahiro Yamada 2021-07-29 09:12:54 +0900 1332) # Cancel sub_make_done so that options such as M=, V=, etc. are parsed.
14ccc638b02f9 (Masahiro Yamada 2021-07-29 09:12:54 +0900 1333)
14ccc638b02f9 (Masahiro Yamada 2021-07-29 09:12:54 +0900 1334) install: sub_make_done :=
14ccc638b02f9 (Masahiro Yamada 2021-07-29 09:12:54 +0900 1335)
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1336) # ---------------------------------------------------------------------------
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1337) # Tools
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1338)
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1339) ifdef CONFIG_STACK_VALIDATION
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1340) prepare: tools/objtool
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1341) endif
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1342)
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1343) ifdef CONFIG_BPF
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1344) ifdef CONFIG_DEBUG_INFO_BTF
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1345) prepare: tools/bpf/resolve_btfids
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1346) endif
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1347) endif
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1348)
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1349) PHONY += resolve_btfids_clean
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1350)
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1351) resolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1352)
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1353) # tools/bpf/resolve_btfids directory might not exist
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1354) # in output directory, skip its clean in that case
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1355) resolve_btfids_clean:
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1356) ifneq ($(wildcard $(resolve_btfids_O)),)
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1357) $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1358) endif
0d989ac2c90b5 (Masahiro Yamada 2021-05-12 15:52:01 +0900 1359)
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1360) # Clear a bunch of variables before executing the submake
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1361) ifeq ($(quiet),silent_)
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1362) tools_silent=s
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1363) endif
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1364)
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1365) tools/: FORCE
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1366) $(Q)mkdir -p $(objtree)/tools
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1367) $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1368)
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1369) tools/%: FORCE
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1370) $(Q)mkdir -p $(objtree)/tools
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1371) $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
1bb0b18a06dce (Masahiro Yamada 2021-05-12 15:52:00 +0900 1372)
5a5da78b3a481 (Shuah Khan 2014-08-07 13:07:46 -0600 1373) # ---------------------------------------------------------------------------
5a5da78b3a481 (Shuah Khan 2014-08-07 13:07:46 -0600 1374) # Kernel selftest
5a5da78b3a481 (Shuah Khan 2014-08-07 13:07:46 -0600 1375)
5a5da78b3a481 (Shuah Khan 2014-08-07 13:07:46 -0600 1376) PHONY += kselftest
5a5da78b3a481 (Shuah Khan 2014-08-07 13:07:46 -0600 1377) kselftest:
2bc84526d174a (Shuah Khan 2017-09-06 16:44:35 -0600 1378) $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
5a5da78b3a481 (Shuah Khan 2014-08-07 13:07:46 -0600 1379)
17eac6c2db8b2 (Shuah Khan 2019-09-26 16:40:14 -0600 1380) kselftest-%: FORCE
17eac6c2db8b2 (Shuah Khan 2019-09-26 16:40:14 -0600 1381) $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
dcb825a9fd865 (Wang Long 2015-10-08 02:41:18 +0000 1382)
3d6dee7af7fe1 (Bamvor Jian Zhang 2016-01-08 15:27:34 +0800 1383) PHONY += kselftest-merge
3d6dee7af7fe1 (Bamvor Jian Zhang 2016-01-08 15:27:34 +0800 1384) kselftest-merge:
3d6dee7af7fe1 (Bamvor Jian Zhang 2016-01-08 15:27:34 +0800 1385) $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!))
6d3db46c8e331 (Dan Rue 2019-05-20 10:16:14 -0500 1386) $(Q)find $(srctree)/tools/testing/selftests -name config | \
6d3db46c8e331 (Dan Rue 2019-05-20 10:16:14 -0500 1387) xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
3e4c6948e78b4 (Masahiro Yamada 2019-08-21 16:03:48 +0900 1388) $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
3d6dee7af7fe1 (Bamvor Jian Zhang 2016-01-08 15:27:34 +0800 1389)
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1390) # ---------------------------------------------------------------------------
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1391) # Devicetree files
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1392)
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1393) ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1394) dtstree := arch/$(SRCARCH)/boot/dts
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1395) endif
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1396)
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1397) ifneq ($(dtstree),)
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1398)
a5139fb368d26 (Masahiro Yamada 2019-08-22 13:46:12 +0900 1399) %.dtb: include/config/kernel.release scripts_dtc
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1400) $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1401)
ce88c9c79455f (Viresh Kumar 2021-01-29 12:54:08 +0530 1402) %.dtbo: include/config/kernel.release scripts_dtc
ce88c9c79455f (Viresh Kumar 2021-01-29 12:54:08 +0530 1403) $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
ce88c9c79455f (Viresh Kumar 2021-01-29 12:54:08 +0530 1404)
c473a8d03ea8e (Masahiro Yamada 2020-02-23 04:04:34 +0900 1405) PHONY += dtbs dtbs_install dtbs_check
b5154bf63e557 (Masahiro Yamada 2020-03-04 12:20:36 +0900 1406) dtbs: include/config/kernel.release scripts_dtc
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1407) $(Q)$(MAKE) $(build)=$(dtstree)
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1408)
b5154bf63e557 (Masahiro Yamada 2020-03-04 12:20:36 +0900 1409) ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),)
e10c4321dc1e0 (Masahiro Yamada 2020-03-04 12:20:37 +0900 1410) export CHECK_DTBS=y
b5154bf63e557 (Masahiro Yamada 2020-03-04 12:20:36 +0900 1411) dtbs: dt_binding_check
b5154bf63e557 (Masahiro Yamada 2020-03-04 12:20:36 +0900 1412) endif
b5154bf63e557 (Masahiro Yamada 2020-03-04 12:20:36 +0900 1413)
b5154bf63e557 (Masahiro Yamada 2020-03-04 12:20:36 +0900 1414) dtbs_check: dtbs
4f0e3a57d6eb7 (Rob Herring 2018-09-06 13:26:07 -0500 1415)
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1416) dtbs_install:
2431f22a911a6 (Masahiro Yamada 2020-03-07 02:08:51 +0900 1417) $(Q)$(MAKE) $(dtbinst)=$(dtstree) dst=$(INSTALL_DTBS_PATH)
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1418)
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1419) ifdef CONFIG_OF_EARLY_FLATTREE
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1420) all: dtbs
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1421) endif
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1422)
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1423) endif
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1424)
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1425) PHONY += scripts_dtc
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1426) scripts_dtc: scripts_basic
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1427) $(Q)$(MAKE) $(build)=scripts/dtc
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1428)
e10c4321dc1e0 (Masahiro Yamada 2020-03-04 12:20:37 +0900 1429) ifneq ($(filter dt_binding_check, $(MAKECMDGOALS)),)
e10c4321dc1e0 (Masahiro Yamada 2020-03-04 12:20:37 +0900 1430) export CHECK_DT_BINDING=y
e10c4321dc1e0 (Masahiro Yamada 2020-03-04 12:20:37 +0900 1431) endif
e10c4321dc1e0 (Masahiro Yamada 2020-03-04 12:20:37 +0900 1432)
c473a8d03ea8e (Masahiro Yamada 2020-02-23 04:04:34 +0900 1433) PHONY += dt_binding_check
4f0e3a57d6eb7 (Rob Herring 2018-09-06 13:26:07 -0500 1434) dt_binding_check: scripts_dtc
4f0e3a57d6eb7 (Rob Herring 2018-09-06 13:26:07 -0500 1435) $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings
4f0e3a57d6eb7 (Rob Herring 2018-09-06 13:26:07 -0500 1436)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1437) # ---------------------------------------------------------------------------
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1438) # Modules
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1439)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1440) ifdef CONFIG_MODULES
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1441)
070b98bfda3d2 (Sam Ravnborg 2006-06-25 00:07:55 +0200 1442) # By default, build modules as well
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1443)
73d1393eb8507 (Michal Marek 2010-03-10 12:28:58 +0100 1444) all: modules
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1445)
4b50c8c4eaf06 (Masahiro Yamada 2020-05-31 17:47:06 +0900 1446) # When we're building modules with modversions, we need to consider
4b50c8c4eaf06 (Masahiro Yamada 2020-05-31 17:47:06 +0900 1447) # the built-in objects during the descend as well, in order to
4b50c8c4eaf06 (Masahiro Yamada 2020-05-31 17:47:06 +0900 1448) # make sure the checksums are up to date before we record them.
4b50c8c4eaf06 (Masahiro Yamada 2020-05-31 17:47:06 +0900 1449) ifdef CONFIG_MODVERSIONS
4b50c8c4eaf06 (Masahiro Yamada 2020-05-31 17:47:06 +0900 1450) KBUILD_BUILTIN := 1
4b50c8c4eaf06 (Masahiro Yamada 2020-05-31 17:47:06 +0900 1451) endif
4b50c8c4eaf06 (Masahiro Yamada 2020-05-31 17:47:06 +0900 1452)
3fbb43df983ac (Masahiro Yamada 2014-04-28 16:32:43 +0900 1453) # Build modules
551559e13af1c (Tejun Heo 2007-12-07 21:04:30 +0900 1454) #
3fbb43df983ac (Masahiro Yamada 2014-04-28 16:32:43 +0900 1455) # A module can be listed more than once in obj-m resulting in
3fbb43df983ac (Masahiro Yamada 2014-04-28 16:32:43 +0900 1456) # duplicate lines in modules.order files. Those are removed
3fbb43df983ac (Masahiro Yamada 2014-04-28 16:32:43 +0900 1457) # using awk while concatenating to the final file.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1458)
4f1933620f571 (Paul Smith 2006-03-05 17:14:10 -0500 1459) PHONY += modules
596b0474d3d9b (Masahiro Yamada 2020-09-08 13:27:08 +0900 1460) modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1461)
b2c8855491226 (Masahiro Yamada 2020-06-01 14:57:00 +0900 1462) cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@
b2c8855491226 (Masahiro Yamada 2020-06-01 14:57:00 +0900 1463)
b2c8855491226 (Masahiro Yamada 2020-06-01 14:57:00 +0900 1464) modules.order: $(subdir-modorder) FORCE
b2c8855491226 (Masahiro Yamada 2020-06-01 14:57:00 +0900 1465) $(call if_changed,modules_order)
b2c8855491226 (Masahiro Yamada 2020-06-01 14:57:00 +0900 1466)
b2c8855491226 (Masahiro Yamada 2020-06-01 14:57:00 +0900 1467) targets += modules.order
68980b4704d5d (Masahiro Yamada 2019-06-24 01:13:28 +0900 1468)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1469) # Target to prepare building external modules
4f1933620f571 (Paul Smith 2006-03-05 17:14:10 -0500 1470) PHONY += modules_prepare
059bc9fc375e0 (Masahiro Yamada 2018-11-29 12:56:30 +0900 1471) modules_prepare: prepare
596b0474d3d9b (Masahiro Yamada 2020-09-08 13:27:08 +0900 1472) $(Q)$(MAKE) $(build)=scripts scripts/module.lds
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1473)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1474) export modules_sign_only :=
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1475)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1476) ifeq ($(CONFIG_MODULE_SIG),y)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1477) PHONY += modules_sign
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1478) modules_sign: modules_install
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1479) @:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1480)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1481) # modules_sign is a subset of modules_install.
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1482) # 'make modules_install modules_sign' is equivalent to 'make modules_install'.
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1483) ifeq ($(filter modules_install,$(MAKECMDGOALS)),)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1484) modules_sign_only := y
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1485) endif
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1486) endif
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1487)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1488) modinst_pre :=
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1489) ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1490) modinst_pre := __modinst_pre
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1491) endif
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1492)
961ab4a3cd66c (Masahiro Yamada 2021-03-31 22:38:09 +0900 1493) modules_install: $(modinst_pre)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1494) PHONY += __modinst_pre
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1495) __modinst_pre:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1496) @rm -rf $(MODLIB)/kernel
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1497) @rm -f $(MODLIB)/source
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1498) @mkdir -p $(MODLIB)/kernel
8e9b466799230 (Masahiro Yamada 2017-08-20 15:04:11 +0900 1499) @ln -s $(abspath $(srctree)) $(MODLIB)/source
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1500) @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1501) rm -f $(MODLIB)/build ; \
7e1c04779efd5 (Michal Marek 2014-04-25 17:29:45 +0200 1502) ln -s $(CURDIR) $(MODLIB)/build ; \
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1503) fi
1bd9a468018dd (Masahiro Yamada 2019-07-17 15:17:50 +0900 1504) @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
2c6d9636ad920 (Masahiro Yamada 2020-06-20 00:09:55 +0900 1505) @cp -f modules.builtin $(MODLIB)/
2c6d9636ad920 (Masahiro Yamada 2020-06-20 00:09:55 +0900 1506) @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1507)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1508) endif # CONFIG_MODULES
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1509)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1510) ###
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1511) # Cleaning is done on three levels.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1512) # make clean Delete most generated files
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1513) # Leave enough to build external modules
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1514) # make mrproper Delete the current configuration, and all generated files
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1515) # make distclean Remove editor backup files, patch leftover files and the like
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1516)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1517) # Directories & files removed with 'make clean'
69bc8d386aebb (Masahiro Yamada 2021-03-26 03:54:09 +0900 1518) CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1519) modules.builtin modules.builtin.modinfo modules.nsdeps \
4c7858b9001c8 (Masahiro Yamada 2021-02-26 04:39:12 +0900 1520) compile_commands.json .thinlto-cache
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1521)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1522) # Directories & files removed with 'make mrproper'
0663c68c4d2d3 (Masahiro Yamada 2020-05-04 17:08:07 +0900 1523) MRPROPER_FILES += include/config include/generated \
46a63d4b0d79c (Masahiro Yamada 2019-08-21 16:02:02 +0900 1524) arch/$(SRCARCH)/include/generated .tmp_objdiff \
0663c68c4d2d3 (Masahiro Yamada 2020-05-04 17:08:07 +0900 1525) debian snap tar-install \
0663c68c4d2d3 (Masahiro Yamada 2020-05-04 17:08:07 +0900 1526) .config .config.old .version \
46457133ac9d5 (Masahiro Yamada 2019-07-15 23:01:49 +0900 1527) Module.symvers \
b31f2a495debc (Nayna Jain 2021-04-09 10:35:05 -0400 1528) certs/signing_key.pem certs/signing_key.x509 \
b31f2a495debc (Nayna Jain 2021-04-09 10:35:05 -0400 1529) certs/x509.genkey \
b31f2a495debc (Nayna Jain 2021-04-09 10:35:05 -0400 1530) vmlinux-gdb.py \
46a63d4b0d79c (Masahiro Yamada 2019-08-21 16:02:02 +0900 1531) *.spec
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1532)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1533) # clean - Delete most, but leave enough to build external modules
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1534) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1535) clean: rm-files := $(CLEAN_FILES)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1536)
76cd306d79792 (Masahiro Yamada 2019-08-11 00:53:05 +0900 1537) PHONY += archclean vmlinuxclean
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1538)
bd1ee804af8bd (Pawel Moll 2012-10-29 11:23:02 +0000 1539) vmlinuxclean:
bd1ee804af8bd (Pawel Moll 2012-10-29 11:23:02 +0000 1540) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
fbe6e37dab974 (Nicholas Piggin 2016-08-24 22:29:21 +1000 1541) $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
bd1ee804af8bd (Pawel Moll 2012-10-29 11:23:02 +0000 1542)
50d3a3f816895 (Jiri Olsa 2021-02-05 13:40:20 +0100 1543) clean: archclean vmlinuxclean resolve_btfids_clean
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1544)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1545) # mrproper - Delete all generated files, including .config
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1546) #
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1547) mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
cb43fb5775dff (Mauro Carvalho Chehab 2017-05-14 11:50:01 -0300 1548) mrproper-dirs := $(addprefix _mrproper_,scripts)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1549)
b421b8a6cb87f (Masahiro Yamada 2019-01-14 17:29:29 +0900 1550) PHONY += $(mrproper-dirs) mrproper
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1551) $(mrproper-dirs):
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1552) $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1553)
b421b8a6cb87f (Masahiro Yamada 2019-01-14 17:29:29 +0900 1554) mrproper: clean $(mrproper-dirs)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1555) $(call cmd,rmfiles)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1556)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1557) # distclean
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1558) #
4f1933620f571 (Paul Smith 2006-03-05 17:14:10 -0500 1559) PHONY += distclean
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1560)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1561) distclean: mrproper
19c8d912837e4 (Masahiro Yamada 2021-05-04 19:10:56 +0900 1562) @find . $(RCS_FIND_IGNORE) \
070b98bfda3d2 (Sam Ravnborg 2006-06-25 00:07:55 +0200 1563) \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
f78271dfb7735 (Masahiro Yamada 2017-01-22 23:02:32 +0900 1564) -o -name '*.bak' -o -name '#*#' -o -name '*%' \
7a02cec523a90 (Masahiro Yamada 2021-05-04 19:10:57 +0900 1565) -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \
7a02cec523a90 (Masahiro Yamada 2021-05-04 19:10:57 +0900 1566) -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1567) -type f -print | xargs rm -f
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1568)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1569)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1570) # Packaging of the kernel to various formats
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1571) # ---------------------------------------------------------------------------
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1572)
bafb67470b294 (Arnaldo Carvalho de Melo 2010-06-07 07:44:25 -0300 1573) %src-pkg: FORCE
000ec95fbe757 (Masahiro Yamada 2019-08-21 16:02:04 +0900 1574) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
031ecc6de7d17 (Zach Brown 2006-06-08 22:12:37 -0700 1575) %pkg: include/config/kernel.release FORCE
000ec95fbe757 (Masahiro Yamada 2019-08-21 16:02:04 +0900 1576) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1577)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1578) # Brief documentation of the typical targets used
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1579) # ---------------------------------------------------------------------------
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1580)
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1581) boards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig)
a1e7b7bb1ab5b (Konstantin Khlebnikov 2014-10-28 17:18:20 +0400 1582) boards := $(sort $(notdir $(boards)))
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1583) board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1584) board-dirs := $(sort $(notdir $(board-dirs:/=)))
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1585)
fe69b420d39d3 (Masahiro Yamada 2016-03-13 09:39:55 +0900 1586) PHONY += help
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1587) help:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1588) @echo 'Cleaning targets:'
5ea084ef9c7d0 (Samuel Tardieu 2006-12-12 19:09:40 +0100 1589) @echo ' clean - Remove most generated files but keep the config and'
5cc8d246d0ebb (Jesper Juhl 2006-09-24 14:01:08 +0200 1590) @echo ' enough build support to build external modules'
5ea084ef9c7d0 (Samuel Tardieu 2006-12-12 19:09:40 +0100 1591) @echo ' mrproper - Remove all generated files + config + various backup files'
5cc8d246d0ebb (Jesper Juhl 2006-09-24 14:01:08 +0200 1592) @echo ' distclean - mrproper + remove editor backup and patch files'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1593) @echo ''
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1594) @echo 'Configuration targets:'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1595) @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1596) @echo ''
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1597) @echo 'Other generic targets:'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1598) @echo ' all - Build all targets marked with [*]'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1599) @echo '* vmlinux - Build the bare kernel'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1600) @echo '* modules - Build all modules'
9cc5d74c847dd (Bodo Eggert 2005-11-23 20:11:34 +0100 1601) @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1602) @echo ' dir/ - Build all files in dir and below'
40ab87a4003c7 (Wang YanQing 2015-12-11 00:35:19 +0800 1603) @echo ' dir/file.[ois] - Build specified target only'
433db3e260bc8 (Vinícius Tinti 2017-04-24 13:04:58 -0700 1604) @echo ' dir/file.ll - Build the LLVM assembly file'
433db3e260bc8 (Vinícius Tinti 2017-04-24 13:04:58 -0700 1605) @echo ' (requires compiler support for LLVM assembly generation)'
6271897978072 (Joe Perches 2010-01-13 09:31:44 -0800 1606) @echo ' dir/file.lst - Build specified mixed source/assembly target only'
6271897978072 (Joe Perches 2010-01-13 09:31:44 -0800 1607) @echo ' (requires a recent binutils and recent build (System.map))'
155ad605b3c9c (Sam Ravnborg 2005-07-07 17:56:08 -0700 1608) @echo ' dir/file.ko - Build module including final link'
c4d5ee67ce265 (Robert P. J. Day 2009-04-24 12:35:23 -0400 1609) @echo ' modules_prepare - Set up for building external modules'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1610) @echo ' tags/TAGS - Generate tags file for editors'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1611) @echo ' cscope - Generate cscope index'
f4ed1009fcea8 (Jianbin Kang 2011-01-14 20:07:05 +0800 1612) @echo ' gtags - Generate GNU GLOBAL index'
3f1d9a6cec011 (Michal Marek 2014-07-11 15:57:24 +0200 1613) @echo ' kernelrelease - Output the release version string (use with make -s)'
3f1d9a6cec011 (Michal Marek 2014-07-11 15:57:24 +0200 1614) @echo ' kernelversion - Output the version stored in Makefile (use with make -s)'
3f1d9a6cec011 (Michal Marek 2014-07-11 15:57:24 +0200 1615) @echo ' image_name - Output the image name (use with make -s)'
2fb9b1bd9dd7f (Sam Ravnborg 2008-06-21 00:24:17 +0200 1616) @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
59df3230fc57f (Geert Uytterhoeven 2007-01-29 13:47:01 +0100 1617) echo ' (default: $(INSTALL_HDR_PATH))'; \
2fb9b1bd9dd7f (Sam Ravnborg 2008-06-21 00:24:17 +0200 1618) echo ''
31b8cc80776c1 (Randy Dunlap 2017-05-08 15:55:08 -0700 1619) @echo 'Static analysers:'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1620) @echo ' checkstack - Generate a list of stack hogs'
aa025e7d5cfbc (Sam Ravnborg 2007-11-14 21:34:55 +0100 1621) @echo ' versioncheck - Sanity check on version.h usage'
ec2d987f98ba7 (Randy Dunlap 2007-11-04 12:01:55 -0800 1622) @echo ' includecheck - Check for duplicate included header files'
295ac051861e0 (Adrian Bunk 2007-08-24 23:04:56 +0200 1623) @echo ' export_report - List the usages of all exported symbols'
74425eee71eb4 (Nicolas Palix 2010-06-06 17:15:01 +0200 1624) @echo ' headerdep - Detect inclusion cycles in headers'
7f855fc805cd9 (Masahiro Yamada 2017-11-14 18:47:20 +0900 1625) @echo ' coccicheck - Check with Coccinelle'
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1626) @echo ' clang-analyzer - Check with clang static analyzer'
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1627) @echo ' clang-tidy - Check with clang-tidy'
74425eee71eb4 (Nicolas Palix 2010-06-06 17:15:01 +0200 1628) @echo ''
eb8305aecb958 (Matthias Maennich 2019-09-06 11:32:32 +0100 1629) @echo 'Tools:'
eb8305aecb958 (Matthias Maennich 2019-09-06 11:32:32 +0100 1630) @echo ' nsdeps - Generate missing symbol namespace dependencies'
eb8305aecb958 (Matthias Maennich 2019-09-06 11:32:32 +0100 1631) @echo ''
31b8cc80776c1 (Randy Dunlap 2017-05-08 15:55:08 -0700 1632) @echo 'Kernel selftest:'
e51d8dacf2724 (Shuah Khan 2020-03-30 12:07:11 -0600 1633) @echo ' kselftest - Build and run kernel selftest'
e51d8dacf2724 (Shuah Khan 2020-03-30 12:07:11 -0600 1634) @echo ' Build, install, and boot kernel before'
e51d8dacf2724 (Shuah Khan 2020-03-30 12:07:11 -0600 1635) @echo ' running kselftest on it'
e51d8dacf2724 (Shuah Khan 2020-03-30 12:07:11 -0600 1636) @echo ' Run as root for full coverage'
e51d8dacf2724 (Shuah Khan 2020-03-30 12:07:11 -0600 1637) @echo ' kselftest-all - Build kernel selftest'
e51d8dacf2724 (Shuah Khan 2020-03-30 12:07:11 -0600 1638) @echo ' kselftest-install - Build and install kernel selftest'
e51d8dacf2724 (Shuah Khan 2020-03-30 12:07:11 -0600 1639) @echo ' kselftest-clean - Remove all generated kselftest files'
e51d8dacf2724 (Shuah Khan 2020-03-30 12:07:11 -0600 1640) @echo ' kselftest-merge - Merge all the config dependencies of'
e51d8dacf2724 (Shuah Khan 2020-03-30 12:07:11 -0600 1641) @echo ' kselftest to existing .config.'
5a5da78b3a481 (Shuah Khan 2014-08-07 13:07:46 -0600 1642) @echo ''
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1643) @$(if $(dtstree), \
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1644) echo 'Devicetree:'; \
7aa8dd91da63a (Stephen Boyd 2019-08-13 11:38:25 -0700 1645) echo '* dtbs - Build device tree blobs for enabled boards'; \
7aa8dd91da63a (Stephen Boyd 2019-08-13 11:38:25 -0700 1646) echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \
7aa8dd91da63a (Stephen Boyd 2019-08-13 11:38:25 -0700 1647) echo ' dt_binding_check - Validate device tree binding documents'; \
7aa8dd91da63a (Stephen Boyd 2019-08-13 11:38:25 -0700 1648) echo ' dtbs_check - Validate device tree source files';\
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1649) echo '')
37c8a5fafa3bb (Rob Herring 2018-01-10 15:19:37 -0600 1650)
31b8cc80776c1 (Randy Dunlap 2017-05-08 15:55:08 -0700 1651) @echo 'Userspace tools targets:'
31b8cc80776c1 (Randy Dunlap 2017-05-08 15:55:08 -0700 1652) @echo ' use "make tools/help"'
31b8cc80776c1 (Randy Dunlap 2017-05-08 15:55:08 -0700 1653) @echo ' or "cd tools; make help"'
31b8cc80776c1 (Randy Dunlap 2017-05-08 15:55:08 -0700 1654) @echo ''
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1655) @echo 'Kernel packaging:'
000ec95fbe757 (Masahiro Yamada 2019-08-21 16:02:04 +0900 1656) @$(MAKE) -f $(srctree)/scripts/Makefile.package help
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1657) @echo ''
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1658) @echo 'Documentation targets:'
cb43fb5775dff (Mauro Carvalho Chehab 2017-05-14 11:50:01 -0300 1659) @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1660) @echo ''
01dee1881d7cb (Andres Salomon 2008-04-25 22:34:58 -0400 1661) @echo 'Architecture specific targets ($(SRCARCH)):'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1662) @$(if $(archhelp),$(archhelp),\
01dee1881d7cb (Andres Salomon 2008-04-25 22:34:58 -0400 1663) echo ' No architecture specific help defined for $(SRCARCH)')
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1664) @echo ''
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1665) @$(if $(boards), \
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1666) $(foreach b, $(boards), \
4234448b7073d (Geert Uytterhoeven 2019-10-25 13:53:05 +0200 1667) printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1668) echo '')
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1669) @$(if $(board-dirs), \
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1670) $(foreach b, $(board-dirs), \
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1671) printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1672) printf " %-16s - Show all of the above\\n" help-boards; \
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1673) echo '')
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1674)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1675) @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
45d506bd65e2e (Sam Ravnborg 2006-08-08 21:35:14 +0200 1676) @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1677) @echo ' make O=dir [targets] Locate all output files in "dir", including .config'
a64c0440dda1f (Geert Uytterhoeven 2019-10-25 13:52:32 +0200 1678) @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK'
a64c0440dda1f (Geert Uytterhoeven 2019-10-25 13:52:32 +0200 1679) @echo ' (sparse by default)'
701842e3bdd7d (Dustin Kirkland 2006-05-23 15:57:23 -0500 1680) @echo ' make C=2 [targets] Force check of all c source with $$CHECK'
af07ce3e77d3b (Ingo Molnar 2011-06-16 13:26:23 +0200 1681) @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
e27128db62834 (Masahiro Yamada 2019-09-01 01:25:55 +0900 1682) @echo ' make W=n [targets] Enable extra build checks, n=1,2,3 where'
28bc20dccadc6 (Sam Ravnborg 2011-04-27 22:15:27 +0200 1683) @echo ' 1: warnings which may be relevant and do not occur too often'
28bc20dccadc6 (Sam Ravnborg 2011-04-27 22:15:27 +0200 1684) @echo ' 2: warnings which occur quite often but may still be relevant'
28bc20dccadc6 (Sam Ravnborg 2011-04-27 22:15:27 +0200 1685) @echo ' 3: more obscure warnings, can most likely be ignored'
a6de553da01c2 (Michal Marek 2011-04-29 14:45:31 +0200 1686) @echo ' Multiple levels can be combined with W=12 or W=123'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1687) @echo ''
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1688) @echo 'Execute "make" or "make all" to build all targets marked with [*] '
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1689) @echo 'For further info see the ./README file'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1690)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1691)
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1692) help-board-dirs := $(addprefix help-,$(board-dirs))
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1693)
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1694) help-boards: $(help-board-dirs)
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1695)
fbae4d585e5a6 (Michal Marek 2014-11-28 13:31:43 +0100 1696) boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1697)
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1698) $(help-board-dirs): help-%:
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1699) @echo 'Architecture specific targets ($(SRCARCH) $*):'
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1700) @$(if $(boards-per-dir), \
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1701) $(foreach b, $(boards-per-dir), \
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1702) printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1703) echo '')
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1704)
5dffbe811b786 (Segher Boessenkool 2008-04-06 22:16:07 +0200 1705)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1706) # Documentation targets
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1707) # ---------------------------------------------------------------------------
e8939222dced6 (Jani Nikula 2017-10-09 18:26:15 +0300 1708) DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
e8939222dced6 (Jani Nikula 2017-10-09 18:26:15 +0300 1709) linkcheckdocs dochelp refcheckdocs
22cba31bae9dc (Jani Nikula 2016-05-19 15:14:05 +0300 1710) PHONY += $(DOC_TARGETS)
bc7b752a7a1c8 (Masahiro Yamada 2019-08-22 02:33:21 +0900 1711) $(DOC_TARGETS):
cb43fb5775dff (Mauro Carvalho Chehab 2017-05-14 11:50:01 -0300 1712) $(Q)$(MAKE) $(build)=Documentation $@
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1713)
67274c0834383 (Masahiro Yamada 2019-02-19 18:33:02 +0900 1714) # Misc
67274c0834383 (Masahiro Yamada 2019-02-19 18:33:02 +0900 1715) # ---------------------------------------------------------------------------
67274c0834383 (Masahiro Yamada 2019-02-19 18:33:02 +0900 1716)
67274c0834383 (Masahiro Yamada 2019-02-19 18:33:02 +0900 1717) PHONY += scripts_gdb
7a739ce51dca7 (Masahiro Yamada 2019-06-04 19:13:57 +0900 1718) scripts_gdb: prepare0
1e5ff84ffe0b0 (Masahiro Yamada 2019-02-19 18:33:04 +0900 1719) $(Q)$(MAKE) $(build)=scripts/gdb
8d2e52003adf4 (Masahiro Yamada 2019-02-19 18:33:05 +0900 1720) $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
67274c0834383 (Masahiro Yamada 2019-02-19 18:33:02 +0900 1721)
67274c0834383 (Masahiro Yamada 2019-02-19 18:33:02 +0900 1722) ifdef CONFIG_GDB_SCRIPTS
67274c0834383 (Masahiro Yamada 2019-02-19 18:33:02 +0900 1723) all: scripts_gdb
67274c0834383 (Masahiro Yamada 2019-02-19 18:33:02 +0900 1724) endif
67274c0834383 (Masahiro Yamada 2019-02-19 18:33:02 +0900 1725)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1726) else # KBUILD_EXTMOD
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1727)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1728) ###
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1729) # External module support.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1730) # When building external modules the kernel used as basis is considered
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1731) # read-only, and no consistency checks are made and the make
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1732) # system is not used on the basis kernel. If updates are required
11122b860bc52 (Masahiro Yamada 2021-05-04 19:10:58 +0900 1733) # in the basis kernel ordinary make commands (without M=...) must be used.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1734)
6212804f2d78e (Masahiro Yamada 2020-09-09 05:55:57 +0900 1735) # We are always building only modules.
6212804f2d78e (Masahiro Yamada 2020-09-09 05:55:57 +0900 1736) KBUILD_BUILTIN :=
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1737) KBUILD_MODULES := 1
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1738)
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1739) build-dirs := $(KBUILD_EXTMOD)
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1740) $(MODORDER): descend
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1741) @:
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1742)
7f69180b8e905 (Masahiro Yamada 2021-03-31 22:38:06 +0900 1743) compile_commands.json: $(extmod_prefix)compile_commands.json
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1744) PHONY += compile_commands.json
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1745)
76cd306d79792 (Masahiro Yamada 2019-08-11 00:53:05 +0900 1746) clean-dirs := $(KBUILD_EXTMOD)
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1747) clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \
dc5723b02e523 (Sami Tolvanen 2020-12-11 10:46:19 -0800 1748) $(KBUILD_EXTMOD)/compile_commands.json $(KBUILD_EXTMOD)/.thinlto-cache
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1749)
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 1750) PHONY += prepare
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 1751) # now expand this into a simple variable to reduce the cost of shell evaluations
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 1752) prepare: CC_VERSION_TEXT := $(CC_VERSION_TEXT)
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 1753) prepare:
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 1754) @if [ "$(CC_VERSION_TEXT)" != $(CONFIG_CC_VERSION_TEXT) ]; then \
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 1755) echo >&2 "warning: the compiler differs from the one used to build the kernel"; \
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 1756) echo >&2 " The kernel was built by: "$(CONFIG_CC_VERSION_TEXT); \
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 1757) echo >&2 " You are using: $(CC_VERSION_TEXT)"; \
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 1758) fi
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 1759)
fe69b420d39d3 (Masahiro Yamada 2016-03-13 09:39:55 +0900 1760) PHONY += help
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1761) help:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1762) @echo ' Building external modules.'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1763) @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1764) @echo ''
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1765) @echo ' modules - default target, build the module(s)'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1766) @echo ' modules_install - install the module'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1767) @echo ' clean - remove generated files in module directory only'
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1768) @echo ''
06300b21f4c79 (Sam Ravnborg 2006-01-25 07:13:18 +0100 1769)
596b0474d3d9b (Masahiro Yamada 2020-09-08 13:27:08 +0900 1770) # no-op for external module builds
6072b2c49d23e (Masahiro Yamada 2021-08-01 11:53:46 +0900 1771) PHONY += modules_prepare
596b0474d3d9b (Masahiro Yamada 2020-09-08 13:27:08 +0900 1772)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1773) endif # KBUILD_EXTMOD
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1774)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1775) # ---------------------------------------------------------------------------
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1776) # Modules
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1777)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1778) PHONY += modules modules_install
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1779)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1780) ifdef CONFIG_MODULES
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1781)
1a998be620a10 (Masahiro Yamada 2021-03-31 22:38:05 +0900 1782) modules: modules_check
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1783) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1784)
1a998be620a10 (Masahiro Yamada 2021-03-31 22:38:05 +0900 1785) PHONY += modules_check
1a998be620a10 (Masahiro Yamada 2021-03-31 22:38:05 +0900 1786) modules_check: $(MODORDER)
1a998be620a10 (Masahiro Yamada 2021-03-31 22:38:05 +0900 1787) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
1a998be620a10 (Masahiro Yamada 2021-03-31 22:38:05 +0900 1788)
3ac42b2112532 (Masahiro Yamada 2021-03-31 22:38:04 +0900 1789) quiet_cmd_depmod = DEPMOD $(MODLIB)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1790) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1791) $(KERNELRELEASE)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1792)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1793) modules_install:
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1794) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1795) $(call cmd,depmod)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1796)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1797) else # CONFIG_MODULES
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1798)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1799) # Modules not configured
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1800) # ---------------------------------------------------------------------------
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1801)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1802) modules modules_install:
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1803) @echo >&2 '***'
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1804) @echo >&2 '*** The present kernel configuration has modules disabled.'
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1805) @echo >&2 '*** To use the module feature, please run "make menuconfig" etc.'
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1806) @echo >&2 '*** to enable CONFIG_MODULES.'
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1807) @echo >&2 '***'
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1808) @exit 1
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1809)
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1810) endif # CONFIG_MODULES
3e3005df73b53 (Masahiro Yamada 2021-03-31 22:38:03 +0900 1811)
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1812) # Single targets
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1813) # ---------------------------------------------------------------------------
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1814) # To build individual files in subdirectories, you can do like this:
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1815) #
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1816) # make foo/bar/baz.s
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1817) #
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1818) # The supported suffixes for single-target are listed in 'single-targets'
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1819) #
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1820) # To build only under specific subdirectories, you can do like this:
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1821) #
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1822) # make foo/bar/baz/
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1823)
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1824) ifdef single-build
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1825)
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1826) # .ko is special because modpost is needed
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1827) single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1828) single-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS)))
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1829)
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1830) $(single-ko): single_modpost
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1831) @:
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1832) $(single-no-ko): descend
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1833) @:
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1834)
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1835) ifeq ($(KBUILD_EXTMOD),)
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1836) # For the single build of in-tree modules, use a temporary file to avoid
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1837) # the situation of modules_install installing an invalid modules.order.
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1838) MODORDER := .modules.tmp
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1839) endif
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1840)
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1841) PHONY += single_modpost
596b0474d3d9b (Masahiro Yamada 2020-09-08 13:27:08 +0900 1842) single_modpost: $(single-no-ko) modules_prepare
7f69180b8e905 (Masahiro Yamada 2021-03-31 22:38:06 +0900 1843) $(Q){ $(foreach m, $(single-ko), echo $(extmod_prefix)$m;) } > $(MODORDER)
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1844) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1845)
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1846) KBUILD_MODULES := 1
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1847)
7f69180b8e905 (Masahiro Yamada 2021-03-31 22:38:06 +0900 1848) export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod_prefix), $(single-no-ko))
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1849)
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1850) # trim unrelated directories
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1851) build-dirs := $(foreach d, $(build-dirs), \
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1852) $(if $(filter $(d)/%, $(KBUILD_SINGLE_TARGETS)), $(d)))
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1853)
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1854) endif
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1855)
b480fec988b05 (Masahiro Yamada 2020-05-22 10:59:59 +0900 1856) ifndef CONFIG_MODULES
b480fec988b05 (Masahiro Yamada 2020-05-22 10:59:59 +0900 1857) KBUILD_MODULES :=
b480fec988b05 (Masahiro Yamada 2020-05-22 10:59:59 +0900 1858) endif
b480fec988b05 (Masahiro Yamada 2020-05-22 10:59:59 +0900 1859)
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1860) # Handle descending into subdirectories listed in $(build-dirs)
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1861) # Preset locale variables to speed up the build process. Limit locale
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1862) # tweaks to this spot to avoid wrong language settings when running
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1863) # make menuconfig etc.
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1864) # Error messages still appears in the original language
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1865) PHONY += descend $(build-dirs)
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1866) descend: $(build-dirs)
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1867) $(build-dirs): prepare
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1868) $(Q)$(MAKE) $(build)=$@ \
20b1be5952829 (Masahiro Yamada 2020-07-08 01:35:08 +0900 1869) single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \
b1fbfcb4a2094 (Masahiro Yamada 2019-11-18 13:52:47 +0900 1870) need-builtin=1 need-modorder=1
c99f3918cf0a6 (Masahiro Yamada 2019-08-11 00:53:04 +0900 1871)
76cd306d79792 (Masahiro Yamada 2019-08-11 00:53:05 +0900 1872) clean-dirs := $(addprefix _clean_, $(clean-dirs))
76cd306d79792 (Masahiro Yamada 2019-08-11 00:53:05 +0900 1873) PHONY += $(clean-dirs) clean
76cd306d79792 (Masahiro Yamada 2019-08-11 00:53:05 +0900 1874) $(clean-dirs):
76cd306d79792 (Masahiro Yamada 2019-08-11 00:53:05 +0900 1875) $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
76cd306d79792 (Masahiro Yamada 2019-08-11 00:53:05 +0900 1876)
88d7be031f9f9 (Michal Marek 2010-09-06 12:00:08 +0200 1877) clean: $(clean-dirs)
88d7be031f9f9 (Michal Marek 2010-09-06 12:00:08 +0200 1878) $(call cmd,rmfiles)
43f67c98161c6 (Kevin Cernekee 2011-05-10 15:47:16 -0700 1879) @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
ef46d9b3dc01d (Masahiro Yamada 2017-11-17 01:49:13 +0900 1880) \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
4f0e3a57d6eb7 (Rob Herring 2018-09-06 13:26:07 -0500 1881) -o -name '*.ko.*' \
ce88c9c79455f (Viresh Kumar 2021-01-29 12:54:08 +0530 1882) -o -name '*.dtb' -o -name '*.dtbo' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
ef46d9b3dc01d (Masahiro Yamada 2017-11-17 01:49:13 +0900 1883) -o -name '*.dwo' -o -name '*.lst' \
bbc55bded4aaf (Masahiro Yamada 2019-10-29 21:38:07 +0900 1884) -o -name '*.su' -o -name '*.mod' \
88d7be031f9f9 (Michal Marek 2010-09-06 12:00:08 +0200 1885) -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
9a8dfb394c046 (Masahiro Yamada 2018-03-23 22:04:31 +0900 1886) -o -name '*.lex.c' -o -name '*.tab.[ch]' \
4fa8bc949de11 (Masahiro Yamada 2018-03-23 22:04:37 +0900 1887) -o -name '*.asn1.[ch]' \
88d7be031f9f9 (Michal Marek 2010-09-06 12:00:08 +0200 1888) -o -name '*.symtypes' -o -name 'modules.order' \
8b41fc4454e36 (Masahiro Yamada 2019-12-19 17:33:29 +0900 1889) -o -name '.tmp_*.o.*' \
6b90bd4ba40b3 (Emese Revfy 2016-05-24 00:09:38 +0200 1890) -o -name '*.c.[012]*.*' \
433db3e260bc8 (Vinícius Tinti 2017-04-24 13:04:58 -0700 1891) -o -name '*.ll' \
38e8918490038 (Sami Tolvanen 2020-12-11 10:46:20 -0800 1892) -o -name '*.gcno' \
38e8918490038 (Sami Tolvanen 2020-12-11 10:46:20 -0800 1893) -o -name '*.*.symversions' \) -type f -print | xargs rm -f
88d7be031f9f9 (Michal Marek 2010-09-06 12:00:08 +0200 1894)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1895) # Generate tags for editors
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1896) # ---------------------------------------------------------------------------
a680eedc6c621 (Sam Ravnborg 2008-12-03 22:24:13 +0100 1897) quiet_cmd_tags = GEN $@
858805b336be1 (Masahiro Yamada 2019-08-25 22:28:37 +0900 1898) cmd_tags = $(BASH) $(srctree)/scripts/tags.sh $@
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1899)
f4ed1009fcea8 (Jianbin Kang 2011-01-14 20:07:05 +0800 1900) tags TAGS cscope gtags: FORCE
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1901) $(call cmd,tags)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1902)
eb8305aecb958 (Matthias Maennich 2019-09-06 11:32:32 +0100 1903) # Script to generate missing namespace dependencies
eb8305aecb958 (Matthias Maennich 2019-09-06 11:32:32 +0100 1904) # ---------------------------------------------------------------------------
eb8305aecb958 (Matthias Maennich 2019-09-06 11:32:32 +0100 1905)
eb8305aecb958 (Matthias Maennich 2019-09-06 11:32:32 +0100 1906) PHONY += nsdeps
bff9c62b5d20d (Masahiro Yamada 2019-10-29 21:38:06 +0900 1907) nsdeps: export KBUILD_NSDEPS=1
eb8305aecb958 (Matthias Maennich 2019-09-06 11:32:32 +0100 1908) nsdeps: modules
bff9c62b5d20d (Masahiro Yamada 2019-10-29 21:38:06 +0900 1909) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/nsdeps
eb8305aecb958 (Matthias Maennich 2019-09-06 11:32:32 +0100 1910)
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1911) # Clang Tooling
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1912) # ---------------------------------------------------------------------------
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1913)
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1914) quiet_cmd_gen_compile_commands = GEN $@
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1915) cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1916)
7f69180b8e905 (Masahiro Yamada 2021-03-31 22:38:06 +0900 1917) $(extmod_prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1918) $(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1919) $(if $(CONFIG_MODULES), $(MODORDER)) FORCE
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1920) $(call if_changed,gen_compile_commands)
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1921)
7f69180b8e905 (Masahiro Yamada 2021-03-31 22:38:06 +0900 1922) targets += $(extmod_prefix)compile_commands.json
3d32285fa9959 (Masahiro Yamada 2020-08-22 23:56:16 +0900 1923)
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1924) PHONY += clang-tidy clang-analyzer
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1925)
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1926) ifdef CONFIG_CC_IS_CLANG
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1927) quiet_cmd_clang_tools = CHECK $<
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1928) cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1929)
7f69180b8e905 (Masahiro Yamada 2021-03-31 22:38:06 +0900 1930) clang-tidy clang-analyzer: $(extmod_prefix)compile_commands.json
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1931) $(call cmd,clang_tools)
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1932) else
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1933) clang-tidy clang-analyzer:
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1934) @echo "$@ requires CC=clang" >&2
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1935) @false
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1936) endif
6ad7cbc015272 (Nathan Huckleberry 2020-08-22 23:56:18 +0900 1937)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1938) # Scripts to check various things for consistency
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1939) # ---------------------------------------------------------------------------
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1940)
7dfbea4c468cf (Jacob Keller 2020-10-09 17:18:44 -0700 1941) PHONY += includecheck versioncheck coccicheck export_report
279f3dd3569d0 (Peter Foley 2011-04-26 17:15:01 -0400 1942)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1943) includecheck:
436f876ccb4ea (Peter Foley 2011-04-26 17:18:29 -0400 1944) find $(srctree)/* $(RCS_FIND_IGNORE) \
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1945) -name '*.[hcS]' -type f -print | sort \
800074345544a (Geert Uytterhoeven 2007-11-05 11:51:44 +0100 1946) | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1947)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1948) versioncheck:
2ee2d29289951 (Peter Foley 2011-04-26 17:19:28 -0400 1949) find $(srctree)/* $(RCS_FIND_IGNORE) \
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1950) -name '*.[hcS]' -type f -print | sort \
800074345544a (Geert Uytterhoeven 2007-11-05 11:51:44 +0100 1951) | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1952)
74425eee71eb4 (Nicolas Palix 2010-06-06 17:15:01 +0200 1953) coccicheck:
858805b336be1 (Masahiro Yamada 2019-08-25 22:28:37 +0900 1954) $(Q)$(BASH) $(srctree)/scripts/$@
74425eee71eb4 (Nicolas Palix 2010-06-06 17:15:01 +0200 1955)
295ac051861e0 (Adrian Bunk 2007-08-24 23:04:56 +0200 1956) export_report:
295ac051861e0 (Adrian Bunk 2007-08-24 23:04:56 +0200 1957) $(PERL) $(srctree)/scripts/export_report.pl
295ac051861e0 (Adrian Bunk 2007-08-24 23:04:56 +0200 1958)
c398ff00f55d5 (Mike Marciniszyn 2013-06-24 08:48:37 -0400 1959) PHONY += checkstack kernelrelease kernelversion image_name
e3ccf6e3699c8 (Jeff Dike 2006-09-27 01:50:37 -0700 1960)
011e3a9ad4891 (Jeff Dike 2006-12-13 00:34:12 -0800 1961) # UML needs a little special treatment here. It wants to use the host
011e3a9ad4891 (Jeff Dike 2006-12-13 00:34:12 -0800 1962) # toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone
011e3a9ad4891 (Jeff Dike 2006-12-13 00:34:12 -0800 1963) # else wants $(ARCH), including people doing cross-builds, which means
011e3a9ad4891 (Jeff Dike 2006-12-13 00:34:12 -0800 1964) # that $(SUBARCH) doesn't work here.
011e3a9ad4891 (Jeff Dike 2006-12-13 00:34:12 -0800 1965) ifeq ($(ARCH), um)
011e3a9ad4891 (Jeff Dike 2006-12-13 00:34:12 -0800 1966) CHECKSTACK_ARCH := $(SUBARCH)
011e3a9ad4891 (Jeff Dike 2006-12-13 00:34:12 -0800 1967) else
011e3a9ad4891 (Jeff Dike 2006-12-13 00:34:12 -0800 1968) CHECKSTACK_ARCH := $(ARCH)
011e3a9ad4891 (Jeff Dike 2006-12-13 00:34:12 -0800 1969) endif
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1970) checkstack:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1971) $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
75dd47472b92c (Masahiro Yamada 2019-07-06 12:07:11 +0900 1972) $(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1973)
7b8ea53d7f186 (Amerigo Wang 2010-08-20 05:36:06 -0400 1974) kernelrelease:
7b8ea53d7f186 (Amerigo Wang 2010-08-20 05:36:06 -0400 1975) @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
01ab17887f4cd (Amerigo Wang 2010-06-28 10:45:21 +0800 1976)
cb58455c48dc4 (Sam Ravnborg 2006-01-09 21:20:34 +0100 1977) kernelversion:
2244cbd8a9185 (Sam Ravnborg 2006-01-16 12:12:12 +0100 1978) @echo $(KERNELVERSION)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1979)
c398ff00f55d5 (Mike Marciniszyn 2013-06-24 08:48:37 -0400 1980) image_name:
c398ff00f55d5 (Mike Marciniszyn 2013-06-24 08:48:37 -0400 1981) @echo $(KBUILD_IMAGE)
c398ff00f55d5 (Mike Marciniszyn 2013-06-24 08:48:37 -0400 1982)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1983) quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)))
0663c68c4d2d3 (Masahiro Yamada 2020-05-04 17:08:07 +0900 1984) cmd_rmfiles = rm -rf $(rm-files)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1985)
392885ee82d35 (Masahiro Yamada 2018-11-30 10:05:22 +0900 1986) # read saved command lines for existing targets
392885ee82d35 (Masahiro Yamada 2018-11-30 10:05:22 +0900 1987) existing-targets := $(wildcard $(sort $(targets)))
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1988)
b999923c29d69 (Masahiro Yamada 2019-02-22 16:40:08 +0900 1989) -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1990)
46b7c49254f89 (SZ Lin (林上智) 2020-03-01 00:09:58 +0800 1991) endif # config-build
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 1992) endif # mixed-build
2042b5486bd31 (Masahiro Yamada 2019-08-11 00:53:03 +0900 1993) endif # need-sub-make
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1994)
4f1933620f571 (Paul Smith 2006-03-05 17:14:10 -0500 1995) PHONY += FORCE
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 1996) FORCE:
4f1933620f571 (Paul Smith 2006-03-05 17:14:10 -0500 1997)
bd412d81b7ea4 (Ulf Magnusson 2018-07-05 12:33:07 +0900 1998) # Declare the contents of the PHONY variable as phony. We keep that
fe8d0a41081d6 (Kirill Smelkov 2009-04-09 15:34:34 +0400 1999) # information in a variable so we can use it in if_changed and friends.
4f1933620f571 (Paul Smith 2006-03-05 17:14:10 -0500 2000) .PHONY: $(PHONY)