Makefile revision 805b2e1d
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
2bfeffd15SLinus TorvaldsVERSION = 5
3fe07bfdaSLinus TorvaldsPATCHLEVEL = 12
455922c9dSLinus TorvaldsSUBLEVEL = 0
51e28eed1SLinus TorvaldsEXTRAVERSION = -rc3
6fe07bfdaSLinus TorvaldsNAME = Frozen Wasteland
71da177e4SLinus Torvalds
81da177e4SLinus Torvalds# *DOCUMENTATION*
91da177e4SLinus Torvalds# To see a list of typical targets execute "make help"
101da177e4SLinus Torvalds# More info can be located in ./README
111da177e4SLinus Torvalds# Comments in this file are targeted only to the developer, do not
121da177e4SLinus Torvalds# expect to learn how to build the kernel reading this file.
131da177e4SLinus Torvalds
14121c2a13SMasahiro Yamada$(if $(filter __%, $(MAKECMDGOALS)), \
15121c2a13SMasahiro Yamada	$(error targets prefixed with '__' are only for internal use))
16121c2a13SMasahiro Yamada
17ba634eceSMasahiro Yamada# That's our default target when none is given on the command line
18121c2a13SMasahiro YamadaPHONY := __all
19121c2a13SMasahiro Yamada__all:
20ba634eceSMasahiro Yamada
211da177e4SLinus Torvalds# We are using a recursive build, so we need to do a little thinking
221da177e4SLinus Torvalds# to get the ordering right.
231da177e4SLinus Torvalds#
241da177e4SLinus Torvalds# Most importantly: sub-Makefiles should only ever modify files in
251da177e4SLinus Torvalds# their own directory. If in some directory we have a dependency on
261da177e4SLinus Torvalds# a file in another dir (which doesn't happen often, but it's often
27f49821eeSNicholas Piggin# unavoidable when linking the built-in.a targets which finally
281da177e4SLinus Torvalds# turn into vmlinux), we will call a sub make in that other dir, and
291da177e4SLinus Torvalds# after that we are sure that everything which is in that other dir
301da177e4SLinus Torvalds# is now up to date.
311da177e4SLinus Torvalds#
321da177e4SLinus Torvalds# The only cases where we need to modify files which have global
331da177e4SLinus Torvalds# effects are thus separated out and done before the recursive
341da177e4SLinus Torvalds# descending is started. They are now explicitly listed as the
351da177e4SLinus Torvalds# prepare rule.
361da177e4SLinus Torvalds
37221cc2d2SMasahiro Yamadaifneq ($(sub_make_done),1)
383812b8c5SMasahiro Yamada
393812b8c5SMasahiro Yamada# Do not use make's built-in rules and variables
403812b8c5SMasahiro Yamada# (this increases performance and avoids hard-to-debug behaviour)
413812b8c5SMasahiro YamadaMAKEFLAGS += -rR
423812b8c5SMasahiro Yamada
433812b8c5SMasahiro Yamada# Avoid funny character set dependencies
443812b8c5SMasahiro Yamadaunexport LC_ALL
453812b8c5SMasahiro YamadaLC_COLLATE=C
463812b8c5SMasahiro YamadaLC_NUMERIC=C
473812b8c5SMasahiro Yamadaexport LC_COLLATE LC_NUMERIC
483812b8c5SMasahiro Yamada
493812b8c5SMasahiro Yamada# Avoid interference with shell env settings
503812b8c5SMasahiro Yamadaunexport GREP_OPTIONS
513812b8c5SMasahiro Yamada
52066b7ed9SMichal Marek# Beautify output
53066b7ed9SMichal Marek# ---------------------------------------------------------------------------
54066b7ed9SMichal Marek#
55066b7ed9SMichal Marek# Normally, we echo the whole command before executing it. By making
56066b7ed9SMichal Marek# that echo $($(quiet)$(cmd)), we now have the possibility to set
57066b7ed9SMichal Marek# $(quiet) to choose other forms of output instead, e.g.
58066b7ed9SMichal Marek#
59066b7ed9SMichal Marek#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
60066b7ed9SMichal Marek#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
61066b7ed9SMichal Marek#
62066b7ed9SMichal Marek# If $(quiet) is empty, the whole command will be printed.
63066b7ed9SMichal Marek# If it is set to "quiet_", only the short version will be printed.
64066b7ed9SMichal Marek# If it is set to "silent_", nothing will be printed at all, since
65066b7ed9SMichal Marek# the variable $(silent_cmd_cc_o_c) doesn't exist.
66066b7ed9SMichal Marek#
67066b7ed9SMichal Marek# A simple variant is to prefix commands with $(Q) - that's useful
68066b7ed9SMichal Marek# for commands that shall be hidden in non-verbose mode.
69066b7ed9SMichal Marek#
70066b7ed9SMichal Marek#	$(Q)ln $@ :<
71066b7ed9SMichal Marek#
72066b7ed9SMichal Marek# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
73066b7ed9SMichal Marek# If KBUILD_VERBOSE equals 1 then the above command is displayed.
74505b12b3SRandy Dunlap# If KBUILD_VERBOSE equals 2 then give the reason why each target is rebuilt.
75066b7ed9SMichal Marek#
761da177e4SLinus Torvalds# To put more focus on warnings, be less verbose as default
771da177e4SLinus Torvalds# Use 'make V=1' to see the full commands
781da177e4SLinus Torvalds
79b8b0618cSCheng Renquanifeq ("$(origin V)", "command line")
80b8b0618cSCheng Renquan  KBUILD_VERBOSE = $(V)
811da177e4SLinus Torvaldsendif
821da177e4SLinus Torvaldsifndef KBUILD_VERBOSE
831da177e4SLinus Torvalds  KBUILD_VERBOSE = 0
841da177e4SLinus Torvaldsendif
851da177e4SLinus Torvalds
86066b7ed9SMichal Marekifeq ($(KBUILD_VERBOSE),1)
87066b7ed9SMichal Marek  quiet =
88066b7ed9SMichal Marek  Q =
89066b7ed9SMichal Marekelse
90066b7ed9SMichal Marek  quiet=quiet_
91066b7ed9SMichal Marek  Q = @
92066b7ed9SMichal Marekendif
93066b7ed9SMichal Marek
94066b7ed9SMichal Marek# If the user is running make -s (silent mode), suppress echoing of
95066b7ed9SMichal Marek# commands
96066b7ed9SMichal Marek
976f0fa58eSMasahiro Yamadaifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
98066b7ed9SMichal Marek  quiet=silent_
9922149454SMasahiro Yamada  KBUILD_VERBOSE = 0
100066b7ed9SMichal Marekendif
101066b7ed9SMichal Marek
102066b7ed9SMichal Marekexport quiet Q KBUILD_VERBOSE
103066b7ed9SMichal Marek
104bcf637f5SMasahiro Yamada# Call a source code checker (by default, "sparse") as part of the
105bcf637f5SMasahiro Yamada# C compilation.
106bcf637f5SMasahiro Yamada#
107bcf637f5SMasahiro Yamada# Use 'make C=1' to enable checking of only re-compiled files.
108bcf637f5SMasahiro Yamada# Use 'make C=2' to enable checking of *all* source files, regardless
109bcf637f5SMasahiro Yamada# of whether they are re-compiled or not.
110bcf637f5SMasahiro Yamada#
111bcf637f5SMasahiro Yamada# See the file "Documentation/dev-tools/sparse.rst" for more details,
112bcf637f5SMasahiro Yamada# including where to get the "sparse" utility.
113bcf637f5SMasahiro Yamada
114bcf637f5SMasahiro Yamadaifeq ("$(origin C)", "command line")
115bcf637f5SMasahiro Yamada  KBUILD_CHECKSRC = $(C)
116bcf637f5SMasahiro Yamadaendif
117bcf637f5SMasahiro Yamadaifndef KBUILD_CHECKSRC
118bcf637f5SMasahiro Yamada  KBUILD_CHECKSRC = 0
119bcf637f5SMasahiro Yamadaendif
120bcf637f5SMasahiro Yamada
121bcf637f5SMasahiro Yamadaexport KBUILD_CHECKSRC
122bcf637f5SMasahiro Yamada
123bcf637f5SMasahiro Yamada# Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
124bcf637f5SMasahiro Yamada# directory of external module to build. Setting M= takes precedence.
125bcf637f5SMasahiro Yamadaifeq ("$(origin M)", "command line")
126bcf637f5SMasahiro Yamada  KBUILD_EXTMOD := $(M)
127bcf637f5SMasahiro Yamadaendif
128bcf637f5SMasahiro Yamada
129bcf637f5SMasahiro Yamada$(if $(word 2, $(KBUILD_EXTMOD)), \
130bcf637f5SMasahiro Yamada	$(error building multiple external modules is not supported))
131bcf637f5SMasahiro Yamada
132bcf637f5SMasahiro Yamadaexport KBUILD_EXTMOD
133bcf637f5SMasahiro Yamada
13425b146c5SMasahiro Yamada# Kbuild will save output files in the current working directory.
13525b146c5SMasahiro Yamada# This does not need to match to the root of the kernel source tree.
13625b146c5SMasahiro Yamada#
13725b146c5SMasahiro Yamada# For example, you can do this:
13825b146c5SMasahiro Yamada#
13925b146c5SMasahiro Yamada#  cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
14025b146c5SMasahiro Yamada#
14125b146c5SMasahiro Yamada# If you want to save output files in a different location, there are
14225b146c5SMasahiro Yamada# two syntaxes to specify it.
14325b146c5SMasahiro Yamada#
1441da177e4SLinus Torvalds# 1) O=
1451da177e4SLinus Torvalds# Use "make O=dir/to/store/output/files/"
146070b98bfSSam Ravnborg#
1471da177e4SLinus Torvalds# 2) Set KBUILD_OUTPUT
14825b146c5SMasahiro Yamada# Set the environment variable KBUILD_OUTPUT to point to the output directory.
14925b146c5SMasahiro Yamada# export KBUILD_OUTPUT=dir/to/store/output/files/; make
1501da177e4SLinus Torvalds#
1511da177e4SLinus Torvalds# The O= assignment takes precedence over the KBUILD_OUTPUT environment
1521da177e4SLinus Torvalds# variable.
1531da177e4SLinus Torvalds
15425b146c5SMasahiro Yamada# Do we want to change the working directory?
155b8b0618cSCheng Renquanifeq ("$(origin O)", "command line")
156b8b0618cSCheng Renquan  KBUILD_OUTPUT := $(O)
1571da177e4SLinus Torvaldsendif
1581da177e4SLinus Torvalds
15925b146c5SMasahiro Yamadaifneq ($(KBUILD_OUTPUT),)
16025b146c5SMasahiro Yamada# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
16125b146c5SMasahiro Yamada# expand a shell special character '~'. We use a somewhat tedious way here.
16225b146c5SMasahiro Yamadaabs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
16325b146c5SMasahiro Yamada$(if $(abs_objtree),, \
16425b146c5SMasahiro Yamada     $(error failed to create output directory "$(KBUILD_OUTPUT)"))
16525b146c5SMasahiro Yamada
16625b146c5SMasahiro Yamada# $(realpath ...) resolves symlinks
16725b146c5SMasahiro Yamadaabs_objtree := $(realpath $(abs_objtree))
16825b146c5SMasahiro Yamadaelse
16925b146c5SMasahiro Yamadaabs_objtree := $(CURDIR)
17025b146c5SMasahiro Yamadaendif # ifneq ($(KBUILD_OUTPUT),)
17125b146c5SMasahiro Yamada
17225b146c5SMasahiro Yamadaifeq ($(abs_objtree),$(CURDIR))
17325b146c5SMasahiro Yamada# Suppress "Entering directory ..." unless we are changing the work directory.
17425b146c5SMasahiro YamadaMAKEFLAGS += --no-print-directory
17525b146c5SMasahiro Yamadaelse
17625b146c5SMasahiro Yamadaneed-sub-make := 1
17751193b76SRobert Jarzmikendif
17851193b76SRobert Jarzmik
17930cef68dSMasahiro Yamadathis-makefile := $(lastword $(MAKEFILE_LIST))
18030cef68dSMasahiro Yamadaabs_srctree := $(realpath $(dir $(this-makefile)))
1811da177e4SLinus Torvalds
18225b146c5SMasahiro Yamadaifneq ($(words $(subst :, ,$(abs_srctree))), 1)
18325b146c5SMasahiro Yamada$(error source directory cannot contain spaces or colons)
18425b146c5SMasahiro Yamadaendif
1851da177e4SLinus Torvalds
18625b146c5SMasahiro Yamadaifneq ($(abs_srctree),$(abs_objtree))
18780463f1bSMasahiro Yamada# Look for make include files relative to root of kernel src
18880463f1bSMasahiro Yamada#
18980463f1bSMasahiro Yamada# This does not become effective immediately because MAKEFLAGS is re-parsed
19025b146c5SMasahiro Yamada# once after the Makefile is read. We need to invoke sub-make.
19125b146c5SMasahiro YamadaMAKEFLAGS += --include-dir=$(abs_srctree)
192688931a5SMasahiro Yamadaneed-sub-make := 1
19325b146c5SMasahiro Yamadaendif
1943812b8c5SMasahiro Yamada
195688931a5SMasahiro Yamadaifneq ($(filter 3.%,$(MAKE_VERSION)),)
196688931a5SMasahiro Yamada# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
197688931a5SMasahiro Yamada# We need to invoke sub-make to avoid implicit rules in the top Makefile.
198688931a5SMasahiro Yamadaneed-sub-make := 1
199688931a5SMasahiro Yamada# Cancel implicit rules for this Makefile.
20093fdddfeSMasahiro Yamada$(this-makefile): ;
201688931a5SMasahiro Yamadaendif
202688931a5SMasahiro Yamada
20325b146c5SMasahiro Yamadaexport abs_srctree abs_objtree
204221cc2d2SMasahiro Yamadaexport sub_make_done := 1
205221cc2d2SMasahiro Yamada
206688931a5SMasahiro Yamadaifeq ($(need-sub-make),1)
207688931a5SMasahiro Yamada
208121c2a13SMasahiro YamadaPHONY += $(MAKECMDGOALS) __sub-make
2090b35786dSMilton Miller
210121c2a13SMasahiro Yamada$(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
21116f89098SCharles Keepax	@:
2120b35786dSMilton Miller
213c4e6fff1SCao jin# Invoke a second make in the output directory, passing relevant variables
214121c2a13SMasahiro Yamada__sub-make:
21525b146c5SMasahiro Yamada	$(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
2161da177e4SLinus Torvalds
217688931a5SMasahiro Yamadaendif # need-sub-make
218221cc2d2SMasahiro Yamadaendif # sub_make_done
219688931a5SMasahiro Yamada
2201da177e4SLinus Torvalds# We process the rest of the Makefile if this is the final invocation of make
221688931a5SMasahiro Yamadaifeq ($(need-sub-make),)
2221da177e4SLinus Torvalds
2237ff52571SMasahiro Yamada# Do not print "Entering directory ...",
2247ff52571SMasahiro Yamada# but we want to display it when entering to the output directory
2257ff52571SMasahiro Yamada# so that IDEs/editors are able to understand relative filenames.
2267ff52571SMasahiro YamadaMAKEFLAGS += --no-print-directory
2277ff52571SMasahiro Yamada
22825b146c5SMasahiro Yamadaifeq ($(abs_srctree),$(abs_objtree))
2299da0763bSMichal Marek        # building in the source tree
2309da0763bSMichal Marek        srctree := .
231051f278eSMasahiro Yamada	building_out_of_srctree :=
2329da0763bSMichal Marekelse
23325b146c5SMasahiro Yamada        ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
2349da0763bSMichal Marek                # building in a subdirectory of the source tree
2359da0763bSMichal Marek                srctree := ..
2369da0763bSMichal Marek        else
23725b146c5SMasahiro Yamada                srctree := $(abs_srctree)
2389da0763bSMichal Marek        endif
239051f278eSMasahiro Yamada	building_out_of_srctree := 1
2409da0763bSMichal Marekendif
2412c1f4f12SMasahiro Yamada
24295fd3f87SMasahiro Yamadaifneq ($(KBUILD_ABS_SRCTREE),)
24395fd3f87SMasahiro Yamadasrctree := $(abs_srctree)
24495fd3f87SMasahiro Yamadaendif
2452c1f4f12SMasahiro Yamada
2467e1c0477SMichal Marekobjtree		:= .
2476b12de69SMasahiro YamadaVPATH		:= $(srctree)
2481da177e4SLinus Torvalds
249051f278eSMasahiro Yamadaexport building_out_of_srctree srctree objtree VPATH
2501da177e4SLinus Torvalds
2512c1f4f12SMasahiro Yamada# To make sure we do not include .config for any of the *config targets
2522c1f4f12SMasahiro Yamada# catch them early, and hand them over to scripts/kconfig/Makefile
2532c1f4f12SMasahiro Yamada# It is allowed to specify more targets when calling make, including
2542c1f4f12SMasahiro Yamada# mixing *config targets and build targets.
2552c1f4f12SMasahiro Yamada# For example 'make oldconfig all'.
2562c1f4f12SMasahiro Yamada# Detect when mixed targets is specified, and make a second invocation
2572c1f4f12SMasahiro Yamada# of make so .config is not included in this case either (for *config).
2582c1f4f12SMasahiro Yamada
2592c1f4f12SMasahiro Yamadaversion_h := include/generated/uapi/linux/version.h
2602c1f4f12SMasahiro Yamada
26122340a06SMasahiro Yamadaclean-targets := %clean mrproper cleandocs
26222340a06SMasahiro Yamadano-dot-config-targets := $(clean-targets) \
2632c1f4f12SMasahiro Yamada			 cscope gtags TAGS tags help% %docs check% coccicheck \
26459b2bd05SMasahiro Yamada			 $(version_h) headers headers_% archheaders archscripts \
2654623980dSDavid Engraf			 %asm-generic kernelversion %src-pkg dt_binding_check \
2664623980dSDavid Engraf			 outputmakefile
267805b2e1dSMasahiro Yamada# Installation targets should not require compiler. Unfortunately, vdso_install
268805b2e1dSMasahiro Yamada# is an exception where build artifacts may be updated. This must be fixed.
269805b2e1dSMasahiro Yamadano-compiler-targets := $(no-dot-config-targets) install dtbs_install \
270805b2e1dSMasahiro Yamada			headers_install modules_install kernelrelease image_name
271993bdde9SMasahiro Yamadano-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
272993bdde9SMasahiro Yamada			  image_name
273394053f4SMasahiro Yamadasingle-targets := %.a %.i %.ko %.ll %.lst %.mod %.o %.s %.symtypes %/
2742c1f4f12SMasahiro Yamada
2752042b548SMasahiro Yamadaconfig-build	:=
2762042b548SMasahiro Yamadamixed-build	:=
2772042b548SMasahiro Yamadaneed-config	:= 1
278805b2e1dSMasahiro Yamadaneed-compiler	:= 1
2792042b548SMasahiro Yamadamay-sync-config	:= 1
280394053f4SMasahiro Yamadasingle-build	:=
2812c1f4f12SMasahiro Yamada
2822c1f4f12SMasahiro Yamadaifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
2832c1f4f12SMasahiro Yamada	ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
2842042b548SMasahiro Yamada		need-config :=
2852c1f4f12SMasahiro Yamada	endif
2862c1f4f12SMasahiro Yamadaendif
2872c1f4f12SMasahiro Yamada
288805b2e1dSMasahiro Yamadaifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),)
289805b2e1dSMasahiro Yamada	ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),)
290805b2e1dSMasahiro Yamada		need-compiler :=
291805b2e1dSMasahiro Yamada	endif
292805b2e1dSMasahiro Yamadaendif
293805b2e1dSMasahiro Yamada
294d7942413SMasahiro Yamadaifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
295d7942413SMasahiro Yamada	ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
2962042b548SMasahiro Yamada		may-sync-config :=
297d7942413SMasahiro Yamada	endif
298d7942413SMasahiro Yamadaendif
299d7942413SMasahiro Yamada
300d7942413SMasahiro Yamadaifneq ($(KBUILD_EXTMOD),)
3012042b548SMasahiro Yamada	may-sync-config :=
302d7942413SMasahiro Yamadaendif
303d7942413SMasahiro Yamada
3042c1f4f12SMasahiro Yamadaifeq ($(KBUILD_EXTMOD),)
305efbf9726SMasahiro Yamada        ifneq ($(filter %config,$(MAKECMDGOALS)),)
3062042b548SMasahiro Yamada		config-build := 1
3072c1f4f12SMasahiro Yamada                ifneq ($(words $(MAKECMDGOALS)),1)
3082042b548SMasahiro Yamada			mixed-build := 1
3092c1f4f12SMasahiro Yamada                endif
3102c1f4f12SMasahiro Yamada        endif
3112c1f4f12SMasahiro Yamadaendif
31222340a06SMasahiro Yamada
313394053f4SMasahiro Yamada# We cannot build single targets and the others at the same time
314394053f4SMasahiro Yamadaifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
315394053f4SMasahiro Yamada	single-build := 1
316394053f4SMasahiro Yamada	ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
317394053f4SMasahiro Yamada		mixed-build := 1
318394053f4SMasahiro Yamada	endif
319394053f4SMasahiro Yamadaendif
320394053f4SMasahiro Yamada
32122340a06SMasahiro Yamada# For "make -j clean all", "make -j mrproper defconfig all", etc.
32222340a06SMasahiro Yamadaifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
32322340a06SMasahiro Yamada        ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
3242042b548SMasahiro Yamada		mixed-build := 1
32522340a06SMasahiro Yamada        endif
32622340a06SMasahiro Yamadaendif
32722340a06SMasahiro Yamada
3282c1f4f12SMasahiro Yamada# install and modules_install need also be processed one by one
3292c1f4f12SMasahiro Yamadaifneq ($(filter install,$(MAKECMDGOALS)),)
3302c1f4f12SMasahiro Yamada        ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
3312042b548SMasahiro Yamada		mixed-build := 1
3322c1f4f12SMasahiro Yamada        endif
3332c1f4f12SMasahiro Yamadaendif
3342c1f4f12SMasahiro Yamada
3352042b548SMasahiro Yamadaifdef mixed-build
3362c1f4f12SMasahiro Yamada# ===========================================================================
3372c1f4f12SMasahiro Yamada# We're called with mixed targets (*config and build targets).
3382c1f4f12SMasahiro Yamada# Handle them one by one.
3392c1f4f12SMasahiro Yamada
3402c1f4f12SMasahiro YamadaPHONY += $(MAKECMDGOALS) __build_one_by_one
3412c1f4f12SMasahiro Yamada
342121c2a13SMasahiro Yamada$(MAKECMDGOALS): __build_one_by_one
3432c1f4f12SMasahiro Yamada	@:
3442c1f4f12SMasahiro Yamada
3452c1f4f12SMasahiro Yamada__build_one_by_one:
3462c1f4f12SMasahiro Yamada	$(Q)set -e; \
3472c1f4f12SMasahiro Yamada	for i in $(MAKECMDGOALS); do \
3482c1f4f12SMasahiro Yamada		$(MAKE) -f $(srctree)/Makefile $$i; \
3492c1f4f12SMasahiro Yamada	done
3502c1f4f12SMasahiro Yamada
3512042b548SMasahiro Yamadaelse # !mixed-build
3522c1f4f12SMasahiro Yamada
3533204a7fbSMasahiro Yamadainclude $(srctree)/scripts/Kbuild.include
3542c1f4f12SMasahiro Yamada
3552c1f4f12SMasahiro Yamada# Read KERNELRELEASE from include/config/kernel.release (if it exists)
3562c1f4f12SMasahiro YamadaKERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
3592c1f4f12SMasahiro Yamada
3603204a7fbSMasahiro Yamadainclude $(srctree)/scripts/subarch.include
3611da177e4SLinus Torvalds
3621da177e4SLinus Torvalds# Cross compiling and selecting different set of gcc/bin-utils
3631da177e4SLinus Torvalds# ---------------------------------------------------------------------------
3641da177e4SLinus Torvalds#
3651da177e4SLinus Torvalds# When performing cross compilation for other architectures ARCH shall be set
3661da177e4SLinus Torvalds# to the target architecture. (See arch/* for the possibilities).
3671da177e4SLinus Torvalds# ARCH can be set during invocation of make:
3681da177e4SLinus Torvalds# make ARCH=ia64
3691da177e4SLinus Torvalds# Another way is to have ARCH set in the environment.
3701da177e4SLinus Torvalds# The default ARCH is the host where make is executed.
3711da177e4SLinus Torvalds
3721da177e4SLinus Torvalds# CROSS_COMPILE specify the prefix used for all executables used
3731da177e4SLinus Torvalds# during compilation. Only gcc and related bin-utils executables
3741da177e4SLinus Torvalds# are prefixed with $(CROSS_COMPILE).
3751da177e4SLinus Torvalds# CROSS_COMPILE can be set on the command line
3761da177e4SLinus Torvalds# make CROSS_COMPILE=ia64-linux-
3771da177e4SLinus Torvalds# Alternatively CROSS_COMPILE can be set in the environment.
3781da177e4SLinus Torvalds# Default value for CROSS_COMPILE is not to prefix executables
3791da177e4SLinus Torvalds# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
3802331d1a6SSam RavnborgARCH		?= $(SUBARCH)
3811da177e4SLinus Torvalds
3821da177e4SLinus Torvalds# Architecture as present in compile.h
3836752ed90SThomas GleixnerUTS_MACHINE 	:= $(ARCH)
3846752ed90SThomas GleixnerSRCARCH 	:= $(ARCH)
3851da177e4SLinus Torvalds
386d746d647SSam Ravnborg# Additional ARCH settings for x86
387d746d647SSam Ravnborgifeq ($(ARCH),i386)
388d746d647SSam Ravnborg        SRCARCH := x86
389d746d647SSam Ravnborgendif
390d746d647SSam Ravnborgifeq ($(ARCH),x86_64)
391d746d647SSam Ravnborg        SRCARCH := x86
392d746d647SSam Ravnborgendif
39374b469f2SSam Ravnborg
3945e538790SSam Ravnborg# Additional ARCH settings for sparc
395e69f58c0SNamhyung Kimifeq ($(ARCH),sparc32)
396e69f58c0SNamhyung Kim       SRCARCH := sparc
397e69f58c0SNamhyung Kimendif
398a439fe51SSam Ravnborgifeq ($(ARCH),sparc64)
3995e538790SSam Ravnborg       SRCARCH := sparc
400a439fe51SSam Ravnborgendif
4012fb9b1bdSSam Ravnborg
4023cc000b5SPaul Mundt# Additional ARCH settings for sh
4033cc000b5SPaul Mundtifeq ($(ARCH),sh64)
4043cc000b5SPaul Mundt       SRCARCH := sh
4053cc000b5SPaul Mundtendif
4063cc000b5SPaul Mundt
40714cdd3c4SRoman ZippelKCONFIG_CONFIG	?= .config
40841263fc6SBen Gardinerexport KCONFIG_CONFIG
40914cdd3c4SRoman Zippel
4102a86f661SMasahiro Yamada# Default file for 'make defconfig'. This may be overridden by arch-Makefile.
4112a86f661SMasahiro Yamadaexport KBUILD_DEFCONFIG := defconfig
4122a86f661SMasahiro Yamada
4131da177e4SLinus Torvalds# SHELL used by kbuild
414858805b3SMasahiro YamadaCONFIG_SHELL := sh
4151da177e4SLinus Torvalds
4166d79a7b4SMasahiro YamadaHOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
4176d79a7b4SMasahiro YamadaHOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
4186d79a7b4SMasahiro YamadaHOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
419d7f14c66SUwe Kleine-König
420a0d1c951SMasahiro Yamadaifneq ($(LLVM),)
421a0d1c951SMasahiro YamadaHOSTCC	= clang
422a0d1c951SMasahiro YamadaHOSTCXX	= clang++
423a0d1c951SMasahiro Yamadaelse
424a0d1c951SMasahiro YamadaHOSTCC	= gcc