Makefile revision 5f6e0fe0
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
2bfeffd15SLinus TorvaldsVERSION = 5
3e73f0f0eSLinus TorvaldsPATCHLEVEL = 14
455922c9dSLinus TorvaldsSUBLEVEL = 0
57d2a07b7SLinus TorvaldsEXTRAVERSION =
613311e74SLinus TorvaldsNAME = Opossums on Parade
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
13274ee585bSMasahiro Yamada# Remove trailing slashes
13374ee585bSMasahiro Yamadaifneq ($(filter %/, $(KBUILD_EXTMOD)),)
13474ee585bSMasahiro YamadaKBUILD_EXTMOD := $(shell dirname $(KBUILD_EXTMOD).)
13574ee585bSMasahiro Yamadaendif
13674ee585bSMasahiro Yamada
137bcf637f5SMasahiro Yamadaexport KBUILD_EXTMOD
138bcf637f5SMasahiro Yamada
13925b146c5SMasahiro Yamada# Kbuild will save output files in the current working directory.
14025b146c5SMasahiro Yamada# This does not need to match to the root of the kernel source tree.
14125b146c5SMasahiro Yamada#
14225b146c5SMasahiro Yamada# For example, you can do this:
14325b146c5SMasahiro Yamada#
14425b146c5SMasahiro Yamada#  cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
14525b146c5SMasahiro Yamada#
14625b146c5SMasahiro Yamada# If you want to save output files in a different location, there are
14725b146c5SMasahiro Yamada# two syntaxes to specify it.
14825b146c5SMasahiro Yamada#
1491da177e4SLinus Torvalds# 1) O=
1501da177e4SLinus Torvalds# Use "make O=dir/to/store/output/files/"
151070b98bfSSam Ravnborg#
1521da177e4SLinus Torvalds# 2) Set KBUILD_OUTPUT
15325b146c5SMasahiro Yamada# Set the environment variable KBUILD_OUTPUT to point to the output directory.
15425b146c5SMasahiro Yamada# export KBUILD_OUTPUT=dir/to/store/output/files/; make
1551da177e4SLinus Torvalds#
1561da177e4SLinus Torvalds# The O= assignment takes precedence over the KBUILD_OUTPUT environment
1571da177e4SLinus Torvalds# variable.
1581da177e4SLinus Torvalds
15925b146c5SMasahiro Yamada# Do we want to change the working directory?
160b8b0618cSCheng Renquanifeq ("$(origin O)", "command line")
161b8b0618cSCheng Renquan  KBUILD_OUTPUT := $(O)
1621da177e4SLinus Torvaldsendif
1631da177e4SLinus Torvalds
16425b146c5SMasahiro Yamadaifneq ($(KBUILD_OUTPUT),)
16525b146c5SMasahiro Yamada# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
16625b146c5SMasahiro Yamada# expand a shell special character '~'. We use a somewhat tedious way here.
16725b146c5SMasahiro Yamadaabs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
16825b146c5SMasahiro Yamada$(if $(abs_objtree),, \
16925b146c5SMasahiro Yamada     $(error failed to create output directory "$(KBUILD_OUTPUT)"))
17025b146c5SMasahiro Yamada
17125b146c5SMasahiro Yamada# $(realpath ...) resolves symlinks
17225b146c5SMasahiro Yamadaabs_objtree := $(realpath $(abs_objtree))
17325b146c5SMasahiro Yamadaelse
17425b146c5SMasahiro Yamadaabs_objtree := $(CURDIR)
17525b146c5SMasahiro Yamadaendif # ifneq ($(KBUILD_OUTPUT),)
17625b146c5SMasahiro Yamada
17725b146c5SMasahiro Yamadaifeq ($(abs_objtree),$(CURDIR))
17825b146c5SMasahiro Yamada# Suppress "Entering directory ..." unless we are changing the work directory.
17925b146c5SMasahiro YamadaMAKEFLAGS += --no-print-directory
18025b146c5SMasahiro Yamadaelse
18125b146c5SMasahiro Yamadaneed-sub-make := 1
18251193b76SRobert Jarzmikendif
18351193b76SRobert Jarzmik
18430cef68dSMasahiro Yamadathis-makefile := $(lastword $(MAKEFILE_LIST))
18530cef68dSMasahiro Yamadaabs_srctree := $(realpath $(dir $(this-makefile)))
1861da177e4SLinus Torvalds
18725b146c5SMasahiro Yamadaifneq ($(words $(subst :, ,$(abs_srctree))), 1)
18825b146c5SMasahiro Yamada$(error source directory cannot contain spaces or colons)
18925b146c5SMasahiro Yamadaendif
1901da177e4SLinus Torvalds
19125b146c5SMasahiro Yamadaifneq ($(abs_srctree),$(abs_objtree))
19280463f1bSMasahiro Yamada# Look for make include files relative to root of kernel src
19380463f1bSMasahiro Yamada#
19480463f1bSMasahiro Yamada# This does not become effective immediately because MAKEFLAGS is re-parsed
19525b146c5SMasahiro Yamada# once after the Makefile is read. We need to invoke sub-make.
19625b146c5SMasahiro YamadaMAKEFLAGS += --include-dir=$(abs_srctree)
197688931a5SMasahiro Yamadaneed-sub-make := 1
19825b146c5SMasahiro Yamadaendif
1993812b8c5SMasahiro Yamada
200688931a5SMasahiro Yamadaifneq ($(filter 3.%,$(MAKE_VERSION)),)
201688931a5SMasahiro Yamada# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
202688931a5SMasahiro Yamada# We need to invoke sub-make to avoid implicit rules in the top Makefile.
203688931a5SMasahiro Yamadaneed-sub-make := 1
204688931a5SMasahiro Yamada# Cancel implicit rules for this Makefile.
20593fdddfeSMasahiro Yamada$(this-makefile): ;
206688931a5SMasahiro Yamadaendif
207688931a5SMasahiro Yamada
20825b146c5SMasahiro Yamadaexport abs_srctree abs_objtree
209221cc2d2SMasahiro Yamadaexport sub_make_done := 1
210221cc2d2SMasahiro Yamada
211688931a5SMasahiro Yamadaifeq ($(need-sub-make),1)
212688931a5SMasahiro Yamada
213121c2a13SMasahiro YamadaPHONY += $(MAKECMDGOALS) __sub-make
2140b35786dSMilton Miller
215121c2a13SMasahiro Yamada$(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
21616f89098SCharles Keepax	@:
2170b35786dSMilton Miller
218c4e6fff1SCao jin# Invoke a second make in the output directory, passing relevant variables
219121c2a13SMasahiro Yamada__sub-make:
22025b146c5SMasahiro Yamada	$(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
2211da177e4SLinus Torvalds
222688931a5SMasahiro Yamadaendif # need-sub-make
223221cc2d2SMasahiro Yamadaendif # sub_make_done
224688931a5SMasahiro Yamada
2251da177e4SLinus Torvalds# We process the rest of the Makefile if this is the final invocation of make
226688931a5SMasahiro Yamadaifeq ($(need-sub-make),)
2271da177e4SLinus Torvalds
2287ff52571SMasahiro Yamada# Do not print "Entering directory ...",
2297ff52571SMasahiro Yamada# but we want to display it when entering to the output directory
2307ff52571SMasahiro Yamada# so that IDEs/editors are able to understand relative filenames.
2317ff52571SMasahiro YamadaMAKEFLAGS += --no-print-directory
2327ff52571SMasahiro Yamada
23325b146c5SMasahiro Yamadaifeq ($(abs_srctree),$(abs_objtree))
2349da0763bSMichal Marek        # building in the source tree
2359da0763bSMichal Marek        srctree := .
236051f278eSMasahiro Yamada	building_out_of_srctree :=
2379da0763bSMichal Marekelse
23825b146c5SMasahiro Yamada        ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
2399da0763bSMichal Marek                # building in a subdirectory of the source tree
2409da0763bSMichal Marek                srctree := ..
2419da0763bSMichal Marek        else
24225b146c5SMasahiro Yamada                srctree := $(abs_srctree)
2439da0763bSMichal Marek        endif
244051f278eSMasahiro Yamada	building_out_of_srctree := 1
2459da0763bSMichal Marekendif
2462c1f4f12SMasahiro Yamada
24795fd3f87SMasahiro Yamadaifneq ($(KBUILD_ABS_SRCTREE),)
24895fd3f87SMasahiro Yamadasrctree := $(abs_srctree)
24995fd3f87SMasahiro Yamadaendif
2502c1f4f12SMasahiro Yamada
2517e1c0477SMichal Marekobjtree		:= .
2526b12de69SMasahiro YamadaVPATH		:= $(srctree)
2531da177e4SLinus Torvalds
254051f278eSMasahiro Yamadaexport building_out_of_srctree srctree objtree VPATH
2551da177e4SLinus Torvalds
2562c1f4f12SMasahiro Yamada# To make sure we do not include .config for any of the *config targets
2572c1f4f12SMasahiro Yamada# catch them early, and hand them over to scripts/kconfig/Makefile
2582c1f4f12SMasahiro Yamada# It is allowed to specify more targets when calling make, including
2592c1f4f12SMasahiro Yamada# mixing *config targets and build targets.
2602c1f4f12SMasahiro Yamada# For example 'make oldconfig all'.
2612c1f4f12SMasahiro Yamada# Detect when mixed targets is specified, and make a second invocation
2622c1f4f12SMasahiro Yamada# of make so .config is not included in this case either (for *config).
2632c1f4f12SMasahiro Yamada
2642c1f4f12SMasahiro Yamadaversion_h := include/generated/uapi/linux/version.h
2652c1f4f12SMasahiro Yamada
26622340a06SMasahiro Yamadaclean-targets := %clean mrproper cleandocs
26722340a06SMasahiro Yamadano-dot-config-targets := $(clean-targets) \
2682c1f4f12SMasahiro Yamada			 cscope gtags TAGS tags help% %docs check% coccicheck \
26959b2bd05SMasahiro Yamada			 $(version_h) headers headers_% archheaders archscripts \
2704623980dSDavid Engraf			 %asm-generic kernelversion %src-pkg dt_binding_check \
2714623980dSDavid Engraf			 outputmakefile
272805b2e1dSMasahiro Yamada# Installation targets should not require compiler. Unfortunately, vdso_install
273805b2e1dSMasahiro Yamada# is an exception where build artifacts may be updated. This must be fixed.
274805b2e1dSMasahiro Yamadano-compiler-targets := $(no-dot-config-targets) install dtbs_install \
275805b2e1dSMasahiro Yamada			headers_install modules_install kernelrelease image_name
276993bdde9SMasahiro Yamadano-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
277993bdde9SMasahiro Yamada			  image_name
278394053f4SMasahiro Yamadasingle-targets := %.a %.i %.ko %.ll %.lst %.mod %.o %.s %.symtypes %/
2792c1f4f12SMasahiro Yamada
2802042b548SMasahiro Yamadaconfig-build	:=
2812042b548SMasahiro Yamadamixed-build	:=
2822042b548SMasahiro Yamadaneed-config	:= 1
283805b2e1dSMasahiro Yamadaneed-compiler	:= 1
2842042b548SMasahiro Yamadamay-sync-config	:= 1
285394053f4SMasahiro Yamadasingle-build	:=
2862c1f4f12SMasahiro Yamada
2872c1f4f12SMasahiro Yamadaifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
2882c1f4f12SMasahiro Yamada	ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
2892042b548SMasahiro Yamada		need-config :=
2902c1f4f12SMasahiro Yamada	endif
2912c1f4f12SMasahiro Yamadaendif
2922c1f4f12SMasahiro Yamada
293805b2e1dSMasahiro Yamadaifneq ($(filter $(no-compiler-targets), $(MAKECMDGOALS)),)
294805b2e1dSMasahiro Yamada	ifeq ($(filter-out $(no-compiler-targets), $(MAKECMDGOALS)),)
295805b2e1dSMasahiro Yamada		need-compiler :=
296805b2e1dSMasahiro Yamada	endif
297805b2e1dSMasahiro Yamadaendif
298805b2e1dSMasahiro Yamada
299d7942413SMasahiro Yamadaifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
300d7942413SMasahiro Yamada	ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
3012042b548SMasahiro Yamada		may-sync-config :=
302d7942413SMasahiro Yamada	endif
303d7942413SMasahiro Yamadaendif
304d7942413SMasahiro Yamada
305d7942413SMasahiro Yamadaifneq ($(KBUILD_EXTMOD),)
3062042b548SMasahiro Yamada	may-sync-config :=
307d7942413SMasahiro Yamadaendif
308d7942413SMasahiro Yamada
3092c1f4f12SMasahiro Yamadaifeq ($(KBUILD_EXTMOD),)
310efbf9726SMasahiro Yamada        ifneq ($(filter %config,$(MAKECMDGOALS)),)
3112042b548SMasahiro Yamada		config-build := 1
3122c1f4f12SMasahiro Yamada                ifneq ($(words $(MAKECMDGOALS)),1)
3132042b548SMasahiro Yamada			mixed-build := 1
3142c1f4f12SMasahiro Yamada                endif
3152c1f4f12SMasahiro Yamada        endif
3162c1f4f12SMasahiro Yamadaendif
31722340a06SMasahiro Yamada
318394053f4SMasahiro Yamada# We cannot build single targets and the others at the same time
319394053f4SMasahiro Yamadaifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
320394053f4SMasahiro Yamada	single-build := 1
321394053f4SMasahiro Yamada	ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
322394053f4SMasahiro Yamada		mixed-build := 1
323394053f4SMasahiro Yamada	endif
324394053f4SMasahiro Yamadaendif
325394053f4SMasahiro Yamada
32622340a06SMasahiro Yamada# For "make -j clean all", "make -j mrproper defconfig all", etc.
32722340a06SMasahiro Yamadaifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
32822340a06SMasahiro Yamada        ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
3292042b548SMasahiro Yamada		mixed-build := 1
33022340a06SMasahiro Yamada        endif
33122340a06SMasahiro Yamadaendif
33222340a06SMasahiro Yamada
3332c1f4f12SMasahiro Yamada# install and modules_install need also be processed one by one
3342c1f4f12SMasahiro Yamadaifneq ($(filter install,$(MAKECMDGOALS)),)
3352c1f4f12SMasahiro Yamada        ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
3362042b548SMasahiro Yamada		mixed-build := 1
3372c1f4f12SMasahiro Yamada        endif
3382c1f4f12SMasahiro Yamadaendif
3392c1f4f12SMasahiro Yamada
3402042b548SMasahiro Yamadaifdef mixed-build
3412c1f4f12SMasahiro Yamada# ===========================================================================
3422c1f4f12SMasahiro Yamada# We're called with mixed targets (*config and build targets).
3432c1f4f12SMasahiro Yamada# Handle them one by one.
3442c1f4f12SMasahiro Yamada
3452c1f4f12SMasahiro YamadaPHONY += $(MAKECMDGOALS) __build_one_by_one
3462c1f4f12SMasahiro Yamada
347121c2a13SMasahiro Yamada$(MAKECMDGOALS): __build_one_by_one
3482c1f4f12SMasahiro Yamada	@:
3492c1f4f12SMasahiro Yamada
3502c1f4f12SMasahiro Yamada__build_one_by_one:
3512c1f4f12SMasahiro Yamada	$(Q)set -e; \
3522c1f4f12SMasahiro Yamada	for i in $(MAKECMDGOALS); do \
3532c1f4f12SMasahiro Yamada		$(MAKE) -f $(srctree)/Makefile $$i; \
3542c1f4f12SMasahiro Yamada	done
3552c1f4f12SMasahiro Yamada
3562042b548SMasahiro Yamadaelse # !mixed-build
3572c1f4f12SMasahiro Yamada
3583204a7fbSMasahiro Yamadainclude $(srctree)/scripts/Kbuild.include
3592c1f4f12SMasahiro Yamada
3602c1f4f12SMasahiro Yamada# Read KERNELRELEASE from include/config/kernel.release (if it exists)
3612c1f4f12SMasahiro YamadaKERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
3642c1f4f12SMasahiro Yamada
3653204a7fbSMasahiro Yamadainclude $(srctree)/scripts/subarch.include
3661da177e4SLinus Torvalds
3671da177e4SLinus Torvalds# Cross compiling and selecting different set of gcc/bin-utils
3681da177e4SLinus Torvalds# ---------------------------------------------------------------------------
3691da177e4SLinus Torvalds#
3701da177e4SLinus Torvalds# When performing cross compilation for other architectures ARCH shall be set
3711da177e4SLinus Torvalds# to the target architecture. (See arch/* for the possibilities).
3721da177e4SLinus Torvalds# ARCH can be set during invocation of make:
3731da177e4SLinus Torvalds# make ARCH=ia64
3741da177e4SLinus Torvalds# Another way is to have ARCH set in the environment.
3751da177e4SLinus Torvalds# The default ARCH is the host where make is executed.
3761da177e4SLinus Torvalds
3771da177e4SLinus Torvalds# CROSS_COMPILE specify the prefix used for all executables used
3781da177e4SLinus Torvalds# during compilation. Only gcc and related bin-utils executables
3791da177e4SLinus Torvalds# are prefixed with $(CROSS_COMPILE).
3801da177e4SLinus Torvalds# CROSS_COMPILE can be set on the command line
3811da177e4SLinus Torvalds# make CROSS_COMPILE=ia64-linux-
3821da177e4SLinus Torvalds# Alternatively CROSS_COMPILE can be set in the environment.
3831da177e4SLinus Torvalds# Default value for CROSS_COMPILE is not to prefix executables
3841da177e4SLinus Torvalds# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
3852331d1a6SSam RavnborgARCH		?= $(SUBARCH)
3861da177e4SLinus Torvalds
3871da177e4SLinus Torvalds# Architecture as present in compile.h
3886752ed90SThomas GleixnerUTS_MACHINE 	:= $(ARCH)
3896752ed90SThomas GleixnerSRCARCH 	:= $(ARCH)
3901da177e4SLinus Torvalds
391d746d647SSam Ravnborg# Additional ARCH settings for x86
392d746d647SSam Ravnborgifeq ($(ARCH),i386)
393d746d647SSam Ravnborg        SRCARCH := x86
394d746d647SSam Ravnborgendif
395d746d647SSam Ravnborgifeq ($(ARCH),x86_64)
396d746d647SSam Ravnborg        SRCARCH := x86
397d746d647SSam Ravnborgendif
39874b469f2SSam Ravnborg
3995e538790SSam Ravnborg# Additional ARCH settings for sparc
400e69f58c0SNamhyung Kimifeq ($(ARCH),sparc32)
401e69f58c0SNamhyung Kim       SRCARCH := sparc
402e69f58c0SNamhyung Kimendif
403a439fe51SSam Ravnborgifeq ($(ARCH),sparc64)
4045e538790SSam Ravnborg       SRCARCH := sparc
405a439fe51SSam Ravnborgendif
4062fb9b1bdSSam Ravnborg
4075f6e0fe0SMasahiro Yamada# Additional ARCH settings for parisc
4085f6e0fe0SMasahiro Yamadaifeq ($(ARCH),parisc64)
4095f6e0fe0SMasahiro Yamada       SRCARCH := parisc
4105f6e0fe0SMasahiro Yamadaendif
4115f6e0fe0SMasahiro Yamada
412f02aa48dSMasahiro Yamadaexport cross_compiling :=
413f02aa48dSMasahiro Yamadaifneq ($(SRCARCH),$(SUBARCH))
414f02aa48dSMasahiro Yamadacross_compiling := 1
415f02aa48dSMasahiro Yamadaendif
416f02aa48dSMasahiro Yamada
41714cdd3c4SRoman ZippelKCONFIG_CONFIG	?= .config
41841263fc6SBen Gardinerexport KCONFIG_CONFIG
41914cdd3c4SRoman Zippel
4201da177e4SLinus Torvalds# SHELL used by kbuild
421858805b3SMasahiro YamadaCONFIG_SHELL := sh
4221da177e4SLinus Torvalds
4236d79a7b4SMasahiro YamadaHOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
4246d79a7b4SMasahiro YamadaHOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
4256d79a7b4SMasahiro YamadaHOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
426d7f14c66SUwe Kleine-König