Makefile revision 2042b548
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
2bfeffd15SLinus TorvaldsVERSION = 5
35f9e832cSLinus TorvaldsPATCHLEVEL = 3
455922c9dSLinus TorvaldsSUBLEVEL = 0
5d45331b0SLinus TorvaldsEXTRAVERSION = -rc4
66fbc7275SLinus TorvaldsNAME = Bobtail Squid
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
14ba634eceSMasahiro Yamada# That's our default target when none is given on the command line
15ba634eceSMasahiro YamadaPHONY := _all
16ba634eceSMasahiro Yamada_all:
17ba634eceSMasahiro Yamada
181da177e4SLinus Torvalds# We are using a recursive build, so we need to do a little thinking
191da177e4SLinus Torvalds# to get the ordering right.
201da177e4SLinus Torvalds#
211da177e4SLinus Torvalds# Most importantly: sub-Makefiles should only ever modify files in
221da177e4SLinus Torvalds# their own directory. If in some directory we have a dependency on
231da177e4SLinus Torvalds# a file in another dir (which doesn't happen often, but it's often
24f49821eeSNicholas Piggin# unavoidable when linking the built-in.a targets which finally
251da177e4SLinus Torvalds# turn into vmlinux), we will call a sub make in that other dir, and
261da177e4SLinus Torvalds# after that we are sure that everything which is in that other dir
271da177e4SLinus Torvalds# is now up to date.
281da177e4SLinus Torvalds#
291da177e4SLinus Torvalds# The only cases where we need to modify files which have global
301da177e4SLinus Torvalds# effects are thus separated out and done before the recursive
311da177e4SLinus Torvalds# descending is started. They are now explicitly listed as the
321da177e4SLinus Torvalds# prepare rule.
331da177e4SLinus Torvalds
34221cc2d2SMasahiro Yamadaifneq ($(sub_make_done),1)
353812b8c5SMasahiro Yamada
363812b8c5SMasahiro Yamada# Do not use make's built-in rules and variables
373812b8c5SMasahiro Yamada# (this increases performance and avoids hard-to-debug behaviour)
383812b8c5SMasahiro YamadaMAKEFLAGS += -rR
393812b8c5SMasahiro Yamada
403812b8c5SMasahiro Yamada# Avoid funny character set dependencies
413812b8c5SMasahiro Yamadaunexport LC_ALL
423812b8c5SMasahiro YamadaLC_COLLATE=C
433812b8c5SMasahiro YamadaLC_NUMERIC=C
443812b8c5SMasahiro Yamadaexport LC_COLLATE LC_NUMERIC
453812b8c5SMasahiro Yamada
463812b8c5SMasahiro Yamada# Avoid interference with shell env settings
473812b8c5SMasahiro Yamadaunexport GREP_OPTIONS
483812b8c5SMasahiro Yamada
49066b7ed9SMichal Marek# Beautify output
50066b7ed9SMichal Marek# ---------------------------------------------------------------------------
51066b7ed9SMichal Marek#
52066b7ed9SMichal Marek# Normally, we echo the whole command before executing it. By making
53066b7ed9SMichal Marek# that echo $($(quiet)$(cmd)), we now have the possibility to set
54066b7ed9SMichal Marek# $(quiet) to choose other forms of output instead, e.g.
55066b7ed9SMichal Marek#
56066b7ed9SMichal Marek#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
57066b7ed9SMichal Marek#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
58066b7ed9SMichal Marek#
59066b7ed9SMichal Marek# If $(quiet) is empty, the whole command will be printed.
60066b7ed9SMichal Marek# If it is set to "quiet_", only the short version will be printed.
61066b7ed9SMichal Marek# If it is set to "silent_", nothing will be printed at all, since
62066b7ed9SMichal Marek# the variable $(silent_cmd_cc_o_c) doesn't exist.
63066b7ed9SMichal Marek#
64066b7ed9SMichal Marek# A simple variant is to prefix commands with $(Q) - that's useful
65066b7ed9SMichal Marek# for commands that shall be hidden in non-verbose mode.
66066b7ed9SMichal Marek#
67066b7ed9SMichal Marek#	$(Q)ln $@ :<
68066b7ed9SMichal Marek#
69066b7ed9SMichal Marek# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
70066b7ed9SMichal Marek# If KBUILD_VERBOSE equals 1 then the above command is displayed.
71066b7ed9SMichal Marek#
721da177e4SLinus Torvalds# To put more focus on warnings, be less verbose as default
731da177e4SLinus Torvalds# Use 'make V=1' to see the full commands
741da177e4SLinus Torvalds
75b8b0618cSCheng Renquanifeq ("$(origin V)", "command line")
76b8b0618cSCheng Renquan  KBUILD_VERBOSE = $(V)
771da177e4SLinus Torvaldsendif
781da177e4SLinus Torvaldsifndef KBUILD_VERBOSE
791da177e4SLinus Torvalds  KBUILD_VERBOSE = 0
801da177e4SLinus Torvaldsendif
811da177e4SLinus Torvalds
82066b7ed9SMichal Marekifeq ($(KBUILD_VERBOSE),1)
83066b7ed9SMichal Marek  quiet =
84066b7ed9SMichal Marek  Q =
85066b7ed9SMichal Marekelse
86066b7ed9SMichal Marek  quiet=quiet_
87066b7ed9SMichal Marek  Q = @
88066b7ed9SMichal Marekendif
89066b7ed9SMichal Marek
90066b7ed9SMichal Marek# If the user is running make -s (silent mode), suppress echoing of
91066b7ed9SMichal Marek# commands
92066b7ed9SMichal Marek
936f0fa58eSMasahiro Yamadaifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
94066b7ed9SMichal Marek  quiet=silent_
95066b7ed9SMichal Marekendif
96066b7ed9SMichal Marek
97066b7ed9SMichal Marekexport quiet Q KBUILD_VERBOSE
98066b7ed9SMichal Marek
9925b146c5SMasahiro Yamada# Kbuild will save output files in the current working directory.
10025b146c5SMasahiro Yamada# This does not need to match to the root of the kernel source tree.
10125b146c5SMasahiro Yamada#
10225b146c5SMasahiro Yamada# For example, you can do this:
10325b146c5SMasahiro Yamada#
10425b146c5SMasahiro Yamada#  cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
10525b146c5SMasahiro Yamada#
10625b146c5SMasahiro Yamada# If you want to save output files in a different location, there are
10725b146c5SMasahiro Yamada# two syntaxes to specify it.
10825b146c5SMasahiro Yamada#
1091da177e4SLinus Torvalds# 1) O=
1101da177e4SLinus Torvalds# Use "make O=dir/to/store/output/files/"
111070b98bfSSam Ravnborg#
1121da177e4SLinus Torvalds# 2) Set KBUILD_OUTPUT
11325b146c5SMasahiro Yamada# Set the environment variable KBUILD_OUTPUT to point to the output directory.
11425b146c5SMasahiro Yamada# export KBUILD_OUTPUT=dir/to/store/output/files/; make
1151da177e4SLinus Torvalds#
1161da177e4SLinus Torvalds# The O= assignment takes precedence over the KBUILD_OUTPUT environment
1171da177e4SLinus Torvalds# variable.
1181da177e4SLinus Torvalds
11925b146c5SMasahiro Yamada# Do we want to change the working directory?
120b8b0618cSCheng Renquanifeq ("$(origin O)", "command line")
121b8b0618cSCheng Renquan  KBUILD_OUTPUT := $(O)
1221da177e4SLinus Torvaldsendif
1231da177e4SLinus Torvalds
12425b146c5SMasahiro Yamadaifneq ($(KBUILD_OUTPUT),)
12525b146c5SMasahiro Yamada# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
12625b146c5SMasahiro Yamada# expand a shell special character '~'. We use a somewhat tedious way here.
12725b146c5SMasahiro Yamadaabs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
12825b146c5SMasahiro Yamada$(if $(abs_objtree),, \
12925b146c5SMasahiro Yamada     $(error failed to create output directory "$(KBUILD_OUTPUT)"))
13025b146c5SMasahiro Yamada
13125b146c5SMasahiro Yamada# $(realpath ...) resolves symlinks
13225b146c5SMasahiro Yamadaabs_objtree := $(realpath $(abs_objtree))
13325b146c5SMasahiro Yamadaelse
13425b146c5SMasahiro Yamadaabs_objtree := $(CURDIR)
13525b146c5SMasahiro Yamadaendif # ifneq ($(KBUILD_OUTPUT),)
13625b146c5SMasahiro Yamada
13725b146c5SMasahiro Yamadaifeq ($(abs_objtree),$(CURDIR))
13825b146c5SMasahiro Yamada# Suppress "Entering directory ..." unless we are changing the work directory.
13925b146c5SMasahiro YamadaMAKEFLAGS += --no-print-directory
14025b146c5SMasahiro Yamadaelse
14125b146c5SMasahiro Yamadaneed-sub-make := 1
14251193b76SRobert Jarzmikendif
14351193b76SRobert Jarzmik
14425b146c5SMasahiro Yamadaabs_srctree := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
1451da177e4SLinus Torvalds
14625b146c5SMasahiro Yamadaifneq ($(words $(subst :, ,$(abs_srctree))), 1)
14725b146c5SMasahiro Yamada$(error source directory cannot contain spaces or colons)
14825b146c5SMasahiro Yamadaendif
1491da177e4SLinus Torvalds
15025b146c5SMasahiro Yamadaifneq ($(abs_srctree),$(abs_objtree))
15180463f1bSMasahiro Yamada# Look for make include files relative to root of kernel src
15280463f1bSMasahiro Yamada#
15380463f1bSMasahiro Yamada# This does not become effective immediately because MAKEFLAGS is re-parsed
15425b146c5SMasahiro Yamada# once after the Makefile is read. We need to invoke sub-make.
15525b146c5SMasahiro YamadaMAKEFLAGS += --include-dir=$(abs_srctree)
156688931a5SMasahiro Yamadaneed-sub-make := 1
15725b146c5SMasahiro Yamadaendif
1583812b8c5SMasahiro Yamada
159688931a5SMasahiro Yamadaifneq ($(filter 3.%,$(MAKE_VERSION)),)
160688931a5SMasahiro Yamada# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
161688931a5SMasahiro Yamada# We need to invoke sub-make to avoid implicit rules in the top Makefile.
162688931a5SMasahiro Yamadaneed-sub-make := 1
163688931a5SMasahiro Yamada# Cancel implicit rules for this Makefile.
164688931a5SMasahiro Yamada$(lastword $(MAKEFILE_LIST)): ;
165688931a5SMasahiro Yamadaendif
166688931a5SMasahiro Yamada
16725b146c5SMasahiro Yamadaexport abs_srctree abs_objtree
168221cc2d2SMasahiro Yamadaexport sub_make_done := 1
169221cc2d2SMasahiro Yamada
170688931a5SMasahiro Yamadaifeq ($(need-sub-make),1)
171688931a5SMasahiro Yamada
1720b35786dSMilton MillerPHONY += $(MAKECMDGOALS) sub-make
1730b35786dSMilton Miller
1740209987fSMasahiro Yamada$(filter-out _all sub-make $(lastword $(MAKEFILE_LIST)), $(MAKECMDGOALS)) _all: sub-make
17516f89098SCharles Keepax	@:
1760b35786dSMilton Miller
177c4e6fff1SCao jin# Invoke a second make in the output directory, passing relevant variables
1782e8d696bSMasahiro Yamadasub-make:
17925b146c5SMasahiro Yamada	$(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
1801da177e4SLinus Torvalds
181688931a5SMasahiro Yamadaendif # need-sub-make
182221cc2d2SMasahiro Yamadaendif # sub_make_done
183688931a5SMasahiro Yamada
1841da177e4SLinus Torvalds# We process the rest of the Makefile if this is the final invocation of make
185688931a5SMasahiro Yamadaifeq ($(need-sub-make),)
1861da177e4SLinus Torvalds
1877ff52571SMasahiro Yamada# Do not print "Entering directory ...",
1887ff52571SMasahiro Yamada# but we want to display it when entering to the output directory
1897ff52571SMasahiro Yamada# so that IDEs/editors are able to understand relative filenames.
1907ff52571SMasahiro YamadaMAKEFLAGS += --no-print-directory
1917ff52571SMasahiro Yamada
192aa55c8e2SMasahiro Yamada# Call a source code checker (by default, "sparse") as part of the
193aa55c8e2SMasahiro Yamada# C compilation.
194aa55c8e2SMasahiro Yamada#
195aa55c8e2SMasahiro Yamada# Use 'make C=1' to enable checking of only re-compiled files.
196aa55c8e2SMasahiro Yamada# Use 'make C=2' to enable checking of *all* source files, regardless
197aa55c8e2SMasahiro Yamada# of whether they are re-compiled or not.
198aa55c8e2SMasahiro Yamada#
199036db11cSCao jin# See the file "Documentation/dev-tools/sparse.rst" for more details,
200036db11cSCao jin# including where to get the "sparse" utility.
201aa55c8e2SMasahiro Yamada
202aa55c8e2SMasahiro Yamadaifeq ("$(origin C)", "command line")
203aa55c8e2SMasahiro Yamada  KBUILD_CHECKSRC = $(C)
204aa55c8e2SMasahiro Yamadaendif
205aa55c8e2SMasahiro Yamadaifndef KBUILD_CHECKSRC
206aa55c8e2SMasahiro Yamada  KBUILD_CHECKSRC = 0
207aa55c8e2SMasahiro Yamadaendif
208aa55c8e2SMasahiro Yamada
209aa55c8e2SMasahiro Yamada# Use make M=dir to specify directory of external module to build
210aa55c8e2SMasahiro Yamada# Old syntax make ... SUBDIRS=$PWD is still supported
211aa55c8e2SMasahiro Yamada# Setting the environment variable KBUILD_EXTMOD take precedence
212aa55c8e2SMasahiro Yamadaifdef SUBDIRS
2130126be38SMasahiro Yamada  $(warning ================= WARNING ================)
2140126be38SMasahiro Yamada  $(warning 'SUBDIRS' will be removed after Linux 5.3)
2154e8fc3f5SMasahiro Yamada  $(warning )
2164e8fc3f5SMasahiro Yamada  $(warning If you are building an individual subdirectory)
2174e8fc3f5SMasahiro Yamada  $(warning in the kernel tree, you can do like this:)
2184e8fc3f5SMasahiro Yamada  $(warning $$ make path/to/dir/you/want/to/build/)
2194e8fc3f5SMasahiro Yamada  $(warning (Do not forget the trailing slash))
2204e8fc3f5SMasahiro Yamada  $(warning )
2214e8fc3f5SMasahiro Yamada  $(warning If you are building an external module,)
2220126be38SMasahiro Yamada  $(warning Please use 'M=' or 'KBUILD_EXTMOD' instead)
2230126be38SMasahiro Yamada  $(warning ==========================================)
224aa55c8e2SMasahiro Yamada  KBUILD_EXTMOD ?= $(SUBDIRS)
225aa55c8e2SMasahiro Yamadaendif
226aa55c8e2SMasahiro Yamada
227aa55c8e2SMasahiro Yamadaifeq ("$(origin M)", "command line")
228aa55c8e2SMasahiro Yamada  KBUILD_EXTMOD := $(M)
229aa55c8e2SMasahiro Yamadaendif
230aa55c8e2SMasahiro Yamada
231051f278eSMasahiro Yamadaexport KBUILD_CHECKSRC KBUILD_EXTMOD
232051f278eSMasahiro 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 Yamadaold_version_h := include/linux/version.h
2662c1f4f12SMasahiro Yamada
26722340a06SMasahiro Yamadaclean-targets := %clean mrproper cleandocs
26822340a06SMasahiro Yamadano-dot-config-targets := $(clean-targets) \
2692c1f4f12SMasahiro Yamada			 cscope gtags TAGS tags help% %docs check% coccicheck \
27059b2bd05SMasahiro Yamada			 $(version_h) headers headers_% archheaders archscripts \
27163e31a67SMasahiro Yamada			 %asm-generic kernelversion %src-pkg
272a29d4d8cSMasahiro Yamadano-sync-config-targets := $(no-dot-config-targets) install %install \
273a29d4d8cSMasahiro Yamada			   kernelrelease
2742c1f4f12SMasahiro Yamada
2752042b548SMasahiro Yamadaconfig-build	:=
2762042b548SMasahiro Yamadamixed-build	:=
2772042b548SMasahiro Yamadaneed-config	:= 1
2782042b548SMasahiro Yamadamay-sync-config	:= 1
2792c1f4f12SMasahiro Yamada
2802c1f4f12SMasahiro Yamadaifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
2812c1f4f12SMasahiro Yamada	ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
2822042b548SMasahiro Yamada		need-config :=
2832c1f4f12SMasahiro Yamada	endif
2842c1f4f12SMasahiro Yamadaendif
2852c1f4f12SMasahiro Yamada
286d7942413SMasahiro Yamadaifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
287d7942413SMasahiro Yamada	ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
2882042b548SMasahiro Yamada		may-sync-config :=
289d7942413SMasahiro Yamada	endif
290d7942413SMasahiro Yamadaendif
291d7942413SMasahiro Yamada
292d7942413SMasahiro Yamadaifneq ($(KBUILD_EXTMOD),)
2932042b548SMasahiro Yamada	may-sync-config :=
294d7942413SMasahiro Yamadaendif
295d7942413SMasahiro Yamada
2962c1f4f12SMasahiro Yamadaifeq ($(KBUILD_EXTMOD),)
2972c1f4f12SMasahiro Yamada        ifneq ($(filter config %config,$(MAKECMDGOALS)),)
2982042b548SMasahiro Yamada		config-build := 1
2992c1f4f12SMasahiro Yamada                ifneq ($(words $(MAKECMDGOALS)),1)
3002042b548SMasahiro Yamada			mixed-build := 1
3012c1f4f12SMasahiro Yamada                endif
3022c1f4f12SMasahiro Yamada        endif
3032c1f4f12SMasahiro Yamadaendif
30422340a06SMasahiro Yamada
30522340a06SMasahiro Yamada# For "make -j clean all", "make -j mrproper defconfig all", etc.
30622340a06SMasahiro Yamadaifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
30722340a06SMasahiro Yamada        ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
3082042b548SMasahiro Yamada		mixed-build := 1
30922340a06SMasahiro Yamada        endif
31022340a06SMasahiro Yamadaendif
31122340a06SMasahiro Yamada
3122c1f4f12SMasahiro Yamada# install and modules_install need also be processed one by one
3132c1f4f12SMasahiro Yamadaifneq ($(filter install,$(MAKECMDGOALS)),)
3142c1f4f12SMasahiro Yamada        ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
3152042b548SMasahiro Yamada		mixed-build := 1
3162c1f4f12SMasahiro Yamada        endif
3172c1f4f12SMasahiro Yamadaendif
3182c1f4f12SMasahiro Yamada
3192042b548SMasahiro Yamadaifdef mixed-build
3202c1f4f12SMasahiro Yamada# ===========================================================================
3212c1f4f12SMasahiro Yamada# We're called with mixed targets (*config and build targets).
3222c1f4f12SMasahiro Yamada# Handle them one by one.
3232c1f4f12SMasahiro Yamada
3242c1f4f12SMasahiro YamadaPHONY += $(MAKECMDGOALS) __build_one_by_one
3252c1f4f12SMasahiro Yamada
3262c1f4f12SMasahiro Yamada$(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one
3272c1f4f12SMasahiro Yamada	@:
3282c1f4f12SMasahiro Yamada
3292c1f4f12SMasahiro Yamada__build_one_by_one:
3302c1f4f12SMasahiro Yamada	$(Q)set -e; \
3312c1f4f12SMasahiro Yamada	for i in $(MAKECMDGOALS); do \
3322c1f4f12SMasahiro Yamada		$(MAKE) -f $(srctree)/Makefile $$i; \
3332c1f4f12SMasahiro Yamada	done
3342c1f4f12SMasahiro Yamada
3352042b548SMasahiro Yamadaelse # !mixed-build
3362c1f4f12SMasahiro Yamada
3372c1f4f12SMasahiro Yamadainclude scripts/Kbuild.include
3382c1f4f12SMasahiro Yamada
3392c1f4f12SMasahiro Yamada# Read KERNELRELEASE from include/config/kernel.release (if it exists)
3402c1f4f12SMasahiro YamadaKERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
3412c1f4f12SMasahiro YamadaKERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
3422c1f4f12SMasahiro Yamadaexport VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
3432c1f4f12SMasahiro Yamada
344b2d35fa5SAnders Roxellinclude scripts/subarch.include
3451da177e4SLinus Torvalds
3461da177e4SLinus Torvalds# Cross compiling and selecting different set of gcc/bin-utils
3471da177e4SLinus Torvalds# ---------------------------------------------------------------------------
3481da177e4SLinus Torvalds#
3491da177e4SLinus Torvalds# When performing cross compilation for other architectures ARCH shall be set
3501da177e4SLinus Torvalds# to the target architecture. (See arch/* for the possibilities).
3511da177e4SLinus Torvalds# ARCH can be set during invocation of make:
3521da177e4SLinus Torvalds# make ARCH=ia64
3531da177e4SLinus Torvalds# Another way is to have ARCH set in the environment.
3541da177e4SLinus Torvalds# The default ARCH is the host where make is executed.
3551da177e4SLinus Torvalds
3561da177e4SLinus Torvalds# CROSS_COMPILE specify the prefix used for all executables used
3571da177e4SLinus Torvalds# during compilation. Only gcc and related bin-utils executables
3581da177e4SLinus Torvalds# are prefixed with $(CROSS_COMPILE).
3591da177e4SLinus Torvalds# CROSS_COMPILE can be set on the command line
3601da177e4SLinus Torvalds# make CROSS_COMPILE=ia64-linux-
3611da177e4SLinus Torvalds# Alternatively CROSS_COMPILE can be set in the environment.
3621da177e4SLinus Torvalds# Default value for CROSS_COMPILE is not to prefix executables
3631da177e4SLinus Torvalds# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
3642331d1a6SSam RavnborgARCH		?= $(SUBARCH)
3651da177e4SLinus Torvalds
3661da177e4SLinus Torvalds# Architecture as present in compile.h
3676752ed90SThomas GleixnerUTS_MACHINE 	:= $(ARCH)
3686752ed90SThomas GleixnerSRCARCH 	:= $(ARCH)
3691da177e4SLinus Torvalds
370d746d647SSam Ravnborg# Additional ARCH settings for x86
371d746d647SSam Ravnborgifeq ($(ARCH),i386)
372d746d647SSam Ravnborg        SRCARCH := x86
373d746d647SSam Ravnborgendif
374d746d647SSam Ravnborgifeq ($(ARCH),x86_64)
375d746d647SSam Ravnborg        SRCARCH := x86
376d746d647SSam Ravnborgendif
37774b469f2SSam Ravnborg
3785e538790SSam Ravnborg# Additional ARCH settings for sparc
379e69f58c0SNamhyung Kimifeq ($(ARCH),sparc32)
380e69f58c0SNamhyung Kim       SRCARCH := sparc
381e69f58c0SNamhyung Kimendif
382a439fe51SSam Ravnborgifeq ($(ARCH),sparc64)
3835e538790SSam Ravnborg       SRCARCH := sparc
384a439fe51SSam Ravnborgendif
3852fb9b1bdSSam Ravnborg
3863cc000b5SPaul Mundt# Additional ARCH settings for sh
3873cc000b5SPaul Mundtifeq ($(ARCH),sh64)
3883cc000b5SPaul Mundt       SRCARCH := sh
3893cc000b5SPaul Mundtendif
3903cc000b5SPaul Mundt
39114cdd3c4SRoman ZippelKCONFIG_CONFIG	?= .config
39241263fc6SBen Gardinerexport KCONFIG_CONFIG
39314cdd3c4SRoman Zippel
3941da177e4SLinus Torvalds# SHELL used by kbuild
3951da177e4SLinus TorvaldsCONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
3961da177e4SLinus Torvalds	  else if [ -x /bin/bash ]; then echo /bin/bash; \
3971da177e4SLinus Torvalds	  else echo sh; fi ; fi)
3981da177e4SLinus Torvalds
3996d79a7b4SMasahiro YamadaHOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
4006d79a7b4SMasahiro YamadaHOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
4016d79a7b4SMasahiro YamadaHOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
402d7f14c66SUwe Kleine-König
403070b98bfSSam RavnborgHOSTCC       = gcc
404070b98bfSSam RavnborgHOSTCXX      = g++
40596f14fe7SLaura AbbottKBUILD_HOSTCFLAGS   := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
406f92d19e0SLaura Abbott		-fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
407f92d19e0SLaura Abbott		$(HOSTCFLAGS)
408f92d19e0SLaura AbbottKBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
409f92d19e0SLaura AbbottKBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
410f92d19e0SLaura AbbottKBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
4111da177e4SLinus Torvalds
4121da177e4SLinus Torvalds# Make variables (CC, etc...)
4131da177e4SLinus TorvaldsAS		= $(CROSS_COMPILE)as
4141da177e4SLinus TorvaldsLD		= $(CROSS_COMPILE)ld
4151da177e4SLinus TorvaldsCC		= $(CROSS_COMPILE)gcc
4161da177e4SLinus TorvaldsCPP		= $(CC) -E
4171da177e4SLinus TorvaldsAR		= $(CROSS_COMPILE)ar
4181da177e4SLinus TorvaldsNM		= $(CROSS_COMPILE)nm
4191da177e4SLinus TorvaldsSTRIP		= $(CROSS_COMPILE)strip
4201da177e4SLinus TorvaldsOBJCOPY		= $(CROSS_COMPILE)objcopy
4211da177e4SLinus TorvaldsOBJDUMP		= $(CROSS_COMPILE)objdump
4227bac9870SVasily GorbikOBJSIZE		= $(CROSS_COMPILE)size
423e83b9f55SAndrii NakryikoPAHOLE		= pahole
42473a4f6dbSMasahiro YamadaLEX		= flex
42573a4f6dbSMasahiro YamadaYACC		= bison
4261da177e4SLinus TorvaldsAWK		= awk
427caa27b66SSam RavnborgINSTALLKERNEL  := installkernel
4281da177e4SLinus TorvaldsDEPMOD		= /sbin/depmod
4291da177e4SLinus TorvaldsPERL		= perl
430011bf125SMasahiro YamadaPYTHON		= python
431e9781b52SMasahiro YamadaPYTHON2		= python2
432e9781b52SMasahiro YamadaPYTHON3		= python3
4331da177e4SLinus TorvaldsCHECK		= sparse
4341da177e4SLinus Torvalds
43580a7d1d9SHannes EderCHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
4366c49f359SLuc Van Oostenryck		  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
4370c22be07SDouglas AndersonNOSTDINC_FLAGS :=
4386588169dSSam RavnborgCFLAGS_MODULE   =
4396588169dSSam RavnborgAFLAGS_MODULE   =
4406588169dSSam RavnborgLDFLAGS_MODULE  =
4411da177e4SLinus TorvaldsCFLAGS_KERNEL	=
4421da177e4SLinus TorvaldsAFLAGS_KERNEL	=
443b36fad65SMichal MarekLDFLAGS_vmlinux =
4441da177e4SLinus Torvalds
445abbf1590SDavid Howells# Use USERINCLUDE when you must reference the UAPI directories only.
446abbf1590SDavid HowellsUSERINCLUDE    := \
4479d022c54SMasahiro Yamada		-I$(srctree)/arch/$(SRCARCH)/include/uapi \
4489d022c54SMasahiro Yamada		-I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
449