Makefile revision bcf637f5
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
2bfeffd15SLinus TorvaldsVERSION = 5
35c8fe583SLinus TorvaldsPATCHLEVEL = 11
455922c9dSLinus TorvaldsSUBLEVEL = 0
592bf2261SLinus TorvaldsEXTRAVERSION = -rc7
6d6d5df1dSLinus TorvaldsNAME = Kleptomaniac Octopus
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_
99066b7ed9SMichal Marekendif
100066b7ed9SMichal Marek
101066b7ed9SMichal Marekexport quiet Q KBUILD_VERBOSE
102066b7ed9SMichal Marek
103bcf637f5SMasahiro Yamada# Call a source code checker (by default, "sparse") as part of the
104bcf637f5SMasahiro Yamada# C compilation.
105bcf637f5SMasahiro Yamada#
106bcf637f5SMasahiro Yamada# Use 'make C=1' to enable checking of only re-compiled files.
107bcf637f5SMasahiro Yamada# Use 'make C=2' to enable checking of *all* source files, regardless
108bcf637f5SMasahiro Yamada# of whether they are re-compiled or not.
109bcf637f5SMasahiro Yamada#
110bcf637f5SMasahiro Yamada# See the file "Documentation/dev-tools/sparse.rst" for more details,
111bcf637f5SMasahiro Yamada# including where to get the "sparse" utility.
112bcf637f5SMasahiro Yamada
113bcf637f5SMasahiro Yamadaifeq ("$(origin C)", "command line")
114bcf637f5SMasahiro Yamada  KBUILD_CHECKSRC = $(C)
115bcf637f5SMasahiro Yamadaendif
116bcf637f5SMasahiro Yamadaifndef KBUILD_CHECKSRC
117bcf637f5SMasahiro Yamada  KBUILD_CHECKSRC = 0
118bcf637f5SMasahiro Yamadaendif
119bcf637f5SMasahiro Yamada
120bcf637f5SMasahiro Yamadaexport KBUILD_CHECKSRC
121bcf637f5SMasahiro Yamada
122bcf637f5SMasahiro Yamada# Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
123bcf637f5SMasahiro Yamada# directory of external module to build. Setting M= takes precedence.
124bcf637f5SMasahiro Yamadaifeq ("$(origin M)", "command line")
125bcf637f5SMasahiro Yamada  KBUILD_EXTMOD := $(M)
126bcf637f5SMasahiro Yamadaendif
127bcf637f5SMasahiro Yamada
128bcf637f5SMasahiro Yamada$(if $(word 2, $(KBUILD_EXTMOD)), \
129bcf637f5SMasahiro Yamada	$(error building multiple external modules is not supported))
130bcf637f5SMasahiro Yamada
131bcf637f5SMasahiro Yamadaexport KBUILD_EXTMOD
132bcf637f5SMasahiro Yamada
13325b146c5SMasahiro Yamada# Kbuild will save output files in the current working directory.
13425b146c5SMasahiro Yamada# This does not need to match to the root of the kernel source tree.
13525b146c5SMasahiro Yamada#
13625b146c5SMasahiro Yamada# For example, you can do this:
13725b146c5SMasahiro Yamada#
13825b146c5SMasahiro Yamada#  cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
13925b146c5SMasahiro Yamada#
14025b146c5SMasahiro Yamada# If you want to save output files in a different location, there are
14125b146c5SMasahiro Yamada# two syntaxes to specify it.
14225b146c5SMasahiro Yamada#
1431da177e4SLinus Torvalds# 1) O=
1441da177e4SLinus Torvalds# Use "make O=dir/to/store/output/files/"
145070b98bfSSam Ravnborg#
1461da177e4SLinus Torvalds# 2) Set KBUILD_OUTPUT
14725b146c5SMasahiro Yamada# Set the environment variable KBUILD_OUTPUT to point to the output directory.
14825b146c5SMasahiro Yamada# export KBUILD_OUTPUT=dir/to/store/output/files/; make
1491da177e4SLinus Torvalds#
1501da177e4SLinus Torvalds# The O= assignment takes precedence over the KBUILD_OUTPUT environment
1511da177e4SLinus Torvalds# variable.
1521da177e4SLinus Torvalds
15325b146c5SMasahiro Yamada# Do we want to change the working directory?
154b8b0618cSCheng Renquanifeq ("$(origin O)", "command line")
155b8b0618cSCheng Renquan  KBUILD_OUTPUT := $(O)
1561da177e4SLinus Torvaldsendif
1571da177e4SLinus Torvalds
15825b146c5SMasahiro Yamadaifneq ($(KBUILD_OUTPUT),)
15925b146c5SMasahiro Yamada# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
16025b146c5SMasahiro Yamada# expand a shell special character '~'. We use a somewhat tedious way here.
16125b146c5SMasahiro Yamadaabs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
16225b146c5SMasahiro Yamada$(if $(abs_objtree),, \
16325b146c5SMasahiro Yamada     $(error failed to create output directory "$(KBUILD_OUTPUT)"))
16425b146c5SMasahiro Yamada
16525b146c5SMasahiro Yamada# $(realpath ...) resolves symlinks
16625b146c5SMasahiro Yamadaabs_objtree := $(realpath $(abs_objtree))
16725b146c5SMasahiro Yamadaelse
16825b146c5SMasahiro Yamadaabs_objtree := $(CURDIR)
16925b146c5SMasahiro Yamadaendif # ifneq ($(KBUILD_OUTPUT),)
17025b146c5SMasahiro Yamada
17125b146c5SMasahiro Yamadaifeq ($(abs_objtree),$(CURDIR))
17225b146c5SMasahiro Yamada# Suppress "Entering directory ..." unless we are changing the work directory.
17325b146c5SMasahiro YamadaMAKEFLAGS += --no-print-directory
17425b146c5SMasahiro Yamadaelse
17525b146c5SMasahiro Yamadaneed-sub-make := 1
17651193b76SRobert Jarzmikendif
17751193b76SRobert Jarzmik
17830cef68dSMasahiro Yamadathis-makefile := $(lastword $(MAKEFILE_LIST))
17930cef68dSMasahiro Yamadaabs_srctree := $(realpath $(dir $(this-makefile)))
1801da177e4SLinus Torvalds
18125b146c5SMasahiro Yamadaifneq ($(words $(subst :, ,$(abs_srctree))), 1)
18225b146c5SMasahiro Yamada$(error source directory cannot contain spaces or colons)
18325b146c5SMasahiro Yamadaendif
1841da177e4SLinus Torvalds
18525b146c5SMasahiro Yamadaifneq ($(abs_srctree),$(abs_objtree))
18680463f1bSMasahiro Yamada# Look for make include files relative to root of kernel src
18780463f1bSMasahiro Yamada#
18880463f1bSMasahiro Yamada# This does not become effective immediately because MAKEFLAGS is re-parsed
18925b146c5SMasahiro Yamada# once after the Makefile is read. We need to invoke sub-make.
19025b146c5SMasahiro YamadaMAKEFLAGS += --include-dir=$(abs_srctree)
191688931a5SMasahiro Yamadaneed-sub-make := 1
19225b146c5SMasahiro Yamadaendif
1933812b8c5SMasahiro Yamada
194688931a5SMasahiro Yamadaifneq ($(filter 3.%,$(MAKE_VERSION)),)
195688931a5SMasahiro Yamada# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
196688931a5SMasahiro Yamada# We need to invoke sub-make to avoid implicit rules in the top Makefile.
197688931a5SMasahiro Yamadaneed-sub-make := 1
198688931a5SMasahiro Yamada# Cancel implicit rules for this Makefile.
19993fdddfeSMasahiro Yamada$(this-makefile): ;
200688931a5SMasahiro Yamadaendif
201688931a5SMasahiro Yamada
20225b146c5SMasahiro Yamadaexport abs_srctree abs_objtree
203221cc2d2SMasahiro Yamadaexport sub_make_done := 1
204221cc2d2SMasahiro Yamada
205688931a5SMasahiro Yamadaifeq ($(need-sub-make),1)
206688931a5SMasahiro Yamada
207121c2a13SMasahiro YamadaPHONY += $(MAKECMDGOALS) __sub-make
2080b35786dSMilton Miller
209121c2a13SMasahiro Yamada$(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
21016f89098SCharles Keepax	@:
2110b35786dSMilton Miller
212c4e6fff1SCao jin# Invoke a second make in the output directory, passing relevant variables
213121c2a13SMasahiro Yamada__sub-make:
21425b146c5SMasahiro Yamada	$(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
2151da177e4SLinus Torvalds
216688931a5SMasahiro Yamadaendif # need-sub-make
217221cc2d2SMasahiro Yamadaendif # sub_make_done
218688931a5SMasahiro Yamada
2191da177e4SLinus Torvalds# We process the rest of the Makefile if this is the final invocation of make
220688931a5SMasahiro Yamadaifeq ($(need-sub-make),)
2211da177e4SLinus Torvalds
2227ff52571SMasahiro Yamada# Do not print "Entering directory ...",
2237ff52571SMasahiro Yamada# but we want to display it when entering to the output directory
2247ff52571SMasahiro Yamada# so that IDEs/editors are able to understand relative filenames.
2257ff52571SMasahiro YamadaMAKEFLAGS += --no-print-directory
2267ff52571SMasahiro Yamada
22725b146c5SMasahiro Yamadaifeq ($(abs_srctree),$(abs_objtree))
2289da0763bSMichal Marek        # building in the source tree
2299da0763bSMichal Marek        srctree := .
230051f278eSMasahiro Yamada	building_out_of_srctree :=
2319da0763bSMichal Marekelse
23225b146c5SMasahiro Yamada        ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
2339da0763bSMichal Marek                # building in a subdirectory of the source tree
2349da0763bSMichal Marek                srctree := ..
2359da0763bSMichal Marek        else
23625b146c5SMasahiro Yamada                srctree := $(abs_srctree)
2379da0763bSMichal Marek        endif
238051f278eSMasahiro Yamada	building_out_of_srctree := 1
2399da0763bSMichal Marekendif
2402c1f4f12SMasahiro Yamada
24195fd3f87SMasahiro Yamadaifneq ($(KBUILD_ABS_SRCTREE),)
24295fd3f87SMasahiro Yamadasrctree := $(abs_srctree)
24395fd3f87SMasahiro Yamadaendif
2442c1f4f12SMasahiro Yamada
2457e1c0477SMichal Marekobjtree		:= .
2466b12de69SMasahiro YamadaVPATH		:= $(srctree)
2471da177e4SLinus Torvalds
248051f278eSMasahiro Yamadaexport building_out_of_srctree srctree objtree VPATH
2491da177e4SLinus Torvalds
2502c1f4f12SMasahiro Yamada# To make sure we do not include .config for any of the *config targets
2512c1f4f12SMasahiro Yamada# catch them early, and hand them over to scripts/kconfig/Makefile
2522c1f4f12SMasahiro Yamada# It is allowed to specify more targets when calling make, including
2532c1f4f12SMasahiro Yamada# mixing *config targets and build targets.
2542c1f4f12SMasahiro Yamada# For example 'make oldconfig all'.
2552c1f4f12SMasahiro Yamada# Detect when mixed targets is specified, and make a second invocation
2562c1f4f12SMasahiro Yamada# of make so .config is not included in this case either (for *config).
2572c1f4f12SMasahiro Yamada
2582c1f4f12SMasahiro Yamadaversion_h := include/generated/uapi/linux/version.h
2592c1f4f12SMasahiro Yamada
26022340a06SMasahiro Yamadaclean-targets := %clean mrproper cleandocs
26122340a06SMasahiro Yamadano-dot-config-targets := $(clean-targets) \
2622c1f4f12SMasahiro Yamada			 cscope gtags TAGS tags help% %docs check% coccicheck \
26359b2bd05SMasahiro Yamada			 $(version_h) headers headers_% archheaders archscripts \
2644623980dSDavid Engraf			 %asm-generic kernelversion %src-pkg dt_binding_check \
2654623980dSDavid Engraf			 outputmakefile
266efbf9726SMasahiro Yamadano-sync-config-targets := $(no-dot-config-targets) %install kernelrelease
267394053f4SMasahiro Yamadasingle-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
2682c1f4f12SMasahiro Yamada
2692042b548SMasahiro Yamadaconfig-build	:=
2702042b548SMasahiro Yamadamixed-build	:=
2712042b548SMasahiro Yamadaneed-config	:= 1
2722042b548SMasahiro Yamadamay-sync-config	:= 1
273394053f4SMasahiro Yamadasingle-build	:=
2742c1f4f12SMasahiro Yamada
2752c1f4f12SMasahiro Yamadaifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
2762c1f4f12SMasahiro Yamada	ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
2772042b548SMasahiro Yamada		need-config :=
2782c1f4f12SMasahiro Yamada	endif
2792c1f4f12SMasahiro Yamadaendif
2802c1f4f12SMasahiro Yamada
281d7942413SMasahiro Yamadaifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
282d7942413SMasahiro Yamada	ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
2832042b548SMasahiro Yamada		may-sync-config :=
284d7942413SMasahiro Yamada	endif
285d7942413SMasahiro Yamadaendif
286d7942413SMasahiro Yamada
287d7942413SMasahiro Yamadaifneq ($(KBUILD_EXTMOD),)
2882042b548SMasahiro Yamada	may-sync-config :=
289d7942413SMasahiro Yamadaendif
290d7942413SMasahiro Yamada
2912c1f4f12SMasahiro Yamadaifeq ($(KBUILD_EXTMOD),)
292efbf9726SMasahiro Yamada        ifneq ($(filter %config,$(MAKECMDGOALS)),)
2932042b548SMasahiro Yamada		config-build := 1
2942c1f4f12SMasahiro Yamada                ifneq ($(words $(MAKECMDGOALS)),1)
2952042b548SMasahiro Yamada			mixed-build := 1
2962c1f4f12SMasahiro Yamada                endif
2972c1f4f12SMasahiro Yamada        endif
2982c1f4f12SMasahiro Yamadaendif
29922340a06SMasahiro Yamada
300394053f4SMasahiro Yamada# We cannot build single targets and the others at the same time
301394053f4SMasahiro Yamadaifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
302394053f4SMasahiro Yamada	single-build := 1
303394053f4SMasahiro Yamada	ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
304394053f4SMasahiro Yamada		mixed-build := 1
305394053f4SMasahiro Yamada	endif
306394053f4SMasahiro Yamadaendif
307394053f4SMasahiro Yamada
30822340a06SMasahiro Yamada# For "make -j clean all", "make -j mrproper defconfig all", etc.
30922340a06SMasahiro Yamadaifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
31022340a06SMasahiro Yamada        ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
3112042b548SMasahiro Yamada		mixed-build := 1
31222340a06SMasahiro Yamada        endif
31322340a06SMasahiro Yamadaendif
31422340a06SMasahiro Yamada
3152c1f4f12SMasahiro Yamada# install and modules_install need also be processed one by one
3162c1f4f12SMasahiro Yamadaifneq ($(filter install,$(MAKECMDGOALS)),)
3172c1f4f12SMasahiro Yamada        ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
3182042b548SMasahiro Yamada		mixed-build := 1
3192c1f4f12SMasahiro Yamada        endif
3202c1f4f12SMasahiro Yamadaendif
3212c1f4f12SMasahiro Yamada
3222042b548SMasahiro Yamadaifdef mixed-build
3232c1f4f12SMasahiro Yamada# ===========================================================================
3242c1f4f12SMasahiro Yamada# We're called with mixed targets (*config and build targets).
3252c1f4f12SMasahiro Yamada# Handle them one by one.
3262c1f4f12SMasahiro Yamada
3272c1f4f12SMasahiro YamadaPHONY += $(MAKECMDGOALS) __build_one_by_one
3282c1f4f12SMasahiro Yamada
329121c2a13SMasahiro Yamada$(MAKECMDGOALS): __build_one_by_one
3302c1f4f12SMasahiro Yamada	@:
3312c1f4f12SMasahiro Yamada
3322c1f4f12SMasahiro Yamada__build_one_by_one:
3332c1f4f12SMasahiro Yamada	$(Q)set -e; \
3342c1f4f12SMasahiro Yamada	for i in $(MAKECMDGOALS); do \
3352c1f4f12SMasahiro Yamada		$(MAKE) -f $(srctree)/Makefile $$i; \
3362c1f4f12SMasahiro Yamada	done
3372c1f4f12SMasahiro Yamada
3382042b548SMasahiro Yamadaelse # !mixed-build
3392c1f4f12SMasahiro Yamada
3402c1f4f12SMasahiro Yamadainclude scripts/Kbuild.include
3412c1f4f12SMasahiro Yamada
3422c1f4f12SMasahiro Yamada# Read KERNELRELEASE from include/config/kernel.release (if it exists)
3432c1f4f12SMasahiro YamadaKERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
3442c1f4f12SMasahiro YamadaKERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
3452c1f4f12SMasahiro Yamadaexport VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
3462c1f4f12SMasahiro Yamada
347b2d35fa5SAnders Roxellinclude scripts/subarch.include
3481da177e4SLinus Torvalds
3491da177e4SLinus Torvalds# Cross compiling and selecting different set of gcc/bin-utils
3501da177e4SLinus Torvalds# ---------------------------------------------------------------------------
3511da177e4SLinus Torvalds#
3521da177e4SLinus Torvalds# When performing cross compilation for other architectures ARCH shall be set
3531da177e4SLinus Torvalds# to the target architecture. (See arch/* for the possibilities).
3541da177e4SLinus Torvalds# ARCH can be set during invocation of make:
3551da177e4SLinus Torvalds# make ARCH=ia64
3561da177e4SLinus Torvalds# Another way is to have ARCH set in the environment.
3571da177e4SLinus Torvalds# The default ARCH is the host where make is executed.
3581da177e4SLinus Torvalds
3591da177e4SLinus Torvalds# CROSS_COMPILE specify the prefix used for all executables used
3601da177e4SLinus Torvalds# during compilation. Only gcc and related bin-utils executables
3611da177e4SLinus Torvalds# are prefixed with $(CROSS_COMPILE).
3621da177e4SLinus Torvalds# CROSS_COMPILE can be set on the command line
3631da177e4SLinus Torvalds# make CROSS_COMPILE=ia64-linux-
3641da177e4SLinus Torvalds# Alternatively CROSS_COMPILE can be set in the environment.
3651da177e4SLinus Torvalds# Default value for CROSS_COMPILE is not to prefix executables
3661da177e4SLinus Torvalds# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
3672331d1a6SSam RavnborgARCH		?= $(SUBARCH)
3681da177e4SLinus Torvalds
3691da177e4SLinus Torvalds# Architecture as present in compile.h
3706752ed90SThomas GleixnerUTS_MACHINE 	:= $(ARCH)
3716752ed90SThomas GleixnerSRCARCH 	:= $(ARCH)
3721da177e4SLinus Torvalds
373d746d647SSam Ravnborg# Additional ARCH settings for x86
374d746d647SSam Ravnborgifeq ($(ARCH),i386)
375d746d647SSam Ravnborg        SRCARCH := x86
376d746d647SSam Ravnborgendif
377d746d647SSam Ravnborgifeq ($(ARCH),x86_64)
378d746d647SSam Ravnborg        SRCARCH := x86
379d746d647SSam Ravnborgendif
38074b469f2SSam Ravnborg
3815e538790SSam Ravnborg# Additional ARCH settings for sparc
382e69f58c0SNamhyung Kimifeq ($(ARCH),sparc32)
383e69f58c0SNamhyung Kim       SRCARCH := sparc
384e69f58c0SNamhyung Kimendif
385a439fe51SSam Ravnborgifeq ($(ARCH),sparc64)
3865e538790SSam Ravnborg       SRCARCH := sparc
387a439fe51SSam Ravnborgendif
3882fb9b1bdSSam Ravnborg
3893cc000b5SPaul Mundt# Additional ARCH settings for sh
3903cc000b5SPaul Mundtifeq ($(ARCH),sh64)
3913cc000b5SPaul Mundt       SRCARCH := sh
3923cc000b5SPaul Mundtendif
3933cc000b5SPaul Mundt
39414cdd3c4SRoman ZippelKCONFIG_CONFIG	?= .config
39541263fc6SBen Gardinerexport KCONFIG_CONFIG
39614cdd3c4SRoman Zippel
3972a86f661SMasahiro Yamada# Default file for 'make defconfig'. This may be overridden by arch-Makefile.
3982a86f661SMasahiro Yamadaexport KBUILD_DEFCONFIG := defconfig
3992a86f661SMasahiro Yamada
4001da177e4SLinus Torvalds# SHELL used by kbuild
401858805b3SMasahiro YamadaCONFIG_SHELL := sh
4021da177e4SLinus Torvalds
4036d79a7b4SMasahiro YamadaHOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
4046d79a7b4SMasahiro YamadaHOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
4056d79a7b4SMasahiro YamadaHOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
406d7f14c66SUwe Kleine-König
407a0d1c951SMasahiro Yamadaifneq ($(LLVM),)
408a0d1c951SMasahiro YamadaHOSTCC	= clang
409a0d1c951SMasahiro YamadaHOSTCXX	= clang++
410a0d1c951SMasahiro Yamadaelse
411a0d1c951SMasahiro YamadaHOSTCC	= gcc
412a0d1c951SMasahiro YamadaHOSTCXX	= g++
413a0d1c951SMasahiro Yamadaendif
4147f3a59dbSMasahiro Yamada
4157f3a59dbSMasahiro Yamadaexport KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
4167f3a59dbSMasahiro Yamada			      -O2 -fomit-frame-pointer -std=gnu89
4177f3a59dbSMasahiro Yamadaexport KBUILD_USERLDFLAGS :=
4187f3a59dbSMasahiro Yamada
419