18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ciVERSION = 5
38c2ecf20Sopenharmony_ciPATCHLEVEL = 10
48c2ecf20Sopenharmony_ciSUBLEVEL = 210
58c2ecf20Sopenharmony_ciEXTRAVERSION =
68c2ecf20Sopenharmony_ciNAME = Dare mighty things
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci# *DOCUMENTATION*
98c2ecf20Sopenharmony_ci# To see a list of typical targets execute "make help"
108c2ecf20Sopenharmony_ci# More info can be located in ./README
118c2ecf20Sopenharmony_ci# Comments in this file are targeted only to the developer, do not
128c2ecf20Sopenharmony_ci# expect to learn how to build the kernel reading this file.
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci$(if $(filter __%, $(MAKECMDGOALS)), \
158c2ecf20Sopenharmony_ci	$(error targets prefixed with '__' are only for internal use))
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci# That's our default target when none is given on the command line
188c2ecf20Sopenharmony_ciPHONY := __all
198c2ecf20Sopenharmony_ci__all:
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci# We are using a recursive build, so we need to do a little thinking
228c2ecf20Sopenharmony_ci# to get the ordering right.
238c2ecf20Sopenharmony_ci#
248c2ecf20Sopenharmony_ci# Most importantly: sub-Makefiles should only ever modify files in
258c2ecf20Sopenharmony_ci# their own directory. If in some directory we have a dependency on
268c2ecf20Sopenharmony_ci# a file in another dir (which doesn't happen often, but it's often
278c2ecf20Sopenharmony_ci# unavoidable when linking the built-in.a targets which finally
288c2ecf20Sopenharmony_ci# turn into vmlinux), we will call a sub make in that other dir, and
298c2ecf20Sopenharmony_ci# after that we are sure that everything which is in that other dir
308c2ecf20Sopenharmony_ci# is now up to date.
318c2ecf20Sopenharmony_ci#
328c2ecf20Sopenharmony_ci# The only cases where we need to modify files which have global
338c2ecf20Sopenharmony_ci# effects are thus separated out and done before the recursive
348c2ecf20Sopenharmony_ci# descending is started. They are now explicitly listed as the
358c2ecf20Sopenharmony_ci# prepare rule.
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ciifneq ($(sub_make_done),1)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci# Do not use make's built-in rules and variables
408c2ecf20Sopenharmony_ci# (this increases performance and avoids hard-to-debug behaviour)
418c2ecf20Sopenharmony_ciMAKEFLAGS += -rR
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci# Avoid funny character set dependencies
448c2ecf20Sopenharmony_ciunexport LC_ALL
458c2ecf20Sopenharmony_ciLC_COLLATE=C
468c2ecf20Sopenharmony_ciLC_NUMERIC=C
478c2ecf20Sopenharmony_ciexport LC_COLLATE LC_NUMERIC
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci# Avoid interference with shell env settings
508c2ecf20Sopenharmony_ciunexport GREP_OPTIONS
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci# Beautify output
538c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
548c2ecf20Sopenharmony_ci#
558c2ecf20Sopenharmony_ci# Normally, we echo the whole command before executing it. By making
568c2ecf20Sopenharmony_ci# that echo $($(quiet)$(cmd)), we now have the possibility to set
578c2ecf20Sopenharmony_ci# $(quiet) to choose other forms of output instead, e.g.
588c2ecf20Sopenharmony_ci#
598c2ecf20Sopenharmony_ci#         quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@
608c2ecf20Sopenharmony_ci#         cmd_cc_o_c       = $(CC) $(c_flags) -c -o $@ $<
618c2ecf20Sopenharmony_ci#
628c2ecf20Sopenharmony_ci# If $(quiet) is empty, the whole command will be printed.
638c2ecf20Sopenharmony_ci# If it is set to "quiet_", only the short version will be printed.
648c2ecf20Sopenharmony_ci# If it is set to "silent_", nothing will be printed at all, since
658c2ecf20Sopenharmony_ci# the variable $(silent_cmd_cc_o_c) doesn't exist.
668c2ecf20Sopenharmony_ci#
678c2ecf20Sopenharmony_ci# A simple variant is to prefix commands with $(Q) - that's useful
688c2ecf20Sopenharmony_ci# for commands that shall be hidden in non-verbose mode.
698c2ecf20Sopenharmony_ci#
708c2ecf20Sopenharmony_ci#	$(Q)ln $@ :<
718c2ecf20Sopenharmony_ci#
728c2ecf20Sopenharmony_ci# If KBUILD_VERBOSE equals 0 then the above command will be hidden.
738c2ecf20Sopenharmony_ci# If KBUILD_VERBOSE equals 1 then the above command is displayed.
748c2ecf20Sopenharmony_ci# If KBUILD_VERBOSE equals 2 then give the reason why each target is rebuilt.
758c2ecf20Sopenharmony_ci#
768c2ecf20Sopenharmony_ci# To put more focus on warnings, be less verbose as default
778c2ecf20Sopenharmony_ci# Use 'make V=1' to see the full commands
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ciifeq ("$(origin V)", "command line")
808c2ecf20Sopenharmony_ci  KBUILD_VERBOSE = $(V)
818c2ecf20Sopenharmony_ciendif
828c2ecf20Sopenharmony_ciifndef KBUILD_VERBOSE
838c2ecf20Sopenharmony_ci  KBUILD_VERBOSE = 0
848c2ecf20Sopenharmony_ciendif
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciifeq ($(KBUILD_VERBOSE),1)
878c2ecf20Sopenharmony_ci  quiet =
888c2ecf20Sopenharmony_ci  Q =
898c2ecf20Sopenharmony_cielse
908c2ecf20Sopenharmony_ci  quiet=quiet_
918c2ecf20Sopenharmony_ci  Q = @
928c2ecf20Sopenharmony_ciendif
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci# If the user is running make -s (silent mode), suppress echoing of
958c2ecf20Sopenharmony_ci# commands
968c2ecf20Sopenharmony_ci# make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS.
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ciifeq ($(filter 3.%,$(MAKE_VERSION)),)
998c2ecf20Sopenharmony_cisilence:=$(findstring s,$(firstword -$(MAKEFLAGS)))
1008c2ecf20Sopenharmony_cielse
1018c2ecf20Sopenharmony_cisilence:=$(findstring s,$(filter-out --%,$(MAKEFLAGS)))
1028c2ecf20Sopenharmony_ciendif
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ciifeq ($(silence),s)
1058c2ecf20Sopenharmony_ciquiet=silent_
1068c2ecf20Sopenharmony_ciendif
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ciexport quiet Q KBUILD_VERBOSE
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci# Kbuild will save output files in the current working directory.
1118c2ecf20Sopenharmony_ci# This does not need to match to the root of the kernel source tree.
1128c2ecf20Sopenharmony_ci#
1138c2ecf20Sopenharmony_ci# For example, you can do this:
1148c2ecf20Sopenharmony_ci#
1158c2ecf20Sopenharmony_ci#  cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile
1168c2ecf20Sopenharmony_ci#
1178c2ecf20Sopenharmony_ci# If you want to save output files in a different location, there are
1188c2ecf20Sopenharmony_ci# two syntaxes to specify it.
1198c2ecf20Sopenharmony_ci#
1208c2ecf20Sopenharmony_ci# 1) O=
1218c2ecf20Sopenharmony_ci# Use "make O=dir/to/store/output/files/"
1228c2ecf20Sopenharmony_ci#
1238c2ecf20Sopenharmony_ci# 2) Set KBUILD_OUTPUT
1248c2ecf20Sopenharmony_ci# Set the environment variable KBUILD_OUTPUT to point to the output directory.
1258c2ecf20Sopenharmony_ci# export KBUILD_OUTPUT=dir/to/store/output/files/; make
1268c2ecf20Sopenharmony_ci#
1278c2ecf20Sopenharmony_ci# The O= assignment takes precedence over the KBUILD_OUTPUT environment
1288c2ecf20Sopenharmony_ci# variable.
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci# Do we want to change the working directory?
1318c2ecf20Sopenharmony_ciifeq ("$(origin O)", "command line")
1328c2ecf20Sopenharmony_ci  KBUILD_OUTPUT := $(O)
1338c2ecf20Sopenharmony_ciendif
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ciifneq ($(KBUILD_OUTPUT),)
1368c2ecf20Sopenharmony_ci# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
1378c2ecf20Sopenharmony_ci# expand a shell special character '~'. We use a somewhat tedious way here.
1388c2ecf20Sopenharmony_ciabs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
1398c2ecf20Sopenharmony_ci$(if $(abs_objtree),, \
1408c2ecf20Sopenharmony_ci     $(error failed to create output directory "$(KBUILD_OUTPUT)"))
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci# $(realpath ...) resolves symlinks
1438c2ecf20Sopenharmony_ciabs_objtree := $(realpath $(abs_objtree))
1448c2ecf20Sopenharmony_cielse
1458c2ecf20Sopenharmony_ciabs_objtree := $(CURDIR)
1468c2ecf20Sopenharmony_ciendif # ifneq ($(KBUILD_OUTPUT),)
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ciifeq ($(abs_objtree),$(CURDIR))
1498c2ecf20Sopenharmony_ci# Suppress "Entering directory ..." unless we are changing the work directory.
1508c2ecf20Sopenharmony_ciMAKEFLAGS += --no-print-directory
1518c2ecf20Sopenharmony_cielse
1528c2ecf20Sopenharmony_cineed-sub-make := 1
1538c2ecf20Sopenharmony_ciendif
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ciabs_srctree := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ciifneq ($(words $(subst :, ,$(abs_srctree))), 1)
1588c2ecf20Sopenharmony_ci$(error source directory cannot contain spaces or colons)
1598c2ecf20Sopenharmony_ciendif
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ciifneq ($(abs_srctree),$(abs_objtree))
1628c2ecf20Sopenharmony_ci# Look for make include files relative to root of kernel src
1638c2ecf20Sopenharmony_ci#
1648c2ecf20Sopenharmony_ci# This does not become effective immediately because MAKEFLAGS is re-parsed
1658c2ecf20Sopenharmony_ci# once after the Makefile is read. We need to invoke sub-make.
1668c2ecf20Sopenharmony_ciMAKEFLAGS += --include-dir=$(abs_srctree)
1678c2ecf20Sopenharmony_cineed-sub-make := 1
1688c2ecf20Sopenharmony_ciendif
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_cithis-makefile := $(lastword $(MAKEFILE_LIST))
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ciifneq ($(filter 3.%,$(MAKE_VERSION)),)
1738c2ecf20Sopenharmony_ci# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
1748c2ecf20Sopenharmony_ci# We need to invoke sub-make to avoid implicit rules in the top Makefile.
1758c2ecf20Sopenharmony_cineed-sub-make := 1
1768c2ecf20Sopenharmony_ci# Cancel implicit rules for this Makefile.
1778c2ecf20Sopenharmony_ci$(this-makefile): ;
1788c2ecf20Sopenharmony_ciendif
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ciexport abs_srctree abs_objtree
1818c2ecf20Sopenharmony_ciexport sub_make_done := 1
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ciifeq ($(need-sub-make),1)
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ciPHONY += $(MAKECMDGOALS) __sub-make
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci$(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make
1888c2ecf20Sopenharmony_ci	@:
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci# Invoke a second make in the output directory, passing relevant variables
1918c2ecf20Sopenharmony_ci__sub-make:
1928c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS)
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ciendif # need-sub-make
1958c2ecf20Sopenharmony_ciendif # sub_make_done
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci# We process the rest of the Makefile if this is the final invocation of make
1988c2ecf20Sopenharmony_ciifeq ($(need-sub-make),)
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci# Do not print "Entering directory ...",
2018c2ecf20Sopenharmony_ci# but we want to display it when entering to the output directory
2028c2ecf20Sopenharmony_ci# so that IDEs/editors are able to understand relative filenames.
2038c2ecf20Sopenharmony_ciMAKEFLAGS += --no-print-directory
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci# Call a source code checker (by default, "sparse") as part of the
2068c2ecf20Sopenharmony_ci# C compilation.
2078c2ecf20Sopenharmony_ci#
2088c2ecf20Sopenharmony_ci# Use 'make C=1' to enable checking of only re-compiled files.
2098c2ecf20Sopenharmony_ci# Use 'make C=2' to enable checking of *all* source files, regardless
2108c2ecf20Sopenharmony_ci# of whether they are re-compiled or not.
2118c2ecf20Sopenharmony_ci#
2128c2ecf20Sopenharmony_ci# See the file "Documentation/dev-tools/sparse.rst" for more details,
2138c2ecf20Sopenharmony_ci# including where to get the "sparse" utility.
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ciifeq ("$(origin C)", "command line")
2168c2ecf20Sopenharmony_ci  KBUILD_CHECKSRC = $(C)
2178c2ecf20Sopenharmony_ciendif
2188c2ecf20Sopenharmony_ciifndef KBUILD_CHECKSRC
2198c2ecf20Sopenharmony_ci  KBUILD_CHECKSRC = 0
2208c2ecf20Sopenharmony_ciendif
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci# Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the
2238c2ecf20Sopenharmony_ci# directory of external module to build. Setting M= takes precedence.
2248c2ecf20Sopenharmony_ciifeq ("$(origin M)", "command line")
2258c2ecf20Sopenharmony_ci  KBUILD_EXTMOD := $(M)
2268c2ecf20Sopenharmony_ciendif
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci$(if $(word 2, $(KBUILD_EXTMOD)), \
2298c2ecf20Sopenharmony_ci	$(error building multiple external modules is not supported))
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ciexport KBUILD_CHECKSRC KBUILD_EXTMOD
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ciextmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ciifeq ($(abs_srctree),$(abs_objtree))
2368c2ecf20Sopenharmony_ci        # building in the source tree
2378c2ecf20Sopenharmony_ci        srctree := .
2388c2ecf20Sopenharmony_ci	building_out_of_srctree :=
2398c2ecf20Sopenharmony_cielse
2408c2ecf20Sopenharmony_ci        ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
2418c2ecf20Sopenharmony_ci                # building in a subdirectory of the source tree
2428c2ecf20Sopenharmony_ci                srctree := ..
2438c2ecf20Sopenharmony_ci        else
2448c2ecf20Sopenharmony_ci                srctree := $(abs_srctree)
2458c2ecf20Sopenharmony_ci        endif
2468c2ecf20Sopenharmony_ci	building_out_of_srctree := 1
2478c2ecf20Sopenharmony_ciendif
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ciifneq ($(KBUILD_ABS_SRCTREE),)
2508c2ecf20Sopenharmony_cisrctree := $(abs_srctree)
2518c2ecf20Sopenharmony_ciendif
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ciobjtree		:= .
2548c2ecf20Sopenharmony_ciVPATH		:= $(srctree)
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ciexport building_out_of_srctree srctree objtree VPATH
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci# To make sure we do not include .config for any of the *config targets
2598c2ecf20Sopenharmony_ci# catch them early, and hand them over to scripts/kconfig/Makefile
2608c2ecf20Sopenharmony_ci# It is allowed to specify more targets when calling make, including
2618c2ecf20Sopenharmony_ci# mixing *config targets and build targets.
2628c2ecf20Sopenharmony_ci# For example 'make oldconfig all'.
2638c2ecf20Sopenharmony_ci# Detect when mixed targets is specified, and make a second invocation
2648c2ecf20Sopenharmony_ci# of make so .config is not included in this case either (for *config).
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_civersion_h := include/generated/uapi/linux/version.h
2678c2ecf20Sopenharmony_ciold_version_h := include/linux/version.h
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ciclean-targets := %clean mrproper cleandocs
2708c2ecf20Sopenharmony_cino-dot-config-targets := $(clean-targets) \
2718c2ecf20Sopenharmony_ci			 cscope gtags TAGS tags help% %docs check% coccicheck \
2728c2ecf20Sopenharmony_ci			 $(version_h) headers headers_% archheaders archscripts \
2738c2ecf20Sopenharmony_ci			 %asm-generic kernelversion %src-pkg dt_binding_check \
2748c2ecf20Sopenharmony_ci			 outputmakefile
2758c2ecf20Sopenharmony_cino-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \
2768c2ecf20Sopenharmony_ci			  image_name
2778c2ecf20Sopenharmony_cisingle-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ciconfig-build	:=
2808c2ecf20Sopenharmony_cimixed-build	:=
2818c2ecf20Sopenharmony_cineed-config	:= 1
2828c2ecf20Sopenharmony_cimay-sync-config	:= 1
2838c2ecf20Sopenharmony_cisingle-build	:=
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ciifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
2868c2ecf20Sopenharmony_ci	ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
2878c2ecf20Sopenharmony_ci		need-config :=
2888c2ecf20Sopenharmony_ci	endif
2898c2ecf20Sopenharmony_ciendif
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ciifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
2928c2ecf20Sopenharmony_ci	ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
2938c2ecf20Sopenharmony_ci		may-sync-config :=
2948c2ecf20Sopenharmony_ci	endif
2958c2ecf20Sopenharmony_ciendif
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ciifneq ($(KBUILD_EXTMOD),)
2988c2ecf20Sopenharmony_ci	may-sync-config :=
2998c2ecf20Sopenharmony_ciendif
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ciifeq ($(KBUILD_EXTMOD),)
3028c2ecf20Sopenharmony_ci        ifneq ($(filter %config,$(MAKECMDGOALS)),)
3038c2ecf20Sopenharmony_ci		config-build := 1
3048c2ecf20Sopenharmony_ci                ifneq ($(words $(MAKECMDGOALS)),1)
3058c2ecf20Sopenharmony_ci			mixed-build := 1
3068c2ecf20Sopenharmony_ci                endif
3078c2ecf20Sopenharmony_ci        endif
3088c2ecf20Sopenharmony_ciendif
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci# We cannot build single targets and the others at the same time
3118c2ecf20Sopenharmony_ciifneq ($(filter $(single-targets), $(MAKECMDGOALS)),)
3128c2ecf20Sopenharmony_ci	single-build := 1
3138c2ecf20Sopenharmony_ci	ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),)
3148c2ecf20Sopenharmony_ci		mixed-build := 1
3158c2ecf20Sopenharmony_ci	endif
3168c2ecf20Sopenharmony_ciendif
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci# For "make -j clean all", "make -j mrproper defconfig all", etc.
3198c2ecf20Sopenharmony_ciifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),)
3208c2ecf20Sopenharmony_ci        ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),)
3218c2ecf20Sopenharmony_ci		mixed-build := 1
3228c2ecf20Sopenharmony_ci        endif
3238c2ecf20Sopenharmony_ciendif
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci# install and modules_install need also be processed one by one
3268c2ecf20Sopenharmony_ciifneq ($(filter install,$(MAKECMDGOALS)),)
3278c2ecf20Sopenharmony_ci        ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
3288c2ecf20Sopenharmony_ci		mixed-build := 1
3298c2ecf20Sopenharmony_ci        endif
3308c2ecf20Sopenharmony_ciendif
3318c2ecf20Sopenharmony_ci
3328c2ecf20Sopenharmony_ciifdef mixed-build
3338c2ecf20Sopenharmony_ci# ===========================================================================
3348c2ecf20Sopenharmony_ci# We're called with mixed targets (*config and build targets).
3358c2ecf20Sopenharmony_ci# Handle them one by one.
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_ciPHONY += $(MAKECMDGOALS) __build_one_by_one
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci$(MAKECMDGOALS): __build_one_by_one
3408c2ecf20Sopenharmony_ci	@:
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci__build_one_by_one:
3438c2ecf20Sopenharmony_ci	$(Q)set -e; \
3448c2ecf20Sopenharmony_ci	for i in $(MAKECMDGOALS); do \
3458c2ecf20Sopenharmony_ci		$(MAKE) -f $(srctree)/Makefile $$i; \
3468c2ecf20Sopenharmony_ci	done
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_cielse # !mixed-build
3498c2ecf20Sopenharmony_ci
3508c2ecf20Sopenharmony_ciinclude scripts/Kbuild.include
3518c2ecf20Sopenharmony_ci
3528c2ecf20Sopenharmony_ci# Read KERNELRELEASE from include/config/kernel.release (if it exists)
3538c2ecf20Sopenharmony_ciKERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
3548c2ecf20Sopenharmony_ciKERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
3558c2ecf20Sopenharmony_ciexport VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ciinclude scripts/subarch.include
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_ci# Cross compiling and selecting different set of gcc/bin-utils
3608c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
3618c2ecf20Sopenharmony_ci#
3628c2ecf20Sopenharmony_ci# When performing cross compilation for other architectures ARCH shall be set
3638c2ecf20Sopenharmony_ci# to the target architecture. (See arch/* for the possibilities).
3648c2ecf20Sopenharmony_ci# ARCH can be set during invocation of make:
3658c2ecf20Sopenharmony_ci# make ARCH=ia64
3668c2ecf20Sopenharmony_ci# Another way is to have ARCH set in the environment.
3678c2ecf20Sopenharmony_ci# The default ARCH is the host where make is executed.
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ci# CROSS_COMPILE specify the prefix used for all executables used
3708c2ecf20Sopenharmony_ci# during compilation. Only gcc and related bin-utils executables
3718c2ecf20Sopenharmony_ci# are prefixed with $(CROSS_COMPILE).
3728c2ecf20Sopenharmony_ci# CROSS_COMPILE can be set on the command line
3738c2ecf20Sopenharmony_ci# make CROSS_COMPILE=ia64-linux-
3748c2ecf20Sopenharmony_ci# Alternatively CROSS_COMPILE can be set in the environment.
3758c2ecf20Sopenharmony_ci# Default value for CROSS_COMPILE is not to prefix executables
3768c2ecf20Sopenharmony_ci# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
3778c2ecf20Sopenharmony_ciARCH		?= $(SUBARCH)
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci# Architecture as present in compile.h
3808c2ecf20Sopenharmony_ciUTS_MACHINE 	:= $(ARCH)
3818c2ecf20Sopenharmony_ciSRCARCH 	:= $(ARCH)
3828c2ecf20Sopenharmony_ci
3838c2ecf20Sopenharmony_ci# Additional ARCH settings for x86
3848c2ecf20Sopenharmony_ciifeq ($(ARCH),i386)
3858c2ecf20Sopenharmony_ci        SRCARCH := x86
3868c2ecf20Sopenharmony_ciendif
3878c2ecf20Sopenharmony_ciifeq ($(ARCH),x86_64)
3888c2ecf20Sopenharmony_ci        SRCARCH := x86
3898c2ecf20Sopenharmony_ciendif
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci# Additional ARCH settings for sparc
3928c2ecf20Sopenharmony_ciifeq ($(ARCH),sparc32)
3938c2ecf20Sopenharmony_ci       SRCARCH := sparc
3948c2ecf20Sopenharmony_ciendif
3958c2ecf20Sopenharmony_ciifeq ($(ARCH),sparc64)
3968c2ecf20Sopenharmony_ci       SRCARCH := sparc
3978c2ecf20Sopenharmony_ciendif
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_ci# Additional ARCH settings for sh
4008c2ecf20Sopenharmony_ciifeq ($(ARCH),sh64)
4018c2ecf20Sopenharmony_ci       SRCARCH := sh
4028c2ecf20Sopenharmony_ciendif
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ciKCONFIG_CONFIG	?= .config
4058c2ecf20Sopenharmony_ciexport KCONFIG_CONFIG
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_ci# Default file for 'make defconfig'. This may be overridden by arch-Makefile.
4088c2ecf20Sopenharmony_ciexport KBUILD_DEFCONFIG := defconfig
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ci# SHELL used by kbuild
4118c2ecf20Sopenharmony_ciCONFIG_SHELL := sh
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ciHOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null)
4148c2ecf20Sopenharmony_ciHOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null)
4158c2ecf20Sopenharmony_ciHOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null)
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ciifneq ($(LLVM),)
4188c2ecf20Sopenharmony_ciHOSTCC	= clang
4198c2ecf20Sopenharmony_ciHOSTCXX	= clang++
4208c2ecf20Sopenharmony_cielse
4218c2ecf20Sopenharmony_ciHOSTCC	= gcc
4228c2ecf20Sopenharmony_ciHOSTCXX	= g++
4238c2ecf20Sopenharmony_ciendif
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_ciexport KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
4268c2ecf20Sopenharmony_ci			      -O2 -fomit-frame-pointer -std=gnu89
4278c2ecf20Sopenharmony_ciexport KBUILD_USERLDFLAGS :=
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_ciKBUILD_HOSTCFLAGS   := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS)
4308c2ecf20Sopenharmony_ciKBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
4318c2ecf20Sopenharmony_ciKBUILD_HOSTLDFLAGS  := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
4328c2ecf20Sopenharmony_ciKBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ci# Make variables (CC, etc...)
4358c2ecf20Sopenharmony_ciCPP		= $(CC) -E
4368c2ecf20Sopenharmony_ciCCACHE          = ccache
4378c2ecf20Sopenharmony_ciifneq ($(LLVM),)
4388c2ecf20Sopenharmony_ciCC		= $(CCACHE) clang
4398c2ecf20Sopenharmony_ciLD		= ld.lld
4408c2ecf20Sopenharmony_ciAR		= llvm-ar
4418c2ecf20Sopenharmony_ciNM		= llvm-nm
4428c2ecf20Sopenharmony_ciOBJCOPY		= llvm-objcopy
4438c2ecf20Sopenharmony_ciOBJDUMP		= llvm-objdump
4448c2ecf20Sopenharmony_ciREADELF		= llvm-readelf
4458c2ecf20Sopenharmony_ciSTRIP		= llvm-strip
4468c2ecf20Sopenharmony_cielse
4478c2ecf20Sopenharmony_ciCC		= $(CCACHE) $(CROSS_COMPILE)gcc
4488c2ecf20Sopenharmony_ciLD		= $(CROSS_COMPILE)ld
4498c2ecf20Sopenharmony_ciAR		= $(CROSS_COMPILE)ar
4508c2ecf20Sopenharmony_ciNM		= $(CROSS_COMPILE)nm
4518c2ecf20Sopenharmony_ciOBJCOPY		= $(CROSS_COMPILE)objcopy
4528c2ecf20Sopenharmony_ciOBJDUMP		= $(CROSS_COMPILE)objdump
4538c2ecf20Sopenharmony_ciREADELF		= $(CROSS_COMPILE)readelf
4548c2ecf20Sopenharmony_ciSTRIP		= $(CROSS_COMPILE)strip
4558c2ecf20Sopenharmony_ciendif
4568c2ecf20Sopenharmony_ciPAHOLE		= pahole
4578c2ecf20Sopenharmony_ciRESOLVE_BTFIDS	= $(objtree)/tools/bpf/resolve_btfids/resolve_btfids
4588c2ecf20Sopenharmony_ciLEX		= flex
4598c2ecf20Sopenharmony_ciYACC		= bison
4608c2ecf20Sopenharmony_ciAWK		= awk
4618c2ecf20Sopenharmony_ciINSTALLKERNEL  := installkernel
4628c2ecf20Sopenharmony_ciDEPMOD		= depmod
4638c2ecf20Sopenharmony_ciPERL		= perl
4648c2ecf20Sopenharmony_ciPYTHON		= python
4658c2ecf20Sopenharmony_ciPYTHON3		= python3
4668c2ecf20Sopenharmony_ciCHECK		= sparse
4678c2ecf20Sopenharmony_ciBASH		= bash
4688c2ecf20Sopenharmony_ciKGZIP		= gzip
4698c2ecf20Sopenharmony_ciKBZIP2		= bzip2
4708c2ecf20Sopenharmony_ciKLZOP		= lzop
4718c2ecf20Sopenharmony_ciLZMA		= lzma
4728c2ecf20Sopenharmony_ciLZ4		= lz4c
4738c2ecf20Sopenharmony_ciXZ		= xz
4748c2ecf20Sopenharmony_ciZSTD		= zstd
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ciPAHOLE_FLAGS	= $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh)
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_ciCHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
4798c2ecf20Sopenharmony_ci		  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
4808c2ecf20Sopenharmony_ciNOSTDINC_FLAGS :=
4818c2ecf20Sopenharmony_ciCFLAGS_MODULE   =
4828c2ecf20Sopenharmony_ciAFLAGS_MODULE   =
4838c2ecf20Sopenharmony_ciLDFLAGS_MODULE  =
4848c2ecf20Sopenharmony_ciCFLAGS_KERNEL	=
4858c2ecf20Sopenharmony_ciAFLAGS_KERNEL	=
4868c2ecf20Sopenharmony_ciLDFLAGS_vmlinux =
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_ci# Use USERINCLUDE when you must reference the UAPI directories only.
4898c2ecf20Sopenharmony_ciUSERINCLUDE    := \
4908c2ecf20Sopenharmony_ci		-I$(srctree)/arch/$(SRCARCH)/include/uapi \
4918c2ecf20Sopenharmony_ci		-I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \
4928c2ecf20Sopenharmony_ci		-I$(srctree)/include/uapi \
4938c2ecf20Sopenharmony_ci		-I$(objtree)/include/generated/uapi \
4948c2ecf20Sopenharmony_ci                -include $(srctree)/include/linux/kconfig.h
4958c2ecf20Sopenharmony_ci
4968c2ecf20Sopenharmony_ci# Use LINUXINCLUDE when you must reference the include/ directory.
4978c2ecf20Sopenharmony_ci# Needed to be compatible with the O= option
4988c2ecf20Sopenharmony_ciLINUXINCLUDE    := \
4998c2ecf20Sopenharmony_ci		-I$(srctree)/arch/$(SRCARCH)/include \
5008c2ecf20Sopenharmony_ci		-I$(objtree)/arch/$(SRCARCH)/include/generated \
5018c2ecf20Sopenharmony_ci		$(if $(building_out_of_srctree),-I$(srctree)/include) \
5028c2ecf20Sopenharmony_ci		-I$(objtree)/include \
5038c2ecf20Sopenharmony_ci		$(USERINCLUDE)
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_ciKBUILD_AFLAGS   := -D__ASSEMBLY__ -fno-PIE
5068c2ecf20Sopenharmony_ciKBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
5078c2ecf20Sopenharmony_ci		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
5088c2ecf20Sopenharmony_ci		   -Werror=implicit-function-declaration -Werror=implicit-int \
5098c2ecf20Sopenharmony_ci		   -Werror=return-type -Wno-format-security \
5108c2ecf20Sopenharmony_ci		   -std=gnu89
5118c2ecf20Sopenharmony_ciKBUILD_CPPFLAGS := -D__KERNEL__
5128c2ecf20Sopenharmony_ciKBUILD_AFLAGS_KERNEL :=
5138c2ecf20Sopenharmony_ciKBUILD_CFLAGS_KERNEL :=
5148c2ecf20Sopenharmony_ciKBUILD_AFLAGS_MODULE  := -DMODULE
5158c2ecf20Sopenharmony_ciKBUILD_CFLAGS_MODULE  := -DMODULE
5168c2ecf20Sopenharmony_ciKBUILD_LDFLAGS_MODULE :=
5178c2ecf20Sopenharmony_ciKBUILD_LDFLAGS :=
5188c2ecf20Sopenharmony_ciCLANG_FLAGS :=
5198c2ecf20Sopenharmony_ci
5208c2ecf20Sopenharmony_ciexport ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
5218c2ecf20Sopenharmony_ciexport CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL
5228c2ecf20Sopenharmony_ciexport PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
5238c2ecf20Sopenharmony_ciexport KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD
5248c2ecf20Sopenharmony_ciexport KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_ciexport KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
5278c2ecf20Sopenharmony_ciexport KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
5288c2ecf20Sopenharmony_ciexport KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
5298c2ecf20Sopenharmony_ciexport KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
5308c2ecf20Sopenharmony_ciexport KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
5318c2ecf20Sopenharmony_ciexport PAHOLE_FLAGS
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_ci# Files to ignore in find ... statements
5348c2ecf20Sopenharmony_ci
5358c2ecf20Sopenharmony_ciexport RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o    \
5368c2ecf20Sopenharmony_ci			  -name CVS -o -name .pc -o -name .hg -o -name .git \) \
5378c2ecf20Sopenharmony_ci			  -prune -o
5388c2ecf20Sopenharmony_ciexport RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
5398c2ecf20Sopenharmony_ci			 --exclude CVS --exclude .pc --exclude .hg --exclude .git
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ci# ===========================================================================
5428c2ecf20Sopenharmony_ci# Rules shared between *config targets and build targets
5438c2ecf20Sopenharmony_ci
5448c2ecf20Sopenharmony_ci# Basic helpers built in scripts/basic/
5458c2ecf20Sopenharmony_ciPHONY += scripts_basic
5468c2ecf20Sopenharmony_ciscripts_basic:
5478c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=scripts/basic
5488c2ecf20Sopenharmony_ci	$(Q)rm -f .tmp_quiet_recordmcount
5498c2ecf20Sopenharmony_ci
5508c2ecf20Sopenharmony_ciPHONY += outputmakefile
5518c2ecf20Sopenharmony_ci# Before starting out-of-tree build, make sure the source tree is clean.
5528c2ecf20Sopenharmony_ci# outputmakefile generates a Makefile in the output directory, if using a
5538c2ecf20Sopenharmony_ci# separate output directory. This allows convenient use of make in the
5548c2ecf20Sopenharmony_ci# output directory.
5558c2ecf20Sopenharmony_ci# At the same time when output Makefile generated, generate .gitignore to
5568c2ecf20Sopenharmony_ci# ignore whole output directory
5578c2ecf20Sopenharmony_cioutputmakefile:
5588c2ecf20Sopenharmony_ciifdef building_out_of_srctree
5598c2ecf20Sopenharmony_ci	$(Q)if [ -f $(srctree)/.config -o \
5608c2ecf20Sopenharmony_ci		 -d $(srctree)/include/config -o \
5618c2ecf20Sopenharmony_ci		 -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \
5628c2ecf20Sopenharmony_ci		echo >&2 "***"; \
5638c2ecf20Sopenharmony_ci		echo >&2 "*** The source tree is not clean, please run 'make$(if $(findstring command line, $(origin ARCH)), ARCH=$(ARCH)) mrproper'"; \
5648c2ecf20Sopenharmony_ci		echo >&2 "*** in $(abs_srctree)";\
5658c2ecf20Sopenharmony_ci		echo >&2 "***"; \
5668c2ecf20Sopenharmony_ci		false; \
5678c2ecf20Sopenharmony_ci	fi
5688c2ecf20Sopenharmony_ci	$(Q)ln -fsn $(srctree) source
5698c2ecf20Sopenharmony_ci	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
5708c2ecf20Sopenharmony_ci	$(Q)test -e .gitignore || \
5718c2ecf20Sopenharmony_ci	{ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
5728c2ecf20Sopenharmony_ciendif
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_ciifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
5758c2ecf20Sopenharmony_ciinclude $(srctree)/scripts/Makefile.clang
5768c2ecf20Sopenharmony_ciendif
5778c2ecf20Sopenharmony_ci
5788c2ecf20Sopenharmony_ci# The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
5798c2ecf20Sopenharmony_ci# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
5808c2ecf20Sopenharmony_ci# CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
5818c2ecf20Sopenharmony_ci# and from include/config/auto.conf.cmd to detect the compiler upgrade.
5828c2ecf20Sopenharmony_ciCC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1)
5838c2ecf20Sopenharmony_ci
5848c2ecf20Sopenharmony_ciifdef config-build
5858c2ecf20Sopenharmony_ci# ===========================================================================
5868c2ecf20Sopenharmony_ci# *config targets only - make sure prerequisites are updated, and descend
5878c2ecf20Sopenharmony_ci# in scripts/kconfig to make the *config target
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_ci# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed.
5908c2ecf20Sopenharmony_ci# KBUILD_DEFCONFIG may point out an alternative default configuration
5918c2ecf20Sopenharmony_ci# used for 'make defconfig'
5928c2ecf20Sopenharmony_ciinclude arch/$(SRCARCH)/Makefile
5938c2ecf20Sopenharmony_ciexport KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT
5948c2ecf20Sopenharmony_ci
5958c2ecf20Sopenharmony_ciconfig: outputmakefile scripts_basic FORCE
5968c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=scripts/kconfig $@
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_ci%config: outputmakefile scripts_basic FORCE
5998c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=scripts/kconfig $@
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_cielse #!config-build
6028c2ecf20Sopenharmony_ci# ===========================================================================
6038c2ecf20Sopenharmony_ci# Build targets only - this includes vmlinux, arch specific targets, clean
6048c2ecf20Sopenharmony_ci# targets and others. In general all targets except *config targets.
6058c2ecf20Sopenharmony_ci
6068c2ecf20Sopenharmony_ci# If building an external module we do not care about the all: rule
6078c2ecf20Sopenharmony_ci# but instead __all depend on modules
6088c2ecf20Sopenharmony_ciPHONY += all
6098c2ecf20Sopenharmony_ciifeq ($(KBUILD_EXTMOD),)
6108c2ecf20Sopenharmony_ci__all: all
6118c2ecf20Sopenharmony_cielse
6128c2ecf20Sopenharmony_ci__all: modules
6138c2ecf20Sopenharmony_ciendif
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ci# Decide whether to build built-in, modular, or both.
6168c2ecf20Sopenharmony_ci# Normally, just do built-in.
6178c2ecf20Sopenharmony_ci
6188c2ecf20Sopenharmony_ciKBUILD_MODULES :=
6198c2ecf20Sopenharmony_ciKBUILD_BUILTIN := 1
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ci# If we have only "make modules", don't compile built-in objects.
6228c2ecf20Sopenharmony_ciifeq ($(MAKECMDGOALS),modules)
6238c2ecf20Sopenharmony_ci  KBUILD_BUILTIN :=
6248c2ecf20Sopenharmony_ciendif
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_ci# If we have "make <whatever> modules", compile modules
6278c2ecf20Sopenharmony_ci# in addition to whatever we do anyway.
6288c2ecf20Sopenharmony_ci# Just "make" or "make all" shall build modules as well
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ciifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECMDGOALS)),)
6318c2ecf20Sopenharmony_ci  KBUILD_MODULES := 1
6328c2ecf20Sopenharmony_ciendif
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_ciifeq ($(MAKECMDGOALS),)
6358c2ecf20Sopenharmony_ci  KBUILD_MODULES := 1
6368c2ecf20Sopenharmony_ciendif
6378c2ecf20Sopenharmony_ci
6388c2ecf20Sopenharmony_ciexport KBUILD_MODULES KBUILD_BUILTIN
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_ciifdef need-config
6418c2ecf20Sopenharmony_ciinclude include/config/auto.conf
6428c2ecf20Sopenharmony_ciendif
6438c2ecf20Sopenharmony_ci
6448c2ecf20Sopenharmony_ciifeq ($(KBUILD_EXTMOD),)
6458c2ecf20Sopenharmony_ci# Objects we will link into vmlinux / subdirs we need to visit
6468c2ecf20Sopenharmony_cicore-y		:= init/ usr/
6478c2ecf20Sopenharmony_cidrivers-y	:= drivers/ sound/
6488c2ecf20Sopenharmony_cidrivers-$(CONFIG_SAMPLES) += samples/
6498c2ecf20Sopenharmony_cidrivers-y	+= net/ virt/
6508c2ecf20Sopenharmony_cilibs-y		:= lib/
6518c2ecf20Sopenharmony_civendor-$(CONFIG_OHOS_VENDOR) := vendor/
6528c2ecf20Sopenharmony_ciendif # KBUILD_EXTMOD
6538c2ecf20Sopenharmony_ci
6548c2ecf20Sopenharmony_ci# The all: target is the default when no target is given on the
6558c2ecf20Sopenharmony_ci# command line.
6568c2ecf20Sopenharmony_ci# This allow a user to issue only 'make' to build a kernel including modules
6578c2ecf20Sopenharmony_ci# Defaults to vmlinux, but the arch makefile usually adds further targets
6588c2ecf20Sopenharmony_ciall: vmlinux
6598c2ecf20Sopenharmony_ci
6608c2ecf20Sopenharmony_ciCFLAGS_GCOV	:= -fprofile-arcs -ftest-coverage \
6618c2ecf20Sopenharmony_ci	$(call cc-option,-fno-tree-loop-im) \
6628c2ecf20Sopenharmony_ci	$(call cc-disable-warning,maybe-uninitialized,)
6638c2ecf20Sopenharmony_ciexport CFLAGS_GCOV
6648c2ecf20Sopenharmony_ci
6658c2ecf20Sopenharmony_ci# The arch Makefiles can override CC_FLAGS_FTRACE. We may also append it later.
6668c2ecf20Sopenharmony_ciifdef CONFIG_FUNCTION_TRACER
6678c2ecf20Sopenharmony_ci  CC_FLAGS_FTRACE := -pg
6688c2ecf20Sopenharmony_ciendif
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ciifdef CONFIG_CC_IS_GCC
6718c2ecf20Sopenharmony_ciRETPOLINE_CFLAGS	:= $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register)
6728c2ecf20Sopenharmony_ciRETPOLINE_CFLAGS	+= $(call cc-option,-mindirect-branch-cs-prefix)
6738c2ecf20Sopenharmony_ciRETPOLINE_VDSO_CFLAGS	:= $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register)
6748c2ecf20Sopenharmony_ciendif
6758c2ecf20Sopenharmony_ciifdef CONFIG_CC_IS_CLANG
6768c2ecf20Sopenharmony_ciRETPOLINE_CFLAGS	:= -mretpoline-external-thunk
6778c2ecf20Sopenharmony_ciRETPOLINE_VDSO_CFLAGS	:= -mretpoline
6788c2ecf20Sopenharmony_ciendif
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ciifdef CONFIG_RETHUNK
6818c2ecf20Sopenharmony_ciRETHUNK_CFLAGS         := -mfunction-return=thunk-extern
6828c2ecf20Sopenharmony_ciRETPOLINE_CFLAGS       += $(RETHUNK_CFLAGS)
6838c2ecf20Sopenharmony_ciendif
6848c2ecf20Sopenharmony_ci
6858c2ecf20Sopenharmony_ciexport RETPOLINE_CFLAGS
6868c2ecf20Sopenharmony_ciexport RETPOLINE_VDSO_CFLAGS
6878c2ecf20Sopenharmony_ci
6888c2ecf20Sopenharmony_ciinclude arch/$(SRCARCH)/Makefile
6898c2ecf20Sopenharmony_ci
6908c2ecf20Sopenharmony_ciifdef need-config
6918c2ecf20Sopenharmony_ciifdef may-sync-config
6928c2ecf20Sopenharmony_ci# Read in dependencies to all Kconfig* files, make sure to run syncconfig if
6938c2ecf20Sopenharmony_ci# changes are detected. This should be included after arch/$(SRCARCH)/Makefile
6948c2ecf20Sopenharmony_ci# because some architectures define CROSS_COMPILE there.
6958c2ecf20Sopenharmony_ciinclude include/config/auto.conf.cmd
6968c2ecf20Sopenharmony_ci
6978c2ecf20Sopenharmony_ci$(KCONFIG_CONFIG):
6988c2ecf20Sopenharmony_ci	@echo >&2 '***'
6998c2ecf20Sopenharmony_ci	@echo >&2 '*** Configuration file "$@" not found!'
7008c2ecf20Sopenharmony_ci	@echo >&2 '***'
7018c2ecf20Sopenharmony_ci	@echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or'
7028c2ecf20Sopenharmony_ci	@echo >&2 '*** "make menuconfig" or "make xconfig").'
7038c2ecf20Sopenharmony_ci	@echo >&2 '***'
7048c2ecf20Sopenharmony_ci	@/bin/false
7058c2ecf20Sopenharmony_ci
7068c2ecf20Sopenharmony_ci# The actual configuration files used during the build are stored in
7078c2ecf20Sopenharmony_ci# include/generated/ and include/config/. Update them if .config is newer than
7088c2ecf20Sopenharmony_ci# include/config/auto.conf (which mirrors .config).
7098c2ecf20Sopenharmony_ci#
7108c2ecf20Sopenharmony_ci# This exploits the 'multi-target pattern rule' trick.
7118c2ecf20Sopenharmony_ci# The syncconfig should be executed only once to make all the targets.
7128c2ecf20Sopenharmony_ci# (Note: use the grouped target '&:' when we bump to GNU Make 4.3)
7138c2ecf20Sopenharmony_ci#
7148c2ecf20Sopenharmony_ci# Do not use $(call cmd,...) here. That would suppress prompts from syncconfig,
7158c2ecf20Sopenharmony_ci# so you cannot notice that Kconfig is waiting for the user input.
7168c2ecf20Sopenharmony_ci%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h: $(KCONFIG_CONFIG)
7178c2ecf20Sopenharmony_ci	$(Q)$(kecho) "  SYNC    $@"
7188c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
7198c2ecf20Sopenharmony_cielse # !may-sync-config
7208c2ecf20Sopenharmony_ci# External modules and some install targets need include/generated/autoconf.h
7218c2ecf20Sopenharmony_ci# and include/config/auto.conf but do not care if they are up-to-date.
7228c2ecf20Sopenharmony_ci# Use auto.conf to trigger the test
7238c2ecf20Sopenharmony_ciPHONY += include/config/auto.conf
7248c2ecf20Sopenharmony_ci
7258c2ecf20Sopenharmony_ciinclude/config/auto.conf:
7268c2ecf20Sopenharmony_ci	$(Q)test -e include/generated/autoconf.h -a -e $@ || (		\
7278c2ecf20Sopenharmony_ci	echo >&2;							\
7288c2ecf20Sopenharmony_ci	echo >&2 "  ERROR: Kernel configuration is invalid.";		\
7298c2ecf20Sopenharmony_ci	echo >&2 "         include/generated/autoconf.h or $@ are missing.";\
7308c2ecf20Sopenharmony_ci	echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";	\
7318c2ecf20Sopenharmony_ci	echo >&2 ;							\
7328c2ecf20Sopenharmony_ci	/bin/false)
7338c2ecf20Sopenharmony_ci
7348c2ecf20Sopenharmony_ciendif # may-sync-config
7358c2ecf20Sopenharmony_ciendif # need-config
7368c2ecf20Sopenharmony_ci
7378c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= $(call cc-option,-fno-delete-null-pointer-checks,)
7388c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= $(call cc-disable-warning,frame-address,)
7398c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= $(call cc-disable-warning, format-truncation)
7408c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= $(call cc-disable-warning, format-overflow)
7418c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= $(call cc-disable-warning, address-of-packed-member)
7428c2ecf20Sopenharmony_ci
7438c2ecf20Sopenharmony_ciifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
7448c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -O2
7458c2ecf20Sopenharmony_cielse ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
7468c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -O3
7478c2ecf20Sopenharmony_cielse ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
7488c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Os
7498c2ecf20Sopenharmony_ciendif
7508c2ecf20Sopenharmony_ci
7518c2ecf20Sopenharmony_ci# Tell gcc to never replace conditional load with a non-conditional one
7528c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= $(call cc-option,--param=allow-store-data-races=0)
7538c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= $(call cc-option,-fno-allow-store-data-races)
7548c2ecf20Sopenharmony_ci
7558c2ecf20Sopenharmony_ciifdef CONFIG_READABLE_ASM
7568c2ecf20Sopenharmony_ci# Disable optimizations that make assembler listings hard to read.
7578c2ecf20Sopenharmony_ci# reorder blocks reorders the control in the function
7588c2ecf20Sopenharmony_ci# ipa clone creates specialized cloned functions
7598c2ecf20Sopenharmony_ci# partial inlining inlines only parts of functions
7608c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
7618c2ecf20Sopenharmony_ci                 $(call cc-option,-fno-ipa-cp-clone,) \
7628c2ecf20Sopenharmony_ci                 $(call cc-option,-fno-partial-inlining)
7638c2ecf20Sopenharmony_ciendif
7648c2ecf20Sopenharmony_ci
7658c2ecf20Sopenharmony_ciifneq ($(CONFIG_FRAME_WARN),0)
7668c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
7678c2ecf20Sopenharmony_ciendif
7688c2ecf20Sopenharmony_ci
7698c2ecf20Sopenharmony_cistackp-flags-y                                    := -fno-stack-protector
7708c2ecf20Sopenharmony_cistackp-flags-$(CONFIG_STACKPROTECTOR)             := -fstack-protector
7718c2ecf20Sopenharmony_cistackp-flags-$(CONFIG_STACKPROTECTOR_STRONG)      := -fstack-protector-strong
7728c2ecf20Sopenharmony_ci
7738c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(stackp-flags-y)
7748c2ecf20Sopenharmony_ci
7758c2ecf20Sopenharmony_ciifdef CONFIG_CC_IS_CLANG
7768c2ecf20Sopenharmony_ciKBUILD_CPPFLAGS += -Qunused-arguments
7778c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-format-invalid-specifier
7788c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-gnu
7798c2ecf20Sopenharmony_ci# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the
7808c2ecf20Sopenharmony_ci# source of a reference will be _MergedGlobals and not on of the whitelisted names.
7818c2ecf20Sopenharmony_ci# See modpost pattern 2
7828c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -mno-global-merge
7838c2ecf20Sopenharmony_cielse
7848c2ecf20Sopenharmony_ci
7858c2ecf20Sopenharmony_ci# Warn about unmarked fall-throughs in switch statement.
7868c2ecf20Sopenharmony_ci# Disabled for clang while comment to attribute conversion happens and
7878c2ecf20Sopenharmony_ci# https://github.com/ClangBuiltLinux/linux/issues/636 is discussed.
7888c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)
7898c2ecf20Sopenharmony_ciendif
7908c2ecf20Sopenharmony_ci
7918c2ecf20Sopenharmony_ci# These warnings generated too much noise in a regular build.
7928c2ecf20Sopenharmony_ci# Use make W=1 to enable them (see scripts/Makefile.extrawarn)
7938c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
7968c2ecf20Sopenharmony_ci
7978c2ecf20Sopenharmony_ci# These result in bogus false positives
7988c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer)
7998c2ecf20Sopenharmony_ci
8008c2ecf20Sopenharmony_ciifdef CONFIG_FRAME_POINTER
8018c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
8028c2ecf20Sopenharmony_cielse
8038c2ecf20Sopenharmony_ci# Some targets (ARM with Thumb2, for example), can't be built with frame
8048c2ecf20Sopenharmony_ci# pointers.  For those, we don't have FUNCTION_TRACER automatically
8058c2ecf20Sopenharmony_ci# select FRAME_POINTER.  However, FUNCTION_TRACER adds -pg, and this is
8068c2ecf20Sopenharmony_ci# incompatible with -fomit-frame-pointer with current GCC, so we don't use
8078c2ecf20Sopenharmony_ci# -fomit-frame-pointer with FUNCTION_TRACER.
8088c2ecf20Sopenharmony_ciifndef CONFIG_FUNCTION_TRACER
8098c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -fomit-frame-pointer
8108c2ecf20Sopenharmony_ciendif
8118c2ecf20Sopenharmony_ciendif
8128c2ecf20Sopenharmony_ci
8138c2ecf20Sopenharmony_ci# Initialize all stack variables with a 0xAA pattern.
8148c2ecf20Sopenharmony_ciifdef CONFIG_INIT_STACK_ALL_PATTERN
8158c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -ftrivial-auto-var-init=pattern
8168c2ecf20Sopenharmony_ciendif
8178c2ecf20Sopenharmony_ci
8188c2ecf20Sopenharmony_ci# Initialize all stack variables with a zero value.
8198c2ecf20Sopenharmony_ciifdef CONFIG_INIT_STACK_ALL_ZERO
8208c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -ftrivial-auto-var-init=zero
8218c2ecf20Sopenharmony_ciifdef CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO_ENABLER
8228c2ecf20Sopenharmony_ci# https://github.com/llvm/llvm-project/issues/44842
8238c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
8248c2ecf20Sopenharmony_ciendif
8258c2ecf20Sopenharmony_ciendif
8268c2ecf20Sopenharmony_ci
8278c2ecf20Sopenharmony_ciDEBUG_CFLAGS	:=
8288c2ecf20Sopenharmony_ci
8298c2ecf20Sopenharmony_ci# Workaround for GCC versions < 5.0
8308c2ecf20Sopenharmony_ci# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801
8318c2ecf20Sopenharmony_ciifdef CONFIG_CC_IS_GCC
8328c2ecf20Sopenharmony_ciDEBUG_CFLAGS	+= $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments))
8338c2ecf20Sopenharmony_ciendif
8348c2ecf20Sopenharmony_ci
8358c2ecf20Sopenharmony_ciifdef CONFIG_DEBUG_INFO
8368c2ecf20Sopenharmony_ci
8378c2ecf20Sopenharmony_ciifdef CONFIG_DEBUG_INFO_SPLIT
8388c2ecf20Sopenharmony_ciDEBUG_CFLAGS	+= -gsplit-dwarf
8398c2ecf20Sopenharmony_cielse
8408c2ecf20Sopenharmony_ciDEBUG_CFLAGS	+= -g
8418c2ecf20Sopenharmony_ciendif
8428c2ecf20Sopenharmony_ci
8438c2ecf20Sopenharmony_ciifdef CONFIG_AS_IS_LLVM
8448c2ecf20Sopenharmony_ciKBUILD_AFLAGS	+= -g
8458c2ecf20Sopenharmony_cielse
8468c2ecf20Sopenharmony_ciKBUILD_AFLAGS	+= -Wa,-gdwarf-2
8478c2ecf20Sopenharmony_ciendif
8488c2ecf20Sopenharmony_ci
8498c2ecf20Sopenharmony_ciifdef CONFIG_DEBUG_INFO_DWARF4
8508c2ecf20Sopenharmony_ciDEBUG_CFLAGS	+= -gdwarf-4
8518c2ecf20Sopenharmony_ciendif
8528c2ecf20Sopenharmony_ci
8538c2ecf20Sopenharmony_ciifdef CONFIG_DEBUG_INFO_REDUCED
8548c2ecf20Sopenharmony_ciDEBUG_CFLAGS	+= $(call cc-option, -femit-struct-debug-baseonly) \
8558c2ecf20Sopenharmony_ci		   $(call cc-option,-fno-var-tracking)
8568c2ecf20Sopenharmony_ciendif
8578c2ecf20Sopenharmony_ci
8588c2ecf20Sopenharmony_ciifdef CONFIG_DEBUG_INFO_COMPRESSED
8598c2ecf20Sopenharmony_ciDEBUG_CFLAGS	+= -gz=zlib
8608c2ecf20Sopenharmony_ciKBUILD_AFLAGS	+= -gz=zlib
8618c2ecf20Sopenharmony_ciKBUILD_LDFLAGS	+= --compress-debug-sections=zlib
8628c2ecf20Sopenharmony_ciendif
8638c2ecf20Sopenharmony_ci
8648c2ecf20Sopenharmony_ciendif # CONFIG_DEBUG_INFO
8658c2ecf20Sopenharmony_ci
8668c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(DEBUG_CFLAGS)
8678c2ecf20Sopenharmony_ciexport DEBUG_CFLAGS
8688c2ecf20Sopenharmony_ci
8698c2ecf20Sopenharmony_ciifdef CONFIG_FUNCTION_TRACER
8708c2ecf20Sopenharmony_ciifdef CONFIG_FTRACE_MCOUNT_USE_CC
8718c2ecf20Sopenharmony_ci  CC_FLAGS_FTRACE	+= -mrecord-mcount
8728c2ecf20Sopenharmony_ci  ifdef CONFIG_HAVE_NOP_MCOUNT
8738c2ecf20Sopenharmony_ci    ifeq ($(call cc-option-yn, -mnop-mcount),y)
8748c2ecf20Sopenharmony_ci      CC_FLAGS_FTRACE	+= -mnop-mcount
8758c2ecf20Sopenharmony_ci      CC_FLAGS_USING	+= -DCC_USING_NOP_MCOUNT
8768c2ecf20Sopenharmony_ci    endif
8778c2ecf20Sopenharmony_ci  endif
8788c2ecf20Sopenharmony_ciendif
8798c2ecf20Sopenharmony_ciifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
8808c2ecf20Sopenharmony_ci  ifdef CONFIG_HAVE_C_RECORDMCOUNT
8818c2ecf20Sopenharmony_ci    BUILD_C_RECORDMCOUNT := y
8828c2ecf20Sopenharmony_ci    export BUILD_C_RECORDMCOUNT
8838c2ecf20Sopenharmony_ci  endif
8848c2ecf20Sopenharmony_ciendif
8858c2ecf20Sopenharmony_ciifdef CONFIG_HAVE_FENTRY
8868c2ecf20Sopenharmony_ci  ifeq ($(call cc-option-yn, -mfentry),y)
8878c2ecf20Sopenharmony_ci    CC_FLAGS_FTRACE	+= -mfentry
8888c2ecf20Sopenharmony_ci    CC_FLAGS_USING	+= -DCC_USING_FENTRY
8898c2ecf20Sopenharmony_ci  endif
8908c2ecf20Sopenharmony_ciendif
8918c2ecf20Sopenharmony_ciexport CC_FLAGS_FTRACE
8928c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING)
8938c2ecf20Sopenharmony_ciKBUILD_AFLAGS	+= $(CC_FLAGS_USING)
8948c2ecf20Sopenharmony_ciendif
8958c2ecf20Sopenharmony_ci
8968c2ecf20Sopenharmony_ci# We trigger additional mismatches with less inlining
8978c2ecf20Sopenharmony_ciifdef CONFIG_DEBUG_SECTION_MISMATCH
8988c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
8998c2ecf20Sopenharmony_ciendif
9008c2ecf20Sopenharmony_ci
9018c2ecf20Sopenharmony_ciifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
9028c2ecf20Sopenharmony_ciKBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections
9038c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += --gc-sections
9048c2ecf20Sopenharmony_ciendif
9058c2ecf20Sopenharmony_ci
9068c2ecf20Sopenharmony_ciifdef CONFIG_SHADOW_CALL_STACK
9078c2ecf20Sopenharmony_ciCC_FLAGS_SCS	:= -fsanitize=shadow-call-stack
9088c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= $(CC_FLAGS_SCS)
9098c2ecf20Sopenharmony_ciexport CC_FLAGS_SCS
9108c2ecf20Sopenharmony_ciendif
9118c2ecf20Sopenharmony_ci
9128c2ecf20Sopenharmony_ciifdef CONFIG_LTO_CLANG
9138c2ecf20Sopenharmony_ciifdef CONFIG_LTO_CLANG_THIN
9148c2ecf20Sopenharmony_ciCC_FLAGS_LTO	:= -flto=thin -fsplit-lto-unit
9158c2ecf20Sopenharmony_ciKBUILD_LDFLAGS	+= --thinlto-cache-dir=$(extmod-prefix).thinlto-cache
9168c2ecf20Sopenharmony_cielse
9178c2ecf20Sopenharmony_ciCC_FLAGS_LTO	:= -flto
9188c2ecf20Sopenharmony_ciendif
9198c2ecf20Sopenharmony_ciCC_FLAGS_LTO	+= -fvisibility=hidden
9208c2ecf20Sopenharmony_ci
9218c2ecf20Sopenharmony_ci# Limit inlining across translation units to reduce binary size
9228c2ecf20Sopenharmony_ciKBUILD_LDFLAGS += -mllvm -import-instr-limit=5
9238c2ecf20Sopenharmony_ciendif
9248c2ecf20Sopenharmony_ci
9258c2ecf20Sopenharmony_ciifdef CONFIG_LTO
9268c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -fno-lto $(CC_FLAGS_LTO)
9278c2ecf20Sopenharmony_ciKBUILD_AFLAGS	+= -fno-lto
9288c2ecf20Sopenharmony_ciexport CC_FLAGS_LTO
9298c2ecf20Sopenharmony_ciendif
9308c2ecf20Sopenharmony_ci
9318c2ecf20Sopenharmony_ciifdef CONFIG_CFI_CLANG
9328c2ecf20Sopenharmony_ciCC_FLAGS_CFI	:= -fsanitize=cfi \
9338c2ecf20Sopenharmony_ci		   -fsanitize-cfi-cross-dso \
9348c2ecf20Sopenharmony_ci		   -fno-sanitize-cfi-canonical-jump-tables \
9358c2ecf20Sopenharmony_ci		   -fno-sanitize-trap=cfi \
9368c2ecf20Sopenharmony_ci		   -fno-sanitize-blacklist
9378c2ecf20Sopenharmony_ci
9388c2ecf20Sopenharmony_ciifdef CONFIG_CFI_PERMISSIVE
9398c2ecf20Sopenharmony_ciCC_FLAGS_CFI	+= -fsanitize-recover=cfi
9408c2ecf20Sopenharmony_ciendif
9418c2ecf20Sopenharmony_ci
9428c2ecf20Sopenharmony_ci# If LTO flags are filtered out, we must also filter out CFI.
9438c2ecf20Sopenharmony_ciCC_FLAGS_LTO	+= $(CC_FLAGS_CFI)
9448c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= $(CC_FLAGS_CFI)
9458c2ecf20Sopenharmony_ciexport CC_FLAGS_CFI
9468c2ecf20Sopenharmony_ciendif
9478c2ecf20Sopenharmony_ci
9488c2ecf20Sopenharmony_ciifdef CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_32B
9498c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -falign-functions=32
9508c2ecf20Sopenharmony_ciendif
9518c2ecf20Sopenharmony_ci
9528c2ecf20Sopenharmony_ci# arch Makefile may override CC so keep this after arch Makefile is included
9538c2ecf20Sopenharmony_ciNOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
9548c2ecf20Sopenharmony_ci
9558c2ecf20Sopenharmony_ci# warn about C99 declaration after statement
9568c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wdeclaration-after-statement
9578c2ecf20Sopenharmony_ci
9588c2ecf20Sopenharmony_ci# Variable Length Arrays (VLAs) should not be used anywhere in the kernel
9598c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wvla
9608c2ecf20Sopenharmony_ci
9618c2ecf20Sopenharmony_ci# disable pointer signed / unsigned warnings in gcc 4.0
9628c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -Wno-pointer-sign
9638c2ecf20Sopenharmony_ci
9648c2ecf20Sopenharmony_ci# disable stringop warnings in gcc 8+
9658c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
9668c2ecf20Sopenharmony_ci
9678c2ecf20Sopenharmony_ci# We'll want to enable this eventually, but it's not going away for 5.7 at least
9688c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds)
9698c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, array-bounds)
9708c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
9718c2ecf20Sopenharmony_ci
9728c2ecf20Sopenharmony_ci# Another good warning that we'll want to enable eventually
9738c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, restrict)
9748c2ecf20Sopenharmony_ci
9758c2ecf20Sopenharmony_ci# Enabled with W=2, disabled by default as noisy
9768c2ecf20Sopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized)
9778c2ecf20Sopenharmony_ci
9788c2ecf20Sopenharmony_ci# disable invalid "can't wrap" optimizations for signed / pointers
9798c2ecf20Sopenharmony_ciKBUILD_CFLAGS	+= -fno-strict-overflow
9808c2ecf20Sopenharmony_ci
9818c2ecf20Sopenharmony_ci# Make sure -fstack-check isn't enabled (like gentoo apparently did)
9828c2ecf20Sopenharmony_ciKBUILD_CFLAGS  += -fno-stack-check
9838c2ecf20Sopenharmony_ci
9848c2ecf20Sopenharmony_ci# conserve stack if available
9858c2ecf20Sopenharmony_ciKBUILD_CFLAGS   += $(call cc-option,-fconserve-stack)
9868c2ecf20Sopenharmony_ci
9878c2ecf20Sopenharmony_ci# Prohibit date/time macros, which would make the build non-deterministic
9888c2ecf20Sopenharmony_ciKBUILD_CFLAGS   += -Werror=date-time
9898c2ecf20Sopenharmony_ci
9908c2ecf20Sopenharmony_ci# enforce correct pointer usage
9918c2ecf20Sopenharmony_ciKBUILD_CFLAGS   += $(call cc-option,-Werror=incompatible-pointer-types)
9928c2ecf20Sopenharmony_ci
9938c2ecf20Sopenharmony_ci# Require designated initializers for all marked structures
9948c2ecf20Sopenharmony_ciKBUILD_CFLAGS   += $(call cc-option,-Werror=designated-init)
9958c2ecf20Sopenharmony_ci
9968c2ecf20Sopenharmony_ci# change __FILE__ to the relative path from the srctree
9978c2ecf20Sopenharmony_ciKBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
9988c2ecf20Sopenharmony_ci
9998c2ecf20Sopenharmony_ci# include additional Makefiles when needed
10008c2ecf20Sopenharmony_ciinclude-y			:= scripts/Makefile.extrawarn
10018c2ecf20Sopenharmony_ciinclude-$(CONFIG_KASAN)		+= scripts/Makefile.kasan
10028c2ecf20Sopenharmony_ciinclude-$(CONFIG_KCSAN)		+= scripts/Makefile.kcsan
10038c2ecf20Sopenharmony_ciinclude-$(CONFIG_UBSAN)		+= scripts/Makefile.ubsan
10048c2ecf20Sopenharmony_ciinclude-$(CONFIG_KCOV)		+= scripts/Makefile.kcov
10058c2ecf20Sopenharmony_ciinclude-$(CONFIG_GCC_PLUGINS)	+= scripts/Makefile.gcc-plugins
10068c2ecf20Sopenharmony_ci
10078c2ecf20Sopenharmony_ciinclude $(addprefix $(srctree)/, $(include-y))
10088c2ecf20Sopenharmony_ci
10098c2ecf20Sopenharmony_ci# scripts/Makefile.gcc-plugins is intentionally included last.
10108c2ecf20Sopenharmony_ci# Do not add $(call cc-option,...) below this line. When you build the kernel
10118c2ecf20Sopenharmony_ci# from the clean source tree, the GCC plugins do not exist at this point.
10128c2ecf20Sopenharmony_ci
10138c2ecf20Sopenharmony_ci# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
10148c2ecf20Sopenharmony_ciKBUILD_CPPFLAGS += $(KCPPFLAGS)
10158c2ecf20Sopenharmony_ciKBUILD_AFLAGS   += $(KAFLAGS)
10168c2ecf20Sopenharmony_ciKBUILD_CFLAGS   += $(KCFLAGS)
10178c2ecf20Sopenharmony_ci
10188c2ecf20Sopenharmony_ciKBUILD_LDFLAGS_MODULE += --build-id=sha1
10198c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += --build-id=sha1
10208c2ecf20Sopenharmony_ci
10218c2ecf20Sopenharmony_ciKBUILD_LDFLAGS	+= -z noexecstack
10228c2ecf20Sopenharmony_ciKBUILD_LDFLAGS	+= $(call ld-option,--no-warn-rwx-segments)
10238c2ecf20Sopenharmony_ci
10248c2ecf20Sopenharmony_ciifeq ($(CONFIG_STRIP_ASM_SYMS),y)
10258c2ecf20Sopenharmony_ciLDFLAGS_vmlinux	+= $(call ld-option, -X,)
10268c2ecf20Sopenharmony_ciendif
10278c2ecf20Sopenharmony_ci
10288c2ecf20Sopenharmony_ciifeq ($(CONFIG_RELR),y)
10298c2ecf20Sopenharmony_ciLDFLAGS_vmlinux	+= --pack-dyn-relocs=relr --use-android-relr-tags
10308c2ecf20Sopenharmony_ciendif
10318c2ecf20Sopenharmony_ci
10328c2ecf20Sopenharmony_ci# We never want expected sections to be placed heuristically by the
10338c2ecf20Sopenharmony_ci# linker. All sections should be explicitly named in the linker script.
10348c2ecf20Sopenharmony_ciifdef CONFIG_LD_ORPHAN_WARN
10358c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += --orphan-handling=warn
10368c2ecf20Sopenharmony_ciendif
10378c2ecf20Sopenharmony_ci
10388c2ecf20Sopenharmony_ci# Align the bit size of userspace programs with the kernel
10398c2ecf20Sopenharmony_ciKBUILD_USERCFLAGS  += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
10408c2ecf20Sopenharmony_ciKBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))
10418c2ecf20Sopenharmony_ci
10428c2ecf20Sopenharmony_ci# make the checker run with the right architecture
10438c2ecf20Sopenharmony_ciCHECKFLAGS += --arch=$(ARCH)
10448c2ecf20Sopenharmony_ci
10458c2ecf20Sopenharmony_ci# insure the checker run with the right endianness
10468c2ecf20Sopenharmony_ciCHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian)
10478c2ecf20Sopenharmony_ci
10488c2ecf20Sopenharmony_ci# the checker needs the correct machine size
10498c2ecf20Sopenharmony_ciCHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32)
10508c2ecf20Sopenharmony_ci
10518c2ecf20Sopenharmony_ci# Default kernel image to build when no specific target is given.
10528c2ecf20Sopenharmony_ci# KBUILD_IMAGE may be overruled on the command line or
10538c2ecf20Sopenharmony_ci# set in the environment
10548c2ecf20Sopenharmony_ci# Also any assignments in arch/$(ARCH)/Makefile take precedence over
10558c2ecf20Sopenharmony_ci# this default value
10568c2ecf20Sopenharmony_ciexport KBUILD_IMAGE ?= vmlinux
10578c2ecf20Sopenharmony_ci
10588c2ecf20Sopenharmony_ci#
10598c2ecf20Sopenharmony_ci# INSTALL_PATH specifies where to place the updated kernel and system map
10608c2ecf20Sopenharmony_ci# images. Default is /boot, but you can set it to other values
10618c2ecf20Sopenharmony_ciexport	INSTALL_PATH ?= /boot
10628c2ecf20Sopenharmony_ci
10638c2ecf20Sopenharmony_ci#
10648c2ecf20Sopenharmony_ci# INSTALL_DTBS_PATH specifies a prefix for relocations required by build roots.
10658c2ecf20Sopenharmony_ci# Like INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed as
10668c2ecf20Sopenharmony_ci# an argument if needed. Otherwise it defaults to the kernel install path
10678c2ecf20Sopenharmony_ci#
10688c2ecf20Sopenharmony_ciexport INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE)
10698c2ecf20Sopenharmony_ci
10708c2ecf20Sopenharmony_ci#
10718c2ecf20Sopenharmony_ci# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
10728c2ecf20Sopenharmony_ci# relocations required by build roots.  This is not defined in the
10738c2ecf20Sopenharmony_ci# makefile but the argument can be passed to make if needed.
10748c2ecf20Sopenharmony_ci#
10758c2ecf20Sopenharmony_ci
10768c2ecf20Sopenharmony_ciMODLIB	= $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
10778c2ecf20Sopenharmony_ciexport MODLIB
10788c2ecf20Sopenharmony_ci
10798c2ecf20Sopenharmony_ci#
10808c2ecf20Sopenharmony_ci# INSTALL_MOD_STRIP, if defined, will cause modules to be
10818c2ecf20Sopenharmony_ci# stripped after they are installed.  If INSTALL_MOD_STRIP is '1', then
10828c2ecf20Sopenharmony_ci# the default option --strip-debug will be used.  Otherwise,
10838c2ecf20Sopenharmony_ci# INSTALL_MOD_STRIP value will be used as the options to the strip command.
10848c2ecf20Sopenharmony_ci
10858c2ecf20Sopenharmony_ciifdef INSTALL_MOD_STRIP
10868c2ecf20Sopenharmony_ciifeq ($(INSTALL_MOD_STRIP),1)
10878c2ecf20Sopenharmony_cimod_strip_cmd = $(STRIP) --strip-debug
10888c2ecf20Sopenharmony_cielse
10898c2ecf20Sopenharmony_cimod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP)
10908c2ecf20Sopenharmony_ciendif # INSTALL_MOD_STRIP=1
10918c2ecf20Sopenharmony_cielse
10928c2ecf20Sopenharmony_cimod_strip_cmd = true
10938c2ecf20Sopenharmony_ciendif # INSTALL_MOD_STRIP
10948c2ecf20Sopenharmony_ciexport mod_strip_cmd
10958c2ecf20Sopenharmony_ci
10968c2ecf20Sopenharmony_ci# CONFIG_MODULE_COMPRESS, if defined, will cause module to be compressed
10978c2ecf20Sopenharmony_ci# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP
10988c2ecf20Sopenharmony_ci# or CONFIG_MODULE_COMPRESS_XZ.
10998c2ecf20Sopenharmony_ci
11008c2ecf20Sopenharmony_cimod_compress_cmd = true
11018c2ecf20Sopenharmony_ciifdef CONFIG_MODULE_COMPRESS
11028c2ecf20Sopenharmony_ci  ifdef CONFIG_MODULE_COMPRESS_GZIP
11038c2ecf20Sopenharmony_ci    mod_compress_cmd = $(KGZIP) -n -f
11048c2ecf20Sopenharmony_ci  endif # CONFIG_MODULE_COMPRESS_GZIP
11058c2ecf20Sopenharmony_ci  ifdef CONFIG_MODULE_COMPRESS_XZ
11068c2ecf20Sopenharmony_ci    mod_compress_cmd = $(XZ) -f
11078c2ecf20Sopenharmony_ci  endif # CONFIG_MODULE_COMPRESS_XZ
11088c2ecf20Sopenharmony_ciendif # CONFIG_MODULE_COMPRESS
11098c2ecf20Sopenharmony_ciexport mod_compress_cmd
11108c2ecf20Sopenharmony_ci
11118c2ecf20Sopenharmony_ciifdef CONFIG_MODULE_SIG_ALL
11128c2ecf20Sopenharmony_ci$(eval $(call config_filename,MODULE_SIG_KEY))
11138c2ecf20Sopenharmony_ci
11148c2ecf20Sopenharmony_cimod_sign_cmd = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY) certs/signing_key.x509
11158c2ecf20Sopenharmony_cielse
11168c2ecf20Sopenharmony_cimod_sign_cmd = true
11178c2ecf20Sopenharmony_ciendif
11188c2ecf20Sopenharmony_ciexport mod_sign_cmd
11198c2ecf20Sopenharmony_ci
11208c2ecf20Sopenharmony_ciHOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
11218c2ecf20Sopenharmony_ci
11228c2ecf20Sopenharmony_cihas_libelf = $(call try-run,\
11238c2ecf20Sopenharmony_ci               echo "int main() {}" | $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
11248c2ecf20Sopenharmony_ci
11258c2ecf20Sopenharmony_ciifdef CONFIG_STACK_VALIDATION
11268c2ecf20Sopenharmony_ci  ifeq ($(has_libelf),1)
11278c2ecf20Sopenharmony_ci    objtool_target := tools/objtool FORCE
11288c2ecf20Sopenharmony_ci  else
11298c2ecf20Sopenharmony_ci    SKIP_STACK_VALIDATION := 1
11308c2ecf20Sopenharmony_ci    export SKIP_STACK_VALIDATION
11318c2ecf20Sopenharmony_ci  endif
11328c2ecf20Sopenharmony_ciendif
11338c2ecf20Sopenharmony_ci
11348c2ecf20Sopenharmony_ciPHONY += resolve_btfids_clean
11358c2ecf20Sopenharmony_ci
11368c2ecf20Sopenharmony_ciresolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids
11378c2ecf20Sopenharmony_ci
11388c2ecf20Sopenharmony_ci# tools/bpf/resolve_btfids directory might not exist
11398c2ecf20Sopenharmony_ci# in output directory, skip its clean in that case
11408c2ecf20Sopenharmony_ciresolve_btfids_clean:
11418c2ecf20Sopenharmony_ciifneq ($(wildcard $(resolve_btfids_O)),)
11428c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean
11438c2ecf20Sopenharmony_ciendif
11448c2ecf20Sopenharmony_ci
11458c2ecf20Sopenharmony_ciifdef CONFIG_BPF
11468c2ecf20Sopenharmony_ciifdef CONFIG_DEBUG_INFO_BTF
11478c2ecf20Sopenharmony_ci  ifeq ($(has_libelf),1)
11488c2ecf20Sopenharmony_ci    resolve_btfids_target := tools/bpf/resolve_btfids FORCE
11498c2ecf20Sopenharmony_ci  else
11508c2ecf20Sopenharmony_ci    ERROR_RESOLVE_BTFIDS := 1
11518c2ecf20Sopenharmony_ci  endif
11528c2ecf20Sopenharmony_ciendif # CONFIG_DEBUG_INFO_BTF
11538c2ecf20Sopenharmony_ciendif # CONFIG_BPF
11548c2ecf20Sopenharmony_ci
11558c2ecf20Sopenharmony_ciPHONY += prepare0
11568c2ecf20Sopenharmony_ci
11578c2ecf20Sopenharmony_ciexport MODORDER := $(extmod-prefix)modules.order
11588c2ecf20Sopenharmony_ciexport MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps
11598c2ecf20Sopenharmony_ci
11608c2ecf20Sopenharmony_ciifeq ($(KBUILD_EXTMOD),)
11618c2ecf20Sopenharmony_cicore-y		+= kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ io_uring/
11628c2ecf20Sopenharmony_ci
11638c2ecf20Sopenharmony_civmlinux-dirs	:= $(patsubst %/,%,$(filter %/, \
11648c2ecf20Sopenharmony_ci		     $(core-y) $(core-m) $(drivers-y) $(drivers-m) $(vendor-y) \
11658c2ecf20Sopenharmony_ci		     $(libs-y) $(libs-m)))
11668c2ecf20Sopenharmony_ci
11678c2ecf20Sopenharmony_civmlinux-alldirs	:= $(sort $(vmlinux-dirs) Documentation \
11688c2ecf20Sopenharmony_ci		     $(patsubst %/,%,$(filter %/, $(core-) \
11698c2ecf20Sopenharmony_ci			$(drivers-) $(vendor-) $(libs-))))
11708c2ecf20Sopenharmony_ci
11718c2ecf20Sopenharmony_cibuild-dirs	:= $(vmlinux-dirs)
11728c2ecf20Sopenharmony_ciclean-dirs	:= $(vmlinux-alldirs)
11738c2ecf20Sopenharmony_ci
11748c2ecf20Sopenharmony_cisubdir-modorder := $(addsuffix /modules.order, $(build-dirs))
11758c2ecf20Sopenharmony_ci
11768c2ecf20Sopenharmony_ci# Externally visible symbols (used by link-vmlinux.sh)
11778c2ecf20Sopenharmony_ciKBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
11788c2ecf20Sopenharmony_ciKBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
11798c2ecf20Sopenharmony_ciifdef CONFIG_MODULES
11808c2ecf20Sopenharmony_ciKBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y)))
11818c2ecf20Sopenharmony_ciKBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y))
11828c2ecf20Sopenharmony_cielse
11838c2ecf20Sopenharmony_ciKBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y))
11848c2ecf20Sopenharmony_ciendif
11858c2ecf20Sopenharmony_ciKBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
11868c2ecf20Sopenharmony_ciKBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(vendor-y))
11878c2ecf20Sopenharmony_ci
11888c2ecf20Sopenharmony_ciexport KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
11898c2ecf20Sopenharmony_ciexport KBUILD_LDS          := arch/$(SRCARCH)/kernel/vmlinux.lds
11908c2ecf20Sopenharmony_ci# used by scripts/Makefile.package
11918c2ecf20Sopenharmony_ciexport KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools)
11928c2ecf20Sopenharmony_ci
11938c2ecf20Sopenharmony_civmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
11948c2ecf20Sopenharmony_ci
11958c2ecf20Sopenharmony_ci# Recurse until adjust_autoksyms.sh is satisfied
11968c2ecf20Sopenharmony_ciPHONY += autoksyms_recursive
11978c2ecf20Sopenharmony_ciifdef CONFIG_TRIM_UNUSED_KSYMS
11988c2ecf20Sopenharmony_ci# For the kernel to actually contain only the needed exported symbols,
11998c2ecf20Sopenharmony_ci# we have to build modules as well to determine what those symbols are.
12008c2ecf20Sopenharmony_ci# (this can be evaluated only once include/config/auto.conf has been included)
12018c2ecf20Sopenharmony_ciKBUILD_MODULES := 1
12028c2ecf20Sopenharmony_ci
12038c2ecf20Sopenharmony_ciautoksyms_recursive: descend modules.order
12048c2ecf20Sopenharmony_ci	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \
12058c2ecf20Sopenharmony_ci	  "$(MAKE) -f $(srctree)/Makefile autoksyms_recursive"
12068c2ecf20Sopenharmony_ciendif
12078c2ecf20Sopenharmony_ci
12088c2ecf20Sopenharmony_ciautoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h)
12098c2ecf20Sopenharmony_ci
12108c2ecf20Sopenharmony_ciquiet_cmd_autoksyms_h = GEN     $@
12118c2ecf20Sopenharmony_ci      cmd_autoksyms_h = mkdir -p $(dir $@); \
12128c2ecf20Sopenharmony_ci			$(CONFIG_SHELL) $(srctree)/scripts/gen_autoksyms.sh $@
12138c2ecf20Sopenharmony_ci
12148c2ecf20Sopenharmony_ci$(autoksyms_h):
12158c2ecf20Sopenharmony_ci	$(call cmd,autoksyms_h)
12168c2ecf20Sopenharmony_ci
12178c2ecf20Sopenharmony_ciARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
12188c2ecf20Sopenharmony_ci
12198c2ecf20Sopenharmony_ci# Final link of vmlinux with optional arch pass after final link
12208c2ecf20Sopenharmony_cicmd_link-vmlinux =                                                 \
12218c2ecf20Sopenharmony_ci	$(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)";    \
12228c2ecf20Sopenharmony_ci	$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
12238c2ecf20Sopenharmony_ci
12248c2ecf20Sopenharmony_civmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
12258c2ecf20Sopenharmony_ci	+$(call if_changed,link-vmlinux)
12268c2ecf20Sopenharmony_ci
12278c2ecf20Sopenharmony_citargets := vmlinux
12288c2ecf20Sopenharmony_ci
12298c2ecf20Sopenharmony_ci# The actual objects are generated when descending,
12308c2ecf20Sopenharmony_ci# make sure no implicit rule kicks in
12318c2ecf20Sopenharmony_ci$(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
12328c2ecf20Sopenharmony_ci
12338c2ecf20Sopenharmony_cifilechk_kernel.release = \
12348c2ecf20Sopenharmony_ci	echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
12358c2ecf20Sopenharmony_ci
12368c2ecf20Sopenharmony_ci# Store (new) KERNELRELEASE string in include/config/kernel.release
12378c2ecf20Sopenharmony_ciinclude/config/kernel.release: FORCE
12388c2ecf20Sopenharmony_ci	$(call filechk,kernel.release)
12398c2ecf20Sopenharmony_ci
12408c2ecf20Sopenharmony_ci# Additional helpers built in scripts/
12418c2ecf20Sopenharmony_ci# Carefully list dependencies so we do not try to build scripts twice
12428c2ecf20Sopenharmony_ci# in parallel
12438c2ecf20Sopenharmony_ciPHONY += scripts
12448c2ecf20Sopenharmony_ciscripts: scripts_basic scripts_dtc
12458c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(@)
12468c2ecf20Sopenharmony_ci
12478c2ecf20Sopenharmony_ci# Things we need to do before we recursively start building the kernel
12488c2ecf20Sopenharmony_ci# or the modules are listed in "prepare".
12498c2ecf20Sopenharmony_ci# A multi level approach is used. prepareN is processed before prepareN-1.
12508c2ecf20Sopenharmony_ci# archprepare is used in arch Makefiles and when processed asm symlink,
12518c2ecf20Sopenharmony_ci# version.h and scripts_basic is processed / created.
12528c2ecf20Sopenharmony_ci
12538c2ecf20Sopenharmony_ciPHONY += prepare archprepare
12548c2ecf20Sopenharmony_ci
12558c2ecf20Sopenharmony_ciarchprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \
12568c2ecf20Sopenharmony_ci	asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
12578c2ecf20Sopenharmony_ci	include/generated/autoconf.h
12588c2ecf20Sopenharmony_ci
12598c2ecf20Sopenharmony_ciprepare0: archprepare
12608c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=scripts/mod
12618c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=.
12628c2ecf20Sopenharmony_ci
12638c2ecf20Sopenharmony_ci# All the preparing..
12648c2ecf20Sopenharmony_ciprepare: prepare0 prepare-objtool prepare-resolve_btfids
12658c2ecf20Sopenharmony_ci
12668c2ecf20Sopenharmony_ci# Support for using generic headers in asm-generic
12678c2ecf20Sopenharmony_ciasm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
12688c2ecf20Sopenharmony_ci
12698c2ecf20Sopenharmony_ciPHONY += asm-generic uapi-asm-generic
12708c2ecf20Sopenharmony_ciasm-generic: uapi-asm-generic
12718c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \
12728c2ecf20Sopenharmony_ci	generic=include/asm-generic
12738c2ecf20Sopenharmony_ciuapi-asm-generic:
12748c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \
12758c2ecf20Sopenharmony_ci	generic=include/uapi/asm-generic
12768c2ecf20Sopenharmony_ci
12778c2ecf20Sopenharmony_ciPHONY += prepare-objtool prepare-resolve_btfids
12788c2ecf20Sopenharmony_ciprepare-objtool: $(objtool_target)
12798c2ecf20Sopenharmony_ciifeq ($(SKIP_STACK_VALIDATION),1)
12808c2ecf20Sopenharmony_ciifdef CONFIG_UNWINDER_ORC
12818c2ecf20Sopenharmony_ci	@echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
12828c2ecf20Sopenharmony_ci	@false
12838c2ecf20Sopenharmony_cielse
12848c2ecf20Sopenharmony_ci	@echo "warning: Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
12858c2ecf20Sopenharmony_ciendif
12868c2ecf20Sopenharmony_ciendif
12878c2ecf20Sopenharmony_ci
12888c2ecf20Sopenharmony_ciprepare-resolve_btfids: $(resolve_btfids_target)
12898c2ecf20Sopenharmony_ciifeq ($(ERROR_RESOLVE_BTFIDS),1)
12908c2ecf20Sopenharmony_ci	@echo "error: Cannot resolve BTF IDs for CONFIG_DEBUG_INFO_BTF, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
12918c2ecf20Sopenharmony_ci	@false
12928c2ecf20Sopenharmony_ciendif
12938c2ecf20Sopenharmony_ci# Generate some files
12948c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
12958c2ecf20Sopenharmony_ci
12968c2ecf20Sopenharmony_ci# KERNELRELEASE can change from a few different places, meaning version.h
12978c2ecf20Sopenharmony_ci# needs to be updated, so this check is forced on all builds
12988c2ecf20Sopenharmony_ci
12998c2ecf20Sopenharmony_ciuts_len := 64
13008c2ecf20Sopenharmony_cidefine filechk_utsrelease.h
13018c2ecf20Sopenharmony_ci	if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \
13028c2ecf20Sopenharmony_ci	  echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2;    \
13038c2ecf20Sopenharmony_ci	  exit 1;                                                         \
13048c2ecf20Sopenharmony_ci	fi;                                                               \
13058c2ecf20Sopenharmony_ci	echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"
13068c2ecf20Sopenharmony_ciendef
13078c2ecf20Sopenharmony_ci
13088c2ecf20Sopenharmony_cidefine filechk_version.h
13098c2ecf20Sopenharmony_ci	if [ $(SUBLEVEL) -gt 255 ]; then                                 \
13108c2ecf20Sopenharmony_ci		echo \#define LINUX_VERSION_CODE $(shell                 \
13118c2ecf20Sopenharmony_ci		expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + 255); \
13128c2ecf20Sopenharmony_ci	else                                                             \
13138c2ecf20Sopenharmony_ci		echo \#define LINUX_VERSION_CODE $(shell                 \
13148c2ecf20Sopenharmony_ci		expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \
13158c2ecf20Sopenharmony_ci	fi;                                                              \
13168c2ecf20Sopenharmony_ci	echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) +  \
13178c2ecf20Sopenharmony_ci	((c) > 255 ? 255 : (c)))'
13188c2ecf20Sopenharmony_ciendef
13198c2ecf20Sopenharmony_ci
13208c2ecf20Sopenharmony_ci$(version_h): PATCHLEVEL := $(if $(PATCHLEVEL), $(PATCHLEVEL), 0)
13218c2ecf20Sopenharmony_ci$(version_h): SUBLEVEL := $(if $(SUBLEVEL), $(SUBLEVEL), 0)
13228c2ecf20Sopenharmony_ci$(version_h): FORCE
13238c2ecf20Sopenharmony_ci	$(call filechk,version.h)
13248c2ecf20Sopenharmony_ci	$(Q)rm -f $(old_version_h)
13258c2ecf20Sopenharmony_ci
13268c2ecf20Sopenharmony_ciinclude/generated/utsrelease.h: include/config/kernel.release FORCE
13278c2ecf20Sopenharmony_ci	$(call filechk,utsrelease.h)
13288c2ecf20Sopenharmony_ci
13298c2ecf20Sopenharmony_ciPHONY += headerdep
13308c2ecf20Sopenharmony_ciheaderdep:
13318c2ecf20Sopenharmony_ci	$(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \
13328c2ecf20Sopenharmony_ci	$(srctree)/scripts/headerdep.pl -I$(srctree)/include
13338c2ecf20Sopenharmony_ci
13348c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
13358c2ecf20Sopenharmony_ci# Kernel headers
13368c2ecf20Sopenharmony_ci
13378c2ecf20Sopenharmony_ci#Default location for installed headers
13388c2ecf20Sopenharmony_ciexport INSTALL_HDR_PATH = $(objtree)/usr
13398c2ecf20Sopenharmony_ci
13408c2ecf20Sopenharmony_ciquiet_cmd_headers_install = INSTALL $(INSTALL_HDR_PATH)/include
13418c2ecf20Sopenharmony_ci      cmd_headers_install = \
13428c2ecf20Sopenharmony_ci	mkdir -p $(INSTALL_HDR_PATH); \
13438c2ecf20Sopenharmony_ci	rsync -mrl --include='*/' --include='*\.h' --exclude='*' \
13448c2ecf20Sopenharmony_ci	usr/include $(INSTALL_HDR_PATH)
13458c2ecf20Sopenharmony_ci
13468c2ecf20Sopenharmony_ciPHONY += headers_install
13478c2ecf20Sopenharmony_ciheaders_install: headers
13488c2ecf20Sopenharmony_ci	$(call cmd,headers_install)
13498c2ecf20Sopenharmony_ci
13508c2ecf20Sopenharmony_ciPHONY += archheaders archscripts
13518c2ecf20Sopenharmony_ci
13528c2ecf20Sopenharmony_cihdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
13538c2ecf20Sopenharmony_ci
13548c2ecf20Sopenharmony_ciPHONY += headers
13558c2ecf20Sopenharmony_ciheaders: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
13568c2ecf20Sopenharmony_ci	$(if $(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/Kbuild),, \
13578c2ecf20Sopenharmony_ci	  $(error Headers not exportable for the $(SRCARCH) architecture))
13588c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(hdr-inst)=include/uapi
13598c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
13608c2ecf20Sopenharmony_ci
13618c2ecf20Sopenharmony_ci# Deprecated. It is no-op now.
13628c2ecf20Sopenharmony_ciPHONY += headers_check
13638c2ecf20Sopenharmony_ciheaders_check:
13648c2ecf20Sopenharmony_ci	@:
13658c2ecf20Sopenharmony_ci
13668c2ecf20Sopenharmony_ciifdef CONFIG_HEADERS_INSTALL
13678c2ecf20Sopenharmony_ciprepare: headers
13688c2ecf20Sopenharmony_ciendif
13698c2ecf20Sopenharmony_ci
13708c2ecf20Sopenharmony_ciPHONY += scripts_unifdef
13718c2ecf20Sopenharmony_ciscripts_unifdef: scripts_basic
13728c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=scripts scripts/unifdef
13738c2ecf20Sopenharmony_ci
13748c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
13758c2ecf20Sopenharmony_ci# Kernel selftest
13768c2ecf20Sopenharmony_ci
13778c2ecf20Sopenharmony_ciPHONY += kselftest
13788c2ecf20Sopenharmony_cikselftest:
13798c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
13808c2ecf20Sopenharmony_ci
13818c2ecf20Sopenharmony_cikselftest-%: FORCE
13828c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
13838c2ecf20Sopenharmony_ci
13848c2ecf20Sopenharmony_ciPHONY += kselftest-merge
13858c2ecf20Sopenharmony_cikselftest-merge:
13868c2ecf20Sopenharmony_ci	$(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!))
13878c2ecf20Sopenharmony_ci	$(Q)find $(srctree)/tools/testing/selftests -name config | \
13888c2ecf20Sopenharmony_ci		xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config
13898c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
13908c2ecf20Sopenharmony_ci
13918c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
13928c2ecf20Sopenharmony_ci# Devicetree files
13938c2ecf20Sopenharmony_ci
13948c2ecf20Sopenharmony_ciifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
13958c2ecf20Sopenharmony_cidtstree := arch/$(SRCARCH)/boot/dts
13968c2ecf20Sopenharmony_ciendif
13978c2ecf20Sopenharmony_ci
13988c2ecf20Sopenharmony_ciifneq ($(dtstree),)
13998c2ecf20Sopenharmony_ci
14008c2ecf20Sopenharmony_ci%.dtb: include/config/kernel.release scripts_dtc
14018c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
14028c2ecf20Sopenharmony_ci
14038c2ecf20Sopenharmony_ciPHONY += dtbs dtbs_install dtbs_check
14048c2ecf20Sopenharmony_cidtbs: include/config/kernel.release scripts_dtc
14058c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=$(dtstree)
14068c2ecf20Sopenharmony_ci
14078c2ecf20Sopenharmony_ciifneq ($(filter dtbs_check, $(MAKECMDGOALS)),)
14088c2ecf20Sopenharmony_ciexport CHECK_DTBS=y
14098c2ecf20Sopenharmony_cidtbs: dt_binding_check
14108c2ecf20Sopenharmony_ciendif
14118c2ecf20Sopenharmony_ci
14128c2ecf20Sopenharmony_cidtbs_check: dtbs
14138c2ecf20Sopenharmony_ci
14148c2ecf20Sopenharmony_cidtbs_install:
14158c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(dtbinst)=$(dtstree) dst=$(INSTALL_DTBS_PATH)
14168c2ecf20Sopenharmony_ci
14178c2ecf20Sopenharmony_ciifdef CONFIG_OF_EARLY_FLATTREE
14188c2ecf20Sopenharmony_ciall: dtbs
14198c2ecf20Sopenharmony_ciendif
14208c2ecf20Sopenharmony_ci
14218c2ecf20Sopenharmony_ciendif
14228c2ecf20Sopenharmony_ci
14238c2ecf20Sopenharmony_ciPHONY += scripts_dtc
14248c2ecf20Sopenharmony_ciscripts_dtc: scripts_basic
14258c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=scripts/dtc
14268c2ecf20Sopenharmony_ci
14278c2ecf20Sopenharmony_ciifneq ($(filter dt_binding_check, $(MAKECMDGOALS)),)
14288c2ecf20Sopenharmony_ciexport CHECK_DT_BINDING=y
14298c2ecf20Sopenharmony_ciendif
14308c2ecf20Sopenharmony_ci
14318c2ecf20Sopenharmony_ciPHONY += dt_binding_check
14328c2ecf20Sopenharmony_cidt_binding_check: scripts_dtc
14338c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=Documentation/devicetree/bindings
14348c2ecf20Sopenharmony_ci
14358c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
14368c2ecf20Sopenharmony_ci# Modules
14378c2ecf20Sopenharmony_ci
14388c2ecf20Sopenharmony_ciifdef CONFIG_MODULES
14398c2ecf20Sopenharmony_ci
14408c2ecf20Sopenharmony_ci# By default, build modules as well
14418c2ecf20Sopenharmony_ci
14428c2ecf20Sopenharmony_ciall: modules
14438c2ecf20Sopenharmony_ci
14448c2ecf20Sopenharmony_ci# When we're building modules with modversions, we need to consider
14458c2ecf20Sopenharmony_ci# the built-in objects during the descend as well, in order to
14468c2ecf20Sopenharmony_ci# make sure the checksums are up to date before we record them.
14478c2ecf20Sopenharmony_ciifdef CONFIG_MODVERSIONS
14488c2ecf20Sopenharmony_ci  KBUILD_BUILTIN := 1
14498c2ecf20Sopenharmony_ciendif
14508c2ecf20Sopenharmony_ci
14518c2ecf20Sopenharmony_ci# Build modules
14528c2ecf20Sopenharmony_ci#
14538c2ecf20Sopenharmony_ci# A module can be listed more than once in obj-m resulting in
14548c2ecf20Sopenharmony_ci# duplicate lines in modules.order files.  Those are removed
14558c2ecf20Sopenharmony_ci# using awk while concatenating to the final file.
14568c2ecf20Sopenharmony_ci
14578c2ecf20Sopenharmony_ciPHONY += modules
14588c2ecf20Sopenharmony_cimodules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare
14598c2ecf20Sopenharmony_ci
14608c2ecf20Sopenharmony_ciPHONY += modules_check
14618c2ecf20Sopenharmony_cimodules_check: modules.order
14628c2ecf20Sopenharmony_ci	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $<
14638c2ecf20Sopenharmony_ci
14648c2ecf20Sopenharmony_cicmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@
14658c2ecf20Sopenharmony_ci
14668c2ecf20Sopenharmony_cimodules.order: $(subdir-modorder) FORCE
14678c2ecf20Sopenharmony_ci	$(call if_changed,modules_order)
14688c2ecf20Sopenharmony_ci
14698c2ecf20Sopenharmony_citargets += modules.order
14708c2ecf20Sopenharmony_ci
14718c2ecf20Sopenharmony_ci# Target to prepare building external modules
14728c2ecf20Sopenharmony_ciPHONY += modules_prepare
14738c2ecf20Sopenharmony_cimodules_prepare: prepare
14748c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=scripts scripts/module.lds
14758c2ecf20Sopenharmony_ci
14768c2ecf20Sopenharmony_cimodules_install: __modinst_pre
14778c2ecf20Sopenharmony_ciPHONY += __modinst_pre
14788c2ecf20Sopenharmony_ci__modinst_pre:
14798c2ecf20Sopenharmony_ci	@rm -rf $(MODLIB)/kernel
14808c2ecf20Sopenharmony_ci	@rm -f $(MODLIB)/source
14818c2ecf20Sopenharmony_ci	@mkdir -p $(MODLIB)/kernel
14828c2ecf20Sopenharmony_ci	@ln -s $(abspath $(srctree)) $(MODLIB)/source
14838c2ecf20Sopenharmony_ci	@if [ ! $(objtree) -ef  $(MODLIB)/build ]; then \
14848c2ecf20Sopenharmony_ci		rm -f $(MODLIB)/build ; \
14858c2ecf20Sopenharmony_ci		ln -s $(CURDIR) $(MODLIB)/build ; \
14868c2ecf20Sopenharmony_ci	fi
14878c2ecf20Sopenharmony_ci	@sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
14888c2ecf20Sopenharmony_ci	@cp -f modules.builtin $(MODLIB)/
14898c2ecf20Sopenharmony_ci	@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
14908c2ecf20Sopenharmony_ci
14918c2ecf20Sopenharmony_ciifeq ($(CONFIG_MODULE_SIG), y)
14928c2ecf20Sopenharmony_ciPHONY += modules_sign
14938c2ecf20Sopenharmony_cimodules_sign:
14948c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign
14958c2ecf20Sopenharmony_ciendif
14968c2ecf20Sopenharmony_ci
14978c2ecf20Sopenharmony_ciendif # CONFIG_MODULES
14988c2ecf20Sopenharmony_ci
14998c2ecf20Sopenharmony_ci###
15008c2ecf20Sopenharmony_ci# Cleaning is done on three levels.
15018c2ecf20Sopenharmony_ci# make clean     Delete most generated files
15028c2ecf20Sopenharmony_ci#                Leave enough to build external modules
15038c2ecf20Sopenharmony_ci# make mrproper  Delete the current configuration, and all generated files
15048c2ecf20Sopenharmony_ci# make distclean Remove editor backup files, patch leftover files and the like
15058c2ecf20Sopenharmony_ci
15068c2ecf20Sopenharmony_ci# Directories & files removed with 'make clean'
15078c2ecf20Sopenharmony_ciCLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
15088c2ecf20Sopenharmony_ci	       modules.builtin modules.builtin.modinfo modules.nsdeps \
15098c2ecf20Sopenharmony_ci	       compile_commands.json .thinlto-cache
15108c2ecf20Sopenharmony_ci
15118c2ecf20Sopenharmony_ci# Directories & files removed with 'make mrproper'
15128c2ecf20Sopenharmony_ciMRPROPER_FILES += include/config include/generated          \
15138c2ecf20Sopenharmony_ci		  arch/$(SRCARCH)/include/generated .tmp_objdiff \
15148c2ecf20Sopenharmony_ci		  debian snap tar-install \
15158c2ecf20Sopenharmony_ci		  .config .config.old .version \
15168c2ecf20Sopenharmony_ci		  Module.symvers \
15178c2ecf20Sopenharmony_ci		  signing_key.pem signing_key.priv signing_key.x509	\
15188c2ecf20Sopenharmony_ci		  x509.genkey extra_certificates signing_key.x509.keyid	\
15198c2ecf20Sopenharmony_ci		  signing_key.x509.signer vmlinux-gdb.py \
15208c2ecf20Sopenharmony_ci		  *.spec
15218c2ecf20Sopenharmony_ci
15228c2ecf20Sopenharmony_ci# Directories & files removed with 'make distclean'
15238c2ecf20Sopenharmony_ciDISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
15248c2ecf20Sopenharmony_ci
15258c2ecf20Sopenharmony_ci# clean - Delete most, but leave enough to build external modules
15268c2ecf20Sopenharmony_ci#
15278c2ecf20Sopenharmony_ciclean: rm-files := $(CLEAN_FILES)
15288c2ecf20Sopenharmony_ci
15298c2ecf20Sopenharmony_ciPHONY += archclean vmlinuxclean
15308c2ecf20Sopenharmony_ci
15318c2ecf20Sopenharmony_civmlinuxclean:
15328c2ecf20Sopenharmony_ci	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean
15338c2ecf20Sopenharmony_ci	$(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean)
15348c2ecf20Sopenharmony_ci
15358c2ecf20Sopenharmony_ciclean: archclean vmlinuxclean resolve_btfids_clean
15368c2ecf20Sopenharmony_ci
15378c2ecf20Sopenharmony_ci# mrproper - Delete all generated files, including .config
15388c2ecf20Sopenharmony_ci#
15398c2ecf20Sopenharmony_cimrproper: rm-files := $(wildcard $(MRPROPER_FILES))
15408c2ecf20Sopenharmony_cimrproper-dirs      := $(addprefix _mrproper_,scripts)
15418c2ecf20Sopenharmony_ci
15428c2ecf20Sopenharmony_ciPHONY += $(mrproper-dirs) mrproper
15438c2ecf20Sopenharmony_ci$(mrproper-dirs):
15448c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
15458c2ecf20Sopenharmony_ci
15468c2ecf20Sopenharmony_cimrproper: clean $(mrproper-dirs)
15478c2ecf20Sopenharmony_ci	$(call cmd,rmfiles)
15488c2ecf20Sopenharmony_ci
15498c2ecf20Sopenharmony_ci# distclean
15508c2ecf20Sopenharmony_ci#
15518c2ecf20Sopenharmony_cidistclean: rm-files := $(wildcard $(DISTCLEAN_FILES))
15528c2ecf20Sopenharmony_ci
15538c2ecf20Sopenharmony_ciPHONY += distclean
15548c2ecf20Sopenharmony_ci
15558c2ecf20Sopenharmony_cidistclean: mrproper
15568c2ecf20Sopenharmony_ci	$(call cmd,rmfiles)
15578c2ecf20Sopenharmony_ci	@find $(srctree) $(RCS_FIND_IGNORE) \
15588c2ecf20Sopenharmony_ci		\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
15598c2ecf20Sopenharmony_ci		-o -name '*.bak' -o -name '#*#' -o -name '*%' \
15608c2ecf20Sopenharmony_ci		-o -name 'core' \) \
15618c2ecf20Sopenharmony_ci		-type f -print | xargs rm -f
15628c2ecf20Sopenharmony_ci
15638c2ecf20Sopenharmony_ci
15648c2ecf20Sopenharmony_ci# Packaging of the kernel to various formats
15658c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
15668c2ecf20Sopenharmony_ci
15678c2ecf20Sopenharmony_ci%src-pkg: FORCE
15688c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
15698c2ecf20Sopenharmony_ci%pkg: include/config/kernel.release FORCE
15708c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@
15718c2ecf20Sopenharmony_ci
15728c2ecf20Sopenharmony_ci# Brief documentation of the typical targets used
15738c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
15748c2ecf20Sopenharmony_ci
15758c2ecf20Sopenharmony_ciboards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig)
15768c2ecf20Sopenharmony_ciboards := $(sort $(notdir $(boards)))
15778c2ecf20Sopenharmony_ciboard-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig))
15788c2ecf20Sopenharmony_ciboard-dirs := $(sort $(notdir $(board-dirs:/=)))
15798c2ecf20Sopenharmony_ci
15808c2ecf20Sopenharmony_ciPHONY += help
15818c2ecf20Sopenharmony_cihelp:
15828c2ecf20Sopenharmony_ci	@echo  'Cleaning targets:'
15838c2ecf20Sopenharmony_ci	@echo  '  clean		  - Remove most generated files but keep the config and'
15848c2ecf20Sopenharmony_ci	@echo  '                    enough build support to build external modules'
15858c2ecf20Sopenharmony_ci	@echo  '  mrproper	  - Remove all generated files + config + various backup files'
15868c2ecf20Sopenharmony_ci	@echo  '  distclean	  - mrproper + remove editor backup and patch files'
15878c2ecf20Sopenharmony_ci	@echo  ''
15888c2ecf20Sopenharmony_ci	@echo  'Configuration targets:'
15898c2ecf20Sopenharmony_ci	@$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help
15908c2ecf20Sopenharmony_ci	@echo  ''
15918c2ecf20Sopenharmony_ci	@echo  'Other generic targets:'
15928c2ecf20Sopenharmony_ci	@echo  '  all		  - Build all targets marked with [*]'
15938c2ecf20Sopenharmony_ci	@echo  '* vmlinux	  - Build the bare kernel'
15948c2ecf20Sopenharmony_ci	@echo  '* modules	  - Build all modules'
15958c2ecf20Sopenharmony_ci	@echo  '  modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
15968c2ecf20Sopenharmony_ci	@echo  '  dir/            - Build all files in dir and below'
15978c2ecf20Sopenharmony_ci	@echo  '  dir/file.[ois]  - Build specified target only'
15988c2ecf20Sopenharmony_ci	@echo  '  dir/file.ll     - Build the LLVM assembly file'
15998c2ecf20Sopenharmony_ci	@echo  '                    (requires compiler support for LLVM assembly generation)'
16008c2ecf20Sopenharmony_ci	@echo  '  dir/file.lst    - Build specified mixed source/assembly target only'
16018c2ecf20Sopenharmony_ci	@echo  '                    (requires a recent binutils and recent build (System.map))'
16028c2ecf20Sopenharmony_ci	@echo  '  dir/file.ko     - Build module including final link'
16038c2ecf20Sopenharmony_ci	@echo  '  modules_prepare - Set up for building external modules'
16048c2ecf20Sopenharmony_ci	@echo  '  tags/TAGS	  - Generate tags file for editors'
16058c2ecf20Sopenharmony_ci	@echo  '  cscope	  - Generate cscope index'
16068c2ecf20Sopenharmony_ci	@echo  '  gtags           - Generate GNU GLOBAL index'
16078c2ecf20Sopenharmony_ci	@echo  '  kernelrelease	  - Output the release version string (use with make -s)'
16088c2ecf20Sopenharmony_ci	@echo  '  kernelversion	  - Output the version stored in Makefile (use with make -s)'
16098c2ecf20Sopenharmony_ci	@echo  '  image_name	  - Output the image name (use with make -s)'
16108c2ecf20Sopenharmony_ci	@echo  '  headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
16118c2ecf20Sopenharmony_ci	 echo  '                    (default: $(INSTALL_HDR_PATH))'; \
16128c2ecf20Sopenharmony_ci	 echo  ''
16138c2ecf20Sopenharmony_ci	@echo  'Static analysers:'
16148c2ecf20Sopenharmony_ci	@echo  '  checkstack      - Generate a list of stack hogs'
16158c2ecf20Sopenharmony_ci	@echo  '  versioncheck    - Sanity check on version.h usage'
16168c2ecf20Sopenharmony_ci	@echo  '  includecheck    - Check for duplicate included header files'
16178c2ecf20Sopenharmony_ci	@echo  '  export_report   - List the usages of all exported symbols'
16188c2ecf20Sopenharmony_ci	@echo  '  headerdep       - Detect inclusion cycles in headers'
16198c2ecf20Sopenharmony_ci	@echo  '  coccicheck      - Check with Coccinelle'
16208c2ecf20Sopenharmony_ci	@echo  '  clang-analyzer  - Check with clang static analyzer'
16218c2ecf20Sopenharmony_ci	@echo  '  clang-tidy      - Check with clang-tidy'
16228c2ecf20Sopenharmony_ci	@echo  ''
16238c2ecf20Sopenharmony_ci	@echo  'Tools:'
16248c2ecf20Sopenharmony_ci	@echo  '  nsdeps          - Generate missing symbol namespace dependencies'
16258c2ecf20Sopenharmony_ci	@echo  ''
16268c2ecf20Sopenharmony_ci	@echo  'Kernel selftest:'
16278c2ecf20Sopenharmony_ci	@echo  '  kselftest         - Build and run kernel selftest'
16288c2ecf20Sopenharmony_ci	@echo  '                      Build, install, and boot kernel before'
16298c2ecf20Sopenharmony_ci	@echo  '                      running kselftest on it'
16308c2ecf20Sopenharmony_ci	@echo  '                      Run as root for full coverage'
16318c2ecf20Sopenharmony_ci	@echo  '  kselftest-all     - Build kernel selftest'
16328c2ecf20Sopenharmony_ci	@echo  '  kselftest-install - Build and install kernel selftest'
16338c2ecf20Sopenharmony_ci	@echo  '  kselftest-clean   - Remove all generated kselftest files'
16348c2ecf20Sopenharmony_ci	@echo  '  kselftest-merge   - Merge all the config dependencies of'
16358c2ecf20Sopenharmony_ci	@echo  '		      kselftest to existing .config.'
16368c2ecf20Sopenharmony_ci	@echo  ''
16378c2ecf20Sopenharmony_ci	@$(if $(dtstree), \
16388c2ecf20Sopenharmony_ci		echo 'Devicetree:'; \
16398c2ecf20Sopenharmony_ci		echo '* dtbs             - Build device tree blobs for enabled boards'; \
16408c2ecf20Sopenharmony_ci		echo '  dtbs_install     - Install dtbs to $(INSTALL_DTBS_PATH)'; \
16418c2ecf20Sopenharmony_ci		echo '  dt_binding_check - Validate device tree binding documents'; \
16428c2ecf20Sopenharmony_ci		echo '  dtbs_check       - Validate device tree source files';\
16438c2ecf20Sopenharmony_ci		echo '')
16448c2ecf20Sopenharmony_ci
16458c2ecf20Sopenharmony_ci	@echo 'Userspace tools targets:'
16468c2ecf20Sopenharmony_ci	@echo '  use "make tools/help"'
16478c2ecf20Sopenharmony_ci	@echo '  or  "cd tools; make help"'
16488c2ecf20Sopenharmony_ci	@echo  ''
16498c2ecf20Sopenharmony_ci	@echo  'Kernel packaging:'
16508c2ecf20Sopenharmony_ci	@$(MAKE) -f $(srctree)/scripts/Makefile.package help
16518c2ecf20Sopenharmony_ci	@echo  ''
16528c2ecf20Sopenharmony_ci	@echo  'Documentation targets:'
16538c2ecf20Sopenharmony_ci	@$(MAKE) -f $(srctree)/Documentation/Makefile dochelp
16548c2ecf20Sopenharmony_ci	@echo  ''
16558c2ecf20Sopenharmony_ci	@echo  'Architecture specific targets ($(SRCARCH)):'
16568c2ecf20Sopenharmony_ci	@$(if $(archhelp),$(archhelp),\
16578c2ecf20Sopenharmony_ci		echo '  No architecture specific help defined for $(SRCARCH)')
16588c2ecf20Sopenharmony_ci	@echo  ''
16598c2ecf20Sopenharmony_ci	@$(if $(boards), \
16608c2ecf20Sopenharmony_ci		$(foreach b, $(boards), \
16618c2ecf20Sopenharmony_ci		printf "  %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \
16628c2ecf20Sopenharmony_ci		echo '')
16638c2ecf20Sopenharmony_ci	@$(if $(board-dirs), \
16648c2ecf20Sopenharmony_ci		$(foreach b, $(board-dirs), \
16658c2ecf20Sopenharmony_ci		printf "  %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \
16668c2ecf20Sopenharmony_ci		printf "  %-16s - Show all of the above\\n" help-boards; \
16678c2ecf20Sopenharmony_ci		echo '')
16688c2ecf20Sopenharmony_ci
16698c2ecf20Sopenharmony_ci	@echo  '  make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
16708c2ecf20Sopenharmony_ci	@echo  '  make V=2   [targets] 2 => give reason for rebuild of target'
16718c2ecf20Sopenharmony_ci	@echo  '  make O=dir [targets] Locate all output files in "dir", including .config'
16728c2ecf20Sopenharmony_ci	@echo  '  make C=1   [targets] Check re-compiled c source with $$CHECK'
16738c2ecf20Sopenharmony_ci	@echo  '                       (sparse by default)'
16748c2ecf20Sopenharmony_ci	@echo  '  make C=2   [targets] Force check of all c source with $$CHECK'
16758c2ecf20Sopenharmony_ci	@echo  '  make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
16768c2ecf20Sopenharmony_ci	@echo  '  make W=n   [targets] Enable extra build checks, n=1,2,3 where'
16778c2ecf20Sopenharmony_ci	@echo  '		1: warnings which may be relevant and do not occur too often'
16788c2ecf20Sopenharmony_ci	@echo  '		2: warnings which occur quite often but may still be relevant'
16798c2ecf20Sopenharmony_ci	@echo  '		3: more obscure warnings, can most likely be ignored'
16808c2ecf20Sopenharmony_ci	@echo  '		Multiple levels can be combined with W=12 or W=123'
16818c2ecf20Sopenharmony_ci	@echo  ''
16828c2ecf20Sopenharmony_ci	@echo  'Execute "make" or "make all" to build all targets marked with [*] '
16838c2ecf20Sopenharmony_ci	@echo  'For further info see the ./README file'
16848c2ecf20Sopenharmony_ci
16858c2ecf20Sopenharmony_ci
16868c2ecf20Sopenharmony_cihelp-board-dirs := $(addprefix help-,$(board-dirs))
16878c2ecf20Sopenharmony_ci
16888c2ecf20Sopenharmony_cihelp-boards: $(help-board-dirs)
16898c2ecf20Sopenharmony_ci
16908c2ecf20Sopenharmony_ciboards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig)))
16918c2ecf20Sopenharmony_ci
16928c2ecf20Sopenharmony_ci$(help-board-dirs): help-%:
16938c2ecf20Sopenharmony_ci	@echo  'Architecture specific targets ($(SRCARCH) $*):'
16948c2ecf20Sopenharmony_ci	@$(if $(boards-per-dir), \
16958c2ecf20Sopenharmony_ci		$(foreach b, $(boards-per-dir), \
16968c2ecf20Sopenharmony_ci		printf "  %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \
16978c2ecf20Sopenharmony_ci		echo '')
16988c2ecf20Sopenharmony_ci
16998c2ecf20Sopenharmony_ci
17008c2ecf20Sopenharmony_ci# Documentation targets
17018c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
17028c2ecf20Sopenharmony_ciDOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \
17038c2ecf20Sopenharmony_ci	       linkcheckdocs dochelp refcheckdocs
17048c2ecf20Sopenharmony_ciPHONY += $(DOC_TARGETS)
17058c2ecf20Sopenharmony_ci$(DOC_TARGETS):
17068c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=Documentation $@
17078c2ecf20Sopenharmony_ci
17088c2ecf20Sopenharmony_ci# Misc
17098c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
17108c2ecf20Sopenharmony_ci
17118c2ecf20Sopenharmony_ciPHONY += scripts_gdb
17128c2ecf20Sopenharmony_ciscripts_gdb: prepare0
17138c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=scripts/gdb
17148c2ecf20Sopenharmony_ci	$(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
17158c2ecf20Sopenharmony_ci
17168c2ecf20Sopenharmony_ciifdef CONFIG_GDB_SCRIPTS
17178c2ecf20Sopenharmony_ciall: scripts_gdb
17188c2ecf20Sopenharmony_ciendif
17198c2ecf20Sopenharmony_ci
17208c2ecf20Sopenharmony_cielse # KBUILD_EXTMOD
17218c2ecf20Sopenharmony_ci
17228c2ecf20Sopenharmony_ci###
17238c2ecf20Sopenharmony_ci# External module support.
17248c2ecf20Sopenharmony_ci# When building external modules the kernel used as basis is considered
17258c2ecf20Sopenharmony_ci# read-only, and no consistency checks are made and the make
17268c2ecf20Sopenharmony_ci# system is not used on the basis kernel. If updates are required
17278c2ecf20Sopenharmony_ci# in the basis kernel ordinary make commands (without M=...) must
17288c2ecf20Sopenharmony_ci# be used.
17298c2ecf20Sopenharmony_ci#
17308c2ecf20Sopenharmony_ci# The following are the only valid targets when building external
17318c2ecf20Sopenharmony_ci# modules.
17328c2ecf20Sopenharmony_ci# make M=dir clean     Delete all automatically generated files
17338c2ecf20Sopenharmony_ci# make M=dir modules   Make all modules in specified dir
17348c2ecf20Sopenharmony_ci# make M=dir	       Same as 'make M=dir modules'
17358c2ecf20Sopenharmony_ci# make M=dir modules_install
17368c2ecf20Sopenharmony_ci#                      Install the modules built in the module directory
17378c2ecf20Sopenharmony_ci#                      Assumes install directory is already created
17388c2ecf20Sopenharmony_ci
17398c2ecf20Sopenharmony_ci# We are always building only modules.
17408c2ecf20Sopenharmony_ciKBUILD_BUILTIN :=
17418c2ecf20Sopenharmony_ciKBUILD_MODULES := 1
17428c2ecf20Sopenharmony_ci
17438c2ecf20Sopenharmony_cibuild-dirs := $(KBUILD_EXTMOD)
17448c2ecf20Sopenharmony_ci$(MODORDER): descend
17458c2ecf20Sopenharmony_ci	@:
17468c2ecf20Sopenharmony_ci
17478c2ecf20Sopenharmony_cicompile_commands.json: $(extmod-prefix)compile_commands.json
17488c2ecf20Sopenharmony_ciPHONY += compile_commands.json
17498c2ecf20Sopenharmony_ci
17508c2ecf20Sopenharmony_ciclean-dirs := $(KBUILD_EXTMOD)
17518c2ecf20Sopenharmony_ciclean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \
17528c2ecf20Sopenharmony_ci	$(KBUILD_EXTMOD)/compile_commands.json $(KBUILD_EXTMOD)/.thinlto-cache
17538c2ecf20Sopenharmony_ci
17548c2ecf20Sopenharmony_ciPHONY += help
17558c2ecf20Sopenharmony_cihelp:
17568c2ecf20Sopenharmony_ci	@echo  '  Building external modules.'
17578c2ecf20Sopenharmony_ci	@echo  '  Syntax: make -C path/to/kernel/src M=$$PWD target'
17588c2ecf20Sopenharmony_ci	@echo  ''
17598c2ecf20Sopenharmony_ci	@echo  '  modules         - default target, build the module(s)'
17608c2ecf20Sopenharmony_ci	@echo  '  modules_install - install the module'
17618c2ecf20Sopenharmony_ci	@echo  '  clean           - remove generated files in module directory only'
17628c2ecf20Sopenharmony_ci	@echo  ''
17638c2ecf20Sopenharmony_ci
17648c2ecf20Sopenharmony_ci# no-op for external module builds
17658c2ecf20Sopenharmony_ciPHONY += prepare modules_prepare
17668c2ecf20Sopenharmony_ci
17678c2ecf20Sopenharmony_ciendif # KBUILD_EXTMOD
17688c2ecf20Sopenharmony_ci
17698c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
17708c2ecf20Sopenharmony_ci# Modules
17718c2ecf20Sopenharmony_ci
17728c2ecf20Sopenharmony_ciPHONY += modules modules_install
17738c2ecf20Sopenharmony_ci
17748c2ecf20Sopenharmony_ciifdef CONFIG_MODULES
17758c2ecf20Sopenharmony_ci
17768c2ecf20Sopenharmony_cimodules: $(MODORDER)
17778c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
17788c2ecf20Sopenharmony_ci
17798c2ecf20Sopenharmony_ciquiet_cmd_depmod = DEPMOD  $(KERNELRELEASE)
17808c2ecf20Sopenharmony_ci      cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
17818c2ecf20Sopenharmony_ci                   $(KERNELRELEASE)
17828c2ecf20Sopenharmony_ci
17838c2ecf20Sopenharmony_cimodules_install:
17848c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
17858c2ecf20Sopenharmony_ci	$(call cmd,depmod)
17868c2ecf20Sopenharmony_ci
17878c2ecf20Sopenharmony_cielse # CONFIG_MODULES
17888c2ecf20Sopenharmony_ci
17898c2ecf20Sopenharmony_ci# Modules not configured
17908c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
17918c2ecf20Sopenharmony_ci
17928c2ecf20Sopenharmony_cimodules modules_install:
17938c2ecf20Sopenharmony_ci	@echo >&2 '***'
17948c2ecf20Sopenharmony_ci	@echo >&2 '*** The present kernel configuration has modules disabled.'
17958c2ecf20Sopenharmony_ci	@echo >&2 '*** To use the module feature, please run "make menuconfig" etc.'
17968c2ecf20Sopenharmony_ci	@echo >&2 '*** to enable CONFIG_MODULES.'
17978c2ecf20Sopenharmony_ci	@echo >&2 '***'
17988c2ecf20Sopenharmony_ci	@exit 1
17998c2ecf20Sopenharmony_ci
18008c2ecf20Sopenharmony_ciKBUILD_MODULES :=
18018c2ecf20Sopenharmony_ci
18028c2ecf20Sopenharmony_ciendif # CONFIG_MODULES
18038c2ecf20Sopenharmony_ci
18048c2ecf20Sopenharmony_ci# Single targets
18058c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
18068c2ecf20Sopenharmony_ci# To build individual files in subdirectories, you can do like this:
18078c2ecf20Sopenharmony_ci#
18088c2ecf20Sopenharmony_ci#   make foo/bar/baz.s
18098c2ecf20Sopenharmony_ci#
18108c2ecf20Sopenharmony_ci# The supported suffixes for single-target are listed in 'single-targets'
18118c2ecf20Sopenharmony_ci#
18128c2ecf20Sopenharmony_ci# To build only under specific subdirectories, you can do like this:
18138c2ecf20Sopenharmony_ci#
18148c2ecf20Sopenharmony_ci#   make foo/bar/baz/
18158c2ecf20Sopenharmony_ci
18168c2ecf20Sopenharmony_ciifdef single-build
18178c2ecf20Sopenharmony_ci
18188c2ecf20Sopenharmony_ci# .ko is special because modpost is needed
18198c2ecf20Sopenharmony_cisingle-ko := $(sort $(filter %.ko, $(MAKECMDGOALS)))
18208c2ecf20Sopenharmony_cisingle-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS)))
18218c2ecf20Sopenharmony_ci
18228c2ecf20Sopenharmony_ci$(single-ko): single_modpost
18238c2ecf20Sopenharmony_ci	@:
18248c2ecf20Sopenharmony_ci$(single-no-ko): descend
18258c2ecf20Sopenharmony_ci	@:
18268c2ecf20Sopenharmony_ci
18278c2ecf20Sopenharmony_ci# Remove MODORDER when done because it is not the real one.
18288c2ecf20Sopenharmony_ciPHONY += single_modpost
18298c2ecf20Sopenharmony_cisingle_modpost: $(single-no-ko) modules_prepare
18308c2ecf20Sopenharmony_ci	$(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER)
18318c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
18328c2ecf20Sopenharmony_ci	$(Q)rm -f $(MODORDER)
18338c2ecf20Sopenharmony_ci
18348c2ecf20Sopenharmony_ciexport KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko))
18358c2ecf20Sopenharmony_ci
18368c2ecf20Sopenharmony_ci# trim unrelated directories
18378c2ecf20Sopenharmony_cibuild-dirs := $(foreach d, $(build-dirs), \
18388c2ecf20Sopenharmony_ci			$(if $(filter $(d)/%, $(KBUILD_SINGLE_TARGETS)), $(d)))
18398c2ecf20Sopenharmony_ci
18408c2ecf20Sopenharmony_ciendif
18418c2ecf20Sopenharmony_ci
18428c2ecf20Sopenharmony_ci# Handle descending into subdirectories listed in $(build-dirs)
18438c2ecf20Sopenharmony_ci# Preset locale variables to speed up the build process. Limit locale
18448c2ecf20Sopenharmony_ci# tweaks to this spot to avoid wrong language settings when running
18458c2ecf20Sopenharmony_ci# make menuconfig etc.
18468c2ecf20Sopenharmony_ci# Error messages still appears in the original language
18478c2ecf20Sopenharmony_ciPHONY += descend $(build-dirs)
18488c2ecf20Sopenharmony_cidescend: $(build-dirs)
18498c2ecf20Sopenharmony_ci$(build-dirs): prepare
18508c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=$@ \
18518c2ecf20Sopenharmony_ci	single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \
18528c2ecf20Sopenharmony_ci	need-builtin=1 need-modorder=1
18538c2ecf20Sopenharmony_ci
18548c2ecf20Sopenharmony_ciclean-dirs := $(addprefix _clean_, $(clean-dirs))
18558c2ecf20Sopenharmony_ciPHONY += $(clean-dirs) clean
18568c2ecf20Sopenharmony_ci$(clean-dirs):
18578c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
18588c2ecf20Sopenharmony_ci
18598c2ecf20Sopenharmony_ciclean: $(clean-dirs)
18608c2ecf20Sopenharmony_ci	$(call cmd,rmfiles)
18618c2ecf20Sopenharmony_ci	@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
18628c2ecf20Sopenharmony_ci		\( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
18638c2ecf20Sopenharmony_ci		-o -name '*.ko.*' \
18648c2ecf20Sopenharmony_ci		-o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
18658c2ecf20Sopenharmony_ci		-o -name '*.dwo' -o -name '*.lst' \
18668c2ecf20Sopenharmony_ci		-o -name '*.su' -o -name '*.mod' \
18678c2ecf20Sopenharmony_ci		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
18688c2ecf20Sopenharmony_ci		-o -name '*.lex.c' -o -name '*.tab.[ch]' \
18698c2ecf20Sopenharmony_ci		-o -name '*.asn1.[ch]' \
18708c2ecf20Sopenharmony_ci		-o -name '*.symtypes' -o -name 'modules.order' \
18718c2ecf20Sopenharmony_ci		-o -name '.tmp_*.o.*' \
18728c2ecf20Sopenharmony_ci		-o -name '*.c.[012]*.*' \
18738c2ecf20Sopenharmony_ci		-o -name '*.ll' \
18748c2ecf20Sopenharmony_ci		-o -name '*.gcno' \
18758c2ecf20Sopenharmony_ci		-o -name '*.*.symversions' \) -type f -print | xargs rm -f
18768c2ecf20Sopenharmony_ci
18778c2ecf20Sopenharmony_ci# Generate tags for editors
18788c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
18798c2ecf20Sopenharmony_ciquiet_cmd_tags = GEN     $@
18808c2ecf20Sopenharmony_ci      cmd_tags = $(BASH) $(srctree)/scripts/tags.sh $@
18818c2ecf20Sopenharmony_ci
18828c2ecf20Sopenharmony_citags TAGS cscope gtags: FORCE
18838c2ecf20Sopenharmony_ci	$(call cmd,tags)
18848c2ecf20Sopenharmony_ci
18858c2ecf20Sopenharmony_ci# Script to generate missing namespace dependencies
18868c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
18878c2ecf20Sopenharmony_ci
18888c2ecf20Sopenharmony_ciPHONY += nsdeps
18898c2ecf20Sopenharmony_cinsdeps: export KBUILD_NSDEPS=1
18908c2ecf20Sopenharmony_cinsdeps: modules
18918c2ecf20Sopenharmony_ci	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/nsdeps
18928c2ecf20Sopenharmony_ci
18938c2ecf20Sopenharmony_ci# Clang Tooling
18948c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
18958c2ecf20Sopenharmony_ci
18968c2ecf20Sopenharmony_ciquiet_cmd_gen_compile_commands = GEN     $@
18978c2ecf20Sopenharmony_ci      cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs))
18988c2ecf20Sopenharmony_ci
18998c2ecf20Sopenharmony_ci$(extmod-prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \
19008c2ecf20Sopenharmony_ci	$(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \
19018c2ecf20Sopenharmony_ci	$(if $(CONFIG_MODULES), $(MODORDER)) FORCE
19028c2ecf20Sopenharmony_ci	$(call if_changed,gen_compile_commands)
19038c2ecf20Sopenharmony_ci
19048c2ecf20Sopenharmony_citargets += $(extmod-prefix)compile_commands.json
19058c2ecf20Sopenharmony_ci
19068c2ecf20Sopenharmony_ciPHONY += clang-tidy clang-analyzer
19078c2ecf20Sopenharmony_ci
19088c2ecf20Sopenharmony_ciifdef CONFIG_CC_IS_CLANG
19098c2ecf20Sopenharmony_ciquiet_cmd_clang_tools = CHECK   $<
19108c2ecf20Sopenharmony_ci      cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $<
19118c2ecf20Sopenharmony_ci
19128c2ecf20Sopenharmony_ciclang-tidy clang-analyzer: $(extmod-prefix)compile_commands.json
19138c2ecf20Sopenharmony_ci	$(call cmd,clang_tools)
19148c2ecf20Sopenharmony_cielse
19158c2ecf20Sopenharmony_ciclang-tidy clang-analyzer:
19168c2ecf20Sopenharmony_ci	@echo "$@ requires CC=clang" >&2
19178c2ecf20Sopenharmony_ci	@false
19188c2ecf20Sopenharmony_ciendif
19198c2ecf20Sopenharmony_ci
19208c2ecf20Sopenharmony_ci# Scripts to check various things for consistency
19218c2ecf20Sopenharmony_ci# ---------------------------------------------------------------------------
19228c2ecf20Sopenharmony_ci
19238c2ecf20Sopenharmony_ciPHONY += includecheck versioncheck coccicheck export_report
19248c2ecf20Sopenharmony_ci
19258c2ecf20Sopenharmony_ciincludecheck:
19268c2ecf20Sopenharmony_ci	find $(srctree)/* $(RCS_FIND_IGNORE) \
19278c2ecf20Sopenharmony_ci		-name '*.[hcS]' -type f -print | sort \
19288c2ecf20Sopenharmony_ci		| xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl
19298c2ecf20Sopenharmony_ci
19308c2ecf20Sopenharmony_civersioncheck:
19318c2ecf20Sopenharmony_ci	find $(srctree)/* $(RCS_FIND_IGNORE) \
19328c2ecf20Sopenharmony_ci		-name '*.[hcS]' -type f -print | sort \
19338c2ecf20Sopenharmony_ci		| xargs $(PERL) -w $(srctree)/scripts/checkversion.pl
19348c2ecf20Sopenharmony_ci
19358c2ecf20Sopenharmony_cicoccicheck:
19368c2ecf20Sopenharmony_ci	$(Q)$(BASH) $(srctree)/scripts/$@
19378c2ecf20Sopenharmony_ci
19388c2ecf20Sopenharmony_ciexport_report:
19398c2ecf20Sopenharmony_ci	$(PERL) $(srctree)/scripts/export_report.pl
19408c2ecf20Sopenharmony_ci
19418c2ecf20Sopenharmony_ciPHONY += checkstack kernelrelease kernelversion image_name
19428c2ecf20Sopenharmony_ci
19438c2ecf20Sopenharmony_ci# UML needs a little special treatment here.  It wants to use the host
19448c2ecf20Sopenharmony_ci# toolchain, so needs $(SUBARCH) passed to checkstack.pl.  Everyone
19458c2ecf20Sopenharmony_ci# else wants $(ARCH), including people doing cross-builds, which means
19468c2ecf20Sopenharmony_ci# that $(SUBARCH) doesn't work here.
19478c2ecf20Sopenharmony_ciifeq ($(ARCH), um)
19488c2ecf20Sopenharmony_ciCHECKSTACK_ARCH := $(SUBARCH)
19498c2ecf20Sopenharmony_cielse
19508c2ecf20Sopenharmony_ciCHECKSTACK_ARCH := $(ARCH)
19518c2ecf20Sopenharmony_ciendif
19528c2ecf20Sopenharmony_cicheckstack:
19538c2ecf20Sopenharmony_ci	$(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
19548c2ecf20Sopenharmony_ci	$(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH)
19558c2ecf20Sopenharmony_ci
19568c2ecf20Sopenharmony_cikernelrelease:
19578c2ecf20Sopenharmony_ci	@echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
19588c2ecf20Sopenharmony_ci
19598c2ecf20Sopenharmony_cikernelversion:
19608c2ecf20Sopenharmony_ci	@echo $(KERNELVERSION)
19618c2ecf20Sopenharmony_ci
19628c2ecf20Sopenharmony_ciimage_name:
19638c2ecf20Sopenharmony_ci	@echo $(KBUILD_IMAGE)
19648c2ecf20Sopenharmony_ci
19658c2ecf20Sopenharmony_ci# Clear a bunch of variables before executing the submake
19668c2ecf20Sopenharmony_ci
19678c2ecf20Sopenharmony_ciifeq ($(quiet),silent_)
19688c2ecf20Sopenharmony_citools_silent=s
19698c2ecf20Sopenharmony_ciendif
19708c2ecf20Sopenharmony_ci
19718c2ecf20Sopenharmony_citools/: FORCE
19728c2ecf20Sopenharmony_ci	$(Q)mkdir -p $(objtree)/tools
19738c2ecf20Sopenharmony_ci	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/
19748c2ecf20Sopenharmony_ci
19758c2ecf20Sopenharmony_citools/%: FORCE
19768c2ecf20Sopenharmony_ci	$(Q)mkdir -p $(objtree)/tools
19778c2ecf20Sopenharmony_ci	$(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $*
19788c2ecf20Sopenharmony_ci
19798c2ecf20Sopenharmony_ciquiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files)))
19808c2ecf20Sopenharmony_ci      cmd_rmfiles = rm -rf $(rm-files)
19818c2ecf20Sopenharmony_ci
19828c2ecf20Sopenharmony_ci# read saved command lines for existing targets
19838c2ecf20Sopenharmony_ciexisting-targets := $(wildcard $(sort $(targets)))
19848c2ecf20Sopenharmony_ci
19858c2ecf20Sopenharmony_ci-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
19868c2ecf20Sopenharmony_ci
19878c2ecf20Sopenharmony_ciendif # config-build
19888c2ecf20Sopenharmony_ciendif # mixed-build
19898c2ecf20Sopenharmony_ciendif # need-sub-make
19908c2ecf20Sopenharmony_ci
19918c2ecf20Sopenharmony_ciPHONY += FORCE
19928c2ecf20Sopenharmony_ciFORCE:
19938c2ecf20Sopenharmony_ci
19948c2ecf20Sopenharmony_ci# Declare the contents of the PHONY variable as phony.  We keep that
19958c2ecf20Sopenharmony_ci# information in a variable so we can use it in if_changed and friends.
19968c2ecf20Sopenharmony_ci.PHONY: $(PHONY)
1997