13d0407baSopenharmony_ci# SPDX-License-Identifier: GPL-2.0 23d0407baSopenharmony_ciVERSION = 5 33d0407baSopenharmony_ciPATCHLEVEL = 10 43d0407baSopenharmony_ciSUBLEVEL = 137 53d0407baSopenharmony_ciEXTRAVERSION = 63d0407baSopenharmony_ciNAME = Dare mighty things 73d0407baSopenharmony_ci 83d0407baSopenharmony_ci# *DOCUMENTATION* 93d0407baSopenharmony_ci# To see a list of typical targets execute "make help" 103d0407baSopenharmony_ci# More info can be located in ./README 113d0407baSopenharmony_ci# Comments in this file are targeted only to the developer, do not 123d0407baSopenharmony_ci# expect to learn how to build the kernel reading this file. 133d0407baSopenharmony_ci 143d0407baSopenharmony_ci$(if $(filter __%, $(MAKECMDGOALS)), \ 153d0407baSopenharmony_ci $(error targets prefixed with '__' are only for internal use)) 163d0407baSopenharmony_ci 173d0407baSopenharmony_ci# That's our default target when none is given on the command line 183d0407baSopenharmony_ciPHONY := __all 193d0407baSopenharmony_ci__all: 203d0407baSopenharmony_ci 213d0407baSopenharmony_ci# We are using a recursive build, so we need to do a little thinking 223d0407baSopenharmony_ci# to get the ordering right. 233d0407baSopenharmony_ci# 243d0407baSopenharmony_ci# Most importantly: sub-Makefiles should only ever modify files in 253d0407baSopenharmony_ci# their own directory. If in some directory we have a dependency on 263d0407baSopenharmony_ci# a file in another dir (which doesn't happen often, but it's often 273d0407baSopenharmony_ci# unavoidable when linking the built-in.a targets which finally 283d0407baSopenharmony_ci# turn into vmlinux), we will call a sub make in that other dir, and 293d0407baSopenharmony_ci# after that we are sure that everything which is in that other dir 303d0407baSopenharmony_ci# is now up to date. 313d0407baSopenharmony_ci# 323d0407baSopenharmony_ci# The only cases where we need to modify files which have global 333d0407baSopenharmony_ci# effects are thus separated out and done before the recursive 343d0407baSopenharmony_ci# descending is started. They are now explicitly listed as the 353d0407baSopenharmony_ci# prepare rule. 363d0407baSopenharmony_ci 373d0407baSopenharmony_ciifneq ($(sub_make_done),1) 383d0407baSopenharmony_ci 393d0407baSopenharmony_ci# Do not use make's built-in rules and variables 403d0407baSopenharmony_ci# (this increases performance and avoids hard-to-debug behaviour) 413d0407baSopenharmony_ciMAKEFLAGS += -rR 423d0407baSopenharmony_ci 433d0407baSopenharmony_ci# Avoid funny character set dependencies 443d0407baSopenharmony_ciunexport LC_ALL 453d0407baSopenharmony_ciLC_COLLATE=C 463d0407baSopenharmony_ciLC_NUMERIC=C 473d0407baSopenharmony_ciexport LC_COLLATE LC_NUMERIC 483d0407baSopenharmony_ci 493d0407baSopenharmony_ci# Avoid interference with shell env settings 503d0407baSopenharmony_ciunexport GREP_OPTIONS 513d0407baSopenharmony_ci 523d0407baSopenharmony_ci# Beautify output 533d0407baSopenharmony_ci# --------------------------------------------------------------------------- 543d0407baSopenharmony_ci# 553d0407baSopenharmony_ci# Normally, we echo the whole command before executing it. By making 563d0407baSopenharmony_ci# that echo $($(quiet)$(cmd)), we now have the possibility to set 573d0407baSopenharmony_ci# $(quiet) to choose other forms of output instead, e.g. 583d0407baSopenharmony_ci# 593d0407baSopenharmony_ci# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ 603d0407baSopenharmony_ci# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 613d0407baSopenharmony_ci# 623d0407baSopenharmony_ci# If $(quiet) is empty, the whole command will be printed. 633d0407baSopenharmony_ci# If it is set to "quiet_", only the short version will be printed. 643d0407baSopenharmony_ci# If it is set to "silent_", nothing will be printed at all, since 653d0407baSopenharmony_ci# the variable $(silent_cmd_cc_o_c) doesn't exist. 663d0407baSopenharmony_ci# 673d0407baSopenharmony_ci# A simple variant is to prefix commands with $(Q) - that's useful 683d0407baSopenharmony_ci# for commands that shall be hidden in non-verbose mode. 693d0407baSopenharmony_ci# 703d0407baSopenharmony_ci# $(Q)ln $@ :< 713d0407baSopenharmony_ci# 723d0407baSopenharmony_ci# If KBUILD_VERBOSE equals 0 then the above command will be hidden. 733d0407baSopenharmony_ci# If KBUILD_VERBOSE equals 1 then the above command is displayed. 743d0407baSopenharmony_ci# If KBUILD_VERBOSE equals 2 then give the reason why each target is rebuilt. 753d0407baSopenharmony_ci# 763d0407baSopenharmony_ci# To put more focus on warnings, be less verbose as default 773d0407baSopenharmony_ci# Use 'make V=1' to see the full commands 783d0407baSopenharmony_ci 793d0407baSopenharmony_ciifeq ("$(origin V)", "command line") 803d0407baSopenharmony_ci KBUILD_VERBOSE = $(V) 813d0407baSopenharmony_ciendif 823d0407baSopenharmony_ciifndef KBUILD_VERBOSE 833d0407baSopenharmony_ci KBUILD_VERBOSE = 0 843d0407baSopenharmony_ciendif 853d0407baSopenharmony_ci 863d0407baSopenharmony_ciifeq ($(KBUILD_VERBOSE),1) 873d0407baSopenharmony_ci quiet = 883d0407baSopenharmony_ci Q = 893d0407baSopenharmony_cielse 903d0407baSopenharmony_ci quiet=quiet_ 913d0407baSopenharmony_ci Q = @ 923d0407baSopenharmony_ciendif 933d0407baSopenharmony_ci 943d0407baSopenharmony_ci# If the user is running make -s (silent mode), suppress echoing of 953d0407baSopenharmony_ci# commands 963d0407baSopenharmony_ci 973d0407baSopenharmony_ciifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) 983d0407baSopenharmony_ci quiet=silent_ 993d0407baSopenharmony_ciendif 1003d0407baSopenharmony_ci 1013d0407baSopenharmony_ciexport quiet Q KBUILD_VERBOSE 1023d0407baSopenharmony_ci 1033d0407baSopenharmony_ci# Kbuild will save output files in the current working directory. 1043d0407baSopenharmony_ci# This does not need to match to the root of the kernel source tree. 1053d0407baSopenharmony_ci# 1063d0407baSopenharmony_ci# For example, you can do this: 1073d0407baSopenharmony_ci# 1083d0407baSopenharmony_ci# cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile 1093d0407baSopenharmony_ci# 1103d0407baSopenharmony_ci# If you want to save output files in a different location, there are 1113d0407baSopenharmony_ci# two syntaxes to specify it. 1123d0407baSopenharmony_ci# 1133d0407baSopenharmony_ci# 1) O= 1143d0407baSopenharmony_ci# Use "make O=dir/to/store/output/files/" 1153d0407baSopenharmony_ci# 1163d0407baSopenharmony_ci# 2) Set KBUILD_OUTPUT 1173d0407baSopenharmony_ci# Set the environment variable KBUILD_OUTPUT to point to the output directory. 1183d0407baSopenharmony_ci# export KBUILD_OUTPUT=dir/to/store/output/files/; make 1193d0407baSopenharmony_ci# 1203d0407baSopenharmony_ci# The O= assignment takes precedence over the KBUILD_OUTPUT environment 1213d0407baSopenharmony_ci# variable. 1223d0407baSopenharmony_ci 1233d0407baSopenharmony_ci# Do we want to change the working directory? 1243d0407baSopenharmony_ciifeq ("$(origin O)", "command line") 1253d0407baSopenharmony_ci KBUILD_OUTPUT := $(O) 1263d0407baSopenharmony_ciendif 1273d0407baSopenharmony_ci 1283d0407baSopenharmony_ciifneq ($(KBUILD_OUTPUT),) 1293d0407baSopenharmony_ci# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot 1303d0407baSopenharmony_ci# expand a shell special character '~'. We use a somewhat tedious way here. 1313d0407baSopenharmony_ciabs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd) 1323d0407baSopenharmony_ci$(if $(abs_objtree),, \ 1333d0407baSopenharmony_ci $(error failed to create output directory "$(KBUILD_OUTPUT)")) 1343d0407baSopenharmony_ci 1353d0407baSopenharmony_ci# $(realpath ...) resolves symlinks 1363d0407baSopenharmony_ciabs_objtree := $(realpath $(abs_objtree)) 1373d0407baSopenharmony_cielse 1383d0407baSopenharmony_ciabs_objtree := $(CURDIR) 1393d0407baSopenharmony_ciendif # ifneq ($(KBUILD_OUTPUT),) 1403d0407baSopenharmony_ci 1413d0407baSopenharmony_ciifeq ($(abs_objtree),$(CURDIR)) 1423d0407baSopenharmony_ci# Suppress "Entering directory ..." unless we are changing the work directory. 1433d0407baSopenharmony_ciMAKEFLAGS += --no-print-directory 1443d0407baSopenharmony_cielse 1453d0407baSopenharmony_cineed-sub-make := 1 1463d0407baSopenharmony_ciendif 1473d0407baSopenharmony_ci 1483d0407baSopenharmony_ciabs_srctree := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) 1493d0407baSopenharmony_ci 1503d0407baSopenharmony_ciifneq ($(words $(subst :, ,$(abs_srctree))), 1) 1513d0407baSopenharmony_ci$(error source directory cannot contain spaces or colons) 1523d0407baSopenharmony_ciendif 1533d0407baSopenharmony_ci 1543d0407baSopenharmony_ciifneq ($(abs_srctree),$(abs_objtree)) 1553d0407baSopenharmony_ci# Look for make include files relative to root of kernel src 1563d0407baSopenharmony_ci# 1573d0407baSopenharmony_ci# This does not become effective immediately because MAKEFLAGS is re-parsed 1583d0407baSopenharmony_ci# once after the Makefile is read. We need to invoke sub-make. 1593d0407baSopenharmony_ciMAKEFLAGS += --include-dir=$(abs_srctree) 1603d0407baSopenharmony_cineed-sub-make := 1 1613d0407baSopenharmony_ciendif 1623d0407baSopenharmony_ci 1633d0407baSopenharmony_cithis-makefile := $(lastword $(MAKEFILE_LIST)) 1643d0407baSopenharmony_ci 1653d0407baSopenharmony_ciifneq ($(filter 3.%,$(MAKE_VERSION)),) 1663d0407baSopenharmony_ci# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x 1673d0407baSopenharmony_ci# We need to invoke sub-make to avoid implicit rules in the top Makefile. 1683d0407baSopenharmony_cineed-sub-make := 1 1693d0407baSopenharmony_ci# Cancel implicit rules for this Makefile. 1703d0407baSopenharmony_ci$(this-makefile): ; 1713d0407baSopenharmony_ciendif 1723d0407baSopenharmony_ci 1733d0407baSopenharmony_ciexport abs_srctree abs_objtree 1743d0407baSopenharmony_ciexport sub_make_done := 1 1753d0407baSopenharmony_ci 1763d0407baSopenharmony_ciifeq ($(need-sub-make),1) 1773d0407baSopenharmony_ci 1783d0407baSopenharmony_ciPHONY += $(MAKECMDGOALS) __sub-make 1793d0407baSopenharmony_ci 1803d0407baSopenharmony_ci$(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make 1813d0407baSopenharmony_ci @: 1823d0407baSopenharmony_ci 1833d0407baSopenharmony_ci# Invoke a second make in the output directory, passing relevant variables 1843d0407baSopenharmony_ci__sub-make: 1853d0407baSopenharmony_ci $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS) 1863d0407baSopenharmony_ci 1873d0407baSopenharmony_ciendif # need-sub-make 1883d0407baSopenharmony_ciendif # sub_make_done 1893d0407baSopenharmony_ci 1903d0407baSopenharmony_ci# We process the rest of the Makefile if this is the final invocation of make 1913d0407baSopenharmony_ciifeq ($(need-sub-make),) 1923d0407baSopenharmony_ci 1933d0407baSopenharmony_ci# Do not print "Entering directory ...", 1943d0407baSopenharmony_ci# but we want to display it when entering to the output directory 1953d0407baSopenharmony_ci# so that IDEs/editors are able to understand relative filenames. 1963d0407baSopenharmony_ciMAKEFLAGS += --no-print-directory 1973d0407baSopenharmony_ci 1983d0407baSopenharmony_ci# Call a source code checker (by default, "sparse") as part of the 1993d0407baSopenharmony_ci# C compilation. 2003d0407baSopenharmony_ci# 2013d0407baSopenharmony_ci# Use 'make C=1' to enable checking of only re-compiled files. 2023d0407baSopenharmony_ci# Use 'make C=2' to enable checking of *all* source files, regardless 2033d0407baSopenharmony_ci# of whether they are re-compiled or not. 2043d0407baSopenharmony_ci# 2053d0407baSopenharmony_ci# See the file "Documentation/dev-tools/sparse.rst" for more details, 2063d0407baSopenharmony_ci# including where to get the "sparse" utility. 2073d0407baSopenharmony_ci 2083d0407baSopenharmony_ciifeq ("$(origin C)", "command line") 2093d0407baSopenharmony_ci KBUILD_CHECKSRC = $(C) 2103d0407baSopenharmony_ciendif 2113d0407baSopenharmony_ciifndef KBUILD_CHECKSRC 2123d0407baSopenharmony_ci KBUILD_CHECKSRC = 0 2133d0407baSopenharmony_ciendif 2143d0407baSopenharmony_ci 2153d0407baSopenharmony_ci# Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the 2163d0407baSopenharmony_ci# directory of external module to build. Setting M= takes precedence. 2173d0407baSopenharmony_ciifeq ("$(origin M)", "command line") 2183d0407baSopenharmony_ci KBUILD_EXTMOD := $(M) 2193d0407baSopenharmony_ciendif 2203d0407baSopenharmony_ci 2213d0407baSopenharmony_ci$(if $(word 2, $(KBUILD_EXTMOD)), \ 2223d0407baSopenharmony_ci $(error building multiple external modules is not supported)) 2233d0407baSopenharmony_ci 2243d0407baSopenharmony_ciexport KBUILD_CHECKSRC KBUILD_EXTMOD 2253d0407baSopenharmony_ci 2263d0407baSopenharmony_ciextmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/) 2273d0407baSopenharmony_ci 2283d0407baSopenharmony_ciifeq ($(abs_srctree),$(abs_objtree)) 2293d0407baSopenharmony_ci # building in the source tree 2303d0407baSopenharmony_ci srctree := . 2313d0407baSopenharmony_ci building_out_of_srctree := 2323d0407baSopenharmony_cielse 2333d0407baSopenharmony_ci ifeq ($(abs_srctree)/,$(dir $(abs_objtree))) 2343d0407baSopenharmony_ci # building in a subdirectory of the source tree 2353d0407baSopenharmony_ci srctree := .. 2363d0407baSopenharmony_ci else 2373d0407baSopenharmony_ci srctree := $(abs_srctree) 2383d0407baSopenharmony_ci endif 2393d0407baSopenharmony_ci building_out_of_srctree := 1 2403d0407baSopenharmony_ciendif 2413d0407baSopenharmony_ci 2423d0407baSopenharmony_ciifneq ($(KBUILD_ABS_SRCTREE),) 2433d0407baSopenharmony_cisrctree := $(abs_srctree) 2443d0407baSopenharmony_ciendif 2453d0407baSopenharmony_ci 2463d0407baSopenharmony_ciobjtree := . 2473d0407baSopenharmony_ciVPATH := $(srctree) 2483d0407baSopenharmony_ci 2493d0407baSopenharmony_ciexport building_out_of_srctree srctree objtree VPATH 2503d0407baSopenharmony_ci 2513d0407baSopenharmony_ci# To make sure we do not include .config for any of the *config targets 2523d0407baSopenharmony_ci# catch them early, and hand them over to scripts/kconfig/Makefile 2533d0407baSopenharmony_ci# It is allowed to specify more targets when calling make, including 2543d0407baSopenharmony_ci# mixing *config targets and build targets. 2553d0407baSopenharmony_ci# For example 'make oldconfig all'. 2563d0407baSopenharmony_ci# Detect when mixed targets is specified, and make a second invocation 2573d0407baSopenharmony_ci# of make so .config is not included in this case either (for *config). 2583d0407baSopenharmony_ci 2593d0407baSopenharmony_civersion_h := include/generated/uapi/linux/version.h 2603d0407baSopenharmony_ciold_version_h := include/linux/version.h 2613d0407baSopenharmony_ci 2623d0407baSopenharmony_ciclean-targets := %clean mrproper cleandocs 2633d0407baSopenharmony_cino-dot-config-targets := $(clean-targets) \ 2643d0407baSopenharmony_ci cscope gtags TAGS tags help% %docs check% coccicheck \ 2653d0407baSopenharmony_ci $(version_h) headers headers_% archheaders archscripts \ 2663d0407baSopenharmony_ci %asm-generic kernelversion %src-pkg dt_binding_check \ 2673d0407baSopenharmony_ci outputmakefile 2683d0407baSopenharmony_cino-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \ 2693d0407baSopenharmony_ci image_name 2703d0407baSopenharmony_cisingle-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/ 2713d0407baSopenharmony_ci 2723d0407baSopenharmony_ciconfig-build := 2733d0407baSopenharmony_cimixed-build := 2743d0407baSopenharmony_cineed-config := 1 2753d0407baSopenharmony_cimay-sync-config := 1 2763d0407baSopenharmony_cisingle-build := 2773d0407baSopenharmony_ci 2783d0407baSopenharmony_ciifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) 2793d0407baSopenharmony_ci ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) 2803d0407baSopenharmony_ci need-config := 2813d0407baSopenharmony_ci endif 2823d0407baSopenharmony_ciendif 2833d0407baSopenharmony_ci 2843d0407baSopenharmony_ciifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) 2853d0407baSopenharmony_ci ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) 2863d0407baSopenharmony_ci may-sync-config := 2873d0407baSopenharmony_ci endif 2883d0407baSopenharmony_ciendif 2893d0407baSopenharmony_ci 2903d0407baSopenharmony_ciifneq ($(KBUILD_EXTMOD),) 2913d0407baSopenharmony_ci may-sync-config := 2923d0407baSopenharmony_ciendif 2933d0407baSopenharmony_ci 2943d0407baSopenharmony_ciifeq ($(KBUILD_EXTMOD),) 2953d0407baSopenharmony_ci ifneq ($(filter %config,$(MAKECMDGOALS)),) 2963d0407baSopenharmony_ci config-build := 1 2973d0407baSopenharmony_ci ifneq ($(words $(MAKECMDGOALS)),1) 2983d0407baSopenharmony_ci mixed-build := 1 2993d0407baSopenharmony_ci endif 3003d0407baSopenharmony_ci endif 3013d0407baSopenharmony_ciendif 3023d0407baSopenharmony_ci 3033d0407baSopenharmony_ci# We cannot build single targets and the others at the same time 3043d0407baSopenharmony_ciifneq ($(filter $(single-targets), $(MAKECMDGOALS)),) 3053d0407baSopenharmony_ci single-build := 1 3063d0407baSopenharmony_ci ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),) 3073d0407baSopenharmony_ci mixed-build := 1 3083d0407baSopenharmony_ci endif 3093d0407baSopenharmony_ciendif 3103d0407baSopenharmony_ci 3113d0407baSopenharmony_ci# For "make -j clean all", "make -j mrproper defconfig all", etc. 3123d0407baSopenharmony_ciifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),) 3133d0407baSopenharmony_ci ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),) 3143d0407baSopenharmony_ci mixed-build := 1 3153d0407baSopenharmony_ci endif 3163d0407baSopenharmony_ciendif 3173d0407baSopenharmony_ci 3183d0407baSopenharmony_ci# install and modules_install need also be processed one by one 3193d0407baSopenharmony_ciifneq ($(filter install,$(MAKECMDGOALS)),) 3203d0407baSopenharmony_ci ifneq ($(filter modules_install,$(MAKECMDGOALS)),) 3213d0407baSopenharmony_ci mixed-build := 1 3223d0407baSopenharmony_ci endif 3233d0407baSopenharmony_ciendif 3243d0407baSopenharmony_ci 3253d0407baSopenharmony_ciifdef mixed-build 3263d0407baSopenharmony_ci# =========================================================================== 3273d0407baSopenharmony_ci# We're called with mixed targets (*config and build targets). 3283d0407baSopenharmony_ci# Handle them one by one. 3293d0407baSopenharmony_ci 3303d0407baSopenharmony_ciPHONY += $(MAKECMDGOALS) __build_one_by_one 3313d0407baSopenharmony_ci 3323d0407baSopenharmony_ci$(MAKECMDGOALS): __build_one_by_one 3333d0407baSopenharmony_ci @: 3343d0407baSopenharmony_ci 3353d0407baSopenharmony_ci__build_one_by_one: 3363d0407baSopenharmony_ci $(Q)set -e; \ 3373d0407baSopenharmony_ci for i in $(MAKECMDGOALS); do \ 3383d0407baSopenharmony_ci $(MAKE) -f $(srctree)/Makefile $$i; \ 3393d0407baSopenharmony_ci done 3403d0407baSopenharmony_ci 3413d0407baSopenharmony_cielse # !mixed-build 3423d0407baSopenharmony_ci 3433d0407baSopenharmony_ciinclude scripts/Kbuild.include 3443d0407baSopenharmony_ci 3453d0407baSopenharmony_ci# Read KERNELRELEASE from include/config/kernel.release (if it exists) 3463d0407baSopenharmony_ciKERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) 3473d0407baSopenharmony_ciKERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) 3483d0407baSopenharmony_ciexport VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION 3493d0407baSopenharmony_ci 3503d0407baSopenharmony_ciinclude scripts/subarch.include 3513d0407baSopenharmony_ci 3523d0407baSopenharmony_ci# Cross compiling and selecting different set of gcc/bin-utils 3533d0407baSopenharmony_ci# --------------------------------------------------------------------------- 3543d0407baSopenharmony_ci# 3553d0407baSopenharmony_ci# When performing cross compilation for other architectures ARCH shall be set 3563d0407baSopenharmony_ci# to the target architecture. (See arch/* for the possibilities). 3573d0407baSopenharmony_ci# ARCH can be set during invocation of make: 3583d0407baSopenharmony_ci# make ARCH=ia64 3593d0407baSopenharmony_ci# Another way is to have ARCH set in the environment. 3603d0407baSopenharmony_ci# The default ARCH is the host where make is executed. 3613d0407baSopenharmony_ci 3623d0407baSopenharmony_ci# CROSS_COMPILE specify the prefix used for all executables used 3633d0407baSopenharmony_ci# during compilation. Only gcc and related bin-utils executables 3643d0407baSopenharmony_ci# are prefixed with $(CROSS_COMPILE). 3653d0407baSopenharmony_ci# CROSS_COMPILE can be set on the command line 3663d0407baSopenharmony_ci# make CROSS_COMPILE=ia64-linux- 3673d0407baSopenharmony_ci# Alternatively CROSS_COMPILE can be set in the environment. 3683d0407baSopenharmony_ci# Default value for CROSS_COMPILE is not to prefix executables 3693d0407baSopenharmony_ci# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile 3703d0407baSopenharmony_ciARCH ?= $(SUBARCH) 3713d0407baSopenharmony_ci 3723d0407baSopenharmony_ci# Architecture as present in compile.h 3733d0407baSopenharmony_ciUTS_MACHINE := $(ARCH) 3743d0407baSopenharmony_ciSRCARCH := $(ARCH) 3753d0407baSopenharmony_ci 3763d0407baSopenharmony_ci# Additional ARCH settings for x86 3773d0407baSopenharmony_ciifeq ($(ARCH),i386) 3783d0407baSopenharmony_ci SRCARCH := x86 3793d0407baSopenharmony_ciendif 3803d0407baSopenharmony_ciifeq ($(ARCH),x86_64) 3813d0407baSopenharmony_ci SRCARCH := x86 3823d0407baSopenharmony_ciendif 3833d0407baSopenharmony_ci 3843d0407baSopenharmony_ci# Additional ARCH settings for sparc 3853d0407baSopenharmony_ciifeq ($(ARCH),sparc32) 3863d0407baSopenharmony_ci SRCARCH := sparc 3873d0407baSopenharmony_ciendif 3883d0407baSopenharmony_ciifeq ($(ARCH),sparc64) 3893d0407baSopenharmony_ci SRCARCH := sparc 3903d0407baSopenharmony_ciendif 3913d0407baSopenharmony_ci 3923d0407baSopenharmony_ci# Additional ARCH settings for sh 3933d0407baSopenharmony_ciifeq ($(ARCH),sh64) 3943d0407baSopenharmony_ci SRCARCH := sh 3953d0407baSopenharmony_ciendif 3963d0407baSopenharmony_ci 3973d0407baSopenharmony_ciKCONFIG_CONFIG ?= .config 3983d0407baSopenharmony_ciexport KCONFIG_CONFIG 3993d0407baSopenharmony_ci 4003d0407baSopenharmony_ci# Default file for 'make defconfig'. This may be overridden by arch-Makefile. 4013d0407baSopenharmony_ciexport KBUILD_DEFCONFIG := defconfig 4023d0407baSopenharmony_ci 4033d0407baSopenharmony_ci# SHELL used by kbuild 4043d0407baSopenharmony_ciCONFIG_SHELL := sh 4053d0407baSopenharmony_ci 4063d0407baSopenharmony_ciHOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null) 4073d0407baSopenharmony_ciHOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null) 4083d0407baSopenharmony_ciHOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null) 4093d0407baSopenharmony_ci 4103d0407baSopenharmony_ciifneq ($(LLVM),) 4113d0407baSopenharmony_ciHOSTCC = clang 4123d0407baSopenharmony_ciHOSTCXX = clang++ 4133d0407baSopenharmony_cielse 4143d0407baSopenharmony_ciHOSTCC = gcc 4153d0407baSopenharmony_ciHOSTCXX = g++ 4163d0407baSopenharmony_ciendif 4173d0407baSopenharmony_ci 4183d0407baSopenharmony_ciexport KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ 4193d0407baSopenharmony_ci -O2 -fomit-frame-pointer -std=gnu89 4203d0407baSopenharmony_ciexport KBUILD_USERLDFLAGS := 4213d0407baSopenharmony_ci 4223d0407baSopenharmony_ciKBUILD_HOSTCFLAGS := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) 4233d0407baSopenharmony_ciKBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) 4243d0407baSopenharmony_ciKBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) 4253d0407baSopenharmony_ciKBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) 4263d0407baSopenharmony_ci 4273d0407baSopenharmony_ci# Make variables (CC, etc...) 4283d0407baSopenharmony_ciCPP = $(CC) -E 4293d0407baSopenharmony_ciCCACHE = ccache 4303d0407baSopenharmony_ciifneq ($(LLVM),) 4313d0407baSopenharmony_ciCC = $(CCACHE) clang 4323d0407baSopenharmony_ciLD = ld.lld 4333d0407baSopenharmony_ciAR = llvm-ar 4343d0407baSopenharmony_ciNM = llvm-nm 4353d0407baSopenharmony_ciOBJCOPY = llvm-objcopy 4363d0407baSopenharmony_ciOBJDUMP = llvm-objdump 4373d0407baSopenharmony_ciREADELF = llvm-readelf 4383d0407baSopenharmony_ciSTRIP = llvm-strip 4393d0407baSopenharmony_cielse 4403d0407baSopenharmony_ciCC = $(CCACHE) $(CROSS_COMPILE)gcc 4413d0407baSopenharmony_ciLD = $(CROSS_COMPILE)ld 4423d0407baSopenharmony_ciAR = $(CROSS_COMPILE)ar 4433d0407baSopenharmony_ciNM = $(CROSS_COMPILE)nm 4443d0407baSopenharmony_ciOBJCOPY = $(CROSS_COMPILE)objcopy 4453d0407baSopenharmony_ciOBJDUMP = $(CROSS_COMPILE)objdump 4463d0407baSopenharmony_ciREADELF = $(CROSS_COMPILE)readelf 4473d0407baSopenharmony_ciSTRIP = $(CROSS_COMPILE)strip 4483d0407baSopenharmony_ciendif 4493d0407baSopenharmony_ciPAHOLE = pahole 4503d0407baSopenharmony_ciRESOLVE_BTFIDS = $(objtree)/tools/bpf/resolve_btfids/resolve_btfids 4513d0407baSopenharmony_ciLEX = flex 4523d0407baSopenharmony_ciYACC = bison 4533d0407baSopenharmony_ciAWK = awk 4543d0407baSopenharmony_ciINSTALLKERNEL := installkernel 4553d0407baSopenharmony_ciDEPMOD = depmod 4563d0407baSopenharmony_ciPERL = perl 4573d0407baSopenharmony_ciPYTHON = python 4583d0407baSopenharmony_ciPYTHON3 = python3 4593d0407baSopenharmony_ciCHECK = sparse 4603d0407baSopenharmony_ciBASH = bash 4613d0407baSopenharmony_ciKGZIP = gzip 4623d0407baSopenharmony_ciKBZIP2 = bzip2 4633d0407baSopenharmony_ciKLZOP = lzop 4643d0407baSopenharmony_ciLZMA = lzma 4653d0407baSopenharmony_ciLZ4 = lz4c 4663d0407baSopenharmony_ciXZ = xz 4673d0407baSopenharmony_ciZSTD = zstd 4683d0407baSopenharmony_ci 4693d0407baSopenharmony_ciCHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ 4703d0407baSopenharmony_ci -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF) 4713d0407baSopenharmony_ciNOSTDINC_FLAGS := 4723d0407baSopenharmony_ciCFLAGS_MODULE = 4733d0407baSopenharmony_ciAFLAGS_MODULE = 4743d0407baSopenharmony_ciLDFLAGS_MODULE = 4753d0407baSopenharmony_ciCFLAGS_KERNEL = 4763d0407baSopenharmony_ciAFLAGS_KERNEL = 4773d0407baSopenharmony_ciLDFLAGS_vmlinux = 4783d0407baSopenharmony_ci 4793d0407baSopenharmony_ci# Use USERINCLUDE when you must reference the UAPI directories only. 4803d0407baSopenharmony_ciUSERINCLUDE := \ 4813d0407baSopenharmony_ci -I$(srctree)/arch/$(SRCARCH)/include/uapi \ 4823d0407baSopenharmony_ci -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \ 4833d0407baSopenharmony_ci -I$(srctree)/include/uapi \ 4843d0407baSopenharmony_ci -I$(objtree)/include/generated/uapi \ 4853d0407baSopenharmony_ci -include $(srctree)/include/linux/kconfig.h 4863d0407baSopenharmony_ci 4873d0407baSopenharmony_ci# Use LINUXINCLUDE when you must reference the include/ directory. 4883d0407baSopenharmony_ci# Needed to be compatible with the O= option 4893d0407baSopenharmony_ciLINUXINCLUDE := \ 4903d0407baSopenharmony_ci -I$(srctree)/arch/$(SRCARCH)/include \ 4913d0407baSopenharmony_ci -I$(objtree)/arch/$(SRCARCH)/include/generated \ 4923d0407baSopenharmony_ci $(if $(building_out_of_srctree),-I$(srctree)/include) \ 4933d0407baSopenharmony_ci -I$(objtree)/include \ 4943d0407baSopenharmony_ci -I$(objtree)/vendor/include \ 4953d0407baSopenharmony_ci $(USERINCLUDE) 4963d0407baSopenharmony_ci 4973d0407baSopenharmony_ciKBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE 4983d0407baSopenharmony_ciKBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ 4993d0407baSopenharmony_ci -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ 5003d0407baSopenharmony_ci -Werror=implicit-function-declaration -Werror=implicit-int \ 5013d0407baSopenharmony_ci -Werror=return-type -Wno-format-security \ 5023d0407baSopenharmony_ci -std=gnu89 5033d0407baSopenharmony_ciKBUILD_CPPFLAGS := -D__KERNEL__ 5043d0407baSopenharmony_ciKBUILD_AFLAGS_KERNEL := 5053d0407baSopenharmony_ciKBUILD_CFLAGS_KERNEL := 5063d0407baSopenharmony_ciKBUILD_AFLAGS_MODULE := -DMODULE 5073d0407baSopenharmony_ciKBUILD_CFLAGS_MODULE := -DMODULE 5083d0407baSopenharmony_ciKBUILD_LDFLAGS_MODULE := 5093d0407baSopenharmony_ciKBUILD_LDFLAGS := 5103d0407baSopenharmony_ciCLANG_FLAGS := 5113d0407baSopenharmony_ci 5123d0407baSopenharmony_ciexport ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC 5133d0407baSopenharmony_ciexport CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL 5143d0407baSopenharmony_ciexport PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX 5153d0407baSopenharmony_ciexport KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD 5163d0407baSopenharmony_ciexport KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE 5173d0407baSopenharmony_ci 5183d0407baSopenharmony_ciexport KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS 5193d0407baSopenharmony_ciexport KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE 5203d0407baSopenharmony_ciexport KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE 5213d0407baSopenharmony_ciexport KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE 5223d0407baSopenharmony_ciexport KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL 5233d0407baSopenharmony_ci 5243d0407baSopenharmony_ci# Files to ignore in find ... statements 5253d0407baSopenharmony_ci 5263d0407baSopenharmony_ciexport RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ 5273d0407baSopenharmony_ci -name CVS -o -name .pc -o -name .hg -o -name .git \) \ 5283d0407baSopenharmony_ci -prune -o 5293d0407baSopenharmony_ciexport RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ 5303d0407baSopenharmony_ci --exclude CVS --exclude .pc --exclude .hg --exclude .git 5313d0407baSopenharmony_ci 5323d0407baSopenharmony_ci# =========================================================================== 5333d0407baSopenharmony_ci# Rules shared between *config targets and build targets 5343d0407baSopenharmony_ci 5353d0407baSopenharmony_ci# Basic helpers built in scripts/basic/ 5363d0407baSopenharmony_ciPHONY += scripts_basic 5373d0407baSopenharmony_ciscripts_basic: 5383d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=scripts/basic 5393d0407baSopenharmony_ci $(Q)rm -f .tmp_quiet_recordmcount 5403d0407baSopenharmony_ci 5413d0407baSopenharmony_ciPHONY += outputmakefile 5423d0407baSopenharmony_ci# Before starting out-of-tree build, make sure the source tree is clean. 5433d0407baSopenharmony_ci# outputmakefile generates a Makefile in the output directory, if using a 5443d0407baSopenharmony_ci# separate output directory. This allows convenient use of make in the 5453d0407baSopenharmony_ci# output directory. 5463d0407baSopenharmony_ci# At the same time when output Makefile generated, generate .gitignore to 5473d0407baSopenharmony_ci# ignore whole output directory 5483d0407baSopenharmony_cioutputmakefile: 5493d0407baSopenharmony_ciifdef building_out_of_srctree 5503d0407baSopenharmony_ci $(Q)if [ -f $(srctree)/.config -o \ 5513d0407baSopenharmony_ci -d $(srctree)/include/config -o \ 5523d0407baSopenharmony_ci -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \ 5533d0407baSopenharmony_ci echo >&2 "***"; \ 5543d0407baSopenharmony_ci echo >&2 "*** The source tree is not clean, please run 'make$(if $(findstring command line, $(origin ARCH)), ARCH=$(ARCH)) mrproper'"; \ 5553d0407baSopenharmony_ci echo >&2 "*** in $(abs_srctree)";\ 5563d0407baSopenharmony_ci echo >&2 "***"; \ 5573d0407baSopenharmony_ci false; \ 5583d0407baSopenharmony_ci fi 5593d0407baSopenharmony_ci $(Q)ln -fsn $(srctree) source 5603d0407baSopenharmony_ci $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) 5613d0407baSopenharmony_ci $(Q)test -e .gitignore || \ 5623d0407baSopenharmony_ci { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore 5633d0407baSopenharmony_ciendif 5643d0407baSopenharmony_ci 5653d0407baSopenharmony_ciifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) 5663d0407baSopenharmony_ciifneq ($(CROSS_COMPILE),) 5673d0407baSopenharmony_ciCLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) 5683d0407baSopenharmony_ciGCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) 5693d0407baSopenharmony_ciCLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) 5703d0407baSopenharmony_ciGCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) 5713d0407baSopenharmony_ciendif 5723d0407baSopenharmony_ciifneq ($(GCC_TOOLCHAIN),) 5733d0407baSopenharmony_ciCLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) 5743d0407baSopenharmony_ciendif 5753d0407baSopenharmony_ciifneq ($(LLVM_IAS),1) 5763d0407baSopenharmony_ciCLANG_FLAGS += -no-integrated-as 5773d0407baSopenharmony_ciendif 5783d0407baSopenharmony_ciCLANG_FLAGS += -Werror=unknown-warning-option 5793d0407baSopenharmony_ciKBUILD_CFLAGS += $(CLANG_FLAGS) 5803d0407baSopenharmony_ciKBUILD_AFLAGS += $(CLANG_FLAGS) 5813d0407baSopenharmony_ciexport CLANG_FLAGS 5823d0407baSopenharmony_ciendif 5833d0407baSopenharmony_ci 5843d0407baSopenharmony_ci# The expansion should be delayed until arch/$(SRCARCH)/Makefile is included. 5853d0407baSopenharmony_ci# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile. 5863d0407baSopenharmony_ci# CC_VERSION_TEXT is referenced from Kconfig (so it needs export), 5873d0407baSopenharmony_ci# and from include/config/auto.conf.cmd to detect the compiler upgrade. 5883d0407baSopenharmony_ciCC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1) 5893d0407baSopenharmony_ci 5903d0407baSopenharmony_ciifdef config-build 5913d0407baSopenharmony_ci# =========================================================================== 5923d0407baSopenharmony_ci# *config targets only - make sure prerequisites are updated, and descend 5933d0407baSopenharmony_ci# in scripts/kconfig to make the *config target 5943d0407baSopenharmony_ci 5953d0407baSopenharmony_ci# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. 5963d0407baSopenharmony_ci# KBUILD_DEFCONFIG may point out an alternative default configuration 5973d0407baSopenharmony_ci# used for 'make defconfig' 5983d0407baSopenharmony_ciinclude arch/$(SRCARCH)/Makefile 5993d0407baSopenharmony_ciexport KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT 6003d0407baSopenharmony_ci 6013d0407baSopenharmony_ciconfig: outputmakefile scripts_basic FORCE 6023d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=scripts/kconfig $@ 6033d0407baSopenharmony_ci 6043d0407baSopenharmony_ci%config: outputmakefile scripts_basic FORCE 6053d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=scripts/kconfig $@ 6063d0407baSopenharmony_ci 6073d0407baSopenharmony_cielse #!config-build 6083d0407baSopenharmony_ci# =========================================================================== 6093d0407baSopenharmony_ci# Build targets only - this includes vmlinux, arch specific targets, clean 6103d0407baSopenharmony_ci# targets and others. In general all targets except *config targets. 6113d0407baSopenharmony_ci 6123d0407baSopenharmony_ci# If building an external module we do not care about the all: rule 6133d0407baSopenharmony_ci# but instead __all depend on modules 6143d0407baSopenharmony_ciPHONY += all 6153d0407baSopenharmony_ciifeq ($(KBUILD_EXTMOD),) 6163d0407baSopenharmony_ci__all: all 6173d0407baSopenharmony_cielse 6183d0407baSopenharmony_ci__all: modules 6193d0407baSopenharmony_ciendif 6203d0407baSopenharmony_ci 6213d0407baSopenharmony_ci# Decide whether to build built-in, modular, or both. 6223d0407baSopenharmony_ci# Normally, just do built-in. 6233d0407baSopenharmony_ci 6243d0407baSopenharmony_ciKBUILD_MODULES := 6253d0407baSopenharmony_ciKBUILD_BUILTIN := 1 6263d0407baSopenharmony_ci 6273d0407baSopenharmony_ci# If we have only "make modules", don't compile built-in objects. 6283d0407baSopenharmony_ciifeq ($(MAKECMDGOALS),modules) 6293d0407baSopenharmony_ci KBUILD_BUILTIN := 6303d0407baSopenharmony_ciendif 6313d0407baSopenharmony_ci 6323d0407baSopenharmony_ci# If we have "make <whatever> modules", compile modules 6333d0407baSopenharmony_ci# in addition to whatever we do anyway. 6343d0407baSopenharmony_ci# Just "make" or "make all" shall build modules as well 6353d0407baSopenharmony_ci 6363d0407baSopenharmony_ciifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECMDGOALS)),) 6373d0407baSopenharmony_ci KBUILD_MODULES := 1 6383d0407baSopenharmony_ciendif 6393d0407baSopenharmony_ci 6403d0407baSopenharmony_ciifeq ($(MAKECMDGOALS),) 6413d0407baSopenharmony_ci KBUILD_MODULES := 1 6423d0407baSopenharmony_ciendif 6433d0407baSopenharmony_ci 6443d0407baSopenharmony_ciexport KBUILD_MODULES KBUILD_BUILTIN 6453d0407baSopenharmony_ci 6463d0407baSopenharmony_ciifdef need-config 6473d0407baSopenharmony_ciinclude include/config/auto.conf 6483d0407baSopenharmony_ciendif 6493d0407baSopenharmony_ci 6503d0407baSopenharmony_ciifeq ($(KBUILD_EXTMOD),) 6513d0407baSopenharmony_ci# Objects we will link into vmlinux / subdirs we need to visit 6523d0407baSopenharmony_cicore-y := init/ usr/ 6533d0407baSopenharmony_cidrivers-y := drivers/ sound/ 6543d0407baSopenharmony_cidrivers-$(CONFIG_SAMPLES) += samples/ 6553d0407baSopenharmony_cidrivers-y += net/ virt/ 6563d0407baSopenharmony_cilibs-y := lib/ 6573d0407baSopenharmony_civendor-y := vendor/ 6583d0407baSopenharmony_ciendif # KBUILD_EXTMOD 6593d0407baSopenharmony_ci 6603d0407baSopenharmony_ci# The all: target is the default when no target is given on the 6613d0407baSopenharmony_ci# command line. 6623d0407baSopenharmony_ci# This allow a user to issue only 'make' to build a kernel including modules 6633d0407baSopenharmony_ci# Defaults to vmlinux, but the arch makefile usually adds further targets 6643d0407baSopenharmony_ciall: vmlinux 6653d0407baSopenharmony_ci 6663d0407baSopenharmony_ciCFLAGS_GCOV := -fprofile-arcs -ftest-coverage \ 6673d0407baSopenharmony_ci $(call cc-option,-fno-tree-loop-im) \ 6683d0407baSopenharmony_ci $(call cc-disable-warning,maybe-uninitialized,) 6693d0407baSopenharmony_ciexport CFLAGS_GCOV 6703d0407baSopenharmony_ci 6713d0407baSopenharmony_ci# The arch Makefiles can override CC_FLAGS_FTRACE. We may also append it later. 6723d0407baSopenharmony_ciifdef CONFIG_FUNCTION_TRACER 6733d0407baSopenharmony_ci CC_FLAGS_FTRACE := -pg 6743d0407baSopenharmony_ciendif 6753d0407baSopenharmony_ci 6763d0407baSopenharmony_ciifdef CONFIG_CC_IS_GCC 6773d0407baSopenharmony_ciRETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) 6783d0407baSopenharmony_ciRETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix) 6793d0407baSopenharmony_ciRETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register) 6803d0407baSopenharmony_ciendif 6813d0407baSopenharmony_ciifdef CONFIG_CC_IS_CLANG 6823d0407baSopenharmony_ciRETPOLINE_CFLAGS := -mretpoline-external-thunk 6833d0407baSopenharmony_ciRETPOLINE_VDSO_CFLAGS := -mretpoline 6843d0407baSopenharmony_ciendif 6853d0407baSopenharmony_ci 6863d0407baSopenharmony_ciifdef CONFIG_RETHUNK 6873d0407baSopenharmony_ciRETHUNK_CFLAGS := -mfunction-return=thunk-extern 6883d0407baSopenharmony_ciRETPOLINE_CFLAGS += $(RETHUNK_CFLAGS) 6893d0407baSopenharmony_ciendif 6903d0407baSopenharmony_ciexport RETPOLINE_CFLAGS 6913d0407baSopenharmony_ciexport RETPOLINE_VDSO_CFLAGS 6923d0407baSopenharmony_ci 6933d0407baSopenharmony_ciinclude arch/$(SRCARCH)/Makefile 6943d0407baSopenharmony_ci 6953d0407baSopenharmony_ciifdef need-config 6963d0407baSopenharmony_ciifdef may-sync-config 6973d0407baSopenharmony_ci# Read in dependencies to all Kconfig* files, make sure to run syncconfig if 6983d0407baSopenharmony_ci# changes are detected. This should be included after arch/$(SRCARCH)/Makefile 6993d0407baSopenharmony_ci# because some architectures define CROSS_COMPILE there. 7003d0407baSopenharmony_ciinclude include/config/auto.conf.cmd 7013d0407baSopenharmony_ci 7023d0407baSopenharmony_ci$(KCONFIG_CONFIG): 7033d0407baSopenharmony_ci @echo >&2 '***' 7043d0407baSopenharmony_ci @echo >&2 '*** Configuration file "$@" not found!' 7053d0407baSopenharmony_ci @echo >&2 '***' 7063d0407baSopenharmony_ci @echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or' 7073d0407baSopenharmony_ci @echo >&2 '*** "make menuconfig" or "make xconfig").' 7083d0407baSopenharmony_ci @echo >&2 '***' 7093d0407baSopenharmony_ci @/bin/false 7103d0407baSopenharmony_ci 7113d0407baSopenharmony_ci# The actual configuration files used during the build are stored in 7123d0407baSopenharmony_ci# include/generated/ and include/config/. Update them if .config is newer than 7133d0407baSopenharmony_ci# include/config/auto.conf (which mirrors .config). 7143d0407baSopenharmony_ci# 7153d0407baSopenharmony_ci# This exploits the 'multi-target pattern rule' trick. 7163d0407baSopenharmony_ci# The syncconfig should be executed only once to make all the targets. 7173d0407baSopenharmony_ci# (Note: use the grouped target '&:' when we bump to GNU Make 4.3) 7183d0407baSopenharmony_ci# 7193d0407baSopenharmony_ci# Do not use $(call cmd,...) here. That would suppress prompts from syncconfig, 7203d0407baSopenharmony_ci# so you cannot notice that Kconfig is waiting for the user input. 7213d0407baSopenharmony_ci%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h: $(KCONFIG_CONFIG) 7223d0407baSopenharmony_ci $(Q)$(kecho) " SYNC $@" 7233d0407baSopenharmony_ci $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig 7243d0407baSopenharmony_cielse # !may-sync-config 7253d0407baSopenharmony_ci# External modules and some install targets need include/generated/autoconf.h 7263d0407baSopenharmony_ci# and include/config/auto.conf but do not care if they are up-to-date. 7273d0407baSopenharmony_ci# Use auto.conf to trigger the test 7283d0407baSopenharmony_ciPHONY += include/config/auto.conf 7293d0407baSopenharmony_ci 7303d0407baSopenharmony_ciinclude/config/auto.conf: 7313d0407baSopenharmony_ci $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \ 7323d0407baSopenharmony_ci echo >&2; \ 7333d0407baSopenharmony_ci echo >&2 " ERROR: Kernel configuration is invalid."; \ 7343d0407baSopenharmony_ci echo >&2 " include/generated/autoconf.h or $@ are missing.";\ 7353d0407baSopenharmony_ci echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ 7363d0407baSopenharmony_ci echo >&2 ; \ 7373d0407baSopenharmony_ci /bin/false) 7383d0407baSopenharmony_ci 7393d0407baSopenharmony_ciendif # may-sync-config 7403d0407baSopenharmony_ciendif # need-config 7413d0407baSopenharmony_ci 7423d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) 7433d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) 7443d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) 7453d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) 7463d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) 7473d0407baSopenharmony_ci 7483d0407baSopenharmony_ciifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE 7493d0407baSopenharmony_ciKBUILD_CFLAGS += -O2 7503d0407baSopenharmony_cielse ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 7513d0407baSopenharmony_ciKBUILD_CFLAGS += -O3 7523d0407baSopenharmony_cielse ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 7533d0407baSopenharmony_ciKBUILD_CFLAGS += -Os 7543d0407baSopenharmony_ciendif 7553d0407baSopenharmony_ci 7563d0407baSopenharmony_ci# Tell gcc to never replace conditional load with a non-conditional one 7573d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) 7583d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races) 7593d0407baSopenharmony_ci 7603d0407baSopenharmony_ciifdef CONFIG_READABLE_ASM 7613d0407baSopenharmony_ci# Disable optimizations that make assembler listings hard to read. 7623d0407baSopenharmony_ci# reorder blocks reorders the control in the function 7633d0407baSopenharmony_ci# ipa clone creates specialized cloned functions 7643d0407baSopenharmony_ci# partial inlining inlines only parts of functions 7653d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \ 7663d0407baSopenharmony_ci $(call cc-option,-fno-ipa-cp-clone,) \ 7673d0407baSopenharmony_ci $(call cc-option,-fno-partial-inlining) 7683d0407baSopenharmony_ciendif 7693d0407baSopenharmony_ci 7703d0407baSopenharmony_ciifneq ($(CONFIG_FRAME_WARN),0) 7713d0407baSopenharmony_ciKBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN) 7723d0407baSopenharmony_ciendif 7733d0407baSopenharmony_ci 7743d0407baSopenharmony_cistackp-flags-y := -fno-stack-protector 7753d0407baSopenharmony_cistackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector 7763d0407baSopenharmony_cistackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong 7773d0407baSopenharmony_ci 7783d0407baSopenharmony_ciKBUILD_CFLAGS += $(stackp-flags-y) 7793d0407baSopenharmony_ci 7803d0407baSopenharmony_ciifdef CONFIG_CC_IS_CLANG 7813d0407baSopenharmony_ciKBUILD_CPPFLAGS += -Qunused-arguments 7823d0407baSopenharmony_ciKBUILD_CFLAGS += -Wno-format-invalid-specifier 7833d0407baSopenharmony_ciKBUILD_CFLAGS += -Wno-gnu 7843d0407baSopenharmony_ci# CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the 7853d0407baSopenharmony_ci# source of a reference will be _MergedGlobals and not on of the whitelisted names. 7863d0407baSopenharmony_ci# See modpost pattern 2 7873d0407baSopenharmony_ciKBUILD_CFLAGS += -mno-global-merge 7883d0407baSopenharmony_cielse 7893d0407baSopenharmony_ci 7903d0407baSopenharmony_ci# Warn about unmarked fall-throughs in switch statement. 7913d0407baSopenharmony_ci# Disabled for clang while comment to attribute conversion happens and 7923d0407baSopenharmony_ci# https://github.com/ClangBuiltLinux/linux/issues/636 is discussed. 7933d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,) 7943d0407baSopenharmony_ciendif 7953d0407baSopenharmony_ci 7963d0407baSopenharmony_ci# These warnings generated too much noise in a regular build. 7973d0407baSopenharmony_ci# Use make W=1 to enable them (see scripts/Makefile.extrawarn) 7983d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) 7993d0407baSopenharmony_ci 8003d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) 8013d0407baSopenharmony_ciifdef CONFIG_FRAME_POINTER 8023d0407baSopenharmony_ciKBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls 8033d0407baSopenharmony_cielse 8043d0407baSopenharmony_ci# Some targets (ARM with Thumb2, for example), can't be built with frame 8053d0407baSopenharmony_ci# pointers. For those, we don't have FUNCTION_TRACER automatically 8063d0407baSopenharmony_ci# select FRAME_POINTER. However, FUNCTION_TRACER adds -pg, and this is 8073d0407baSopenharmony_ci# incompatible with -fomit-frame-pointer with current GCC, so we don't use 8083d0407baSopenharmony_ci# -fomit-frame-pointer with FUNCTION_TRACER. 8093d0407baSopenharmony_ciifndef CONFIG_FUNCTION_TRACER 8103d0407baSopenharmony_ciKBUILD_CFLAGS += -fomit-frame-pointer 8113d0407baSopenharmony_ciendif 8123d0407baSopenharmony_ciendif 8133d0407baSopenharmony_ci 8143d0407baSopenharmony_ci# Initialize all stack variables with a 0xAA pattern. 8153d0407baSopenharmony_ciifdef CONFIG_INIT_STACK_ALL_PATTERN 8163d0407baSopenharmony_ciKBUILD_CFLAGS += -ftrivial-auto-var-init=pattern 8173d0407baSopenharmony_ciendif 8183d0407baSopenharmony_ci 8193d0407baSopenharmony_ci# Initialize all stack variables with a zero value. 8203d0407baSopenharmony_ciifdef CONFIG_INIT_STACK_ALL_ZERO 8213d0407baSopenharmony_ci# Future support for zero initialization is still being debated, see 8223d0407baSopenharmony_ci# https://bugs.llvm.org/show_bug.cgi?id=45497. These flags are subject to being 8233d0407baSopenharmony_ci# renamed or dropped. 8243d0407baSopenharmony_ciKBUILD_CFLAGS += -ftrivial-auto-var-init=zero 8253d0407baSopenharmony_ciKBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang 8263d0407baSopenharmony_ciendif 8273d0407baSopenharmony_ci 8283d0407baSopenharmony_ciDEBUG_CFLAGS := 8293d0407baSopenharmony_ci 8303d0407baSopenharmony_ci# Workaround for GCC versions < 5.0 8313d0407baSopenharmony_ci# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801 8323d0407baSopenharmony_ciifdef CONFIG_CC_IS_GCC 8333d0407baSopenharmony_ciDEBUG_CFLAGS += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments)) 8343d0407baSopenharmony_ciendif 8353d0407baSopenharmony_ci 8363d0407baSopenharmony_ciifdef CONFIG_DEBUG_INFO 8373d0407baSopenharmony_ci 8383d0407baSopenharmony_ciifdef CONFIG_DEBUG_INFO_SPLIT 8393d0407baSopenharmony_ciDEBUG_CFLAGS += -gsplit-dwarf 8403d0407baSopenharmony_cielse 8413d0407baSopenharmony_ciDEBUG_CFLAGS += -g 8423d0407baSopenharmony_ciendif 8433d0407baSopenharmony_ci 8443d0407baSopenharmony_ciifneq ($(LLVM_IAS),1) 8453d0407baSopenharmony_ciKBUILD_AFLAGS += -Wa,-gdwarf-2 8463d0407baSopenharmony_ciendif 8473d0407baSopenharmony_ci 8483d0407baSopenharmony_ciifdef CONFIG_DEBUG_INFO_DWARF4 8493d0407baSopenharmony_ciDEBUG_CFLAGS += -gdwarf-4 8503d0407baSopenharmony_ciendif 8513d0407baSopenharmony_ci 8523d0407baSopenharmony_ciifdef CONFIG_DEBUG_INFO_REDUCED 8533d0407baSopenharmony_ciDEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ 8543d0407baSopenharmony_ci $(call cc-option,-fno-var-tracking) 8553d0407baSopenharmony_ciendif 8563d0407baSopenharmony_ci 8573d0407baSopenharmony_ciifdef CONFIG_DEBUG_INFO_COMPRESSED 8583d0407baSopenharmony_ciDEBUG_CFLAGS += -gz=zlib 8593d0407baSopenharmony_ciKBUILD_AFLAGS += -gz=zlib 8603d0407baSopenharmony_ciKBUILD_LDFLAGS += --compress-debug-sections=zlib 8613d0407baSopenharmony_ciendif 8623d0407baSopenharmony_ci 8633d0407baSopenharmony_ciendif # CONFIG_DEBUG_INFO 8643d0407baSopenharmony_ciKBUILD_CFLAGS += -Wno-unused-function 8653d0407baSopenharmony_ciKBUILD_CFLAGS += $(DEBUG_CFLAGS) 8663d0407baSopenharmony_ciexport DEBUG_CFLAGS 8673d0407baSopenharmony_ci 8683d0407baSopenharmony_ciifdef CONFIG_FUNCTION_TRACER 8693d0407baSopenharmony_ciifdef CONFIG_FTRACE_MCOUNT_USE_CC 8703d0407baSopenharmony_ci CC_FLAGS_FTRACE += -mrecord-mcount 8713d0407baSopenharmony_ci ifdef CONFIG_HAVE_NOP_MCOUNT 8723d0407baSopenharmony_ci ifeq ($(call cc-option-yn, -mnop-mcount),y) 8733d0407baSopenharmony_ci CC_FLAGS_FTRACE += -mnop-mcount 8743d0407baSopenharmony_ci CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT 8753d0407baSopenharmony_ci endif 8763d0407baSopenharmony_ci endif 8773d0407baSopenharmony_ciendif 8783d0407baSopenharmony_ciifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT 8793d0407baSopenharmony_ci ifdef CONFIG_HAVE_C_RECORDMCOUNT 8803d0407baSopenharmony_ci BUILD_C_RECORDMCOUNT := y 8813d0407baSopenharmony_ci export BUILD_C_RECORDMCOUNT 8823d0407baSopenharmony_ci endif 8833d0407baSopenharmony_ciendif 8843d0407baSopenharmony_ciifdef CONFIG_HAVE_FENTRY 8853d0407baSopenharmony_ci ifeq ($(call cc-option-yn, -mfentry),y) 8863d0407baSopenharmony_ci CC_FLAGS_FTRACE += -mfentry 8873d0407baSopenharmony_ci CC_FLAGS_USING += -DCC_USING_FENTRY 8883d0407baSopenharmony_ci endif 8893d0407baSopenharmony_ciendif 8903d0407baSopenharmony_ciexport CC_FLAGS_FTRACE 8913d0407baSopenharmony_ciKBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING) 8923d0407baSopenharmony_ciKBUILD_AFLAGS += $(CC_FLAGS_USING) 8933d0407baSopenharmony_ciendif 8943d0407baSopenharmony_ci 8953d0407baSopenharmony_ci# We trigger additional mismatches with less inlining 8963d0407baSopenharmony_ciifdef CONFIG_DEBUG_SECTION_MISMATCH 8973d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) 8983d0407baSopenharmony_ciendif 8993d0407baSopenharmony_ci 9003d0407baSopenharmony_ciifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION 9013d0407baSopenharmony_ciKBUILD_CFLAGS_KERNEL += -ffunction-sections -fdata-sections 9023d0407baSopenharmony_ciLDFLAGS_vmlinux += --gc-sections 9033d0407baSopenharmony_ciendif 9043d0407baSopenharmony_ci 9053d0407baSopenharmony_ciifdef CONFIG_SHADOW_CALL_STACK 9063d0407baSopenharmony_ciCC_FLAGS_SCS := -fsanitize=shadow-call-stack 9073d0407baSopenharmony_ciKBUILD_CFLAGS += $(CC_FLAGS_SCS) 9083d0407baSopenharmony_ciexport CC_FLAGS_SCS 9093d0407baSopenharmony_ciendif 9103d0407baSopenharmony_ciifdef CONFIG_LTO_CLANG 9113d0407baSopenharmony_ciifdef CONFIG_LTO_CLANG_THIN 9123d0407baSopenharmony_ciCC_FLAGS_LTO := -flto=thin -fsplit-lto-unit 9133d0407baSopenharmony_ciKBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache 9143d0407baSopenharmony_cielse 9153d0407baSopenharmony_ciCC_FLAGS_LTO := -flto 9163d0407baSopenharmony_ciendif 9173d0407baSopenharmony_ciCC_FLAGS_LTO += -fvisibility=hidden 9183d0407baSopenharmony_ci# Limit inlining across translation units to reduce binary size 9193d0407baSopenharmony_ciKBUILD_LDFLAGS += -mllvm -import-instr-limit=5 9203d0407baSopenharmony_ciendif 9213d0407baSopenharmony_ciifdef CONFIG_LTO 9223d0407baSopenharmony_ciKBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO) 9233d0407baSopenharmony_ciKBUILD_AFLAGS += -fno-lto 9243d0407baSopenharmony_ciexport CC_FLAGS_LTO 9253d0407baSopenharmony_ciendif 9263d0407baSopenharmony_ciifdef CONFIG_CFI_CLANG 9273d0407baSopenharmony_ciCC_FLAGS_CFI := -fsanitize=cfi \ 9283d0407baSopenharmony_ci -fsanitize-cfi-cross-dso \ 9293d0407baSopenharmony_ci -fno-sanitize-cfi-canonical-jump-tables \ 9303d0407baSopenharmony_ci -fno-sanitize-trap=cfi \ 9313d0407baSopenharmony_ci -fno-sanitize-blacklist 9323d0407baSopenharmony_ciifdef CONFIG_CFI_PERMISSIVE 9333d0407baSopenharmony_ciCC_FLAGS_CFI += -fsanitize-recover=cfi 9343d0407baSopenharmony_ciendif 9353d0407baSopenharmony_ci# If LTO flags are filtered out, we must also filter out CFI. 9363d0407baSopenharmony_ciCC_FLAGS_LTO += $(CC_FLAGS_CFI) 9373d0407baSopenharmony_ciKBUILD_CFLAGS += $(CC_FLAGS_CFI) 9383d0407baSopenharmony_ciexport CC_FLAGS_CFI 9393d0407baSopenharmony_ciendif 9403d0407baSopenharmony_ci 9413d0407baSopenharmony_ciifdef CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_32B 9423d0407baSopenharmony_ciKBUILD_CFLAGS += -falign-functions=32 9433d0407baSopenharmony_ciendif 9443d0407baSopenharmony_ci 9453d0407baSopenharmony_ci# arch Makefile may override CC so keep this after arch Makefile is included 9463d0407baSopenharmony_ciNOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) 9473d0407baSopenharmony_ci 9483d0407baSopenharmony_ci# warn about C99 declaration after statement 9493d0407baSopenharmony_ciKBUILD_CFLAGS += -Wdeclaration-after-statement 9503d0407baSopenharmony_ci 9513d0407baSopenharmony_ci# Variable Length Arrays (VLAs) should not be used anywhere in the kernel 9523d0407baSopenharmony_ciKBUILD_CFLAGS += -Wvla 9533d0407baSopenharmony_ci 9543d0407baSopenharmony_ci# disable pointer signed / unsigned warnings in gcc 4.0 9553d0407baSopenharmony_ciKBUILD_CFLAGS += -Wno-pointer-sign 9563d0407baSopenharmony_ci 9573d0407baSopenharmony_ci# disable stringop warnings in gcc 8+ 9583d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) 9593d0407baSopenharmony_ci 9603d0407baSopenharmony_ci# We'll want to enable this eventually, but it's not going away for 5.7 at least 9613d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds) 9623d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, array-bounds) 9633d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) 9643d0407baSopenharmony_ci 9653d0407baSopenharmony_ci# Another good warning that we'll want to enable eventually 9663d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, restrict) 9673d0407baSopenharmony_ci 9683d0407baSopenharmony_ci# Enabled with W=2, disabled by default as noisy 9693d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) 9703d0407baSopenharmony_ci 9713d0407baSopenharmony_ci# disable invalid "can't wrap" optimizations for signed / pointers 9723d0407baSopenharmony_ciKBUILD_CFLAGS += -fno-strict-overflow 9733d0407baSopenharmony_ci 9743d0407baSopenharmony_ci# Make sure -fstack-check isn't enabled (like gentoo apparently did) 9753d0407baSopenharmony_ciKBUILD_CFLAGS += -fno-stack-check 9763d0407baSopenharmony_ci 9773d0407baSopenharmony_ci# conserve stack if available 9783d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-option,-fconserve-stack) 9793d0407baSopenharmony_ci 9803d0407baSopenharmony_ci# Prohibit date/time macros, which would make the build non-deterministic 9813d0407baSopenharmony_ciKBUILD_CFLAGS += -Werror=date-time 9823d0407baSopenharmony_ci 9833d0407baSopenharmony_ci# enforce correct pointer usage 9843d0407baSopenharmony_ci#KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) 9853d0407baSopenharmony_ci 9863d0407baSopenharmony_ci# Require designated initializers for all marked structures 9873d0407baSopenharmony_ciKBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) 9883d0407baSopenharmony_ci 9893d0407baSopenharmony_ci# change __FILE__ to the relative path from the srctree 9903d0407baSopenharmony_ciKBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) 9913d0407baSopenharmony_ci 9923d0407baSopenharmony_ci# include additional Makefiles when needed 9933d0407baSopenharmony_ciinclude-y := scripts/Makefile.extrawarn 9943d0407baSopenharmony_ciinclude-$(CONFIG_KASAN) += scripts/Makefile.kasan 9953d0407baSopenharmony_ciinclude-$(CONFIG_KCSAN) += scripts/Makefile.kcsan 9963d0407baSopenharmony_ciinclude-$(CONFIG_UBSAN) += scripts/Makefile.ubsan 9973d0407baSopenharmony_ciinclude-$(CONFIG_KCOV) += scripts/Makefile.kcov 9983d0407baSopenharmony_ciinclude-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins 9993d0407baSopenharmony_ci 10003d0407baSopenharmony_ciinclude $(addprefix $(srctree)/, $(include-y)) 10013d0407baSopenharmony_ci 10023d0407baSopenharmony_ci# scripts/Makefile.gcc-plugins is intentionally included last. 10033d0407baSopenharmony_ci# Do not add $(call cc-option,...) below this line. When you build the kernel 10043d0407baSopenharmony_ci# from the clean source tree, the GCC plugins do not exist at this point. 10053d0407baSopenharmony_ci 10063d0407baSopenharmony_ci# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments 10073d0407baSopenharmony_ciKBUILD_CPPFLAGS += $(KCPPFLAGS) 10083d0407baSopenharmony_ciKBUILD_AFLAGS += $(KAFLAGS) 10093d0407baSopenharmony_ciKBUILD_CFLAGS += $(KCFLAGS) 10103d0407baSopenharmony_ci 10113d0407baSopenharmony_ciKBUILD_LDFLAGS_MODULE += --build-id=sha1 10123d0407baSopenharmony_ciLDFLAGS_vmlinux += --build-id=sha1 10133d0407baSopenharmony_ciKBUILD_LDFLAGS += -z noexecstack 10143d0407baSopenharmony_ciKBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments) 10153d0407baSopenharmony_ci 10163d0407baSopenharmony_ciifeq ($(CONFIG_STRIP_ASM_SYMS),y) 10173d0407baSopenharmony_ciLDFLAGS_vmlinux += $(call ld-option, -X,) 10183d0407baSopenharmony_ciendif 10193d0407baSopenharmony_ci 10203d0407baSopenharmony_ciifeq ($(CONFIG_RELR),y) 10213d0407baSopenharmony_ciLDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags 10223d0407baSopenharmony_ciendif 10233d0407baSopenharmony_ci 10243d0407baSopenharmony_ci# We never want expected sections to be placed heuristically by the 10253d0407baSopenharmony_ci# linker. All sections should be explicitly named in the linker script. 10263d0407baSopenharmony_ciifdef CONFIG_LD_ORPHAN_WARN 10273d0407baSopenharmony_ciLDFLAGS_vmlinux += --orphan-handling=warn 10283d0407baSopenharmony_ciendif 10293d0407baSopenharmony_ci 10303d0407baSopenharmony_ci# Align the bit size of userspace programs with the kernel 10313d0407baSopenharmony_ciKBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) 10323d0407baSopenharmony_ciKBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) 10333d0407baSopenharmony_ci 10343d0407baSopenharmony_ci# make the checker run with the right architecture 10353d0407baSopenharmony_ciCHECKFLAGS += --arch=$(ARCH) 10363d0407baSopenharmony_ci 10373d0407baSopenharmony_ci# insure the checker run with the right endianness 10383d0407baSopenharmony_ciCHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian) 10393d0407baSopenharmony_ci 10403d0407baSopenharmony_ci# the checker needs the correct machine size 10413d0407baSopenharmony_ciCHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32) 10423d0407baSopenharmony_ci 10433d0407baSopenharmony_ci# Default kernel image to build when no specific target is given. 10443d0407baSopenharmony_ci# KBUILD_IMAGE may be overruled on the command line or 10453d0407baSopenharmony_ci# set in the environment 10463d0407baSopenharmony_ci# Also any assignments in arch/$(ARCH)/Makefile take precedence over 10473d0407baSopenharmony_ci# this default value 10483d0407baSopenharmony_ciexport KBUILD_IMAGE ?= vmlinux 10493d0407baSopenharmony_ci 10503d0407baSopenharmony_ci# 10513d0407baSopenharmony_ci# INSTALL_PATH specifies where to place the updated kernel and system map 10523d0407baSopenharmony_ci# images. Default is /boot, but you can set it to other values 10533d0407baSopenharmony_ciexport INSTALL_PATH ?= /boot 10543d0407baSopenharmony_ci 10553d0407baSopenharmony_ci# 10563d0407baSopenharmony_ci# INSTALL_DTBS_PATH specifies a prefix for relocations required by build roots. 10573d0407baSopenharmony_ci# Like INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed as 10583d0407baSopenharmony_ci# an argument if needed. Otherwise it defaults to the kernel install path 10593d0407baSopenharmony_ci# 10603d0407baSopenharmony_ciexport INSTALL_DTBS_PATH ?= $(INSTALL_PATH)/dtbs/$(KERNELRELEASE) 10613d0407baSopenharmony_ci 10623d0407baSopenharmony_ci# 10633d0407baSopenharmony_ci# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory 10643d0407baSopenharmony_ci# relocations required by build roots. This is not defined in the 10653d0407baSopenharmony_ci# makefile but the argument can be passed to make if needed. 10663d0407baSopenharmony_ci# 10673d0407baSopenharmony_ci 10683d0407baSopenharmony_ciMODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) 10693d0407baSopenharmony_ciexport MODLIB 10703d0407baSopenharmony_ci 10713d0407baSopenharmony_ci# 10723d0407baSopenharmony_ci# INSTALL_MOD_STRIP, if defined, will cause modules to be 10733d0407baSopenharmony_ci# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then 10743d0407baSopenharmony_ci# the default option --strip-debug will be used. Otherwise, 10753d0407baSopenharmony_ci# INSTALL_MOD_STRIP value will be used as the options to the strip command. 10763d0407baSopenharmony_ci 10773d0407baSopenharmony_ciifdef INSTALL_MOD_STRIP 10783d0407baSopenharmony_ciifeq ($(INSTALL_MOD_STRIP),1) 10793d0407baSopenharmony_cimod_strip_cmd = $(STRIP) --strip-debug 10803d0407baSopenharmony_cielse 10813d0407baSopenharmony_cimod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP) 10823d0407baSopenharmony_ciendif # INSTALL_MOD_STRIP=1 10833d0407baSopenharmony_cielse 10843d0407baSopenharmony_cimod_strip_cmd = true 10853d0407baSopenharmony_ciendif # INSTALL_MOD_STRIP 10863d0407baSopenharmony_ciexport mod_strip_cmd 10873d0407baSopenharmony_ci 10883d0407baSopenharmony_ci# CONFIG_MODULE_COMPRESS, if defined, will cause module to be compressed 10893d0407baSopenharmony_ci# after they are installed in agreement with CONFIG_MODULE_COMPRESS_GZIP 10903d0407baSopenharmony_ci# or CONFIG_MODULE_COMPRESS_XZ. 10913d0407baSopenharmony_ci 10923d0407baSopenharmony_cimod_compress_cmd = true 10933d0407baSopenharmony_ciifdef CONFIG_MODULE_COMPRESS 10943d0407baSopenharmony_ci ifdef CONFIG_MODULE_COMPRESS_GZIP 10953d0407baSopenharmony_ci mod_compress_cmd = $(KGZIP) -n -f 10963d0407baSopenharmony_ci endif # CONFIG_MODULE_COMPRESS_GZIP 10973d0407baSopenharmony_ci ifdef CONFIG_MODULE_COMPRESS_XZ 10983d0407baSopenharmony_ci mod_compress_cmd = $(XZ) -f 10993d0407baSopenharmony_ci endif # CONFIG_MODULE_COMPRESS_XZ 11003d0407baSopenharmony_ciendif # CONFIG_MODULE_COMPRESS 11013d0407baSopenharmony_ciexport mod_compress_cmd 11023d0407baSopenharmony_ci 11033d0407baSopenharmony_ciifdef CONFIG_MODULE_SIG_ALL 11043d0407baSopenharmony_ci$(eval $(call config_filename,MODULE_SIG_KEY)) 11053d0407baSopenharmony_ci 11063d0407baSopenharmony_cimod_sign_cmd = scripts/sign-file $(CONFIG_MODULE_SIG_HASH) $(MODULE_SIG_KEY_SRCPREFIX)$(CONFIG_MODULE_SIG_KEY) certs/signing_key.x509 11073d0407baSopenharmony_cielse 11083d0407baSopenharmony_cimod_sign_cmd = true 11093d0407baSopenharmony_ciendif 11103d0407baSopenharmony_ciexport mod_sign_cmd 11113d0407baSopenharmony_ci 11123d0407baSopenharmony_ciHOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) 11133d0407baSopenharmony_ci 11143d0407baSopenharmony_cihas_libelf = $(call try-run,\ 11153d0407baSopenharmony_ci echo "int main() {}" | $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0) 11163d0407baSopenharmony_ci 11173d0407baSopenharmony_ciifdef CONFIG_STACK_VALIDATION 11183d0407baSopenharmony_ci ifeq ($(has_libelf),1) 11193d0407baSopenharmony_ci objtool_target := tools/objtool FORCE 11203d0407baSopenharmony_ci else 11213d0407baSopenharmony_ci SKIP_STACK_VALIDATION := 1 11223d0407baSopenharmony_ci export SKIP_STACK_VALIDATION 11233d0407baSopenharmony_ci endif 11243d0407baSopenharmony_ciendif 11253d0407baSopenharmony_ci 11263d0407baSopenharmony_ciPHONY += resolve_btfids_clean 11273d0407baSopenharmony_ci 11283d0407baSopenharmony_ciresolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids 11293d0407baSopenharmony_ci 11303d0407baSopenharmony_ci# tools/bpf/resolve_btfids directory might not exist 11313d0407baSopenharmony_ci# in output directory, skip its clean in that case 11323d0407baSopenharmony_ciresolve_btfids_clean: 11333d0407baSopenharmony_ciifneq ($(wildcard $(resolve_btfids_O)),) 11343d0407baSopenharmony_ci $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean 11353d0407baSopenharmony_ciendif 11363d0407baSopenharmony_ci 11373d0407baSopenharmony_ciifdef CONFIG_BPF 11383d0407baSopenharmony_ciifdef CONFIG_DEBUG_INFO_BTF 11393d0407baSopenharmony_ci ifeq ($(has_libelf),1) 11403d0407baSopenharmony_ci resolve_btfids_target := tools/bpf/resolve_btfids FORCE 11413d0407baSopenharmony_ci else 11423d0407baSopenharmony_ci ERROR_RESOLVE_BTFIDS := 1 11433d0407baSopenharmony_ci endif 11443d0407baSopenharmony_ciendif # CONFIG_DEBUG_INFO_BTF 11453d0407baSopenharmony_ciendif # CONFIG_BPF 11463d0407baSopenharmony_ci 11473d0407baSopenharmony_ciPHONY += prepare0 11483d0407baSopenharmony_ci 11493d0407baSopenharmony_ciexport MODORDER := $(extmod-prefix)modules.order 11503d0407baSopenharmony_ciexport MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps 11513d0407baSopenharmony_ci 11523d0407baSopenharmony_ciifeq ($(KBUILD_EXTMOD),) 11533d0407baSopenharmony_cicore-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ io_uring/ 11543d0407baSopenharmony_ci 11553d0407baSopenharmony_civmlinux-dirs := $(patsubst %/,%,$(filter %/, \ 11563d0407baSopenharmony_ci $(core-y) $(core-m) $(drivers-y) $(drivers-m) $(vendor-y)\ 11573d0407baSopenharmony_ci $(libs-y) $(libs-m))) 11583d0407baSopenharmony_ci 11593d0407baSopenharmony_civmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ 11603d0407baSopenharmony_ci $(patsubst %/,%,$(filter %/, $(core-) \ 11613d0407baSopenharmony_ci $(drivers-) $(vendor-) $(libs-)))) 11623d0407baSopenharmony_ci 11633d0407baSopenharmony_cisubdir-modorder := $(addsuffix modules.order,$(filter %/, \ 11643d0407baSopenharmony_ci $(core-y) $(core-m) $(libs-y) $(libs-m) \ 11653d0407baSopenharmony_ci $(drivers-y) $(drivers-m) $(vendor-y))) 11663d0407baSopenharmony_ci 11673d0407baSopenharmony_cibuild-dirs := $(vmlinux-dirs) 11683d0407baSopenharmony_ciclean-dirs := $(vmlinux-alldirs) 11693d0407baSopenharmony_ci 11703d0407baSopenharmony_ci# Externally visible symbols (used by link-vmlinux.sh) 11713d0407baSopenharmony_ciKBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y)) 11723d0407baSopenharmony_ciKBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y))) 11733d0407baSopenharmony_ciifdef CONFIG_MODULES 11743d0407baSopenharmony_ciKBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y))) 11753d0407baSopenharmony_ciKBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y)) 11763d0407baSopenharmony_cielse 11773d0407baSopenharmony_ciKBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y)) 11783d0407baSopenharmony_ciendif 11793d0407baSopenharmony_ciKBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y)) 11803d0407baSopenharmony_ciKBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(vendor-y)) 11813d0407baSopenharmony_ci 11823d0407baSopenharmony_ciexport KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS 11833d0407baSopenharmony_ciexport KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds 11843d0407baSopenharmony_ci# used by scripts/Makefile.package 11853d0407baSopenharmony_ciexport KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools) 11863d0407baSopenharmony_ci 11873d0407baSopenharmony_civmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) 11883d0407baSopenharmony_ci 11893d0407baSopenharmony_ci# Recurse until adjust_autoksyms.sh is satisfied 11903d0407baSopenharmony_ciPHONY += autoksyms_recursive 11913d0407baSopenharmony_ciifdef CONFIG_TRIM_UNUSED_KSYMS 11923d0407baSopenharmony_ci# For the kernel to actually contain only the needed exported symbols, 11933d0407baSopenharmony_ci# we have to build modules as well to determine what those symbols are. 11943d0407baSopenharmony_ci# (this can be evaluated only once include/config/auto.conf has been included) 11953d0407baSopenharmony_ciKBUILD_MODULES := 1 11963d0407baSopenharmony_ci 11973d0407baSopenharmony_ciautoksyms_recursive: descend modules.order 11983d0407baSopenharmony_ci $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ 11993d0407baSopenharmony_ci "$(MAKE) -f $(srctree)/Makefile autoksyms_recursive" 12003d0407baSopenharmony_ciendif 12013d0407baSopenharmony_ci 12023d0407baSopenharmony_ciautoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h) 12033d0407baSopenharmony_ci 12043d0407baSopenharmony_ciquiet_cmd_autoksyms_h = GEN $@ 12053d0407baSopenharmony_ci cmd_autoksyms_h = mkdir -p $(dir $@); \ 12063d0407baSopenharmony_ci $(CONFIG_SHELL) $(srctree)/scripts/gen_autoksyms.sh $@ 12073d0407baSopenharmony_ci 12083d0407baSopenharmony_ci$(autoksyms_h): 12093d0407baSopenharmony_ci $(call cmd,autoksyms_h) 12103d0407baSopenharmony_ci 12113d0407baSopenharmony_ciARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) 12123d0407baSopenharmony_ci 12133d0407baSopenharmony_ci# Final link of vmlinux with optional arch pass after final link 12143d0407baSopenharmony_cicmd_link-vmlinux = \ 12153d0407baSopenharmony_ci $(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \ 12163d0407baSopenharmony_ci $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 12173d0407baSopenharmony_ci 12183d0407baSopenharmony_civmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE 12193d0407baSopenharmony_ci +$(call if_changed,link-vmlinux) 12203d0407baSopenharmony_ci 12213d0407baSopenharmony_citargets := vmlinux 12223d0407baSopenharmony_ci 12233d0407baSopenharmony_ci# The actual objects are generated when descending, 12243d0407baSopenharmony_ci# make sure no implicit rule kicks in 12253d0407baSopenharmony_ci$(sort $(vmlinux-deps) $(subdir-modorder)): descend ; 12263d0407baSopenharmony_ci 12273d0407baSopenharmony_cifilechk_kernel.release = \ 12283d0407baSopenharmony_ci echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" 12293d0407baSopenharmony_ci 12303d0407baSopenharmony_ci# Store (new) KERNELRELEASE string in include/config/kernel.release 12313d0407baSopenharmony_ciinclude/config/kernel.release: FORCE 12323d0407baSopenharmony_ci $(call filechk,kernel.release) 12333d0407baSopenharmony_ci 12343d0407baSopenharmony_ci# Additional helpers built in scripts/ 12353d0407baSopenharmony_ci# Carefully list dependencies so we do not try to build scripts twice 12363d0407baSopenharmony_ci# in parallel 12373d0407baSopenharmony_ciPHONY += scripts 12383d0407baSopenharmony_ciscripts: scripts_basic scripts_dtc 12393d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=$(@) 12403d0407baSopenharmony_ci 12413d0407baSopenharmony_ci# Things we need to do before we recursively start building the kernel 12423d0407baSopenharmony_ci# or the modules are listed in "prepare". 12433d0407baSopenharmony_ci# A multi level approach is used. prepareN is processed before prepareN-1. 12443d0407baSopenharmony_ci# archprepare is used in arch Makefiles and when processed asm symlink, 12453d0407baSopenharmony_ci# version.h and scripts_basic is processed / created. 12463d0407baSopenharmony_ci 12473d0407baSopenharmony_ciPHONY += prepare archprepare 12483d0407baSopenharmony_ci 12493d0407baSopenharmony_ciarchprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \ 12503d0407baSopenharmony_ci asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \ 12513d0407baSopenharmony_ci include/generated/autoconf.h 12523d0407baSopenharmony_ci 12533d0407baSopenharmony_ciprepare0: archprepare 12543d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=scripts/mod 12553d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=. 12563d0407baSopenharmony_ci 12573d0407baSopenharmony_ci# All the preparing.. 12583d0407baSopenharmony_ciprepare: prepare0 prepare-objtool prepare-resolve_btfids 12593d0407baSopenharmony_ci 12603d0407baSopenharmony_ci# Support for using generic headers in asm-generic 12613d0407baSopenharmony_ciasm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj 12623d0407baSopenharmony_ci 12633d0407baSopenharmony_ciPHONY += asm-generic uapi-asm-generic 12643d0407baSopenharmony_ciasm-generic: uapi-asm-generic 12653d0407baSopenharmony_ci $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \ 12663d0407baSopenharmony_ci generic=include/asm-generic 12673d0407baSopenharmony_ciuapi-asm-generic: 12683d0407baSopenharmony_ci $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \ 12693d0407baSopenharmony_ci generic=include/uapi/asm-generic 12703d0407baSopenharmony_ci 12713d0407baSopenharmony_ciPHONY += prepare-objtool prepare-resolve_btfids 12723d0407baSopenharmony_ciprepare-objtool: $(objtool_target) 12733d0407baSopenharmony_ciifeq ($(SKIP_STACK_VALIDATION),1) 12743d0407baSopenharmony_ciifdef CONFIG_UNWINDER_ORC 12753d0407baSopenharmony_ci @echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 12763d0407baSopenharmony_ci @false 12773d0407baSopenharmony_cielse 12783d0407baSopenharmony_ci @echo "warning: Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 12793d0407baSopenharmony_ciendif 12803d0407baSopenharmony_ciendif 12813d0407baSopenharmony_ci 12823d0407baSopenharmony_ciprepare-resolve_btfids: $(resolve_btfids_target) 12833d0407baSopenharmony_ciifeq ($(ERROR_RESOLVE_BTFIDS),1) 12843d0407baSopenharmony_ci @echo "error: Cannot resolve BTF IDs for CONFIG_DEBUG_INFO_BTF, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 12853d0407baSopenharmony_ci @false 12863d0407baSopenharmony_ciendif 12873d0407baSopenharmony_ci# Generate some files 12883d0407baSopenharmony_ci# --------------------------------------------------------------------------- 12893d0407baSopenharmony_ci 12903d0407baSopenharmony_ci# KERNELRELEASE can change from a few different places, meaning version.h 12913d0407baSopenharmony_ci# needs to be updated, so this check is forced on all builds 12923d0407baSopenharmony_ci 12933d0407baSopenharmony_ciuts_len := 64 12943d0407baSopenharmony_cidefine filechk_utsrelease.h 12953d0407baSopenharmony_ci if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ 12963d0407baSopenharmony_ci echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ 12973d0407baSopenharmony_ci exit 1; \ 12983d0407baSopenharmony_ci fi; \ 12993d0407baSopenharmony_ci echo \#define UTS_RELEASE \"$(KERNELRELEASE)\" 13003d0407baSopenharmony_ciendef 13013d0407baSopenharmony_ci 13023d0407baSopenharmony_cidefine filechk_version.h 13033d0407baSopenharmony_ci if [ $(SUBLEVEL) -gt 255 ]; then \ 13043d0407baSopenharmony_ci echo \#define LINUX_VERSION_CODE $(shell \ 13053d0407baSopenharmony_ci expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + 255); \ 13063d0407baSopenharmony_ci else \ 13073d0407baSopenharmony_ci echo \#define LINUX_VERSION_CODE $(shell \ 13083d0407baSopenharmony_ci expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \ 13093d0407baSopenharmony_ci fi; \ 13103d0407baSopenharmony_ci echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + \ 13113d0407baSopenharmony_ci ((c) > 255 ? 255 : (c)))' 13123d0407baSopenharmony_ciendef 13133d0407baSopenharmony_ci 13143d0407baSopenharmony_ci$(version_h): PATCHLEVEL := $(if $(PATCHLEVEL), $(PATCHLEVEL), 0) 13153d0407baSopenharmony_ci$(version_h): SUBLEVEL := $(if $(SUBLEVEL), $(SUBLEVEL), 0) 13163d0407baSopenharmony_ci$(version_h): FORCE 13173d0407baSopenharmony_ci $(call filechk,version.h) 13183d0407baSopenharmony_ci $(Q)rm -f $(old_version_h) 13193d0407baSopenharmony_ci 13203d0407baSopenharmony_ciinclude/generated/utsrelease.h: include/config/kernel.release FORCE 13213d0407baSopenharmony_ci $(call filechk,utsrelease.h) 13223d0407baSopenharmony_ci 13233d0407baSopenharmony_ciPHONY += headerdep 13243d0407baSopenharmony_ciheaderdep: 13253d0407baSopenharmony_ci $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \ 13263d0407baSopenharmony_ci $(srctree)/scripts/headerdep.pl -I$(srctree)/include 13273d0407baSopenharmony_ci 13283d0407baSopenharmony_ci# --------------------------------------------------------------------------- 13293d0407baSopenharmony_ci# Kernel headers 13303d0407baSopenharmony_ci 13313d0407baSopenharmony_ci#Default location for installed headers 13323d0407baSopenharmony_ciexport INSTALL_HDR_PATH = $(objtree)/usr 13333d0407baSopenharmony_ci 13343d0407baSopenharmony_ciquiet_cmd_headers_install = INSTALL $(INSTALL_HDR_PATH)/include 13353d0407baSopenharmony_ci cmd_headers_install = \ 13363d0407baSopenharmony_ci mkdir -p $(INSTALL_HDR_PATH); \ 13373d0407baSopenharmony_ci rsync -mrl --include='*/' --include='*\.h' --exclude='*' \ 13383d0407baSopenharmony_ci usr/include $(INSTALL_HDR_PATH) 13393d0407baSopenharmony_ci 13403d0407baSopenharmony_ciPHONY += headers_install 13413d0407baSopenharmony_ciheaders_install: headers 13423d0407baSopenharmony_ci $(call cmd,headers_install) 13433d0407baSopenharmony_ci 13443d0407baSopenharmony_ciPHONY += archheaders archscripts 13453d0407baSopenharmony_ci 13463d0407baSopenharmony_cihdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj 13473d0407baSopenharmony_ci 13483d0407baSopenharmony_ciPHONY += headers 13493d0407baSopenharmony_ciheaders: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts 13503d0407baSopenharmony_ci $(if $(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/Kbuild),, \ 13513d0407baSopenharmony_ci $(error Headers not exportable for the $(SRCARCH) architecture)) 13523d0407baSopenharmony_ci $(Q)$(MAKE) $(hdr-inst)=include/uapi 13533d0407baSopenharmony_ci $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi 13543d0407baSopenharmony_ci 13553d0407baSopenharmony_ci# Deprecated. It is no-op now. 13563d0407baSopenharmony_ciPHONY += headers_check 13573d0407baSopenharmony_ciheaders_check: 13583d0407baSopenharmony_ci @: 13593d0407baSopenharmony_ci 13603d0407baSopenharmony_ciifdef CONFIG_HEADERS_INSTALL 13613d0407baSopenharmony_ciprepare: headers 13623d0407baSopenharmony_ciendif 13633d0407baSopenharmony_ci 13643d0407baSopenharmony_ciPHONY += scripts_unifdef 13653d0407baSopenharmony_ciscripts_unifdef: scripts_basic 13663d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=scripts scripts/unifdef 13673d0407baSopenharmony_ci 13683d0407baSopenharmony_ci# --------------------------------------------------------------------------- 13693d0407baSopenharmony_ci# Kernel selftest 13703d0407baSopenharmony_ci 13713d0407baSopenharmony_ciPHONY += kselftest 13723d0407baSopenharmony_cikselftest: 13733d0407baSopenharmony_ci $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests 13743d0407baSopenharmony_ci 13753d0407baSopenharmony_cikselftest-%: FORCE 13763d0407baSopenharmony_ci $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $* 13773d0407baSopenharmony_ci 13783d0407baSopenharmony_ciPHONY += kselftest-merge 13793d0407baSopenharmony_cikselftest-merge: 13803d0407baSopenharmony_ci $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!)) 13813d0407baSopenharmony_ci $(Q)find $(srctree)/tools/testing/selftests -name config | \ 13823d0407baSopenharmony_ci xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config 13833d0407baSopenharmony_ci $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 13843d0407baSopenharmony_ci 13853d0407baSopenharmony_ci# --------------------------------------------------------------------------- 13863d0407baSopenharmony_ci# Devicetree files 13873d0407baSopenharmony_ci 13883d0407baSopenharmony_ciifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),) 13893d0407baSopenharmony_cidtstree := arch/$(SRCARCH)/boot/dts 13903d0407baSopenharmony_ciendif 13913d0407baSopenharmony_ci 13923d0407baSopenharmony_ciifneq ($(dtstree),) 13933d0407baSopenharmony_ci 13943d0407baSopenharmony_ci%.dtb: include/config/kernel.release scripts_dtc 13953d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ 13963d0407baSopenharmony_ci 13973d0407baSopenharmony_ciPHONY += dtbs dtbs_install dtbs_check 13983d0407baSopenharmony_cidtbs: include/config/kernel.release scripts_dtc 13993d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=$(dtstree) 14003d0407baSopenharmony_ci 14013d0407baSopenharmony_ciifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) 14023d0407baSopenharmony_ciexport CHECK_DTBS=y 14033d0407baSopenharmony_cidtbs: dt_binding_check 14043d0407baSopenharmony_ciendif 14053d0407baSopenharmony_ci 14063d0407baSopenharmony_cidtbs_check: dtbs 14073d0407baSopenharmony_ci 14083d0407baSopenharmony_cidtbs_install: 14093d0407baSopenharmony_ci $(Q)$(MAKE) $(dtbinst)=$(dtstree) dst=$(INSTALL_DTBS_PATH) 14103d0407baSopenharmony_ci 14113d0407baSopenharmony_ciifdef CONFIG_OF_EARLY_FLATTREE 14123d0407baSopenharmony_ciall: dtbs 14133d0407baSopenharmony_ciendif 14143d0407baSopenharmony_ci 14153d0407baSopenharmony_ciendif 14163d0407baSopenharmony_ci 14173d0407baSopenharmony_ciPHONY += scripts_dtc 14183d0407baSopenharmony_ciscripts_dtc: scripts_basic 14193d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=scripts/dtc 14203d0407baSopenharmony_ci 14213d0407baSopenharmony_ciifneq ($(filter dt_binding_check, $(MAKECMDGOALS)),) 14223d0407baSopenharmony_ciexport CHECK_DT_BINDING=y 14233d0407baSopenharmony_ciendif 14243d0407baSopenharmony_ci 14253d0407baSopenharmony_ciPHONY += dt_binding_check 14263d0407baSopenharmony_cidt_binding_check: scripts_dtc 14273d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings 14283d0407baSopenharmony_ci 14293d0407baSopenharmony_ci# --------------------------------------------------------------------------- 14303d0407baSopenharmony_ci# Modules 14313d0407baSopenharmony_ci 14323d0407baSopenharmony_ciifdef CONFIG_MODULES 14333d0407baSopenharmony_ci 14343d0407baSopenharmony_ci# By default, build modules as well 14353d0407baSopenharmony_ci 14363d0407baSopenharmony_ciall: modules 14373d0407baSopenharmony_ci 14383d0407baSopenharmony_ci# When we're building modules with modversions, we need to consider 14393d0407baSopenharmony_ci# the built-in objects during the descend as well, in order to 14403d0407baSopenharmony_ci# make sure the checksums are up to date before we record them. 14413d0407baSopenharmony_ciifdef CONFIG_MODVERSIONS 14423d0407baSopenharmony_ci KBUILD_BUILTIN := 1 14433d0407baSopenharmony_ciendif 14443d0407baSopenharmony_ci 14453d0407baSopenharmony_ci# Build modules 14463d0407baSopenharmony_ci# 14473d0407baSopenharmony_ci# A module can be listed more than once in obj-m resulting in 14483d0407baSopenharmony_ci# duplicate lines in modules.order files. Those are removed 14493d0407baSopenharmony_ci# using awk while concatenating to the final file. 14503d0407baSopenharmony_ci 14513d0407baSopenharmony_ciPHONY += modules 14523d0407baSopenharmony_cimodules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare 14533d0407baSopenharmony_ci $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 14543d0407baSopenharmony_ci 14553d0407baSopenharmony_ciPHONY += modules_check 14563d0407baSopenharmony_cimodules_check: modules.order 14573d0407baSopenharmony_ci $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $< 14583d0407baSopenharmony_ci 14593d0407baSopenharmony_cicmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@ 14603d0407baSopenharmony_ci 14613d0407baSopenharmony_cimodules.order: $(subdir-modorder) FORCE 14623d0407baSopenharmony_ci $(call if_changed,modules_order) 14633d0407baSopenharmony_ci 14643d0407baSopenharmony_citargets += modules.order 14653d0407baSopenharmony_ci 14663d0407baSopenharmony_ci# Target to prepare building external modules 14673d0407baSopenharmony_ciPHONY += modules_prepare 14683d0407baSopenharmony_cimodules_prepare: prepare 14693d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=scripts scripts/module.lds 14703d0407baSopenharmony_ci 14713d0407baSopenharmony_ci# Target to install modules 14723d0407baSopenharmony_ciPHONY += modules_install 14733d0407baSopenharmony_cimodules_install: _modinst_ _modinst_post 14743d0407baSopenharmony_ci 14753d0407baSopenharmony_ciPHONY += _modinst_ 14763d0407baSopenharmony_ci_modinst_: 14773d0407baSopenharmony_ci @rm -rf $(MODLIB)/kernel 14783d0407baSopenharmony_ci @rm -f $(MODLIB)/source 14793d0407baSopenharmony_ci @mkdir -p $(MODLIB)/kernel 14803d0407baSopenharmony_ci @ln -s $(abspath $(srctree)) $(MODLIB)/source 14813d0407baSopenharmony_ci @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ 14823d0407baSopenharmony_ci rm -f $(MODLIB)/build ; \ 14833d0407baSopenharmony_ci ln -s $(CURDIR) $(MODLIB)/build ; \ 14843d0407baSopenharmony_ci fi 14853d0407baSopenharmony_ci @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order 14863d0407baSopenharmony_ci @cp -f modules.builtin $(MODLIB)/ 14873d0407baSopenharmony_ci @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ 14883d0407baSopenharmony_ci $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst 14893d0407baSopenharmony_ci 14903d0407baSopenharmony_ci# This depmod is only for convenience to give the initial 14913d0407baSopenharmony_ci# boot a modules.dep even before / is mounted read-write. However the 14923d0407baSopenharmony_ci# boot script depmod is the master version. 14933d0407baSopenharmony_ciPHONY += _modinst_post 14943d0407baSopenharmony_ci_modinst_post: _modinst_ 14953d0407baSopenharmony_ci $(call cmd,depmod) 14963d0407baSopenharmony_ci 14973d0407baSopenharmony_ciifeq ($(CONFIG_MODULE_SIG), y) 14983d0407baSopenharmony_ciPHONY += modules_sign 14993d0407baSopenharmony_cimodules_sign: 15003d0407baSopenharmony_ci $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign 15013d0407baSopenharmony_ciendif 15023d0407baSopenharmony_ci 15033d0407baSopenharmony_cielse # CONFIG_MODULES 15043d0407baSopenharmony_ci 15053d0407baSopenharmony_ci# Modules not configured 15063d0407baSopenharmony_ci# --------------------------------------------------------------------------- 15073d0407baSopenharmony_ci 15083d0407baSopenharmony_ciPHONY += modules modules_install 15093d0407baSopenharmony_cimodules modules_install: 15103d0407baSopenharmony_ci @echo >&2 15113d0407baSopenharmony_ci @echo >&2 "The present kernel configuration has modules disabled." 15123d0407baSopenharmony_ci @echo >&2 "Type 'make config' and enable loadable module support." 15133d0407baSopenharmony_ci @echo >&2 "Then build a kernel with module support enabled." 15143d0407baSopenharmony_ci @echo >&2 15153d0407baSopenharmony_ci @exit 1 15163d0407baSopenharmony_ci 15173d0407baSopenharmony_ciendif # CONFIG_MODULES 15183d0407baSopenharmony_ci 15193d0407baSopenharmony_ci### 15203d0407baSopenharmony_ci# Cleaning is done on three levels. 15213d0407baSopenharmony_ci# make clean Delete most generated files 15223d0407baSopenharmony_ci# Leave enough to build external modules 15233d0407baSopenharmony_ci# make mrproper Delete the current configuration, and all generated files 15243d0407baSopenharmony_ci# make distclean Remove editor backup files, patch leftover files and the like 15253d0407baSopenharmony_ci 15263d0407baSopenharmony_ci# Directories & files removed with 'make clean' 15273d0407baSopenharmony_ciCLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \ 15283d0407baSopenharmony_ci modules.builtin modules.builtin.modinfo modules.nsdeps \ 15293d0407baSopenharmony_ci compile_commands.json .thinlto-cache 15303d0407baSopenharmony_ci 15313d0407baSopenharmony_ci# Directories & files removed with 'make mrproper' 15323d0407baSopenharmony_ciMRPROPER_FILES += include/config include/generated \ 15333d0407baSopenharmony_ci arch/$(SRCARCH)/include/generated .tmp_objdiff \ 15343d0407baSopenharmony_ci debian snap tar-install \ 15353d0407baSopenharmony_ci .config .config.old .version \ 15363d0407baSopenharmony_ci Module.symvers \ 15373d0407baSopenharmony_ci signing_key.pem signing_key.priv signing_key.x509 \ 15383d0407baSopenharmony_ci x509.genkey extra_certificates signing_key.x509.keyid \ 15393d0407baSopenharmony_ci signing_key.x509.signer vmlinux-gdb.py \ 15403d0407baSopenharmony_ci *.spec 15413d0407baSopenharmony_ci 15423d0407baSopenharmony_ci# Directories & files removed with 'make distclean' 15433d0407baSopenharmony_ciDISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS 15443d0407baSopenharmony_ci 15453d0407baSopenharmony_ci# clean - Delete most, but leave enough to build external modules 15463d0407baSopenharmony_ci# 15473d0407baSopenharmony_ciclean: rm-files := $(CLEAN_FILES) 15483d0407baSopenharmony_ci 15493d0407baSopenharmony_ciPHONY += archclean vmlinuxclean 15503d0407baSopenharmony_ci 15513d0407baSopenharmony_civmlinuxclean: 15523d0407baSopenharmony_ci $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean 15533d0407baSopenharmony_ci $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) 15543d0407baSopenharmony_ci 15553d0407baSopenharmony_ciclean: archclean vmlinuxclean resolve_btfids_clean 15563d0407baSopenharmony_ci 15573d0407baSopenharmony_ci# mrproper - Delete all generated files, including .config 15583d0407baSopenharmony_ci# 15593d0407baSopenharmony_cimrproper: rm-files := $(wildcard $(MRPROPER_FILES)) 15603d0407baSopenharmony_cimrproper-dirs := $(addprefix _mrproper_,scripts) 15613d0407baSopenharmony_ci 15623d0407baSopenharmony_ciPHONY += $(mrproper-dirs) mrproper 15633d0407baSopenharmony_ci$(mrproper-dirs): 15643d0407baSopenharmony_ci $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) 15653d0407baSopenharmony_ci 15663d0407baSopenharmony_cimrproper: clean $(mrproper-dirs) 15673d0407baSopenharmony_ci $(call cmd,rmfiles) 15683d0407baSopenharmony_ci 15693d0407baSopenharmony_ci# distclean 15703d0407baSopenharmony_ci# 15713d0407baSopenharmony_cidistclean: rm-files := $(wildcard $(DISTCLEAN_FILES)) 15723d0407baSopenharmony_ci 15733d0407baSopenharmony_ciPHONY += distclean 15743d0407baSopenharmony_ci 15753d0407baSopenharmony_cidistclean: mrproper 15763d0407baSopenharmony_ci $(call cmd,rmfiles) 15773d0407baSopenharmony_ci @find $(srctree) $(RCS_FIND_IGNORE) \ 15783d0407baSopenharmony_ci \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ 15793d0407baSopenharmony_ci -o -name '*.bak' -o -name '#*#' -o -name '*%' \ 15803d0407baSopenharmony_ci -o -name 'core' \) \ 15813d0407baSopenharmony_ci -type f -print | xargs rm -f 15823d0407baSopenharmony_ci 15833d0407baSopenharmony_ci 15843d0407baSopenharmony_ci# Packaging of the kernel to various formats 15853d0407baSopenharmony_ci# --------------------------------------------------------------------------- 15863d0407baSopenharmony_ci 15873d0407baSopenharmony_ci%src-pkg: FORCE 15883d0407baSopenharmony_ci $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@ 15893d0407baSopenharmony_ci%pkg: include/config/kernel.release FORCE 15903d0407baSopenharmony_ci $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@ 15913d0407baSopenharmony_ci 15923d0407baSopenharmony_ci# Brief documentation of the typical targets used 15933d0407baSopenharmony_ci# --------------------------------------------------------------------------- 15943d0407baSopenharmony_ci 15953d0407baSopenharmony_ciboards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig) 15963d0407baSopenharmony_ciboards := $(sort $(notdir $(boards))) 15973d0407baSopenharmony_ciboard-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig)) 15983d0407baSopenharmony_ciboard-dirs := $(sort $(notdir $(board-dirs:/=))) 15993d0407baSopenharmony_ci 16003d0407baSopenharmony_ciPHONY += help 16013d0407baSopenharmony_cihelp: 16023d0407baSopenharmony_ci @echo 'Cleaning targets:' 16033d0407baSopenharmony_ci @echo ' clean - Remove most generated files but keep the config and' 16043d0407baSopenharmony_ci @echo ' enough build support to build external modules' 16053d0407baSopenharmony_ci @echo ' mrproper - Remove all generated files + config + various backup files' 16063d0407baSopenharmony_ci @echo ' distclean - mrproper + remove editor backup and patch files' 16073d0407baSopenharmony_ci @echo '' 16083d0407baSopenharmony_ci @echo 'Configuration targets:' 16093d0407baSopenharmony_ci @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help 16103d0407baSopenharmony_ci @echo '' 16113d0407baSopenharmony_ci @echo 'Other generic targets:' 16123d0407baSopenharmony_ci @echo ' all - Build all targets marked with [*]' 16133d0407baSopenharmony_ci @echo '* vmlinux - Build the bare kernel' 16143d0407baSopenharmony_ci @echo '* modules - Build all modules' 16153d0407baSopenharmony_ci @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)' 16163d0407baSopenharmony_ci @echo ' dir/ - Build all files in dir and below' 16173d0407baSopenharmony_ci @echo ' dir/file.[ois] - Build specified target only' 16183d0407baSopenharmony_ci @echo ' dir/file.ll - Build the LLVM assembly file' 16193d0407baSopenharmony_ci @echo ' (requires compiler support for LLVM assembly generation)' 16203d0407baSopenharmony_ci @echo ' dir/file.lst - Build specified mixed source/assembly target only' 16213d0407baSopenharmony_ci @echo ' (requires a recent binutils and recent build (System.map))' 16223d0407baSopenharmony_ci @echo ' dir/file.ko - Build module including final link' 16233d0407baSopenharmony_ci @echo ' modules_prepare - Set up for building external modules' 16243d0407baSopenharmony_ci @echo ' tags/TAGS - Generate tags file for editors' 16253d0407baSopenharmony_ci @echo ' cscope - Generate cscope index' 16263d0407baSopenharmony_ci @echo ' gtags - Generate GNU GLOBAL index' 16273d0407baSopenharmony_ci @echo ' kernelrelease - Output the release version string (use with make -s)' 16283d0407baSopenharmony_ci @echo ' kernelversion - Output the version stored in Makefile (use with make -s)' 16293d0407baSopenharmony_ci @echo ' image_name - Output the image name (use with make -s)' 16303d0407baSopenharmony_ci @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ 16313d0407baSopenharmony_ci echo ' (default: $(INSTALL_HDR_PATH))'; \ 16323d0407baSopenharmony_ci echo '' 16333d0407baSopenharmony_ci @echo 'Static analysers:' 16343d0407baSopenharmony_ci @echo ' checkstack - Generate a list of stack hogs' 16353d0407baSopenharmony_ci @echo ' versioncheck - Sanity check on version.h usage' 16363d0407baSopenharmony_ci @echo ' includecheck - Check for duplicate included header files' 16373d0407baSopenharmony_ci @echo ' export_report - List the usages of all exported symbols' 16383d0407baSopenharmony_ci @echo ' headerdep - Detect inclusion cycles in headers' 16393d0407baSopenharmony_ci @echo ' coccicheck - Check with Coccinelle' 16403d0407baSopenharmony_ci @echo ' clang-analyzer - Check with clang static analyzer' 16413d0407baSopenharmony_ci @echo ' clang-tidy - Check with clang-tidy' 16423d0407baSopenharmony_ci @echo '' 16433d0407baSopenharmony_ci @echo 'Tools:' 16443d0407baSopenharmony_ci @echo ' nsdeps - Generate missing symbol namespace dependencies' 16453d0407baSopenharmony_ci @echo '' 16463d0407baSopenharmony_ci @echo 'Kernel selftest:' 16473d0407baSopenharmony_ci @echo ' kselftest - Build and run kernel selftest' 16483d0407baSopenharmony_ci @echo ' Build, install, and boot kernel before' 16493d0407baSopenharmony_ci @echo ' running kselftest on it' 16503d0407baSopenharmony_ci @echo ' Run as root for full coverage' 16513d0407baSopenharmony_ci @echo ' kselftest-all - Build kernel selftest' 16523d0407baSopenharmony_ci @echo ' kselftest-install - Build and install kernel selftest' 16533d0407baSopenharmony_ci @echo ' kselftest-clean - Remove all generated kselftest files' 16543d0407baSopenharmony_ci @echo ' kselftest-merge - Merge all the config dependencies of' 16553d0407baSopenharmony_ci @echo ' kselftest to existing .config.' 16563d0407baSopenharmony_ci @echo '' 16573d0407baSopenharmony_ci @$(if $(dtstree), \ 16583d0407baSopenharmony_ci echo 'Devicetree:'; \ 16593d0407baSopenharmony_ci echo '* dtbs - Build device tree blobs for enabled boards'; \ 16603d0407baSopenharmony_ci echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \ 16613d0407baSopenharmony_ci echo ' dt_binding_check - Validate device tree binding documents'; \ 16623d0407baSopenharmony_ci echo ' dtbs_check - Validate device tree source files';\ 16633d0407baSopenharmony_ci echo '') 16643d0407baSopenharmony_ci 16653d0407baSopenharmony_ci @echo 'Userspace tools targets:' 16663d0407baSopenharmony_ci @echo ' use "make tools/help"' 16673d0407baSopenharmony_ci @echo ' or "cd tools; make help"' 16683d0407baSopenharmony_ci @echo '' 16693d0407baSopenharmony_ci @echo 'Kernel packaging:' 16703d0407baSopenharmony_ci @$(MAKE) -f $(srctree)/scripts/Makefile.package help 16713d0407baSopenharmony_ci @echo '' 16723d0407baSopenharmony_ci @echo 'Documentation targets:' 16733d0407baSopenharmony_ci @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp 16743d0407baSopenharmony_ci @echo '' 16753d0407baSopenharmony_ci @echo 'Architecture specific targets ($(SRCARCH)):' 16763d0407baSopenharmony_ci @$(if $(archhelp),$(archhelp),\ 16773d0407baSopenharmony_ci echo ' No architecture specific help defined for $(SRCARCH)') 16783d0407baSopenharmony_ci @echo '' 16793d0407baSopenharmony_ci @$(if $(boards), \ 16803d0407baSopenharmony_ci $(foreach b, $(boards), \ 16813d0407baSopenharmony_ci printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \ 16823d0407baSopenharmony_ci echo '') 16833d0407baSopenharmony_ci @$(if $(board-dirs), \ 16843d0407baSopenharmony_ci $(foreach b, $(board-dirs), \ 16853d0407baSopenharmony_ci printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \ 16863d0407baSopenharmony_ci printf " %-16s - Show all of the above\\n" help-boards; \ 16873d0407baSopenharmony_ci echo '') 16883d0407baSopenharmony_ci 16893d0407baSopenharmony_ci @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' 16903d0407baSopenharmony_ci @echo ' make V=2 [targets] 2 => give reason for rebuild of target' 16913d0407baSopenharmony_ci @echo ' make O=dir [targets] Locate all output files in "dir", including .config' 16923d0407baSopenharmony_ci @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK' 16933d0407baSopenharmony_ci @echo ' (sparse by default)' 16943d0407baSopenharmony_ci @echo ' make C=2 [targets] Force check of all c source with $$CHECK' 16953d0407baSopenharmony_ci @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' 16963d0407baSopenharmony_ci @echo ' make W=n [targets] Enable extra build checks, n=1,2,3 where' 16973d0407baSopenharmony_ci @echo ' 1: warnings which may be relevant and do not occur too often' 16983d0407baSopenharmony_ci @echo ' 2: warnings which occur quite often but may still be relevant' 16993d0407baSopenharmony_ci @echo ' 3: more obscure warnings, can most likely be ignored' 17003d0407baSopenharmony_ci @echo ' Multiple levels can be combined with W=12 or W=123' 17013d0407baSopenharmony_ci @echo '' 17023d0407baSopenharmony_ci @echo 'Execute "make" or "make all" to build all targets marked with [*] ' 17033d0407baSopenharmony_ci @echo 'For further info see the ./README file' 17043d0407baSopenharmony_ci 17053d0407baSopenharmony_ci 17063d0407baSopenharmony_cihelp-board-dirs := $(addprefix help-,$(board-dirs)) 17073d0407baSopenharmony_ci 17083d0407baSopenharmony_cihelp-boards: $(help-board-dirs) 17093d0407baSopenharmony_ci 17103d0407baSopenharmony_ciboards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig))) 17113d0407baSopenharmony_ci 17123d0407baSopenharmony_ci$(help-board-dirs): help-%: 17133d0407baSopenharmony_ci @echo 'Architecture specific targets ($(SRCARCH) $*):' 17143d0407baSopenharmony_ci @$(if $(boards-per-dir), \ 17153d0407baSopenharmony_ci $(foreach b, $(boards-per-dir), \ 17163d0407baSopenharmony_ci printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \ 17173d0407baSopenharmony_ci echo '') 17183d0407baSopenharmony_ci 17193d0407baSopenharmony_ci 17203d0407baSopenharmony_ci# Documentation targets 17213d0407baSopenharmony_ci# --------------------------------------------------------------------------- 17223d0407baSopenharmony_ciDOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \ 17233d0407baSopenharmony_ci linkcheckdocs dochelp refcheckdocs 17243d0407baSopenharmony_ciPHONY += $(DOC_TARGETS) 17253d0407baSopenharmony_ci$(DOC_TARGETS): 17263d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=Documentation $@ 17273d0407baSopenharmony_ci 17283d0407baSopenharmony_ci# Misc 17293d0407baSopenharmony_ci# --------------------------------------------------------------------------- 17303d0407baSopenharmony_ci 17313d0407baSopenharmony_ciPHONY += scripts_gdb 17323d0407baSopenharmony_ciscripts_gdb: prepare0 17333d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=scripts/gdb 17343d0407baSopenharmony_ci $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) 17353d0407baSopenharmony_ci 17363d0407baSopenharmony_ciifdef CONFIG_GDB_SCRIPTS 17373d0407baSopenharmony_ciall: scripts_gdb 17383d0407baSopenharmony_ciendif 17393d0407baSopenharmony_ci 17403d0407baSopenharmony_cielse # KBUILD_EXTMOD 17413d0407baSopenharmony_ci 17423d0407baSopenharmony_ci### 17433d0407baSopenharmony_ci# External module support. 17443d0407baSopenharmony_ci# When building external modules the kernel used as basis is considered 17453d0407baSopenharmony_ci# read-only, and no consistency checks are made and the make 17463d0407baSopenharmony_ci# system is not used on the basis kernel. If updates are required 17473d0407baSopenharmony_ci# in the basis kernel ordinary make commands (without M=...) must 17483d0407baSopenharmony_ci# be used. 17493d0407baSopenharmony_ci# 17503d0407baSopenharmony_ci# The following are the only valid targets when building external 17513d0407baSopenharmony_ci# modules. 17523d0407baSopenharmony_ci# make M=dir clean Delete all automatically generated files 17533d0407baSopenharmony_ci# make M=dir modules Make all modules in specified dir 17543d0407baSopenharmony_ci# make M=dir Same as 'make M=dir modules' 17553d0407baSopenharmony_ci# make M=dir modules_install 17563d0407baSopenharmony_ci# Install the modules built in the module directory 17573d0407baSopenharmony_ci# Assumes install directory is already created 17583d0407baSopenharmony_ci 17593d0407baSopenharmony_ci# We are always building only modules. 17603d0407baSopenharmony_ciKBUILD_BUILTIN := 17613d0407baSopenharmony_ciKBUILD_MODULES := 1 17623d0407baSopenharmony_ci 17633d0407baSopenharmony_cibuild-dirs := $(KBUILD_EXTMOD) 17643d0407baSopenharmony_ciPHONY += modules 17653d0407baSopenharmony_cimodules: $(MODORDER) 17663d0407baSopenharmony_ci $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 17673d0407baSopenharmony_ci 17683d0407baSopenharmony_ci$(MODORDER): descend 17693d0407baSopenharmony_ci @: 17703d0407baSopenharmony_ci 17713d0407baSopenharmony_ciPHONY += modules_install 17723d0407baSopenharmony_cimodules_install: _emodinst_ _emodinst_post 17733d0407baSopenharmony_ci 17743d0407baSopenharmony_ciinstall-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) 17753d0407baSopenharmony_ciPHONY += _emodinst_ 17763d0407baSopenharmony_ci_emodinst_: 17773d0407baSopenharmony_ci $(Q)mkdir -p $(MODLIB)/$(install-dir) 17783d0407baSopenharmony_ci $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst 17793d0407baSopenharmony_ci 17803d0407baSopenharmony_ciPHONY += _emodinst_post 17813d0407baSopenharmony_ci_emodinst_post: _emodinst_ 17823d0407baSopenharmony_ci $(call cmd,depmod) 17833d0407baSopenharmony_ci 17843d0407baSopenharmony_cicompile_commands.json: $(extmod-prefix)compile_commands.json 17853d0407baSopenharmony_ciPHONY += compile_commands.json 17863d0407baSopenharmony_ci 17873d0407baSopenharmony_ciclean-dirs := $(KBUILD_EXTMOD) 17883d0407baSopenharmony_ciclean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \ 17893d0407baSopenharmony_ci $(KBUILD_EXTMOD)/compile_commands.json $(KBUILD_EXTMOD)/.thinlto-cache 17903d0407baSopenharmony_ci 17913d0407baSopenharmony_ciPHONY += help 17923d0407baSopenharmony_cihelp: 17933d0407baSopenharmony_ci @echo ' Building external modules.' 17943d0407baSopenharmony_ci @echo ' Syntax: make -C path/to/kernel/src M=$$PWD target' 17953d0407baSopenharmony_ci @echo '' 17963d0407baSopenharmony_ci @echo ' modules - default target, build the module(s)' 17973d0407baSopenharmony_ci @echo ' modules_install - install the module' 17983d0407baSopenharmony_ci @echo ' clean - remove generated files in module directory only' 17993d0407baSopenharmony_ci @echo '' 18003d0407baSopenharmony_ci 18013d0407baSopenharmony_ci# no-op for external module builds 18023d0407baSopenharmony_ciPHONY += prepare modules_prepare 18033d0407baSopenharmony_ci 18043d0407baSopenharmony_ciendif # KBUILD_EXTMOD 18053d0407baSopenharmony_ci 18063d0407baSopenharmony_ci# Single targets 18073d0407baSopenharmony_ci# --------------------------------------------------------------------------- 18083d0407baSopenharmony_ci# To build individual files in subdirectories, you can do like this: 18093d0407baSopenharmony_ci# 18103d0407baSopenharmony_ci# make foo/bar/baz.s 18113d0407baSopenharmony_ci# 18123d0407baSopenharmony_ci# The supported suffixes for single-target are listed in 'single-targets' 18133d0407baSopenharmony_ci# 18143d0407baSopenharmony_ci# To build only under specific subdirectories, you can do like this: 18153d0407baSopenharmony_ci# 18163d0407baSopenharmony_ci# make foo/bar/baz/ 18173d0407baSopenharmony_ci 18183d0407baSopenharmony_ciifdef single-build 18193d0407baSopenharmony_ci 18203d0407baSopenharmony_ci# .ko is special because modpost is needed 18213d0407baSopenharmony_cisingle-ko := $(sort $(filter %.ko, $(MAKECMDGOALS))) 18223d0407baSopenharmony_cisingle-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS))) 18233d0407baSopenharmony_ci 18243d0407baSopenharmony_ci$(single-ko): single_modpost 18253d0407baSopenharmony_ci @: 18263d0407baSopenharmony_ci$(single-no-ko): descend 18273d0407baSopenharmony_ci @: 18283d0407baSopenharmony_ci 18293d0407baSopenharmony_ciifeq ($(KBUILD_EXTMOD),) 18303d0407baSopenharmony_ci# For the single build of in-tree modules, use a temporary file to avoid 18313d0407baSopenharmony_ci# the situation of modules_install installing an invalid modules.order. 18323d0407baSopenharmony_ciMODORDER := .modules.tmp 18333d0407baSopenharmony_ciendif 18343d0407baSopenharmony_ci 18353d0407baSopenharmony_ciPHONY += single_modpost 18363d0407baSopenharmony_cisingle_modpost: $(single-no-ko) modules_prepare 18373d0407baSopenharmony_ci $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER) 18383d0407baSopenharmony_ci $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 18393d0407baSopenharmony_ci 18403d0407baSopenharmony_ciKBUILD_MODULES := 1 18413d0407baSopenharmony_ci 18423d0407baSopenharmony_ciexport KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko)) 18433d0407baSopenharmony_ci 18443d0407baSopenharmony_ci# trim unrelated directories 18453d0407baSopenharmony_cibuild-dirs := $(foreach d, $(build-dirs), \ 18463d0407baSopenharmony_ci $(if $(filter $(d)/%, $(KBUILD_SINGLE_TARGETS)), $(d))) 18473d0407baSopenharmony_ci 18483d0407baSopenharmony_ciendif 18493d0407baSopenharmony_ci 18503d0407baSopenharmony_ciifndef CONFIG_MODULES 18513d0407baSopenharmony_ciKBUILD_MODULES := 18523d0407baSopenharmony_ciendif 18533d0407baSopenharmony_ci 18543d0407baSopenharmony_ci# Handle descending into subdirectories listed in $(build-dirs) 18553d0407baSopenharmony_ci# Preset locale variables to speed up the build process. Limit locale 18563d0407baSopenharmony_ci# tweaks to this spot to avoid wrong language settings when running 18573d0407baSopenharmony_ci# make menuconfig etc. 18583d0407baSopenharmony_ci# Error messages still appears in the original language 18593d0407baSopenharmony_ciPHONY += descend $(build-dirs) 18603d0407baSopenharmony_cidescend: $(build-dirs) 18613d0407baSopenharmony_ci$(build-dirs): prepare 18623d0407baSopenharmony_ci $(Q)$(MAKE) $(build)=$@ \ 18633d0407baSopenharmony_ci single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \ 18643d0407baSopenharmony_ci need-builtin=1 need-modorder=1 18653d0407baSopenharmony_ci 18663d0407baSopenharmony_ciclean-dirs := $(addprefix _clean_, $(clean-dirs)) 18673d0407baSopenharmony_ciPHONY += $(clean-dirs) clean 18683d0407baSopenharmony_ci$(clean-dirs): 18693d0407baSopenharmony_ci $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 18703d0407baSopenharmony_ci 18713d0407baSopenharmony_ciclean: $(clean-dirs) 18723d0407baSopenharmony_ci $(call cmd,rmfiles) 18733d0407baSopenharmony_ci @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ 18743d0407baSopenharmony_ci \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \ 18753d0407baSopenharmony_ci -o -name '*.ko.*' \ 18763d0407baSopenharmony_ci -o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \ 18773d0407baSopenharmony_ci -o -name '*.dwo' -o -name '*.lst' \ 18783d0407baSopenharmony_ci -o -name '*.su' -o -name '*.mod' \ 18793d0407baSopenharmony_ci -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 18803d0407baSopenharmony_ci -o -name '*.lex.c' -o -name '*.tab.[ch]' \ 18813d0407baSopenharmony_ci -o -name '*.asn1.[ch]' \ 18823d0407baSopenharmony_ci -o -name '*.symtypes' -o -name 'modules.order' \ 18833d0407baSopenharmony_ci -o -name '.tmp_*.o.*' \ 18843d0407baSopenharmony_ci -o -name '*.c.[012]*.*' \ 18853d0407baSopenharmony_ci -o -name '*.ll' \ 18863d0407baSopenharmony_ci -o -name '*.gcno' \ 18873d0407baSopenharmony_ci -o -name '*.*.symversions' \) -type f -print | xargs rm -f 18883d0407baSopenharmony_ci 18893d0407baSopenharmony_ci# Generate tags for editors 18903d0407baSopenharmony_ci# --------------------------------------------------------------------------- 18913d0407baSopenharmony_ciquiet_cmd_tags = GEN $@ 18923d0407baSopenharmony_ci cmd_tags = $(BASH) $(srctree)/scripts/tags.sh $@ 18933d0407baSopenharmony_ci 18943d0407baSopenharmony_citags TAGS cscope gtags: FORCE 18953d0407baSopenharmony_ci $(call cmd,tags) 18963d0407baSopenharmony_ci 18973d0407baSopenharmony_ci# Script to generate missing namespace dependencies 18983d0407baSopenharmony_ci# --------------------------------------------------------------------------- 18993d0407baSopenharmony_ci 19003d0407baSopenharmony_ciPHONY += nsdeps 19013d0407baSopenharmony_cinsdeps: export KBUILD_NSDEPS=1 19023d0407baSopenharmony_cinsdeps: modules 19033d0407baSopenharmony_ci $(Q)$(CONFIG_SHELL) $(srctree)/scripts/nsdeps 19043d0407baSopenharmony_ci 19053d0407baSopenharmony_ci# Clang Tooling 19063d0407baSopenharmony_ci# --------------------------------------------------------------------------- 19073d0407baSopenharmony_ci 19083d0407baSopenharmony_ciquiet_cmd_gen_compile_commands = GEN $@ 19093d0407baSopenharmony_ci cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs)) 19103d0407baSopenharmony_ci 19113d0407baSopenharmony_ci$(extmod-prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \ 19123d0407baSopenharmony_ci $(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \ 19133d0407baSopenharmony_ci $(if $(CONFIG_MODULES), $(MODORDER)) FORCE 19143d0407baSopenharmony_ci $(call if_changed,gen_compile_commands) 19153d0407baSopenharmony_ci 19163d0407baSopenharmony_citargets += $(extmod-prefix)compile_commands.json 19173d0407baSopenharmony_ci 19183d0407baSopenharmony_ciPHONY += clang-tidy clang-analyzer 19193d0407baSopenharmony_ci 19203d0407baSopenharmony_ciifdef CONFIG_CC_IS_CLANG 19213d0407baSopenharmony_ciquiet_cmd_clang_tools = CHECK $< 19223d0407baSopenharmony_ci cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $< 19233d0407baSopenharmony_ci 19243d0407baSopenharmony_ciclang-tidy clang-analyzer: $(extmod-prefix)compile_commands.json 19253d0407baSopenharmony_ci $(call cmd,clang_tools) 19263d0407baSopenharmony_cielse 19273d0407baSopenharmony_ciclang-tidy clang-analyzer: 19283d0407baSopenharmony_ci @echo "$@ requires CC=clang" >&2 19293d0407baSopenharmony_ci @false 19303d0407baSopenharmony_ciendif 19313d0407baSopenharmony_ci 19323d0407baSopenharmony_ci# Scripts to check various things for consistency 19333d0407baSopenharmony_ci# --------------------------------------------------------------------------- 19343d0407baSopenharmony_ci 19353d0407baSopenharmony_ciPHONY += includecheck versioncheck coccicheck export_report 19363d0407baSopenharmony_ci 19373d0407baSopenharmony_ciincludecheck: 19383d0407baSopenharmony_ci find $(srctree)/* $(RCS_FIND_IGNORE) \ 19393d0407baSopenharmony_ci -name '*.[hcS]' -type f -print | sort \ 19403d0407baSopenharmony_ci | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl 19413d0407baSopenharmony_ci 19423d0407baSopenharmony_civersioncheck: 19433d0407baSopenharmony_ci find $(srctree)/* $(RCS_FIND_IGNORE) \ 19443d0407baSopenharmony_ci -name '*.[hcS]' -type f -print | sort \ 19453d0407baSopenharmony_ci | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl 19463d0407baSopenharmony_ci 19473d0407baSopenharmony_cicoccicheck: 19483d0407baSopenharmony_ci $(Q)$(BASH) $(srctree)/scripts/$@ 19493d0407baSopenharmony_ci 19503d0407baSopenharmony_ciexport_report: 19513d0407baSopenharmony_ci $(PERL) $(srctree)/scripts/export_report.pl 19523d0407baSopenharmony_ci 19533d0407baSopenharmony_ciPHONY += checkstack kernelrelease kernelversion image_name 19543d0407baSopenharmony_ci 19553d0407baSopenharmony_ci# UML needs a little special treatment here. It wants to use the host 19563d0407baSopenharmony_ci# toolchain, so needs $(SUBARCH) passed to checkstack.pl. Everyone 19573d0407baSopenharmony_ci# else wants $(ARCH), including people doing cross-builds, which means 19583d0407baSopenharmony_ci# that $(SUBARCH) doesn't work here. 19593d0407baSopenharmony_ciifeq ($(ARCH), um) 19603d0407baSopenharmony_ciCHECKSTACK_ARCH := $(SUBARCH) 19613d0407baSopenharmony_cielse 19623d0407baSopenharmony_ciCHECKSTACK_ARCH := $(ARCH) 19633d0407baSopenharmony_ciendif 19643d0407baSopenharmony_cicheckstack: 19653d0407baSopenharmony_ci $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ 19663d0407baSopenharmony_ci $(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH) 19673d0407baSopenharmony_ci 19683d0407baSopenharmony_cikernelrelease: 19693d0407baSopenharmony_ci @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" 19703d0407baSopenharmony_ci 19713d0407baSopenharmony_cikernelversion: 19723d0407baSopenharmony_ci @echo $(KERNELVERSION) 19733d0407baSopenharmony_ci 19743d0407baSopenharmony_ciimage_name: 19753d0407baSopenharmony_ci @echo $(KBUILD_IMAGE) 19763d0407baSopenharmony_ci 19773d0407baSopenharmony_ci# Clear a bunch of variables before executing the submake 19783d0407baSopenharmony_ci 19793d0407baSopenharmony_ciifeq ($(quiet),silent_) 19803d0407baSopenharmony_citools_silent=s 19813d0407baSopenharmony_ciendif 19823d0407baSopenharmony_ci 19833d0407baSopenharmony_citools/: FORCE 19843d0407baSopenharmony_ci $(Q)mkdir -p $(objtree)/tools 19853d0407baSopenharmony_ci $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ 19863d0407baSopenharmony_ci 19873d0407baSopenharmony_citools/%: FORCE 19883d0407baSopenharmony_ci $(Q)mkdir -p $(objtree)/tools 19893d0407baSopenharmony_ci $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $* 19903d0407baSopenharmony_ci 19913d0407baSopenharmony_ciquiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) 19923d0407baSopenharmony_ci cmd_rmfiles = rm -rf $(rm-files) 19933d0407baSopenharmony_ci 19943d0407baSopenharmony_ci# Run depmod only if we have System.map and depmod is executable 19953d0407baSopenharmony_ciquiet_cmd_depmod = DEPMOD $(KERNELRELEASE) 19963d0407baSopenharmony_ci cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ 19973d0407baSopenharmony_ci $(KERNELRELEASE) 19983d0407baSopenharmony_ci 19993d0407baSopenharmony_ci# read saved command lines for existing targets 20003d0407baSopenharmony_ciexisting-targets := $(wildcard $(sort $(targets))) 20013d0407baSopenharmony_ci 20023d0407baSopenharmony_ci-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 20033d0407baSopenharmony_ci 20043d0407baSopenharmony_ciendif # config-build 20053d0407baSopenharmony_ciendif # mixed-build 20063d0407baSopenharmony_ciendif # need-sub-make 20073d0407baSopenharmony_ci 20083d0407baSopenharmony_ciPHONY += FORCE 20093d0407baSopenharmony_ciFORCE: 20103d0407baSopenharmony_ci 20113d0407baSopenharmony_ci# Declare the contents of the PHONY variable as phony. We keep that 20123d0407baSopenharmony_ci# information in a variable so we can use it in if_changed and friends. 20133d0407baSopenharmony_ci.PHONY: $(PHONY) 2014