.. | .. |
---|
1 | 1 | # SPDX-License-Identifier: GPL-2.0 |
---|
2 | | -VERSION = 4 |
---|
3 | | -PATCHLEVEL = 19 |
---|
4 | | -SUBLEVEL = 232 |
---|
| 2 | +VERSION = 5 |
---|
| 3 | +PATCHLEVEL = 10 |
---|
| 4 | +SUBLEVEL = 198 |
---|
5 | 5 | EXTRAVERSION = |
---|
6 | | -NAME = "People's Front" |
---|
| 6 | +NAME = Dare mighty things |
---|
7 | 7 | |
---|
8 | 8 | # *DOCUMENTATION* |
---|
9 | 9 | # To see a list of typical targets execute "make help" |
---|
.. | .. |
---|
11 | 11 | # Comments in this file are targeted only to the developer, do not |
---|
12 | 12 | # expect to learn how to build the kernel reading this file. |
---|
13 | 13 | |
---|
| 14 | +$(if $(filter __%, $(MAKECMDGOALS)), \ |
---|
| 15 | + $(error targets prefixed with '__' are only for internal use)) |
---|
| 16 | + |
---|
14 | 17 | # That's our default target when none is given on the command line |
---|
15 | | -PHONY := _all |
---|
16 | | -_all: |
---|
17 | | - |
---|
18 | | -# o Do not use make's built-in rules and variables |
---|
19 | | -# (this increases performance and avoids hard-to-debug behaviour); |
---|
20 | | -# o Look for make include files relative to root of kernel src |
---|
21 | | -MAKEFLAGS += -rR --include-dir=$(CURDIR) |
---|
22 | | - |
---|
23 | | -# Avoid funny character set dependencies |
---|
24 | | -unexport LC_ALL |
---|
25 | | -LC_COLLATE=C |
---|
26 | | -LC_NUMERIC=C |
---|
27 | | -export LC_COLLATE LC_NUMERIC |
---|
28 | | - |
---|
29 | | -# Avoid interference with shell env settings |
---|
30 | | -unexport GREP_OPTIONS |
---|
| 18 | +PHONY := __all |
---|
| 19 | +__all: |
---|
31 | 20 | |
---|
32 | 21 | # We are using a recursive build, so we need to do a little thinking |
---|
33 | 22 | # to get the ordering right. |
---|
.. | .. |
---|
44 | 33 | # effects are thus separated out and done before the recursive |
---|
45 | 34 | # descending is started. They are now explicitly listed as the |
---|
46 | 35 | # prepare rule. |
---|
| 36 | + |
---|
| 37 | +ifneq ($(sub_make_done),1) |
---|
| 38 | + |
---|
| 39 | +# Do not use make's built-in rules and variables |
---|
| 40 | +# (this increases performance and avoids hard-to-debug behaviour) |
---|
| 41 | +MAKEFLAGS += -rR |
---|
| 42 | + |
---|
| 43 | +# Avoid funny character set dependencies |
---|
| 44 | +unexport LC_ALL |
---|
| 45 | +LC_COLLATE=C |
---|
| 46 | +LC_NUMERIC=C |
---|
| 47 | +export LC_COLLATE LC_NUMERIC |
---|
| 48 | + |
---|
| 49 | +# Avoid interference with shell env settings |
---|
| 50 | +unexport GREP_OPTIONS |
---|
47 | 51 | |
---|
48 | 52 | # Beautify output |
---|
49 | 53 | # --------------------------------------------------------------------------- |
---|
.. | .. |
---|
67 | 71 | # |
---|
68 | 72 | # If KBUILD_VERBOSE equals 0 then the above command will be hidden. |
---|
69 | 73 | # If KBUILD_VERBOSE equals 1 then the above command is displayed. |
---|
| 74 | +# If KBUILD_VERBOSE equals 2 then give the reason why each target is rebuilt. |
---|
70 | 75 | # |
---|
71 | 76 | # To put more focus on warnings, be less verbose as default |
---|
72 | 77 | # Use 'make V=1' to see the full commands |
---|
.. | .. |
---|
88 | 93 | |
---|
89 | 94 | # If the user is running make -s (silent mode), suppress echoing of |
---|
90 | 95 | # commands |
---|
| 96 | +# make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS. |
---|
91 | 97 | |
---|
92 | | -ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) |
---|
93 | | - quiet=silent_ |
---|
94 | | - tools_silent=s |
---|
| 98 | +ifeq ($(filter 3.%,$(MAKE_VERSION)),) |
---|
| 99 | +silence:=$(findstring s,$(firstword -$(MAKEFLAGS))) |
---|
| 100 | +else |
---|
| 101 | +silence:=$(findstring s,$(filter-out --%,$(MAKEFLAGS))) |
---|
| 102 | +endif |
---|
| 103 | + |
---|
| 104 | +ifeq ($(silence),s) |
---|
| 105 | +quiet=silent_ |
---|
95 | 106 | endif |
---|
96 | 107 | |
---|
97 | 108 | export quiet Q KBUILD_VERBOSE |
---|
98 | 109 | |
---|
99 | | -# kbuild supports saving output files in a separate directory. |
---|
100 | | -# To locate output files in a separate directory two syntaxes are supported. |
---|
101 | | -# In both cases the working directory must be the root of the kernel src. |
---|
| 110 | +# Kbuild will save output files in the current working directory. |
---|
| 111 | +# This does not need to match to the root of the kernel source tree. |
---|
| 112 | +# |
---|
| 113 | +# For example, you can do this: |
---|
| 114 | +# |
---|
| 115 | +# cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile |
---|
| 116 | +# |
---|
| 117 | +# If you want to save output files in a different location, there are |
---|
| 118 | +# two syntaxes to specify it. |
---|
| 119 | +# |
---|
102 | 120 | # 1) O= |
---|
103 | 121 | # Use "make O=dir/to/store/output/files/" |
---|
104 | 122 | # |
---|
105 | 123 | # 2) Set KBUILD_OUTPUT |
---|
106 | | -# Set the environment variable KBUILD_OUTPUT to point to the directory |
---|
107 | | -# where the output files shall be placed. |
---|
108 | | -# export KBUILD_OUTPUT=dir/to/store/output/files/ |
---|
109 | | -# make |
---|
| 124 | +# Set the environment variable KBUILD_OUTPUT to point to the output directory. |
---|
| 125 | +# export KBUILD_OUTPUT=dir/to/store/output/files/; make |
---|
110 | 126 | # |
---|
111 | 127 | # The O= assignment takes precedence over the KBUILD_OUTPUT environment |
---|
112 | 128 | # variable. |
---|
113 | 129 | |
---|
114 | | -# KBUILD_SRC is not intended to be used by the regular user (for now), |
---|
115 | | -# it is set on invocation of make with KBUILD_OUTPUT or O= specified. |
---|
116 | | -ifeq ($(KBUILD_SRC),) |
---|
117 | | - |
---|
118 | | -# OK, Make called in directory where kernel src resides |
---|
119 | | -# Do we want to locate output files in a separate directory? |
---|
| 130 | +# Do we want to change the working directory? |
---|
120 | 131 | ifeq ("$(origin O)", "command line") |
---|
121 | 132 | KBUILD_OUTPUT := $(O) |
---|
122 | 133 | endif |
---|
123 | 134 | |
---|
124 | | -# Cancel implicit rules on top Makefile |
---|
125 | | -$(CURDIR)/Makefile Makefile: ; |
---|
| 135 | +ifneq ($(KBUILD_OUTPUT),) |
---|
| 136 | +# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot |
---|
| 137 | +# expand a shell special character '~'. We use a somewhat tedious way here. |
---|
| 138 | +abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd) |
---|
| 139 | +$(if $(abs_objtree),, \ |
---|
| 140 | + $(error failed to create output directory "$(KBUILD_OUTPUT)")) |
---|
126 | 141 | |
---|
127 | | -ifneq ($(words $(subst :, ,$(CURDIR))), 1) |
---|
128 | | - $(error main directory cannot contain spaces nor colons) |
---|
| 142 | +# $(realpath ...) resolves symlinks |
---|
| 143 | +abs_objtree := $(realpath $(abs_objtree)) |
---|
| 144 | +else |
---|
| 145 | +abs_objtree := $(CURDIR) |
---|
| 146 | +endif # ifneq ($(KBUILD_OUTPUT),) |
---|
| 147 | + |
---|
| 148 | +ifeq ($(abs_objtree),$(CURDIR)) |
---|
| 149 | +# Suppress "Entering directory ..." unless we are changing the work directory. |
---|
| 150 | +MAKEFLAGS += --no-print-directory |
---|
| 151 | +else |
---|
| 152 | +need-sub-make := 1 |
---|
129 | 153 | endif |
---|
130 | 154 | |
---|
131 | | -ifneq ($(KBUILD_OUTPUT),) |
---|
132 | | -# check that the output directory actually exists |
---|
133 | | -saved-output := $(KBUILD_OUTPUT) |
---|
134 | | -KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ |
---|
135 | | - && pwd) |
---|
136 | | -$(if $(KBUILD_OUTPUT),, \ |
---|
137 | | - $(error failed to create output directory "$(saved-output)")) |
---|
| 155 | +abs_srctree := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) |
---|
138 | 156 | |
---|
139 | | -PHONY += $(MAKECMDGOALS) sub-make |
---|
| 157 | +ifneq ($(words $(subst :, ,$(abs_srctree))), 1) |
---|
| 158 | +$(error source directory cannot contain spaces or colons) |
---|
| 159 | +endif |
---|
140 | 160 | |
---|
141 | | -$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make |
---|
| 161 | +ifneq ($(abs_srctree),$(abs_objtree)) |
---|
| 162 | +# Look for make include files relative to root of kernel src |
---|
| 163 | +# |
---|
| 164 | +# This does not become effective immediately because MAKEFLAGS is re-parsed |
---|
| 165 | +# once after the Makefile is read. We need to invoke sub-make. |
---|
| 166 | +MAKEFLAGS += --include-dir=$(abs_srctree) |
---|
| 167 | +need-sub-make := 1 |
---|
| 168 | +endif |
---|
| 169 | + |
---|
| 170 | +this-makefile := $(lastword $(MAKEFILE_LIST)) |
---|
| 171 | + |
---|
| 172 | +ifneq ($(filter 3.%,$(MAKE_VERSION)),) |
---|
| 173 | +# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x |
---|
| 174 | +# We need to invoke sub-make to avoid implicit rules in the top Makefile. |
---|
| 175 | +need-sub-make := 1 |
---|
| 176 | +# Cancel implicit rules for this Makefile. |
---|
| 177 | +$(this-makefile): ; |
---|
| 178 | +endif |
---|
| 179 | + |
---|
| 180 | +export abs_srctree abs_objtree |
---|
| 181 | +export sub_make_done := 1 |
---|
| 182 | + |
---|
| 183 | +ifeq ($(need-sub-make),1) |
---|
| 184 | + |
---|
| 185 | +PHONY += $(MAKECMDGOALS) __sub-make |
---|
| 186 | + |
---|
| 187 | +$(filter-out $(this-makefile), $(MAKECMDGOALS)) __all: __sub-make |
---|
142 | 188 | @: |
---|
143 | 189 | |
---|
144 | 190 | # Invoke a second make in the output directory, passing relevant variables |
---|
145 | | -sub-make: |
---|
146 | | - $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ |
---|
147 | | - -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) |
---|
| 191 | +__sub-make: |
---|
| 192 | + $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS) |
---|
148 | 193 | |
---|
149 | | -# Leave processing to above invocation of make |
---|
150 | | -skip-makefile := 1 |
---|
151 | | -endif # ifneq ($(KBUILD_OUTPUT),) |
---|
152 | | -endif # ifeq ($(KBUILD_SRC),) |
---|
| 194 | +endif # need-sub-make |
---|
| 195 | +endif # sub_make_done |
---|
153 | 196 | |
---|
154 | 197 | # We process the rest of the Makefile if this is the final invocation of make |
---|
155 | | -ifeq ($(skip-makefile),) |
---|
| 198 | +ifeq ($(need-sub-make),) |
---|
156 | 199 | |
---|
157 | 200 | # Do not print "Entering directory ...", |
---|
158 | 201 | # but we want to display it when entering to the output directory |
---|
.. | .. |
---|
176 | 219 | KBUILD_CHECKSRC = 0 |
---|
177 | 220 | endif |
---|
178 | 221 | |
---|
179 | | -# Use make M=dir to specify directory of external module to build |
---|
180 | | -# Old syntax make ... SUBDIRS=$PWD is still supported |
---|
181 | | -# Setting the environment variable KBUILD_EXTMOD take precedence |
---|
182 | | -ifdef SUBDIRS |
---|
183 | | - KBUILD_EXTMOD ?= $(SUBDIRS) |
---|
184 | | -endif |
---|
185 | | - |
---|
| 222 | +# Use make M=dir or set the environment variable KBUILD_EXTMOD to specify the |
---|
| 223 | +# directory of external module to build. Setting M= takes precedence. |
---|
186 | 224 | ifeq ("$(origin M)", "command line") |
---|
187 | 225 | KBUILD_EXTMOD := $(M) |
---|
188 | 226 | endif |
---|
189 | 227 | |
---|
190 | | -ifeq ($(KBUILD_SRC),) |
---|
| 228 | +$(if $(word 2, $(KBUILD_EXTMOD)), \ |
---|
| 229 | + $(error building multiple external modules is not supported)) |
---|
| 230 | + |
---|
| 231 | +export KBUILD_CHECKSRC KBUILD_EXTMOD |
---|
| 232 | + |
---|
| 233 | +extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/) |
---|
| 234 | + |
---|
| 235 | +# ANDROID: set up mixed-build support. mixed-build allows device kernel modules |
---|
| 236 | +# to be compiled against a GKI kernel. This approach still uses the headers and |
---|
| 237 | +# Kbuild from device kernel, so care must be taken to ensure that those headers match. |
---|
| 238 | +ifdef KBUILD_MIXED_TREE |
---|
| 239 | +# Need vmlinux.symvers for modpost and System.map for depmod, check whether they exist in KBUILD_MIXED_TREE |
---|
| 240 | +required_mixed_files=vmlinux.symvers System.map |
---|
| 241 | +$(if $(filter-out $(words $(required_mixed_files)), \ |
---|
| 242 | + $(words $(wildcard $(add-prefix $(KBUILD_MIXED_TREE)/,$(required_mixed_files))))),,\ |
---|
| 243 | + $(error KBUILD_MIXED_TREE=$(KBUILD_MIXED_TREE) doesn't contain $(required_mixed_files))) |
---|
| 244 | +endif |
---|
| 245 | + |
---|
| 246 | +mixed-build-prefix = $(if $(KBUILD_MIXED_TREE),$(KBUILD_MIXED_TREE)/) |
---|
| 247 | +export KBUILD_MIXED_TREE |
---|
| 248 | + |
---|
| 249 | +ifeq ($(abs_srctree),$(abs_objtree)) |
---|
191 | 250 | # building in the source tree |
---|
192 | 251 | srctree := . |
---|
| 252 | + building_out_of_srctree := |
---|
193 | 253 | else |
---|
194 | | - ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR))) |
---|
| 254 | + ifeq ($(abs_srctree)/,$(dir $(abs_objtree))) |
---|
195 | 255 | # building in a subdirectory of the source tree |
---|
196 | 256 | srctree := .. |
---|
197 | 257 | else |
---|
198 | | - srctree := $(KBUILD_SRC) |
---|
| 258 | + srctree := $(abs_srctree) |
---|
199 | 259 | endif |
---|
| 260 | + building_out_of_srctree := 1 |
---|
200 | 261 | endif |
---|
201 | 262 | |
---|
202 | | -export KBUILD_CHECKSRC KBUILD_EXTMOD KBUILD_SRC |
---|
| 263 | +ifneq ($(KBUILD_ABS_SRCTREE),) |
---|
| 264 | +srctree := $(abs_srctree) |
---|
| 265 | +endif |
---|
203 | 266 | |
---|
204 | 267 | objtree := . |
---|
205 | | -src := $(srctree) |
---|
206 | | -obj := $(objtree) |
---|
| 268 | +VPATH := $(srctree) |
---|
207 | 269 | |
---|
208 | | -VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) |
---|
209 | | - |
---|
210 | | -export srctree objtree VPATH |
---|
| 270 | +export building_out_of_srctree srctree objtree VPATH |
---|
211 | 271 | |
---|
212 | 272 | # To make sure we do not include .config for any of the *config targets |
---|
213 | 273 | # catch them early, and hand them over to scripts/kconfig/Makefile |
---|
.. | .. |
---|
223 | 283 | clean-targets := %clean mrproper cleandocs |
---|
224 | 284 | no-dot-config-targets := $(clean-targets) \ |
---|
225 | 285 | cscope gtags TAGS tags help% %docs check% coccicheck \ |
---|
226 | | - $(version_h) headers_% archheaders archscripts \ |
---|
227 | | - %asm-generic kernelversion %src-pkg |
---|
228 | | -no-sync-config-targets := $(no-dot-config-targets) install %install \ |
---|
229 | | - kernelrelease |
---|
| 286 | + $(version_h) headers headers_% archheaders archscripts \ |
---|
| 287 | + %asm-generic kernelversion %src-pkg dt_binding_check \ |
---|
| 288 | + outputmakefile |
---|
| 289 | +no-sync-config-targets := $(no-dot-config-targets) %install kernelrelease \ |
---|
| 290 | + image_name |
---|
| 291 | +single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/ |
---|
230 | 292 | |
---|
231 | | -config-targets := 0 |
---|
232 | | -mixed-targets := 0 |
---|
233 | | -dot-config := 1 |
---|
234 | | -may-sync-config := 1 |
---|
| 293 | +config-build := |
---|
| 294 | +mixed-build := |
---|
| 295 | +need-config := 1 |
---|
| 296 | +may-sync-config := 1 |
---|
| 297 | +single-build := |
---|
235 | 298 | |
---|
236 | 299 | ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) |
---|
237 | 300 | ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) |
---|
238 | | - dot-config := 0 |
---|
| 301 | + need-config := |
---|
239 | 302 | endif |
---|
240 | 303 | endif |
---|
241 | 304 | |
---|
242 | 305 | ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) |
---|
243 | 306 | ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) |
---|
244 | | - may-sync-config := 0 |
---|
| 307 | + may-sync-config := |
---|
245 | 308 | endif |
---|
246 | 309 | endif |
---|
247 | 310 | |
---|
248 | 311 | ifneq ($(KBUILD_EXTMOD),) |
---|
249 | | - may-sync-config := 0 |
---|
| 312 | + may-sync-config := |
---|
250 | 313 | endif |
---|
251 | 314 | |
---|
252 | 315 | ifeq ($(KBUILD_EXTMOD),) |
---|
253 | | - ifneq ($(filter config %config,$(MAKECMDGOALS)),) |
---|
254 | | - config-targets := 1 |
---|
| 316 | + ifneq ($(filter %config,$(MAKECMDGOALS)),) |
---|
| 317 | + config-build := 1 |
---|
255 | 318 | ifneq ($(words $(MAKECMDGOALS)),1) |
---|
256 | | - mixed-targets := 1 |
---|
| 319 | + mixed-build := 1 |
---|
257 | 320 | endif |
---|
258 | 321 | endif |
---|
| 322 | +endif |
---|
| 323 | + |
---|
| 324 | +# We cannot build single targets and the others at the same time |
---|
| 325 | +ifneq ($(filter $(single-targets), $(MAKECMDGOALS)),) |
---|
| 326 | + single-build := 1 |
---|
| 327 | + ifneq ($(filter-out $(single-targets), $(MAKECMDGOALS)),) |
---|
| 328 | + mixed-build := 1 |
---|
| 329 | + endif |
---|
259 | 330 | endif |
---|
260 | 331 | |
---|
261 | 332 | # For "make -j clean all", "make -j mrproper defconfig all", etc. |
---|
262 | 333 | ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),) |
---|
263 | 334 | ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),) |
---|
264 | | - mixed-targets := 1 |
---|
| 335 | + mixed-build := 1 |
---|
265 | 336 | endif |
---|
266 | 337 | endif |
---|
267 | 338 | |
---|
268 | 339 | # install and modules_install need also be processed one by one |
---|
269 | 340 | ifneq ($(filter install,$(MAKECMDGOALS)),) |
---|
270 | 341 | ifneq ($(filter modules_install,$(MAKECMDGOALS)),) |
---|
271 | | - mixed-targets := 1 |
---|
| 342 | + mixed-build := 1 |
---|
272 | 343 | endif |
---|
273 | 344 | endif |
---|
274 | 345 | |
---|
275 | | -ifeq ($(mixed-targets),1) |
---|
| 346 | +ifdef mixed-build |
---|
276 | 347 | # =========================================================================== |
---|
277 | 348 | # We're called with mixed targets (*config and build targets). |
---|
278 | 349 | # Handle them one by one. |
---|
279 | 350 | |
---|
280 | 351 | PHONY += $(MAKECMDGOALS) __build_one_by_one |
---|
281 | 352 | |
---|
282 | | -$(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one |
---|
| 353 | +$(MAKECMDGOALS): __build_one_by_one |
---|
283 | 354 | @: |
---|
284 | 355 | |
---|
285 | 356 | __build_one_by_one: |
---|
.. | .. |
---|
288 | 359 | $(MAKE) -f $(srctree)/Makefile $$i; \ |
---|
289 | 360 | done |
---|
290 | 361 | |
---|
291 | | -else |
---|
| 362 | +else # !mixed-build |
---|
292 | 363 | |
---|
293 | | -# We need some generic definitions (do not try to remake the file). |
---|
294 | | -scripts/Kbuild.include: ; |
---|
295 | 364 | include scripts/Kbuild.include |
---|
296 | 365 | |
---|
297 | 366 | # Read KERNELRELEASE from include/config/kernel.release (if it exists) |
---|
.. | .. |
---|
320 | 389 | # Default value for CROSS_COMPILE is not to prefix executables |
---|
321 | 390 | # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile |
---|
322 | 391 | ARCH ?= $(SUBARCH) |
---|
323 | | -ifeq ($(ARCH),arm64) |
---|
324 | | -ifneq ($(wildcard $(srctree)/../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu),) |
---|
325 | | -CROSS_COMPILE ?= $(srctree)/../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- |
---|
326 | | -endif |
---|
327 | | -ifneq ($(wildcard $(srctree)/../prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9),) |
---|
328 | | -CROSS_COMPILE ?= $(srctree)/../prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android- |
---|
329 | | -endif |
---|
330 | | -endif |
---|
331 | | -ifeq ($(ARCH),arm) |
---|
332 | | -ifneq ($(wildcard $(srctree)/../prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf),) |
---|
333 | | -CROSS_COMPILE ?= $(srctree)/../prebuilts/gcc/linux-x86/arm/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- |
---|
334 | | -endif |
---|
335 | | -ifneq ($(wildcard $(srctree)/../prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9),) |
---|
336 | | -CROSS_COMPILE ?= $(srctree)/../prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androidkernel- |
---|
337 | | -endif |
---|
338 | | -endif |
---|
339 | 392 | |
---|
340 | 393 | # Architecture as present in compile.h |
---|
341 | 394 | UTS_MACHINE := $(ARCH) |
---|
.. | .. |
---|
365 | 418 | KCONFIG_CONFIG ?= .config |
---|
366 | 419 | export KCONFIG_CONFIG |
---|
367 | 420 | |
---|
| 421 | +# Default file for 'make defconfig'. This may be overridden by arch-Makefile. |
---|
| 422 | +export KBUILD_DEFCONFIG := defconfig |
---|
| 423 | + |
---|
368 | 424 | # SHELL used by kbuild |
---|
369 | | -CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ |
---|
370 | | - else if [ -x /bin/bash ]; then echo /bin/bash; \ |
---|
371 | | - else echo sh; fi ; fi) |
---|
| 425 | +CONFIG_SHELL := sh |
---|
372 | 426 | |
---|
373 | 427 | HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null) |
---|
374 | 428 | HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null) |
---|
.. | .. |
---|
381 | 435 | HOSTCC = gcc |
---|
382 | 436 | HOSTCXX = g++ |
---|
383 | 437 | endif |
---|
384 | | -KBUILD_HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \ |
---|
385 | | - -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \ |
---|
386 | | - $(HOSTCFLAGS) |
---|
387 | | -KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) |
---|
| 438 | + |
---|
| 439 | +KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ |
---|
| 440 | + -O2 -fomit-frame-pointer -std=gnu89 |
---|
| 441 | +KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS) |
---|
| 442 | +KBUILD_USERLDFLAGS := $(USERLDFLAGS) |
---|
| 443 | + |
---|
| 444 | +KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) |
---|
| 445 | +KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) |
---|
388 | 446 | KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) |
---|
389 | 447 | KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) |
---|
390 | 448 | |
---|
.. | .. |
---|
398 | 456 | OBJCOPY = llvm-objcopy |
---|
399 | 457 | OBJDUMP = llvm-objdump |
---|
400 | 458 | READELF = llvm-readelf |
---|
401 | | -OBJSIZE = llvm-size |
---|
402 | 459 | STRIP = llvm-strip |
---|
403 | 460 | else |
---|
404 | 461 | CC = $(CROSS_COMPILE)gcc |
---|
.. | .. |
---|
408 | 465 | OBJCOPY = $(CROSS_COMPILE)objcopy |
---|
409 | 466 | OBJDUMP = $(CROSS_COMPILE)objdump |
---|
410 | 467 | READELF = $(CROSS_COMPILE)readelf |
---|
411 | | -OBJSIZE = $(CROSS_COMPILE)size |
---|
412 | 468 | STRIP = $(CROSS_COMPILE)strip |
---|
413 | 469 | endif |
---|
| 470 | +PAHOLE = pahole |
---|
| 471 | +RESOLVE_BTFIDS = $(objtree)/tools/bpf/resolve_btfids/resolve_btfids |
---|
414 | 472 | LEX = flex |
---|
415 | 473 | YACC = bison |
---|
416 | 474 | AWK = awk |
---|
417 | | -GENKSYMS = scripts/genksyms/genksyms |
---|
418 | 475 | INSTALLKERNEL := installkernel |
---|
419 | 476 | DEPMOD = depmod |
---|
420 | 477 | PERL = perl |
---|
421 | 478 | PYTHON = python |
---|
422 | | -PYTHON2 = python2 |
---|
423 | 479 | PYTHON3 = python3 |
---|
424 | 480 | CHECK = sparse |
---|
| 481 | +BASH = bash |
---|
| 482 | +KGZIP = gzip |
---|
| 483 | +KBZIP2 = bzip2 |
---|
| 484 | +KLZOP = lzop |
---|
| 485 | +LZMA = lzma |
---|
| 486 | +LZ4 = lz4 |
---|
| 487 | +XZ = xz |
---|
| 488 | +ZSTD = zstd |
---|
425 | 489 | |
---|
426 | 490 | # Use the wrapper for the compiler. This wrapper scans for new |
---|
427 | 491 | # warnings and causes the build to stop upon encountering them. |
---|
428 | 492 | ifeq ($(CC),$(CROSS_COMPILE)gcc) |
---|
429 | 493 | ifneq ($(wildcard $(srctree)/scripts/gcc-wrapper.py),) |
---|
430 | | -CC = $(srctree)/scripts/gcc-wrapper.py $(CROSS_COMPILE)gcc |
---|
| 494 | +CC = $(abspath $(srctree)/scripts/gcc-wrapper.py) $(CROSS_COMPILE)gcc |
---|
431 | 495 | endif |
---|
432 | 496 | endif |
---|
433 | 497 | |
---|
| 498 | +PAHOLE_FLAGS = $(shell PAHOLE=$(PAHOLE) $(srctree)/scripts/pahole-flags.sh) |
---|
| 499 | + |
---|
434 | 500 | CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ |
---|
435 | 501 | -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF) |
---|
436 | | -NOSTDINC_FLAGS = |
---|
| 502 | +NOSTDINC_FLAGS := |
---|
437 | 503 | CFLAGS_MODULE = |
---|
438 | 504 | AFLAGS_MODULE = |
---|
439 | 505 | LDFLAGS_MODULE = |
---|
.. | .. |
---|
454 | 520 | LINUXINCLUDE := \ |
---|
455 | 521 | -I$(srctree)/arch/$(SRCARCH)/include \ |
---|
456 | 522 | -I$(objtree)/arch/$(SRCARCH)/include/generated \ |
---|
457 | | - $(if $(KBUILD_SRC), -I$(srctree)/include) \ |
---|
| 523 | + $(if $(building_out_of_srctree),-I$(srctree)/include) \ |
---|
458 | 524 | -I$(objtree)/include \ |
---|
459 | 525 | $(USERINCLUDE) |
---|
460 | 526 | |
---|
461 | | -KBUILD_AFLAGS := -D__ASSEMBLY__ |
---|
462 | | -KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ |
---|
463 | | - -fno-strict-aliasing -fno-common -fshort-wchar \ |
---|
464 | | - -Werror-implicit-function-declaration \ |
---|
| 527 | +KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE |
---|
| 528 | +KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ |
---|
| 529 | + -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ |
---|
| 530 | + -Werror=implicit-function-declaration -Werror=implicit-int \ |
---|
465 | 531 | -Werror=return-type -Wno-format-security \ |
---|
466 | | - -w \ |
---|
467 | 532 | -std=gnu89 |
---|
468 | 533 | KBUILD_CPPFLAGS := -D__KERNEL__ |
---|
469 | 534 | KBUILD_AFLAGS_KERNEL := |
---|
470 | 535 | KBUILD_CFLAGS_KERNEL := |
---|
471 | 536 | KBUILD_AFLAGS_MODULE := -DMODULE |
---|
472 | 537 | KBUILD_CFLAGS_MODULE := -DMODULE |
---|
473 | | -KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds |
---|
| 538 | +KBUILD_LDFLAGS_MODULE := |
---|
474 | 539 | KBUILD_LDFLAGS := |
---|
475 | | -GCC_PLUGINS_CFLAGS := |
---|
476 | 540 | CLANG_FLAGS := |
---|
477 | 541 | |
---|
478 | | -export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC |
---|
479 | | -export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS |
---|
480 | | -export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE |
---|
481 | | -export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS |
---|
| 542 | +export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC |
---|
| 543 | +export CPP AR NM STRIP OBJCOPY OBJDUMP READELF PAHOLE RESOLVE_BTFIDS LEX YACC AWK INSTALLKERNEL |
---|
| 544 | +export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX |
---|
| 545 | +export KGZIP KBZIP2 KLZOP LZMA LZ4 XZ ZSTD |
---|
| 546 | +export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE |
---|
| 547 | +export KBUILD_USERCFLAGS KBUILD_USERLDFLAGS |
---|
482 | 548 | |
---|
483 | 549 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS |
---|
484 | 550 | export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE |
---|
485 | | -export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN |
---|
486 | 551 | export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE |
---|
487 | 552 | export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE |
---|
488 | 553 | export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL |
---|
489 | | -export KBUILD_ARFLAGS |
---|
490 | | - |
---|
491 | | -# When compiling out-of-tree modules, put MODVERDIR in the module |
---|
492 | | -# tree rather than in the kernel tree. The kernel tree might |
---|
493 | | -# even be read-only. |
---|
494 | | -export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions |
---|
| 554 | +export PAHOLE_FLAGS |
---|
495 | 555 | |
---|
496 | 556 | # Files to ignore in find ... statements |
---|
497 | 557 | |
---|
.. | .. |
---|
510 | 570 | $(Q)$(MAKE) $(build)=scripts/basic |
---|
511 | 571 | $(Q)rm -f .tmp_quiet_recordmcount |
---|
512 | 572 | |
---|
513 | | -# To avoid any implicit rule to kick in, define an empty command. |
---|
514 | | -scripts/basic/%: scripts_basic ; |
---|
515 | | - |
---|
516 | 573 | PHONY += outputmakefile |
---|
| 574 | +# Before starting out-of-tree build, make sure the source tree is clean. |
---|
517 | 575 | # outputmakefile generates a Makefile in the output directory, if using a |
---|
518 | 576 | # separate output directory. This allows convenient use of make in the |
---|
519 | 577 | # output directory. |
---|
| 578 | +# At the same time when output Makefile generated, generate .gitignore to |
---|
| 579 | +# ignore whole output directory |
---|
520 | 580 | outputmakefile: |
---|
521 | | -ifneq ($(KBUILD_SRC),) |
---|
| 581 | +ifdef building_out_of_srctree |
---|
| 582 | + $(Q)if [ -f $(srctree)/.config -o \ |
---|
| 583 | + -d $(srctree)/include/config -o \ |
---|
| 584 | + -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \ |
---|
| 585 | + echo >&2 "***"; \ |
---|
| 586 | + echo >&2 "*** The source tree is not clean, please run 'make$(if $(findstring command line, $(origin ARCH)), ARCH=$(ARCH)) mrproper'"; \ |
---|
| 587 | + echo >&2 "*** in $(abs_srctree)";\ |
---|
| 588 | + echo >&2 "***"; \ |
---|
| 589 | + false; \ |
---|
| 590 | + fi |
---|
522 | 591 | $(Q)ln -fsn $(srctree) source |
---|
523 | | - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ |
---|
524 | | - $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) |
---|
| 592 | + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) |
---|
| 593 | + $(Q)test -e .gitignore || \ |
---|
| 594 | + { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore |
---|
525 | 595 | endif |
---|
526 | 596 | |
---|
527 | | -ifeq ($(cc-name),clang) |
---|
| 597 | +ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) |
---|
528 | 598 | ifneq ($(CROSS_COMPILE),) |
---|
529 | 599 | CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) |
---|
530 | 600 | GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) |
---|
.. | .. |
---|
534 | 604 | ifneq ($(GCC_TOOLCHAIN),) |
---|
535 | 605 | CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) |
---|
536 | 606 | endif |
---|
537 | | -ifneq ($(LLVM_IAS),1) |
---|
538 | | -CLANG_FLAGS += -no-integrated-as |
---|
| 607 | +ifeq ($(LLVM_IAS),1) |
---|
| 608 | +CLANG_FLAGS += -fintegrated-as |
---|
| 609 | +else |
---|
| 610 | +CLANG_FLAGS += -fno-integrated-as |
---|
539 | 611 | endif |
---|
540 | 612 | CLANG_FLAGS += -Werror=unknown-warning-option |
---|
541 | 613 | KBUILD_CFLAGS += $(CLANG_FLAGS) |
---|
.. | .. |
---|
543 | 615 | export CLANG_FLAGS |
---|
544 | 616 | endif |
---|
545 | 617 | |
---|
546 | | -RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register |
---|
547 | | -RETPOLINE_VDSO_CFLAGS_GCC := -mindirect-branch=thunk-inline -mindirect-branch-register |
---|
548 | | -RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk |
---|
549 | | -RETPOLINE_VDSO_CFLAGS_CLANG := -mretpoline |
---|
550 | | -RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG))) |
---|
551 | | -RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_VDSO_CFLAGS_CLANG))) |
---|
552 | | -export RETPOLINE_CFLAGS |
---|
553 | | -export RETPOLINE_VDSO_CFLAGS |
---|
554 | | - |
---|
555 | | -KBUILD_CFLAGS += $(call cc-option,-fno-PIE) |
---|
556 | | -KBUILD_AFLAGS += $(call cc-option,-fno-PIE) |
---|
557 | | - |
---|
558 | 618 | # The expansion should be delayed until arch/$(SRCARCH)/Makefile is included. |
---|
559 | 619 | # Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile. |
---|
560 | 620 | # CC_VERSION_TEXT is referenced from Kconfig (so it needs export), |
---|
561 | 621 | # and from include/config/auto.conf.cmd to detect the compiler upgrade. |
---|
562 | | -CC_VERSION_TEXT = $(shell $(CC) --version | head -n 1) |
---|
| 622 | +CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1) |
---|
563 | 623 | |
---|
564 | | -ifeq ($(config-targets),1) |
---|
| 624 | +ifdef config-build |
---|
565 | 625 | # =========================================================================== |
---|
566 | 626 | # *config targets only - make sure prerequisites are updated, and descend |
---|
567 | 627 | # in scripts/kconfig to make the *config target |
---|
.. | .. |
---|
572 | 632 | include arch/$(SRCARCH)/Makefile |
---|
573 | 633 | export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT |
---|
574 | 634 | |
---|
575 | | -config: scripts_basic outputmakefile FORCE |
---|
| 635 | +config: outputmakefile scripts_basic FORCE |
---|
576 | 636 | $(Q)$(MAKE) $(build)=scripts/kconfig $@ |
---|
577 | 637 | |
---|
578 | | -%config: scripts_basic outputmakefile FORCE |
---|
| 638 | +%config: outputmakefile scripts_basic FORCE |
---|
579 | 639 | $(Q)$(MAKE) $(build)=scripts/kconfig $@ |
---|
580 | 640 | |
---|
581 | | -else |
---|
| 641 | +else #!config-build |
---|
582 | 642 | # =========================================================================== |
---|
583 | 643 | # Build targets only - this includes vmlinux, arch specific targets, clean |
---|
584 | 644 | # targets and others. In general all targets except *config targets. |
---|
585 | 645 | |
---|
586 | 646 | # If building an external module we do not care about the all: rule |
---|
587 | | -# but instead _all depend on modules |
---|
| 647 | +# but instead __all depend on modules |
---|
588 | 648 | PHONY += all |
---|
589 | 649 | ifeq ($(KBUILD_EXTMOD),) |
---|
590 | | -_all: all |
---|
| 650 | +__all: all |
---|
591 | 651 | else |
---|
592 | | -_all: modules |
---|
| 652 | +__all: modules |
---|
593 | 653 | endif |
---|
594 | 654 | |
---|
595 | 655 | # Decide whether to build built-in, modular, or both. |
---|
.. | .. |
---|
607 | 667 | # in addition to whatever we do anyway. |
---|
608 | 668 | # Just "make" or "make all" shall build modules as well |
---|
609 | 669 | |
---|
610 | | -ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) |
---|
| 670 | +ifneq ($(filter all modules nsdeps %compile_commands.json clang-%,$(MAKECMDGOALS)),) |
---|
611 | 671 | KBUILD_MODULES := 1 |
---|
612 | 672 | endif |
---|
613 | 673 | |
---|
.. | .. |
---|
617 | 677 | |
---|
618 | 678 | export KBUILD_MODULES KBUILD_BUILTIN |
---|
619 | 679 | |
---|
620 | | -ifeq ($(KBUILD_EXTMOD),) |
---|
621 | | -# Objects we will link into vmlinux / subdirs we need to visit |
---|
622 | | -init-y := init/ |
---|
623 | | -drivers-y := drivers/ sound/ firmware/ |
---|
624 | | -net-y := net/ |
---|
625 | | -libs-y := lib/ |
---|
626 | | -core-y := usr/ |
---|
627 | | -virt-y := virt/ |
---|
628 | | -endif # KBUILD_EXTMOD |
---|
629 | | - |
---|
630 | | -ifeq ($(dot-config),1) |
---|
| 680 | +ifdef need-config |
---|
631 | 681 | include include/config/auto.conf |
---|
632 | 682 | endif |
---|
633 | 683 | |
---|
| 684 | +ifeq ($(KBUILD_EXTMOD),) |
---|
| 685 | +# Objects we will link into vmlinux / subdirs we need to visit |
---|
| 686 | +core-y := init/ usr/ |
---|
| 687 | +drivers-y := drivers/ sound/ |
---|
| 688 | +drivers-$(CONFIG_SAMPLES) += samples/ |
---|
| 689 | +drivers-y += net/ virt/ |
---|
| 690 | +libs-y := lib/ |
---|
| 691 | +endif # KBUILD_EXTMOD |
---|
| 692 | + |
---|
| 693 | +ifndef KBUILD_MIXED_TREE |
---|
634 | 694 | # The all: target is the default when no target is given on the |
---|
635 | 695 | # command line. |
---|
636 | 696 | # This allow a user to issue only 'make' to build a kernel including modules |
---|
637 | 697 | # Defaults to vmlinux, but the arch makefile usually adds further targets |
---|
638 | 698 | all: vmlinux |
---|
| 699 | +endif |
---|
639 | 700 | |
---|
640 | 701 | CFLAGS_GCOV := -fprofile-arcs -ftest-coverage \ |
---|
641 | 702 | $(call cc-option,-fno-tree-loop-im) \ |
---|
.. | .. |
---|
647 | 708 | CC_FLAGS_FTRACE := -pg |
---|
648 | 709 | endif |
---|
649 | 710 | |
---|
650 | | -# Make toolchain changes before including arch/$(SRCARCH)/Makefile to ensure |
---|
651 | | -# ar/cc/ld-* macros return correct values. |
---|
652 | | -ifdef CONFIG_LTO_CLANG |
---|
653 | | -# use llvm-ar for building symbol tables from IR files, and llvm-nm instead |
---|
654 | | -# of objdump for processing symbol versions and exports |
---|
655 | | -LLVM_AR := llvm-ar |
---|
656 | | -LLVM_NM := llvm-nm |
---|
657 | | -export LLVM_AR LLVM_NM |
---|
| 711 | +ifdef CONFIG_CC_IS_GCC |
---|
| 712 | +RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) |
---|
| 713 | +RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix) |
---|
| 714 | +RETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register) |
---|
| 715 | +endif |
---|
| 716 | +ifdef CONFIG_CC_IS_CLANG |
---|
| 717 | +RETPOLINE_CFLAGS := -mretpoline-external-thunk |
---|
| 718 | +RETPOLINE_VDSO_CFLAGS := -mretpoline |
---|
658 | 719 | endif |
---|
659 | 720 | |
---|
660 | | -# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default |
---|
661 | | -# values of the respective KBUILD_* variables |
---|
662 | | -ARCH_CPPFLAGS := |
---|
663 | | -ARCH_AFLAGS := |
---|
664 | | -ARCH_CFLAGS := |
---|
| 721 | +ifdef CONFIG_RETHUNK |
---|
| 722 | +RETHUNK_CFLAGS := -mfunction-return=thunk-extern |
---|
| 723 | +RETPOLINE_CFLAGS += $(RETHUNK_CFLAGS) |
---|
| 724 | +endif |
---|
| 725 | + |
---|
| 726 | +export RETPOLINE_CFLAGS |
---|
| 727 | +export RETPOLINE_VDSO_CFLAGS |
---|
| 728 | + |
---|
665 | 729 | include arch/$(SRCARCH)/Makefile |
---|
666 | 730 | |
---|
667 | | -ifeq ($(dot-config),1) |
---|
668 | | -ifeq ($(may-sync-config),1) |
---|
| 731 | +ifdef need-config |
---|
| 732 | +ifdef may-sync-config |
---|
669 | 733 | # Read in dependencies to all Kconfig* files, make sure to run syncconfig if |
---|
670 | 734 | # changes are detected. This should be included after arch/$(SRCARCH)/Makefile |
---|
671 | 735 | # because some architectures define CROSS_COMPILE there. |
---|
672 | 736 | include include/config/auto.conf.cmd |
---|
673 | 737 | |
---|
674 | | -# To avoid any implicit rule to kick in, define an empty command |
---|
675 | | -$(KCONFIG_CONFIG): ; |
---|
| 738 | +$(KCONFIG_CONFIG): |
---|
| 739 | + @echo >&2 '***' |
---|
| 740 | + @echo >&2 '*** Configuration file "$@" not found!' |
---|
| 741 | + @echo >&2 '***' |
---|
| 742 | + @echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or' |
---|
| 743 | + @echo >&2 '*** "make menuconfig" or "make xconfig").' |
---|
| 744 | + @echo >&2 '***' |
---|
| 745 | + @/bin/false |
---|
676 | 746 | |
---|
677 | 747 | # The actual configuration files used during the build are stored in |
---|
678 | 748 | # include/generated/ and include/config/. Update them if .config is newer than |
---|
.. | .. |
---|
680 | 750 | # |
---|
681 | 751 | # This exploits the 'multi-target pattern rule' trick. |
---|
682 | 752 | # The syncconfig should be executed only once to make all the targets. |
---|
683 | | -%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG) |
---|
| 753 | +# (Note: use the grouped target '&:' when we bump to GNU Make 4.3) |
---|
| 754 | +# |
---|
| 755 | +# Do not use $(call cmd,...) here. That would suppress prompts from syncconfig, |
---|
| 756 | +# so you cannot notice that Kconfig is waiting for the user input. |
---|
| 757 | +%/config/auto.conf %/config/auto.conf.cmd %/generated/autoconf.h: $(KCONFIG_CONFIG) |
---|
| 758 | + $(Q)$(kecho) " SYNC $@" |
---|
684 | 759 | $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig |
---|
685 | | -else |
---|
| 760 | +else # !may-sync-config |
---|
686 | 761 | # External modules and some install targets need include/generated/autoconf.h |
---|
687 | 762 | # and include/config/auto.conf but do not care if they are up-to-date. |
---|
688 | 763 | # Use auto.conf to trigger the test |
---|
.. | .. |
---|
698 | 773 | /bin/false) |
---|
699 | 774 | |
---|
700 | 775 | endif # may-sync-config |
---|
701 | | -endif # $(dot-config) |
---|
| 776 | +endif # need-config |
---|
702 | 777 | |
---|
703 | 778 | KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) |
---|
704 | 779 | KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) |
---|
705 | 780 | KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) |
---|
706 | 781 | KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) |
---|
707 | | -KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) |
---|
708 | 782 | KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) |
---|
709 | 783 | |
---|
710 | | -ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE |
---|
711 | | -KBUILD_CFLAGS += -Os |
---|
712 | | -else |
---|
713 | | -KBUILD_CFLAGS += -O2 |
---|
| 784 | +ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE |
---|
| 785 | +KBUILD_CFLAGS += -O2 |
---|
| 786 | +else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 |
---|
| 787 | +KBUILD_CFLAGS += -O3 |
---|
| 788 | +else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE |
---|
| 789 | +KBUILD_CFLAGS += -Os |
---|
714 | 790 | endif |
---|
715 | 791 | |
---|
716 | 792 | # Tell gcc to never replace conditional load with a non-conditional one |
---|
717 | 793 | KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) |
---|
718 | 794 | KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races) |
---|
719 | | - |
---|
720 | | -# check for 'asm goto' |
---|
721 | | -ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) |
---|
722 | | - KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO |
---|
723 | | - KBUILD_AFLAGS += -DCC_HAVE_ASM_GOTO |
---|
724 | | -endif |
---|
725 | | - |
---|
726 | | -include scripts/Makefile.kcov |
---|
727 | | -include scripts/Makefile.gcc-plugins |
---|
728 | 795 | |
---|
729 | 796 | ifdef CONFIG_READABLE_ASM |
---|
730 | 797 | # Disable optimizations that make assembler listings hard to read. |
---|
.. | .. |
---|
737 | 804 | endif |
---|
738 | 805 | |
---|
739 | 806 | ifneq ($(CONFIG_FRAME_WARN),0) |
---|
740 | | -KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN}) |
---|
| 807 | +KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN) |
---|
741 | 808 | endif |
---|
742 | 809 | |
---|
743 | | -stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector |
---|
| 810 | +stackp-flags-y := -fno-stack-protector |
---|
744 | 811 | stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector |
---|
745 | 812 | stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong |
---|
746 | 813 | |
---|
747 | 814 | KBUILD_CFLAGS += $(stackp-flags-y) |
---|
748 | 815 | |
---|
749 | | -ifeq ($(cc-name),clang) |
---|
750 | | -KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) |
---|
751 | | -KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) |
---|
752 | | -KBUILD_CFLAGS += $(call cc-disable-warning, gnu) |
---|
753 | | -# Quiet clang warning: comparison of unsigned expression < 0 is always false |
---|
754 | | -KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare) |
---|
| 816 | +KBUILD_CFLAGS-$(CONFIG_WERROR) += -Werror |
---|
| 817 | +KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) |
---|
| 818 | + |
---|
| 819 | +ifdef CONFIG_CC_IS_CLANG |
---|
| 820 | +KBUILD_CPPFLAGS += -Qunused-arguments |
---|
| 821 | +KBUILD_CFLAGS += -Wno-format-invalid-specifier |
---|
| 822 | +KBUILD_CFLAGS += -Wno-gnu |
---|
755 | 823 | # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the |
---|
756 | 824 | # source of a reference will be _MergedGlobals and not on of the whitelisted names. |
---|
757 | 825 | # See modpost pattern 2 |
---|
758 | | -KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,) |
---|
759 | | -KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior) |
---|
| 826 | +KBUILD_CFLAGS += -mno-global-merge |
---|
| 827 | +else |
---|
| 828 | + |
---|
| 829 | +# Warn about unmarked fall-throughs in switch statement. |
---|
| 830 | +# Disabled for clang while comment to attribute conversion happens and |
---|
| 831 | +# https://github.com/ClangBuiltLinux/linux/issues/636 is discussed. |
---|
| 832 | +KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,) |
---|
760 | 833 | endif |
---|
761 | 834 | |
---|
762 | 835 | # These warnings generated too much noise in a regular build. |
---|
.. | .. |
---|
764 | 837 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) |
---|
765 | 838 | |
---|
766 | 839 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) |
---|
| 840 | + |
---|
| 841 | +# These result in bogus false positives |
---|
| 842 | +KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer) |
---|
| 843 | + |
---|
767 | 844 | ifdef CONFIG_FRAME_POINTER |
---|
768 | 845 | KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls |
---|
769 | 846 | else |
---|
.. | .. |
---|
784 | 861 | |
---|
785 | 862 | # Initialize all stack variables with a zero value. |
---|
786 | 863 | ifdef CONFIG_INIT_STACK_ALL_ZERO |
---|
787 | | -# Future support for zero initialization is still being debated, see |
---|
788 | | -# https://bugs.llvm.org/show_bug.cgi?id=45497. These flags are subject to being |
---|
789 | | -# renamed or dropped. |
---|
790 | 864 | KBUILD_CFLAGS += -ftrivial-auto-var-init=zero |
---|
| 865 | +ifdef CONFIG_CC_HAS_AUTO_VAR_INIT_ZERO_ENABLER |
---|
| 866 | +# https://github.com/llvm/llvm-project/issues/44842 |
---|
791 | 867 | KBUILD_CFLAGS += -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang |
---|
792 | 868 | endif |
---|
| 869 | +endif |
---|
793 | 870 | |
---|
794 | | -KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments) |
---|
| 871 | +DEBUG_CFLAGS := |
---|
| 872 | + |
---|
| 873 | +# Workaround for GCC versions < 5.0 |
---|
| 874 | +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801 |
---|
| 875 | +ifdef CONFIG_CC_IS_GCC |
---|
| 876 | +DEBUG_CFLAGS += $(call cc-ifversion, -lt, 0500, $(call cc-option, -fno-var-tracking-assignments)) |
---|
| 877 | +endif |
---|
795 | 878 | |
---|
796 | 879 | ifdef CONFIG_DEBUG_INFO |
---|
| 880 | + |
---|
797 | 881 | ifdef CONFIG_DEBUG_INFO_SPLIT |
---|
798 | | -KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) |
---|
| 882 | +DEBUG_CFLAGS += -gsplit-dwarf |
---|
799 | 883 | else |
---|
800 | | -KBUILD_CFLAGS += -g |
---|
| 884 | +DEBUG_CFLAGS += -g |
---|
801 | 885 | endif |
---|
802 | | -ifneq ($(LLVM_IAS),1) |
---|
| 886 | + |
---|
| 887 | +ifdef CONFIG_AS_IS_LLVM |
---|
| 888 | +KBUILD_AFLAGS += -g |
---|
| 889 | +else |
---|
803 | 890 | KBUILD_AFLAGS += -Wa,-gdwarf-2 |
---|
804 | | -endif |
---|
805 | 891 | endif |
---|
806 | 892 | |
---|
807 | 893 | ifdef CONFIG_DEBUG_INFO_DWARF4 |
---|
808 | | -KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,) |
---|
| 894 | +DEBUG_CFLAGS += -gdwarf-4 |
---|
809 | 895 | endif |
---|
810 | 896 | |
---|
811 | 897 | ifdef CONFIG_DEBUG_INFO_REDUCED |
---|
812 | | -KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ |
---|
| 898 | +DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ |
---|
813 | 899 | $(call cc-option,-fno-var-tracking) |
---|
814 | 900 | endif |
---|
815 | 901 | |
---|
| 902 | +ifdef CONFIG_DEBUG_INFO_COMPRESSED |
---|
| 903 | +DEBUG_CFLAGS += -gz=zlib |
---|
| 904 | +KBUILD_AFLAGS += -gz=zlib |
---|
| 905 | +KBUILD_LDFLAGS += --compress-debug-sections=zlib |
---|
| 906 | +endif |
---|
| 907 | + |
---|
| 908 | +endif # CONFIG_DEBUG_INFO |
---|
| 909 | + |
---|
| 910 | +KBUILD_CFLAGS += $(DEBUG_CFLAGS) |
---|
| 911 | +export DEBUG_CFLAGS |
---|
| 912 | + |
---|
816 | 913 | ifdef CONFIG_FUNCTION_TRACER |
---|
817 | | -ifdef CONFIG_FTRACE_MCOUNT_RECORD |
---|
818 | | - # gcc 5 supports generating the mcount tables directly |
---|
819 | | - ifeq ($(call cc-option-yn,-mrecord-mcount),y) |
---|
820 | | - CC_FLAGS_FTRACE += -mrecord-mcount |
---|
821 | | - export CC_USING_RECORD_MCOUNT := 1 |
---|
822 | | - endif |
---|
| 914 | +ifdef CONFIG_FTRACE_MCOUNT_USE_CC |
---|
| 915 | + CC_FLAGS_FTRACE += -mrecord-mcount |
---|
823 | 916 | ifdef CONFIG_HAVE_NOP_MCOUNT |
---|
824 | 917 | ifeq ($(call cc-option-yn, -mnop-mcount),y) |
---|
825 | 918 | CC_FLAGS_FTRACE += -mnop-mcount |
---|
826 | 919 | CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT |
---|
827 | 920 | endif |
---|
| 921 | + endif |
---|
| 922 | +endif |
---|
| 923 | +ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL |
---|
| 924 | + CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT |
---|
| 925 | +endif |
---|
| 926 | +ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT |
---|
| 927 | + ifdef CONFIG_HAVE_C_RECORDMCOUNT |
---|
| 928 | + BUILD_C_RECORDMCOUNT := y |
---|
| 929 | + export BUILD_C_RECORDMCOUNT |
---|
828 | 930 | endif |
---|
829 | 931 | endif |
---|
830 | 932 | ifdef CONFIG_HAVE_FENTRY |
---|
.. | .. |
---|
836 | 938 | export CC_FLAGS_FTRACE |
---|
837 | 939 | KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING) |
---|
838 | 940 | KBUILD_AFLAGS += $(CC_FLAGS_USING) |
---|
839 | | -ifdef CONFIG_DYNAMIC_FTRACE |
---|
840 | | - ifdef CONFIG_HAVE_C_RECORDMCOUNT |
---|
841 | | - BUILD_C_RECORDMCOUNT := y |
---|
842 | | - export BUILD_C_RECORDMCOUNT |
---|
843 | | - endif |
---|
844 | | -endif |
---|
845 | 941 | endif |
---|
846 | 942 | |
---|
847 | 943 | # We trigger additional mismatches with less inlining |
---|
.. | .. |
---|
854 | 950 | LDFLAGS_vmlinux += --gc-sections |
---|
855 | 951 | endif |
---|
856 | 952 | |
---|
857 | | -ifdef CONFIG_LTO_CLANG |
---|
858 | | -ifdef CONFIG_THINLTO |
---|
859 | | -lto-clang-flags := -flto=thin |
---|
860 | | -KBUILD_LDFLAGS += --thinlto-cache-dir=.thinlto-cache |
---|
861 | | -else |
---|
862 | | -lto-clang-flags := -flto |
---|
863 | | -endif |
---|
864 | | -lto-clang-flags += -fvisibility=default $(call cc-option, -fsplit-lto-unit) |
---|
865 | | - |
---|
866 | | -# Limit inlining across translation units to reduce binary size |
---|
867 | | -LD_FLAGS_LTO_CLANG := -mllvm -import-instr-limit=5 |
---|
868 | | - |
---|
869 | | -KBUILD_LDFLAGS += $(LD_FLAGS_LTO_CLANG) |
---|
870 | | -KBUILD_LDFLAGS_MODULE += $(LD_FLAGS_LTO_CLANG) |
---|
871 | | - |
---|
872 | | -KBUILD_LDFLAGS_MODULE += -T scripts/module-lto.lds |
---|
873 | | - |
---|
874 | | -# allow disabling only clang LTO where needed |
---|
875 | | -DISABLE_LTO_CLANG := -fno-lto |
---|
876 | | -export DISABLE_LTO_CLANG |
---|
877 | | -endif |
---|
878 | | - |
---|
879 | | -ifdef CONFIG_LTO |
---|
880 | | -LTO_CFLAGS := $(lto-clang-flags) |
---|
881 | | -KBUILD_CFLAGS += $(LTO_CFLAGS) |
---|
882 | | - |
---|
883 | | -DISABLE_LTO := $(DISABLE_LTO_CLANG) |
---|
884 | | -export LTO_CFLAGS DISABLE_LTO |
---|
885 | | -endif |
---|
886 | | - |
---|
887 | | -ifdef CONFIG_CFI_CLANG |
---|
888 | | -cfi-clang-flags += -fsanitize=cfi -fno-sanitize-cfi-canonical-jump-tables \ |
---|
889 | | - -fno-sanitize-blacklist |
---|
890 | | -DISABLE_CFI_CLANG := -fno-sanitize=cfi |
---|
891 | | -ifdef CONFIG_MODULES |
---|
892 | | -cfi-clang-flags += -fsanitize-cfi-cross-dso |
---|
893 | | -DISABLE_CFI_CLANG += -fno-sanitize-cfi-cross-dso |
---|
894 | | -endif |
---|
895 | | -ifdef CONFIG_CFI_PERMISSIVE |
---|
896 | | -cfi-clang-flags += -fsanitize-recover=cfi -fno-sanitize-trap=cfi |
---|
897 | | -endif |
---|
898 | | - |
---|
899 | | -# also disable CFI when LTO is disabled |
---|
900 | | -DISABLE_LTO_CLANG += $(DISABLE_CFI_CLANG) |
---|
901 | | -# allow disabling only clang CFI where needed |
---|
902 | | -export DISABLE_CFI_CLANG |
---|
903 | | -endif |
---|
904 | | - |
---|
905 | | -ifdef CONFIG_CFI |
---|
906 | | -CFI_CFLAGS := $(cfi-clang-flags) |
---|
907 | | -KBUILD_CFLAGS += $(CFI_CFLAGS) |
---|
908 | | - |
---|
909 | | -DISABLE_CFI := $(DISABLE_CFI_CLANG) |
---|
910 | | -DISABLE_LTO += $(DISABLE_CFI) |
---|
911 | | -export CFI_CFLAGS DISABLE_CFI |
---|
912 | | -endif |
---|
913 | | - |
---|
914 | 953 | ifdef CONFIG_SHADOW_CALL_STACK |
---|
915 | 954 | CC_FLAGS_SCS := -fsanitize=shadow-call-stack |
---|
916 | 955 | KBUILD_CFLAGS += $(CC_FLAGS_SCS) |
---|
917 | 956 | export CC_FLAGS_SCS |
---|
918 | 957 | endif |
---|
919 | 958 | |
---|
| 959 | +ifdef CONFIG_LTO_CLANG |
---|
| 960 | +ifdef CONFIG_LTO_CLANG_THIN |
---|
| 961 | +CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit |
---|
| 962 | +KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache |
---|
| 963 | +else |
---|
| 964 | +CC_FLAGS_LTO := -flto |
---|
| 965 | +endif |
---|
| 966 | + |
---|
| 967 | +ifeq ($(SRCARCH),x86) |
---|
| 968 | +# TODO(b/182572011): Revert workaround for compiler / linker bug. |
---|
| 969 | +CC_FLAGS_LTO += -fvisibility=hidden |
---|
| 970 | +else |
---|
| 971 | +CC_FLAGS_LTO += -fvisibility=default |
---|
| 972 | +endif |
---|
| 973 | + |
---|
| 974 | +# Limit inlining across translation units to reduce binary size |
---|
| 975 | +KBUILD_LDFLAGS += -mllvm -import-instr-limit=5 |
---|
| 976 | +endif |
---|
| 977 | + |
---|
| 978 | +ifdef CONFIG_LTO |
---|
| 979 | +KBUILD_CFLAGS += $(CC_FLAGS_LTO) |
---|
| 980 | +export CC_FLAGS_LTO |
---|
| 981 | +endif |
---|
| 982 | + |
---|
| 983 | +ifdef CONFIG_CFI_CLANG |
---|
| 984 | +CC_FLAGS_CFI := -fsanitize=cfi \ |
---|
| 985 | + -fsanitize-cfi-cross-dso \ |
---|
| 986 | + -fno-sanitize-cfi-canonical-jump-tables \ |
---|
| 987 | + -fno-sanitize-blacklist |
---|
| 988 | + |
---|
| 989 | +ifdef CONFIG_CFI_PERMISSIVE |
---|
| 990 | +CC_FLAGS_CFI += -fsanitize-recover=cfi \ |
---|
| 991 | + -fno-sanitize-trap=cfi |
---|
| 992 | +else |
---|
| 993 | +ifndef CONFIG_UBSAN_TRAP |
---|
| 994 | +CC_FLAGS_CFI += -ftrap-function=__ubsan_handle_cfi_check_fail_abort |
---|
| 995 | +endif |
---|
| 996 | +endif |
---|
| 997 | + |
---|
| 998 | +# If LTO flags are filtered out, we must also filter out CFI. |
---|
| 999 | +CC_FLAGS_LTO += $(CC_FLAGS_CFI) |
---|
| 1000 | +KBUILD_CFLAGS += $(CC_FLAGS_CFI) |
---|
| 1001 | +export CC_FLAGS_CFI |
---|
| 1002 | +endif |
---|
| 1003 | + |
---|
| 1004 | +ifdef CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_32B |
---|
| 1005 | +KBUILD_CFLAGS += -falign-functions=32 |
---|
| 1006 | +endif |
---|
| 1007 | + |
---|
920 | 1008 | # arch Makefile may override CC so keep this after arch Makefile is included |
---|
921 | 1009 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) |
---|
922 | 1010 | |
---|
923 | 1011 | # warn about C99 declaration after statement |
---|
924 | | -KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) |
---|
| 1012 | +KBUILD_CFLAGS += -Wdeclaration-after-statement |
---|
| 1013 | + |
---|
| 1014 | +# Variable Length Arrays (VLAs) should not be used anywhere in the kernel |
---|
| 1015 | +KBUILD_CFLAGS += -Wvla |
---|
925 | 1016 | |
---|
926 | 1017 | # disable pointer signed / unsigned warnings in gcc 4.0 |
---|
927 | | -KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) |
---|
| 1018 | +KBUILD_CFLAGS += -Wno-pointer-sign |
---|
928 | 1019 | |
---|
929 | 1020 | # disable stringop warnings in gcc 8+ |
---|
930 | 1021 | KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) |
---|
.. | .. |
---|
941 | 1032 | KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) |
---|
942 | 1033 | |
---|
943 | 1034 | # disable invalid "can't wrap" optimizations for signed / pointers |
---|
944 | | -KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) |
---|
945 | | - |
---|
946 | | -# clang sets -fmerge-all-constants by default as optimization, but this |
---|
947 | | -# is non-conforming behavior for C and in fact breaks the kernel, so we |
---|
948 | | -# need to disable it here generally. |
---|
949 | | -KBUILD_CFLAGS += $(call cc-option,-fno-merge-all-constants) |
---|
950 | | - |
---|
951 | | -# for gcc -fno-merge-all-constants disables everything, but it is fine |
---|
952 | | -# to have actual conforming behavior enabled. |
---|
953 | | -KBUILD_CFLAGS += $(call cc-option,-fmerge-constants) |
---|
| 1035 | +KBUILD_CFLAGS += -fno-strict-overflow |
---|
954 | 1036 | |
---|
955 | 1037 | # Make sure -fstack-check isn't enabled (like gentoo apparently did) |
---|
956 | | -KBUILD_CFLAGS += $(call cc-option,-fno-stack-check,) |
---|
| 1038 | +KBUILD_CFLAGS += -fno-stack-check |
---|
957 | 1039 | |
---|
958 | 1040 | # conserve stack if available |
---|
959 | 1041 | KBUILD_CFLAGS += $(call cc-option,-fconserve-stack) |
---|
960 | 1042 | |
---|
961 | | -# disallow errors like 'EXPORT_GPL(foo);' with missing header |
---|
962 | | -KBUILD_CFLAGS += $(call cc-option,-Werror=implicit-int) |
---|
963 | | - |
---|
964 | | -# require functions to have arguments in prototypes, not empty 'int foo()' |
---|
965 | | -KBUILD_CFLAGS += $(call cc-option,-Werror=strict-prototypes) |
---|
966 | | - |
---|
967 | 1043 | # Prohibit date/time macros, which would make the build non-deterministic |
---|
968 | | -KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) |
---|
| 1044 | +KBUILD_CFLAGS += -Werror=date-time |
---|
969 | 1045 | |
---|
970 | 1046 | # enforce correct pointer usage |
---|
971 | 1047 | KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) |
---|
.. | .. |
---|
974 | 1050 | KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) |
---|
975 | 1051 | |
---|
976 | 1052 | # change __FILE__ to the relative path from the srctree |
---|
977 | | -KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) |
---|
| 1053 | +KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) |
---|
978 | 1054 | |
---|
979 | | -# use the deterministic mode of AR if available |
---|
980 | | -KBUILD_ARFLAGS := $(call ar-option,D) |
---|
| 1055 | +# include additional Makefiles when needed |
---|
| 1056 | +include-y := scripts/Makefile.extrawarn |
---|
| 1057 | +include-$(CONFIG_KASAN) += scripts/Makefile.kasan |
---|
| 1058 | +include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan |
---|
| 1059 | +include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan |
---|
| 1060 | +include-$(CONFIG_KCOV) += scripts/Makefile.kcov |
---|
| 1061 | +include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins |
---|
981 | 1062 | |
---|
982 | | -include scripts/Makefile.kasan |
---|
983 | | -include scripts/Makefile.extrawarn |
---|
984 | | -include scripts/Makefile.ubsan |
---|
| 1063 | +include $(addprefix $(srctree)/, $(include-y)) |
---|
985 | 1064 | |
---|
986 | | -# Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the |
---|
987 | | -# last assignments |
---|
988 | | -KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS) |
---|
989 | | -KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS) |
---|
990 | | -KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS) |
---|
| 1065 | +# scripts/Makefile.gcc-plugins is intentionally included last. |
---|
| 1066 | +# Do not add $(call cc-option,...) below this line. When you build the kernel |
---|
| 1067 | +# from the clean source tree, the GCC plugins do not exist at this point. |
---|
991 | 1068 | |
---|
992 | | -# Use --build-id when available. |
---|
993 | | -LDFLAGS_BUILD_ID := $(call ld-option, --build-id) |
---|
994 | | -KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) |
---|
995 | | -LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) |
---|
| 1069 | +# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments |
---|
| 1070 | +KBUILD_CPPFLAGS += $(KCPPFLAGS) |
---|
| 1071 | +KBUILD_AFLAGS += $(KAFLAGS) |
---|
| 1072 | +KBUILD_CFLAGS += $(KCFLAGS) |
---|
| 1073 | + |
---|
| 1074 | +KBUILD_LDFLAGS_MODULE += --build-id=sha1 |
---|
| 1075 | +LDFLAGS_vmlinux += --build-id=sha1 |
---|
| 1076 | + |
---|
| 1077 | +KBUILD_LDFLAGS += -z noexecstack |
---|
| 1078 | +KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments) |
---|
996 | 1079 | |
---|
997 | 1080 | ifeq ($(CONFIG_STRIP_ASM_SYMS),y) |
---|
998 | 1081 | LDFLAGS_vmlinux += $(call ld-option, -X,) |
---|
999 | 1082 | endif |
---|
1000 | 1083 | |
---|
1001 | 1084 | ifeq ($(CONFIG_RELR),y) |
---|
1002 | | -LDFLAGS_vmlinux += --pack-dyn-relocs=relr |
---|
| 1085 | +LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags |
---|
1003 | 1086 | endif |
---|
| 1087 | + |
---|
| 1088 | +# We never want expected sections to be placed heuristically by the |
---|
| 1089 | +# linker. All sections should be explicitly named in the linker script. |
---|
| 1090 | +ifdef CONFIG_LD_ORPHAN_WARN |
---|
| 1091 | +LDFLAGS_vmlinux += --orphan-handling=warn |
---|
| 1092 | +endif |
---|
| 1093 | + |
---|
| 1094 | +# Align the bit size of userspace programs with the kernel |
---|
| 1095 | +KBUILD_USERCFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) |
---|
| 1096 | +KBUILD_USERLDFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS)) |
---|
| 1097 | + |
---|
| 1098 | +# make the checker run with the right architecture |
---|
| 1099 | +CHECKFLAGS += --arch=$(ARCH) |
---|
1004 | 1100 | |
---|
1005 | 1101 | # insure the checker run with the right endianness |
---|
1006 | 1102 | CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian) |
---|
.. | .. |
---|
1060 | 1156 | mod_compress_cmd = true |
---|
1061 | 1157 | ifdef CONFIG_MODULE_COMPRESS |
---|
1062 | 1158 | ifdef CONFIG_MODULE_COMPRESS_GZIP |
---|
1063 | | - mod_compress_cmd = gzip -n -f |
---|
| 1159 | + mod_compress_cmd = $(KGZIP) -n -f |
---|
1064 | 1160 | endif # CONFIG_MODULE_COMPRESS_GZIP |
---|
1065 | 1161 | ifdef CONFIG_MODULE_COMPRESS_XZ |
---|
1066 | | - mod_compress_cmd = xz -f |
---|
| 1162 | + mod_compress_cmd = $(XZ) -f |
---|
1067 | 1163 | endif # CONFIG_MODULE_COMPRESS_XZ |
---|
1068 | 1164 | endif # CONFIG_MODULE_COMPRESS |
---|
1069 | 1165 | export mod_compress_cmd |
---|
1070 | | - |
---|
1071 | | -# Select initial ramdisk compression format, default is gzip(1). |
---|
1072 | | -# This shall be used by the dracut(8) tool while creating an initramfs image. |
---|
1073 | | -# |
---|
1074 | | -INITRD_COMPRESS-y := gzip |
---|
1075 | | -INITRD_COMPRESS-$(CONFIG_RD_BZIP2) := bzip2 |
---|
1076 | | -INITRD_COMPRESS-$(CONFIG_RD_LZMA) := lzma |
---|
1077 | | -INITRD_COMPRESS-$(CONFIG_RD_XZ) := xz |
---|
1078 | | -INITRD_COMPRESS-$(CONFIG_RD_LZO) := lzo |
---|
1079 | | -INITRD_COMPRESS-$(CONFIG_RD_LZ4) := lz4 |
---|
1080 | | -# do not export INITRD_COMPRESS, since we didn't actually |
---|
1081 | | -# choose a sane default compression above. |
---|
1082 | | -# export INITRD_COMPRESS := $(INITRD_COMPRESS-y) |
---|
1083 | 1166 | |
---|
1084 | 1167 | ifdef CONFIG_MODULE_SIG_ALL |
---|
1085 | 1168 | $(eval $(call config_filename,MODULE_SIG_KEY)) |
---|
.. | .. |
---|
1092 | 1175 | |
---|
1093 | 1176 | HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) |
---|
1094 | 1177 | |
---|
| 1178 | +has_libelf := $(call try-run,\ |
---|
| 1179 | + echo "int main() {}" | \ |
---|
| 1180 | + $(HOSTCC) $(KBUILD_HOSTCFLAGS) -xc -o /dev/null $(KBUILD_HOSTLDFLAGS) $(HOST_LIBELF_LIBS) -,1,0) |
---|
| 1181 | + |
---|
1095 | 1182 | ifdef CONFIG_STACK_VALIDATION |
---|
1096 | | - has_libelf := $(call try-run,\ |
---|
1097 | | - echo "int main() {}" | $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0) |
---|
1098 | 1183 | ifeq ($(has_libelf),1) |
---|
1099 | 1184 | objtool_target := tools/objtool FORCE |
---|
1100 | 1185 | else |
---|
.. | .. |
---|
1103 | 1188 | endif |
---|
1104 | 1189 | endif |
---|
1105 | 1190 | |
---|
| 1191 | +PHONY += resolve_btfids_clean |
---|
| 1192 | + |
---|
| 1193 | +resolve_btfids_O = $(abspath $(objtree))/tools/bpf/resolve_btfids |
---|
| 1194 | + |
---|
| 1195 | +# tools/bpf/resolve_btfids directory might not exist |
---|
| 1196 | +# in output directory, skip its clean in that case |
---|
| 1197 | +resolve_btfids_clean: |
---|
| 1198 | +ifneq ($(wildcard $(resolve_btfids_O)),) |
---|
| 1199 | + $(Q)$(MAKE) -sC $(srctree)/tools/bpf/resolve_btfids O=$(resolve_btfids_O) clean |
---|
| 1200 | +endif |
---|
| 1201 | + |
---|
| 1202 | +ifdef CONFIG_BPF |
---|
| 1203 | +ifdef CONFIG_DEBUG_INFO_BTF |
---|
| 1204 | + ifeq ($(has_libelf),1) |
---|
| 1205 | + resolve_btfids_target := tools/bpf/resolve_btfids FORCE |
---|
| 1206 | + else |
---|
| 1207 | + ERROR_RESOLVE_BTFIDS := 1 |
---|
| 1208 | + endif |
---|
| 1209 | +endif # CONFIG_DEBUG_INFO_BTF |
---|
| 1210 | +endif # CONFIG_BPF |
---|
| 1211 | + |
---|
1106 | 1212 | PHONY += prepare0 |
---|
1107 | 1213 | |
---|
| 1214 | +export MODORDER := $(extmod-prefix)modules.order |
---|
| 1215 | +export MODULES_NSDEPS := $(extmod-prefix)modules.nsdeps |
---|
| 1216 | + |
---|
| 1217 | +# --------------------------------------------------------------------------- |
---|
| 1218 | +# Kernel headers |
---|
| 1219 | + |
---|
| 1220 | +PHONY += headers |
---|
| 1221 | + |
---|
| 1222 | +#Default location for installed headers |
---|
1108 | 1223 | ifeq ($(KBUILD_EXTMOD),) |
---|
1109 | | -core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ |
---|
| 1224 | +PHONY += archheaders archscripts |
---|
| 1225 | +hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj |
---|
| 1226 | +headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts |
---|
| 1227 | +else |
---|
| 1228 | +hdr-prefix = $(KBUILD_EXTMOD)/ |
---|
| 1229 | +hdr-inst := -f $(srctree)/scripts/Makefile.headersinst dst=$(KBUILD_EXTMOD)/usr/include objtree=$(objtree)/$(KBUILD_EXTMOD) obj |
---|
| 1230 | +endif |
---|
1110 | 1231 | |
---|
1111 | | -vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ |
---|
| 1232 | +export INSTALL_HDR_PATH = $(objtree)/$(hdr-prefix)usr |
---|
| 1233 | + |
---|
| 1234 | +quiet_cmd_headers_install = INSTALL $(INSTALL_HDR_PATH)/include |
---|
| 1235 | + cmd_headers_install = \ |
---|
| 1236 | + mkdir -p $(INSTALL_HDR_PATH); \ |
---|
| 1237 | + rsync -mrl --include='*/' --include='*\.h' --exclude='*' \ |
---|
| 1238 | + $(hdr-prefix)usr/include $(INSTALL_HDR_PATH); |
---|
| 1239 | + |
---|
| 1240 | +PHONY += headers_install |
---|
| 1241 | +headers_install: headers |
---|
| 1242 | + $(call cmd,headers_install) |
---|
| 1243 | + |
---|
| 1244 | +headers: |
---|
| 1245 | +ifeq ($(KBUILD_EXTMOD),) |
---|
| 1246 | + $(if $(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/Kbuild),, \ |
---|
| 1247 | + $(error Headers not exportable for the $(SRCARCH) architecture)) |
---|
| 1248 | +endif |
---|
| 1249 | + $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)include/uapi |
---|
| 1250 | + $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)arch/$(SRCARCH)/include/uapi |
---|
| 1251 | + |
---|
| 1252 | +ifeq ($(KBUILD_EXTMOD),) |
---|
| 1253 | +core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ io_uring/ |
---|
| 1254 | + |
---|
| 1255 | +vmlinux-dirs := $(patsubst %/,%,$(filter %/, \ |
---|
1112 | 1256 | $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ |
---|
1113 | | - $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y))) |
---|
| 1257 | + $(libs-y) $(libs-m))) |
---|
1114 | 1258 | |
---|
1115 | | -vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \ |
---|
1116 | | - $(init-) $(core-) $(drivers-) $(net-) $(libs-) $(virt-)))) |
---|
| 1259 | +vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ |
---|
| 1260 | + $(patsubst %/,%,$(filter %/, $(core-) \ |
---|
| 1261 | + $(drivers-) $(libs-)))) |
---|
1117 | 1262 | |
---|
1118 | | -init-y := $(patsubst %/, %/built-in.a, $(init-y)) |
---|
1119 | | -core-y := $(patsubst %/, %/built-in.a, $(core-y)) |
---|
1120 | | -drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y)) |
---|
1121 | | -net-y := $(patsubst %/, %/built-in.a, $(net-y)) |
---|
1122 | | -libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) |
---|
1123 | | -libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y))) |
---|
1124 | | -virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) |
---|
| 1263 | +build-dirs := $(vmlinux-dirs) |
---|
| 1264 | +clean-dirs := $(vmlinux-alldirs) |
---|
| 1265 | + |
---|
| 1266 | +subdir-modorder := $(addsuffix /modules.order, $(build-dirs)) |
---|
1125 | 1267 | |
---|
1126 | 1268 | # Externally visible symbols (used by link-vmlinux.sh) |
---|
1127 | | -export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) |
---|
1128 | | -export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y) |
---|
1129 | | -export KBUILD_VMLINUX_LIBS := $(libs-y1) |
---|
1130 | | -export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds |
---|
1131 | | -export LDFLAGS_vmlinux |
---|
1132 | | -# used by scripts/package/Makefile |
---|
1133 | | -export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) |
---|
| 1269 | +KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y)) |
---|
| 1270 | +KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y))) |
---|
| 1271 | +ifdef CONFIG_MODULES |
---|
| 1272 | +KBUILD_VMLINUX_OBJS += $(patsubst %/, %/lib.a, $(filter %/, $(libs-y))) |
---|
| 1273 | +KBUILD_VMLINUX_LIBS := $(filter-out %/, $(libs-y)) |
---|
| 1274 | +else |
---|
| 1275 | +KBUILD_VMLINUX_LIBS := $(patsubst %/,%/lib.a, $(libs-y)) |
---|
| 1276 | +endif |
---|
| 1277 | +KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y)) |
---|
1134 | 1278 | |
---|
1135 | | -vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) |
---|
| 1279 | +export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS |
---|
| 1280 | +export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds |
---|
| 1281 | +# used by scripts/Makefile.package |
---|
| 1282 | +export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools) |
---|
| 1283 | + |
---|
| 1284 | +vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) |
---|
1136 | 1285 | |
---|
1137 | 1286 | # Recurse until adjust_autoksyms.sh is satisfied |
---|
1138 | 1287 | PHONY += autoksyms_recursive |
---|
1139 | | -autoksyms_recursive: $(vmlinux-deps) |
---|
1140 | 1288 | ifdef CONFIG_TRIM_UNUSED_KSYMS |
---|
1141 | | - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ |
---|
1142 | | - "$(MAKE) -f $(srctree)/Makefile vmlinux" |
---|
1143 | | -endif |
---|
1144 | | - |
---|
1145 | 1289 | # For the kernel to actually contain only the needed exported symbols, |
---|
1146 | 1290 | # we have to build modules as well to determine what those symbols are. |
---|
1147 | 1291 | # (this can be evaluated only once include/config/auto.conf has been included) |
---|
1148 | | -ifdef CONFIG_TRIM_UNUSED_KSYMS |
---|
1149 | | - KBUILD_MODULES := 1 |
---|
| 1292 | +KBUILD_MODULES := 1 |
---|
| 1293 | + |
---|
| 1294 | +autoksyms_recursive: descend modules.order |
---|
| 1295 | + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ |
---|
| 1296 | + "$(MAKE) -f $(srctree)/Makefile autoksyms_recursive" |
---|
1150 | 1297 | endif |
---|
1151 | 1298 | |
---|
1152 | 1299 | autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h) |
---|
.. | .. |
---|
1162 | 1309 | |
---|
1163 | 1310 | # Final link of vmlinux with optional arch pass after final link |
---|
1164 | 1311 | cmd_link-vmlinux = \ |
---|
1165 | | - $(CONFIG_SHELL) $< $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_vmlinux) ; \ |
---|
| 1312 | + $(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \ |
---|
1166 | 1313 | $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) |
---|
1167 | 1314 | |
---|
| 1315 | +ifndef KBUILD_MIXED_TREE |
---|
1168 | 1316 | vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE |
---|
1169 | | -ifdef CONFIG_HEADERS_CHECK |
---|
1170 | | - $(Q)$(MAKE) -f $(srctree)/Makefile headers_check |
---|
1171 | | -endif |
---|
1172 | | -ifdef CONFIG_GDB_SCRIPTS |
---|
1173 | | - $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) |
---|
1174 | | -endif |
---|
1175 | 1317 | +$(call if_changed,link-vmlinux) |
---|
1176 | | - |
---|
1177 | | -# Build samples along the rest of the kernel. This needs headers_install. |
---|
1178 | | -ifdef CONFIG_SAMPLES |
---|
1179 | | -vmlinux-dirs += samples |
---|
1180 | | -samples: headers_install |
---|
1181 | 1318 | endif |
---|
| 1319 | + |
---|
| 1320 | +targets := vmlinux |
---|
1182 | 1321 | |
---|
1183 | 1322 | # The actual objects are generated when descending, |
---|
1184 | 1323 | # make sure no implicit rule kicks in |
---|
1185 | | -$(sort $(vmlinux-deps)): $(vmlinux-dirs) ; |
---|
| 1324 | +$(sort $(vmlinux-deps) $(subdir-modorder)): descend ; |
---|
1186 | 1325 | |
---|
1187 | | -# Handle descending into subdirectories listed in $(vmlinux-dirs) |
---|
1188 | | -# Preset locale variables to speed up the build process. Limit locale |
---|
1189 | | -# tweaks to this spot to avoid wrong language settings when running |
---|
1190 | | -# make menuconfig etc. |
---|
1191 | | -# Error messages still appears in the original language |
---|
1192 | | - |
---|
1193 | | -PHONY += $(vmlinux-dirs) |
---|
1194 | | -$(vmlinux-dirs): prepare scripts |
---|
1195 | | - $(Q)$(MAKE) $(build)=$@ need-builtin=1 |
---|
1196 | | - |
---|
1197 | | -define filechk_kernel.release |
---|
| 1326 | +filechk_kernel.release = \ |
---|
1198 | 1327 | echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion \ |
---|
1199 | 1328 | $(srctree) $(BRANCH) $(KMI_GENERATION))" |
---|
1200 | | -endef |
---|
1201 | 1329 | |
---|
1202 | 1330 | # Store (new) KERNELRELEASE string in include/config/kernel.release |
---|
1203 | | -include/config/kernel.release: $(srctree)/Makefile FORCE |
---|
| 1331 | +include/config/kernel.release: FORCE |
---|
1204 | 1332 | $(call filechk,kernel.release) |
---|
1205 | 1333 | |
---|
1206 | 1334 | # Additional helpers built in scripts/ |
---|
1207 | 1335 | # Carefully list dependencies so we do not try to build scripts twice |
---|
1208 | 1336 | # in parallel |
---|
1209 | 1337 | PHONY += scripts |
---|
1210 | | -scripts: scripts_basic asm-generic gcc-plugins $(autoksyms_h) |
---|
| 1338 | +scripts: scripts_basic scripts_dtc |
---|
1211 | 1339 | $(Q)$(MAKE) $(build)=$(@) |
---|
1212 | 1340 | |
---|
1213 | 1341 | # Things we need to do before we recursively start building the kernel |
---|
.. | .. |
---|
1216 | 1344 | # archprepare is used in arch Makefiles and when processed asm symlink, |
---|
1217 | 1345 | # version.h and scripts_basic is processed / created. |
---|
1218 | 1346 | |
---|
1219 | | -PHONY += prepare archprepare prepare1 prepare2 prepare3 |
---|
| 1347 | +PHONY += prepare archprepare |
---|
1220 | 1348 | |
---|
1221 | | -# prepare3 is used to check if we are building in a separate output directory, |
---|
1222 | | -# and if so do: |
---|
1223 | | -# 1) Check that make has not been executed in the kernel src $(srctree) |
---|
1224 | | -prepare3: include/config/kernel.release |
---|
1225 | | -ifneq ($(KBUILD_SRC),) |
---|
1226 | | - @$(kecho) ' Using $(srctree) as source for kernel' |
---|
1227 | | - $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ |
---|
1228 | | - echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ |
---|
1229 | | - echo >&2 " in the '$(srctree)' directory.";\ |
---|
1230 | | - /bin/false; \ |
---|
1231 | | - fi; |
---|
1232 | | -endif |
---|
| 1349 | +archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \ |
---|
| 1350 | + asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \ |
---|
| 1351 | + include/generated/autoconf.h |
---|
1233 | 1352 | |
---|
1234 | | -# prepare2 creates a makefile if using a separate output directory. |
---|
1235 | | -# From this point forward, .config has been reprocessed, so any rules |
---|
1236 | | -# that need to depend on updated CONFIG_* values can be checked here. |
---|
1237 | | -prepare2: prepare3 outputmakefile asm-generic |
---|
1238 | | - |
---|
1239 | | -prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h |
---|
1240 | | - $(cmd_crmodverdir) |
---|
1241 | | - |
---|
1242 | | -archprepare: archheaders archscripts prepare1 scripts_basic |
---|
1243 | | - |
---|
1244 | | -prepare0: archprepare gcc-plugins |
---|
| 1353 | +prepare0: archprepare |
---|
| 1354 | + $(Q)$(MAKE) $(build)=scripts/mod |
---|
1245 | 1355 | $(Q)$(MAKE) $(build)=. |
---|
1246 | 1356 | |
---|
1247 | 1357 | # All the preparing.. |
---|
1248 | | -prepare: prepare0 prepare-objtool |
---|
| 1358 | +prepare: prepare0 prepare-objtool prepare-resolve_btfids |
---|
1249 | 1359 | |
---|
1250 | 1360 | # Support for using generic headers in asm-generic |
---|
| 1361 | +asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj |
---|
| 1362 | + |
---|
1251 | 1363 | PHONY += asm-generic uapi-asm-generic |
---|
1252 | 1364 | asm-generic: uapi-asm-generic |
---|
1253 | | - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ |
---|
1254 | | - src=asm obj=arch/$(SRCARCH)/include/generated/asm |
---|
| 1365 | + $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \ |
---|
| 1366 | + generic=include/asm-generic |
---|
1255 | 1367 | uapi-asm-generic: |
---|
1256 | | - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ |
---|
1257 | | - src=uapi/asm obj=arch/$(SRCARCH)/include/generated/uapi/asm |
---|
| 1368 | + $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \ |
---|
| 1369 | + generic=include/uapi/asm-generic |
---|
1258 | 1370 | |
---|
1259 | | -PHONY += prepare-objtool |
---|
| 1371 | +PHONY += prepare-objtool prepare-resolve_btfids |
---|
1260 | 1372 | prepare-objtool: $(objtool_target) |
---|
1261 | 1373 | ifeq ($(SKIP_STACK_VALIDATION),1) |
---|
| 1374 | +ifdef CONFIG_FTRACE_MCOUNT_USE_OBJTOOL |
---|
| 1375 | + @echo "error: Cannot generate __mcount_loc for CONFIG_DYNAMIC_FTRACE=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 |
---|
| 1376 | + @false |
---|
| 1377 | +endif |
---|
1262 | 1378 | ifdef CONFIG_UNWINDER_ORC |
---|
1263 | 1379 | @echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 |
---|
1264 | 1380 | @false |
---|
.. | .. |
---|
1267 | 1383 | endif |
---|
1268 | 1384 | endif |
---|
1269 | 1385 | |
---|
| 1386 | +prepare-resolve_btfids: $(resolve_btfids_target) |
---|
| 1387 | +ifeq ($(ERROR_RESOLVE_BTFIDS),1) |
---|
| 1388 | + @echo "error: Cannot resolve BTF IDs for CONFIG_DEBUG_INFO_BTF, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 |
---|
| 1389 | + @false |
---|
| 1390 | +endif |
---|
1270 | 1391 | # Generate some files |
---|
1271 | 1392 | # --------------------------------------------------------------------------- |
---|
1272 | 1393 | |
---|
.. | .. |
---|
1284 | 1405 | echo '"$(UTS_RELEASE)" exceeds $(uts_len) characters' >&2; \ |
---|
1285 | 1406 | exit 1; \ |
---|
1286 | 1407 | fi; \ |
---|
1287 | | - (echo \#define UTS_RELEASE \"$(UTS_RELEASE)\";) |
---|
| 1408 | + echo \#define UTS_RELEASE \"$(UTS_RELEASE)\" |
---|
1288 | 1409 | endef |
---|
1289 | 1410 | |
---|
1290 | 1411 | define filechk_version.h |
---|
1291 | | - (echo \#define LINUX_VERSION_CODE $(shell \ |
---|
1292 | | - expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 255); \ |
---|
1293 | | - echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))';) |
---|
| 1412 | + if [ $(SUBLEVEL) -gt 255 ]; then \ |
---|
| 1413 | + echo \#define LINUX_VERSION_CODE $(shell \ |
---|
| 1414 | + expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + 255); \ |
---|
| 1415 | + else \ |
---|
| 1416 | + echo \#define LINUX_VERSION_CODE $(shell \ |
---|
| 1417 | + expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \ |
---|
| 1418 | + fi; \ |
---|
| 1419 | + echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + \ |
---|
| 1420 | + ((c) > 255 ? 255 : (c)))' |
---|
1294 | 1421 | endef |
---|
1295 | 1422 | |
---|
| 1423 | +$(version_h): PATCHLEVEL := $(if $(PATCHLEVEL), $(PATCHLEVEL), 0) |
---|
| 1424 | +$(version_h): SUBLEVEL := $(if $(SUBLEVEL), $(SUBLEVEL), 0) |
---|
1296 | 1425 | $(version_h): FORCE |
---|
1297 | 1426 | $(call filechk,version.h) |
---|
1298 | 1427 | $(Q)rm -f $(old_version_h) |
---|
.. | .. |
---|
1305 | 1434 | $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \ |
---|
1306 | 1435 | $(srctree)/scripts/headerdep.pl -I$(srctree)/include |
---|
1307 | 1436 | |
---|
1308 | | -# --------------------------------------------------------------------------- |
---|
1309 | | -# Kernel headers |
---|
1310 | | - |
---|
1311 | | -#Default location for installed headers |
---|
1312 | | -export INSTALL_HDR_PATH = $(objtree)/usr |
---|
1313 | | - |
---|
1314 | | -# If we do an all arch process set dst to include/arch-$(SRCARCH) |
---|
1315 | | -hdr-dst = $(if $(KBUILD_HEADERS), dst=include/arch-$(SRCARCH), dst=include) |
---|
1316 | | - |
---|
1317 | | -PHONY += archheaders |
---|
1318 | | -archheaders: |
---|
1319 | | - |
---|
1320 | | -PHONY += archscripts |
---|
1321 | | -archscripts: |
---|
1322 | | - |
---|
1323 | | -PHONY += __headers |
---|
1324 | | -__headers: $(version_h) scripts_basic uapi-asm-generic archheaders archscripts |
---|
1325 | | - $(Q)$(MAKE) $(build)=scripts build_unifdef |
---|
1326 | | - |
---|
1327 | | -PHONY += headers_install_all |
---|
1328 | | -headers_install_all: |
---|
1329 | | - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh install |
---|
1330 | | - |
---|
1331 | | -PHONY += headers_install |
---|
1332 | | -headers_install: __headers |
---|
1333 | | - $(if $(wildcard $(srctree)/arch/$(SRCARCH)/include/uapi/asm/Kbuild),, \ |
---|
1334 | | - $(error Headers not exportable for the $(SRCARCH) architecture)) |
---|
1335 | | - $(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include |
---|
1336 | | - $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi $(hdr-dst) |
---|
1337 | | - |
---|
1338 | | -PHONY += headers_check_all |
---|
1339 | | -headers_check_all: headers_install_all |
---|
1340 | | - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/headers.sh check |
---|
1341 | | - |
---|
| 1437 | +# Deprecated. It is no-op now. |
---|
1342 | 1438 | PHONY += headers_check |
---|
1343 | | -headers_check: headers_install |
---|
1344 | | - $(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1 |
---|
1345 | | - $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi $(hdr-dst) HDRCHECK=1 |
---|
| 1439 | +headers_check: |
---|
| 1440 | + @: |
---|
| 1441 | + |
---|
| 1442 | +ifdef CONFIG_HEADERS_INSTALL |
---|
| 1443 | +prepare: headers |
---|
| 1444 | +endif |
---|
| 1445 | + |
---|
| 1446 | +PHONY += scripts_unifdef |
---|
| 1447 | +scripts_unifdef: scripts_basic |
---|
| 1448 | + $(Q)$(MAKE) $(build)=scripts scripts/unifdef |
---|
1346 | 1449 | |
---|
1347 | 1450 | # --------------------------------------------------------------------------- |
---|
1348 | 1451 | # Kernel selftest |
---|
.. | .. |
---|
1351 | 1454 | kselftest: |
---|
1352 | 1455 | $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests |
---|
1353 | 1456 | |
---|
1354 | | -PHONY += kselftest-clean |
---|
1355 | | -kselftest-clean: |
---|
1356 | | - $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests clean |
---|
| 1457 | +kselftest-%: FORCE |
---|
| 1458 | + $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $* |
---|
1357 | 1459 | |
---|
1358 | 1460 | PHONY += kselftest-merge |
---|
1359 | 1461 | kselftest-merge: |
---|
1360 | 1462 | $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!)) |
---|
1361 | | - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \ |
---|
1362 | | - -m $(objtree)/.config \ |
---|
1363 | | - $(srctree)/tools/testing/selftests/*/config |
---|
1364 | | - +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig |
---|
| 1463 | + $(Q)find $(srctree)/tools/testing/selftests -name config | \ |
---|
| 1464 | + xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config |
---|
| 1465 | + $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig |
---|
| 1466 | + |
---|
| 1467 | +# --------------------------------------------------------------------------- |
---|
| 1468 | +# Devicetree files |
---|
| 1469 | + |
---|
| 1470 | +ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),) |
---|
| 1471 | +dtstree := arch/$(SRCARCH)/boot/dts |
---|
| 1472 | +endif |
---|
| 1473 | + |
---|
| 1474 | +ifneq ($(dtstree),) |
---|
| 1475 | + |
---|
| 1476 | +%.dtb: include/config/kernel.release scripts_dtc |
---|
| 1477 | + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ |
---|
| 1478 | + |
---|
| 1479 | +PHONY += dtbs dtbs_install dtbs_check |
---|
| 1480 | +dtbs: include/config/kernel.release scripts_dtc |
---|
| 1481 | + $(Q)$(MAKE) $(build)=$(dtstree) |
---|
| 1482 | + |
---|
| 1483 | +ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) |
---|
| 1484 | +export CHECK_DTBS=y |
---|
| 1485 | +dtbs: dt_binding_check |
---|
| 1486 | +endif |
---|
| 1487 | + |
---|
| 1488 | +dtbs_check: dtbs |
---|
| 1489 | + |
---|
| 1490 | +dtbs_install: |
---|
| 1491 | + $(Q)$(MAKE) $(dtbinst)=$(dtstree) dst=$(INSTALL_DTBS_PATH) |
---|
| 1492 | + |
---|
| 1493 | +ifdef CONFIG_OF_EARLY_FLATTREE |
---|
| 1494 | +all: dtbs |
---|
| 1495 | +endif |
---|
| 1496 | + |
---|
| 1497 | +endif |
---|
| 1498 | + |
---|
| 1499 | +PHONY += scripts_dtc |
---|
| 1500 | +scripts_dtc: scripts_basic |
---|
| 1501 | + $(Q)$(MAKE) $(build)=scripts/dtc |
---|
| 1502 | + |
---|
| 1503 | +ifneq ($(filter dt_binding_check, $(MAKECMDGOALS)),) |
---|
| 1504 | +export CHECK_DT_BINDING=y |
---|
| 1505 | +endif |
---|
| 1506 | + |
---|
| 1507 | +PHONY += dt_binding_check |
---|
| 1508 | +dt_binding_check: scripts_dtc |
---|
| 1509 | + $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings |
---|
1365 | 1510 | |
---|
1366 | 1511 | # --------------------------------------------------------------------------- |
---|
1367 | 1512 | # Modules |
---|
.. | .. |
---|
1386 | 1531 | # using awk while concatenating to the final file. |
---|
1387 | 1532 | |
---|
1388 | 1533 | PHONY += modules |
---|
1389 | | -modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin |
---|
1390 | | - $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order |
---|
1391 | | - @$(kecho) ' Building modules, stage 2.'; |
---|
1392 | | - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost |
---|
| 1534 | +# if KBUILD_BUILTIN && !KBUILD_MIXED_TREE, depend on vmlinux |
---|
| 1535 | +modules: $(if $(KBUILD_BUILTIN), $(if $(KBUILD_MIXED_TREE),,vmlinux)) modules_check modules_prepare |
---|
1393 | 1536 | |
---|
1394 | | -modules.builtin: $(vmlinux-dirs:%=%/modules.builtin) |
---|
1395 | | - $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin |
---|
| 1537 | +PHONY += modules_check |
---|
| 1538 | +modules_check: modules.order |
---|
| 1539 | + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/modules-check.sh $< |
---|
1396 | 1540 | |
---|
1397 | | -%/modules.builtin: include/config/auto.conf include/config/tristate.conf |
---|
1398 | | - $(Q)$(MAKE) $(modbuiltin)=$* |
---|
| 1541 | +cmd_modules_order = $(AWK) '!x[$$0]++' $(real-prereqs) > $@ |
---|
1399 | 1542 | |
---|
| 1543 | +modules.order: $(subdir-modorder) FORCE |
---|
| 1544 | + $(call if_changed,modules_order) |
---|
| 1545 | + |
---|
| 1546 | +targets += modules.order |
---|
1400 | 1547 | |
---|
1401 | 1548 | # Target to prepare building external modules |
---|
1402 | 1549 | PHONY += modules_prepare |
---|
1403 | | -modules_prepare: prepare scripts |
---|
| 1550 | +modules_prepare: prepare |
---|
| 1551 | + $(Q)$(MAKE) $(build)=scripts scripts/module.lds |
---|
1404 | 1552 | |
---|
1405 | | -# Target to install modules |
---|
1406 | | -PHONY += modules_install |
---|
1407 | | -modules_install: _modinst_ _modinst_post |
---|
1408 | | - |
---|
1409 | | -PHONY += _modinst_ |
---|
1410 | | -_modinst_: |
---|
| 1553 | +modules_install: __modinst_pre |
---|
| 1554 | +PHONY += __modinst_pre |
---|
| 1555 | +__modinst_pre: |
---|
1411 | 1556 | @rm -rf $(MODLIB)/kernel |
---|
1412 | 1557 | @rm -f $(MODLIB)/source |
---|
1413 | 1558 | @mkdir -p $(MODLIB)/kernel |
---|
.. | .. |
---|
1416 | 1561 | rm -f $(MODLIB)/build ; \ |
---|
1417 | 1562 | ln -s $(CURDIR) $(MODLIB)/build ; \ |
---|
1418 | 1563 | fi |
---|
1419 | | - @cp -f $(objtree)/modules.order $(MODLIB)/ |
---|
1420 | | - @cp -f $(objtree)/modules.builtin $(MODLIB)/ |
---|
1421 | | - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst |
---|
1422 | | - |
---|
1423 | | -# This depmod is only for convenience to give the initial |
---|
1424 | | -# boot a modules.dep even before / is mounted read-write. However the |
---|
1425 | | -# boot script depmod is the master version. |
---|
1426 | | -PHONY += _modinst_post |
---|
1427 | | -_modinst_post: _modinst_ |
---|
1428 | | - $(call cmd,depmod) |
---|
| 1564 | + @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order |
---|
| 1565 | + @cp -f $(mixed-build-prefix)modules.builtin $(MODLIB)/ |
---|
| 1566 | + @cp -f $(or $(mixed-build-prefix),$(objtree)/)modules.builtin.modinfo $(MODLIB)/ |
---|
1429 | 1567 | |
---|
1430 | 1568 | ifeq ($(CONFIG_MODULE_SIG), y) |
---|
1431 | 1569 | PHONY += modules_sign |
---|
1432 | 1570 | modules_sign: |
---|
1433 | 1571 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign |
---|
1434 | 1572 | endif |
---|
1435 | | - |
---|
1436 | | -else # CONFIG_MODULES |
---|
1437 | | - |
---|
1438 | | -# Modules not configured |
---|
1439 | | -# --------------------------------------------------------------------------- |
---|
1440 | | - |
---|
1441 | | -PHONY += modules modules_install |
---|
1442 | | -modules modules_install: |
---|
1443 | | - @echo >&2 |
---|
1444 | | - @echo >&2 "The present kernel configuration has modules disabled." |
---|
1445 | | - @echo >&2 "Type 'make config' and enable loadable module support." |
---|
1446 | | - @echo >&2 "Then build a kernel with module support enabled." |
---|
1447 | | - @echo >&2 |
---|
1448 | | - @exit 1 |
---|
1449 | 1573 | |
---|
1450 | 1574 | endif # CONFIG_MODULES |
---|
1451 | 1575 | |
---|
.. | .. |
---|
1457 | 1581 | # make distclean Remove editor backup files, patch leftover files and the like |
---|
1458 | 1582 | |
---|
1459 | 1583 | # Directories & files removed with 'make clean' |
---|
1460 | | -CLEAN_DIRS += $(MODVERDIR) include/ksym |
---|
| 1584 | +CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \ |
---|
| 1585 | + modules.builtin modules.builtin.modinfo modules.nsdeps \ |
---|
| 1586 | + compile_commands.json .thinlto-cache |
---|
1461 | 1587 | |
---|
1462 | 1588 | # Directories & files removed with 'make mrproper' |
---|
1463 | | -MRPROPER_DIRS += include/config usr/include include/generated \ |
---|
1464 | | - arch/*/include/generated .tmp_objdiff |
---|
1465 | | -MRPROPER_FILES += .config .config.old .version \ |
---|
1466 | | - Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ |
---|
| 1589 | +MRPROPER_FILES += include/config include/generated \ |
---|
| 1590 | + arch/$(SRCARCH)/include/generated .tmp_objdiff \ |
---|
| 1591 | + debian snap tar-install \ |
---|
| 1592 | + .config .config.old .version \ |
---|
| 1593 | + Module.symvers \ |
---|
1467 | 1594 | signing_key.pem signing_key.priv signing_key.x509 \ |
---|
1468 | 1595 | x509.genkey extra_certificates signing_key.x509.keyid \ |
---|
1469 | | - signing_key.x509.signer vmlinux-gdb.py |
---|
| 1596 | + signing_key.x509.signer vmlinux-gdb.py \ |
---|
| 1597 | + *.spec |
---|
| 1598 | + |
---|
| 1599 | +# Directories & files removed with 'make distclean' |
---|
| 1600 | +DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS |
---|
1470 | 1601 | |
---|
1471 | 1602 | # clean - Delete most, but leave enough to build external modules |
---|
1472 | 1603 | # |
---|
1473 | | -clean: rm-dirs := $(CLEAN_DIRS) |
---|
1474 | 1604 | clean: rm-files := $(CLEAN_FILES) |
---|
1475 | | -clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation samples) |
---|
1476 | 1605 | |
---|
1477 | | -PHONY += $(clean-dirs) clean archclean vmlinuxclean |
---|
1478 | | -$(clean-dirs): |
---|
1479 | | - $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) |
---|
| 1606 | +PHONY += archclean vmlinuxclean |
---|
1480 | 1607 | |
---|
1481 | 1608 | vmlinuxclean: |
---|
1482 | 1609 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean |
---|
1483 | 1610 | $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) |
---|
1484 | 1611 | |
---|
1485 | | -clean: archclean vmlinuxclean |
---|
| 1612 | +clean: archclean vmlinuxclean resolve_btfids_clean |
---|
1486 | 1613 | |
---|
1487 | 1614 | # mrproper - Delete all generated files, including .config |
---|
1488 | 1615 | # |
---|
1489 | | -mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) |
---|
1490 | 1616 | mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) |
---|
1491 | 1617 | mrproper-dirs := $(addprefix _mrproper_,scripts) |
---|
1492 | 1618 | |
---|
1493 | | -PHONY += $(mrproper-dirs) mrproper archmrproper |
---|
| 1619 | +PHONY += $(mrproper-dirs) mrproper |
---|
1494 | 1620 | $(mrproper-dirs): |
---|
1495 | 1621 | $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) |
---|
1496 | 1622 | |
---|
1497 | | -mrproper: clean archmrproper $(mrproper-dirs) |
---|
1498 | | - $(call cmd,rmdirs) |
---|
| 1623 | +mrproper: clean $(mrproper-dirs) |
---|
1499 | 1624 | $(call cmd,rmfiles) |
---|
1500 | 1625 | |
---|
1501 | 1626 | # distclean |
---|
1502 | 1627 | # |
---|
| 1628 | +distclean: rm-files := $(wildcard $(DISTCLEAN_FILES)) |
---|
| 1629 | + |
---|
1503 | 1630 | PHONY += distclean |
---|
1504 | 1631 | |
---|
1505 | 1632 | distclean: mrproper |
---|
| 1633 | + $(call cmd,rmfiles) |
---|
1506 | 1634 | @find $(srctree) $(RCS_FIND_IGNORE) \ |
---|
1507 | 1635 | \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ |
---|
1508 | 1636 | -o -name '*.bak' -o -name '#*#' -o -name '*%' \ |
---|
.. | .. |
---|
1512 | 1640 | |
---|
1513 | 1641 | # Packaging of the kernel to various formats |
---|
1514 | 1642 | # --------------------------------------------------------------------------- |
---|
1515 | | -package-dir := scripts/package |
---|
1516 | 1643 | |
---|
1517 | 1644 | %src-pkg: FORCE |
---|
1518 | | - $(Q)$(MAKE) $(build)=$(package-dir) $@ |
---|
| 1645 | + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@ |
---|
1519 | 1646 | %pkg: include/config/kernel.release FORCE |
---|
1520 | | - $(Q)$(MAKE) $(build)=$(package-dir) $@ |
---|
1521 | | - |
---|
| 1647 | + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.package $@ |
---|
1522 | 1648 | |
---|
1523 | 1649 | # Brief documentation of the typical targets used |
---|
1524 | 1650 | # --------------------------------------------------------------------------- |
---|
.. | .. |
---|
1563 | 1689 | echo '' |
---|
1564 | 1690 | @echo 'Static analysers:' |
---|
1565 | 1691 | @echo ' checkstack - Generate a list of stack hogs' |
---|
1566 | | - @echo ' namespacecheck - Name space analysis on compiled kernel' |
---|
1567 | 1692 | @echo ' versioncheck - Sanity check on version.h usage' |
---|
1568 | 1693 | @echo ' includecheck - Check for duplicate included header files' |
---|
1569 | 1694 | @echo ' export_report - List the usages of all exported symbols' |
---|
1570 | | - @echo ' headers_check - Sanity check on exported headers' |
---|
1571 | 1695 | @echo ' headerdep - Detect inclusion cycles in headers' |
---|
1572 | 1696 | @echo ' coccicheck - Check with Coccinelle' |
---|
| 1697 | + @echo ' clang-analyzer - Check with clang static analyzer' |
---|
| 1698 | + @echo ' clang-tidy - Check with clang-tidy' |
---|
| 1699 | + @echo '' |
---|
| 1700 | + @echo 'Tools:' |
---|
| 1701 | + @echo ' nsdeps - Generate missing symbol namespace dependencies' |
---|
1573 | 1702 | @echo '' |
---|
1574 | 1703 | @echo 'Kernel selftest:' |
---|
1575 | | - @echo ' kselftest - Build and run kernel selftest (run as root)' |
---|
1576 | | - @echo ' Build, install, and boot kernel before' |
---|
1577 | | - @echo ' running kselftest on it' |
---|
1578 | | - @echo ' kselftest-clean - Remove all generated kselftest files' |
---|
1579 | | - @echo ' kselftest-merge - Merge all the config dependencies of kselftest to existing' |
---|
1580 | | - @echo ' .config.' |
---|
| 1704 | + @echo ' kselftest - Build and run kernel selftest' |
---|
| 1705 | + @echo ' Build, install, and boot kernel before' |
---|
| 1706 | + @echo ' running kselftest on it' |
---|
| 1707 | + @echo ' Run as root for full coverage' |
---|
| 1708 | + @echo ' kselftest-all - Build kernel selftest' |
---|
| 1709 | + @echo ' kselftest-install - Build and install kernel selftest' |
---|
| 1710 | + @echo ' kselftest-clean - Remove all generated kselftest files' |
---|
| 1711 | + @echo ' kselftest-merge - Merge all the config dependencies of' |
---|
| 1712 | + @echo ' kselftest to existing .config.' |
---|
1581 | 1713 | @echo '' |
---|
| 1714 | + @$(if $(dtstree), \ |
---|
| 1715 | + echo 'Devicetree:'; \ |
---|
| 1716 | + echo '* dtbs - Build device tree blobs for enabled boards'; \ |
---|
| 1717 | + echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \ |
---|
| 1718 | + echo ' dt_binding_check - Validate device tree binding documents'; \ |
---|
| 1719 | + echo ' dtbs_check - Validate device tree source files';\ |
---|
| 1720 | + echo '') |
---|
| 1721 | + |
---|
1582 | 1722 | @echo 'Userspace tools targets:' |
---|
1583 | 1723 | @echo ' use "make tools/help"' |
---|
1584 | 1724 | @echo ' or "cd tools; make help"' |
---|
1585 | 1725 | @echo '' |
---|
1586 | 1726 | @echo 'Kernel packaging:' |
---|
1587 | | - @$(MAKE) $(build)=$(package-dir) help |
---|
| 1727 | + @$(MAKE) -f $(srctree)/scripts/Makefile.package help |
---|
1588 | 1728 | @echo '' |
---|
1589 | 1729 | @echo 'Documentation targets:' |
---|
1590 | 1730 | @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp |
---|
.. | .. |
---|
1595 | 1735 | @echo '' |
---|
1596 | 1736 | @$(if $(boards), \ |
---|
1597 | 1737 | $(foreach b, $(boards), \ |
---|
1598 | | - printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \ |
---|
| 1738 | + printf " %-27s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \ |
---|
1599 | 1739 | echo '') |
---|
1600 | 1740 | @$(if $(board-dirs), \ |
---|
1601 | 1741 | $(foreach b, $(board-dirs), \ |
---|
.. | .. |
---|
1606 | 1746 | @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' |
---|
1607 | 1747 | @echo ' make V=2 [targets] 2 => give reason for rebuild of target' |
---|
1608 | 1748 | @echo ' make O=dir [targets] Locate all output files in "dir", including .config' |
---|
1609 | | - @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK (sparse by default)' |
---|
| 1749 | + @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK' |
---|
| 1750 | + @echo ' (sparse by default)' |
---|
1610 | 1751 | @echo ' make C=2 [targets] Force check of all c source with $$CHECK' |
---|
1611 | 1752 | @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' |
---|
1612 | | - @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' |
---|
| 1753 | + @echo ' make W=n [targets] Enable extra build checks, n=1,2,3 where' |
---|
1613 | 1754 | @echo ' 1: warnings which may be relevant and do not occur too often' |
---|
1614 | 1755 | @echo ' 2: warnings which occur quite often but may still be relevant' |
---|
1615 | 1756 | @echo ' 3: more obscure warnings, can most likely be ignored' |
---|
.. | .. |
---|
1638 | 1779 | DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \ |
---|
1639 | 1780 | linkcheckdocs dochelp refcheckdocs |
---|
1640 | 1781 | PHONY += $(DOC_TARGETS) |
---|
1641 | | -$(DOC_TARGETS): scripts_basic FORCE |
---|
| 1782 | +$(DOC_TARGETS): |
---|
1642 | 1783 | $(Q)$(MAKE) $(build)=Documentation $@ |
---|
| 1784 | + |
---|
| 1785 | +# Misc |
---|
| 1786 | +# --------------------------------------------------------------------------- |
---|
| 1787 | + |
---|
| 1788 | +PHONY += scripts_gdb |
---|
| 1789 | +scripts_gdb: prepare0 |
---|
| 1790 | + $(Q)$(MAKE) $(build)=scripts/gdb |
---|
| 1791 | + $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) |
---|
| 1792 | + |
---|
| 1793 | +ifdef CONFIG_GDB_SCRIPTS |
---|
| 1794 | +all: scripts_gdb |
---|
| 1795 | +endif |
---|
1643 | 1796 | |
---|
1644 | 1797 | else # KBUILD_EXTMOD |
---|
1645 | 1798 | |
---|
.. | .. |
---|
1660 | 1813 | # Install the modules built in the module directory |
---|
1661 | 1814 | # Assumes install directory is already created |
---|
1662 | 1815 | |
---|
1663 | | -# We are always building modules |
---|
| 1816 | +# We are always building only modules. |
---|
| 1817 | +KBUILD_BUILTIN := |
---|
1664 | 1818 | KBUILD_MODULES := 1 |
---|
1665 | 1819 | |
---|
1666 | | -PHONY += $(objtree)/Module.symvers |
---|
1667 | | -$(objtree)/Module.symvers: |
---|
1668 | | - @test -e $(objtree)/Module.symvers || ( \ |
---|
1669 | | - echo; \ |
---|
1670 | | - echo " WARNING: Symbol version dump $(objtree)/Module.symvers"; \ |
---|
1671 | | - echo " is missing; modules will have no dependencies and modversions."; \ |
---|
1672 | | - echo ) |
---|
| 1820 | +build-dirs := $(KBUILD_EXTMOD) |
---|
| 1821 | +$(MODORDER): descend |
---|
| 1822 | + @: |
---|
1673 | 1823 | |
---|
1674 | | -module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) |
---|
1675 | | -PHONY += $(module-dirs) modules |
---|
1676 | | -$(module-dirs): prepare $(objtree)/Module.symvers |
---|
1677 | | - $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) |
---|
| 1824 | +compile_commands.json: $(extmod-prefix)compile_commands.json |
---|
| 1825 | +PHONY += compile_commands.json |
---|
1678 | 1826 | |
---|
1679 | | -modules: $(module-dirs) |
---|
1680 | | - @$(kecho) ' Building modules, stage 2.'; |
---|
1681 | | - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost |
---|
1682 | | - |
---|
1683 | | -PHONY += modules_install |
---|
1684 | | -modules_install: _emodinst_ _emodinst_post |
---|
1685 | | - |
---|
1686 | | -install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra) |
---|
1687 | | -PHONY += _emodinst_ |
---|
1688 | | -_emodinst_: |
---|
1689 | | - $(Q)mkdir -p $(MODLIB)/$(install-dir) |
---|
1690 | | - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst |
---|
1691 | | - |
---|
1692 | | -PHONY += _emodinst_post |
---|
1693 | | -_emodinst_post: _emodinst_ |
---|
1694 | | - $(call cmd,depmod) |
---|
1695 | | - |
---|
1696 | | -clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) |
---|
1697 | | - |
---|
1698 | | -PHONY += $(clean-dirs) clean |
---|
1699 | | -$(clean-dirs): |
---|
1700 | | - $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) |
---|
1701 | | - |
---|
1702 | | -clean: rm-dirs := $(MODVERDIR) |
---|
1703 | | -clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers |
---|
| 1827 | +clean-dirs := $(KBUILD_EXTMOD) |
---|
| 1828 | +clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers $(KBUILD_EXTMOD)/modules.nsdeps \ |
---|
| 1829 | + $(KBUILD_EXTMOD)/compile_commands.json $(KBUILD_EXTMOD)/.thinlto-cache |
---|
1704 | 1830 | |
---|
1705 | 1831 | PHONY += help |
---|
1706 | 1832 | help: |
---|
.. | .. |
---|
1709 | 1835 | @echo '' |
---|
1710 | 1836 | @echo ' modules - default target, build the module(s)' |
---|
1711 | 1837 | @echo ' modules_install - install the module' |
---|
| 1838 | + @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH' |
---|
| 1839 | + @echo ' (default: $(abspath $(INSTALL_HDR_PATH)))' |
---|
1712 | 1840 | @echo ' clean - remove generated files in module directory only' |
---|
1713 | 1841 | @echo '' |
---|
1714 | 1842 | |
---|
1715 | | -# Dummies... |
---|
1716 | | -PHONY += prepare scripts |
---|
1717 | | -prepare: |
---|
1718 | | - $(cmd_crmodverdir) |
---|
1719 | | -scripts: ; |
---|
| 1843 | +# no-op for external module builds |
---|
| 1844 | +PHONY += prepare modules_prepare |
---|
| 1845 | + |
---|
1720 | 1846 | endif # KBUILD_EXTMOD |
---|
1721 | 1847 | |
---|
| 1848 | +# --------------------------------------------------------------------------- |
---|
| 1849 | +# Modules |
---|
| 1850 | + |
---|
| 1851 | +PHONY += modules modules_install |
---|
| 1852 | + |
---|
| 1853 | +ifdef CONFIG_MODULES |
---|
| 1854 | + |
---|
| 1855 | +modules: $(MODORDER) |
---|
| 1856 | + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost |
---|
| 1857 | + |
---|
| 1858 | +quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) |
---|
| 1859 | + cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ |
---|
| 1860 | + $(KERNELRELEASE) $(mixed-build-prefix) |
---|
| 1861 | + |
---|
| 1862 | +modules_install: |
---|
| 1863 | + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst |
---|
| 1864 | + $(call cmd,depmod) |
---|
| 1865 | + |
---|
| 1866 | +else # CONFIG_MODULES |
---|
| 1867 | + |
---|
| 1868 | +# Modules not configured |
---|
| 1869 | +# --------------------------------------------------------------------------- |
---|
| 1870 | + |
---|
| 1871 | +modules modules_install: |
---|
| 1872 | + @echo >&2 '***' |
---|
| 1873 | + @echo >&2 '*** The present kernel configuration has modules disabled.' |
---|
| 1874 | + @echo >&2 '*** To use the module feature, please run "make menuconfig" etc.' |
---|
| 1875 | + @echo >&2 '*** to enable CONFIG_MODULES.' |
---|
| 1876 | + @echo >&2 '***' |
---|
| 1877 | + @exit 1 |
---|
| 1878 | + |
---|
| 1879 | +KBUILD_MODULES := |
---|
| 1880 | + |
---|
| 1881 | +endif # CONFIG_MODULES |
---|
| 1882 | + |
---|
| 1883 | +# Single targets |
---|
| 1884 | +# --------------------------------------------------------------------------- |
---|
| 1885 | +# To build individual files in subdirectories, you can do like this: |
---|
| 1886 | +# |
---|
| 1887 | +# make foo/bar/baz.s |
---|
| 1888 | +# |
---|
| 1889 | +# The supported suffixes for single-target are listed in 'single-targets' |
---|
| 1890 | +# |
---|
| 1891 | +# To build only under specific subdirectories, you can do like this: |
---|
| 1892 | +# |
---|
| 1893 | +# make foo/bar/baz/ |
---|
| 1894 | + |
---|
| 1895 | +ifdef single-build |
---|
| 1896 | + |
---|
| 1897 | +# .ko is special because modpost is needed |
---|
| 1898 | +single-ko := $(sort $(filter %.ko, $(MAKECMDGOALS))) |
---|
| 1899 | +single-no-ko := $(sort $(patsubst %.ko,%.mod, $(MAKECMDGOALS))) |
---|
| 1900 | + |
---|
| 1901 | +$(single-ko): single_modpost |
---|
| 1902 | + @: |
---|
| 1903 | +$(single-no-ko): descend |
---|
| 1904 | + @: |
---|
| 1905 | + |
---|
| 1906 | +# Remove MODORDER when done because it is not the real one. |
---|
| 1907 | +PHONY += single_modpost |
---|
| 1908 | +single_modpost: $(single-no-ko) modules_prepare |
---|
| 1909 | + $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER) |
---|
| 1910 | + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost |
---|
| 1911 | + $(Q)rm -f $(MODORDER) |
---|
| 1912 | + |
---|
| 1913 | +export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko)) |
---|
| 1914 | + |
---|
| 1915 | +# trim unrelated directories |
---|
| 1916 | +build-dirs := $(foreach d, $(build-dirs), \ |
---|
| 1917 | + $(if $(filter $(d)/%, $(KBUILD_SINGLE_TARGETS)), $(d))) |
---|
| 1918 | + |
---|
| 1919 | +endif |
---|
| 1920 | + |
---|
| 1921 | +# Handle descending into subdirectories listed in $(build-dirs) |
---|
| 1922 | +# Preset locale variables to speed up the build process. Limit locale |
---|
| 1923 | +# tweaks to this spot to avoid wrong language settings when running |
---|
| 1924 | +# make menuconfig etc. |
---|
| 1925 | +# Error messages still appears in the original language |
---|
| 1926 | +PHONY += descend $(build-dirs) |
---|
| 1927 | +descend: $(build-dirs) |
---|
| 1928 | +$(build-dirs): prepare |
---|
| 1929 | + $(Q)$(MAKE) $(build)=$@ \ |
---|
| 1930 | + single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \ |
---|
| 1931 | + $(if $(KBUILD_MIXED_TREE),,need-builtin=1) need-modorder=1 |
---|
| 1932 | + |
---|
| 1933 | +clean-dirs := $(addprefix _clean_, $(clean-dirs)) |
---|
| 1934 | +PHONY += $(clean-dirs) clean |
---|
| 1935 | +$(clean-dirs): |
---|
| 1936 | + $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) |
---|
| 1937 | + |
---|
1722 | 1938 | clean: $(clean-dirs) |
---|
1723 | | - $(call cmd,rmdirs) |
---|
1724 | 1939 | $(call cmd,rmfiles) |
---|
1725 | 1940 | @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ |
---|
1726 | 1941 | \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \ |
---|
1727 | | - -o -name '*.ko.*' -o -name '*.dtb' -o -name '*.dtb.S' \ |
---|
| 1942 | + -o -name '*.ko.*' \ |
---|
| 1943 | + -o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \ |
---|
1728 | 1944 | -o -name '*.dwo' -o -name '*.lst' \ |
---|
1729 | | - -o -name '*.su' \ |
---|
| 1945 | + -o -name '*.su' -o -name '*.mod' \ |
---|
1730 | 1946 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ |
---|
1731 | 1947 | -o -name '*.lex.c' -o -name '*.tab.[ch]' \ |
---|
1732 | 1948 | -o -name '*.asn1.[ch]' \ |
---|
1733 | 1949 | -o -name '*.symtypes' -o -name 'modules.order' \ |
---|
1734 | | - -o -name modules.builtin -o -name '.tmp_*.o.*' \ |
---|
| 1950 | + -o -name '.tmp_*.o.*' \ |
---|
1735 | 1951 | -o -name '*.c.[012]*.*' \ |
---|
1736 | 1952 | -o -name '*.ll' \ |
---|
1737 | 1953 | -o -name '*.gcno' \ |
---|
.. | .. |
---|
1740 | 1956 | # Generate tags for editors |
---|
1741 | 1957 | # --------------------------------------------------------------------------- |
---|
1742 | 1958 | quiet_cmd_tags = GEN $@ |
---|
1743 | | - cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@ |
---|
| 1959 | + cmd_tags = $(BASH) $(srctree)/scripts/tags.sh $@ |
---|
1744 | 1960 | |
---|
1745 | 1961 | tags TAGS cscope gtags: FORCE |
---|
1746 | 1962 | $(call cmd,tags) |
---|
1747 | 1963 | |
---|
| 1964 | +# Script to generate missing namespace dependencies |
---|
| 1965 | +# --------------------------------------------------------------------------- |
---|
| 1966 | + |
---|
| 1967 | +PHONY += nsdeps |
---|
| 1968 | +nsdeps: export KBUILD_NSDEPS=1 |
---|
| 1969 | +nsdeps: modules |
---|
| 1970 | + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/nsdeps |
---|
| 1971 | + |
---|
| 1972 | +# Clang Tooling |
---|
| 1973 | +# --------------------------------------------------------------------------- |
---|
| 1974 | + |
---|
| 1975 | +quiet_cmd_gen_compile_commands = GEN $@ |
---|
| 1976 | + cmd_gen_compile_commands = $(PYTHON3) $< -a $(AR) -o $@ $(filter-out $<, $(real-prereqs)) |
---|
| 1977 | + |
---|
| 1978 | +$(extmod-prefix)compile_commands.json: scripts/clang-tools/gen_compile_commands.py \ |
---|
| 1979 | + $(if $(KBUILD_EXTMOD),,$(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)) \ |
---|
| 1980 | + $(if $(CONFIG_MODULES), $(MODORDER)) FORCE |
---|
| 1981 | + $(call if_changed,gen_compile_commands) |
---|
| 1982 | + |
---|
| 1983 | +targets += $(extmod-prefix)compile_commands.json |
---|
| 1984 | + |
---|
| 1985 | +PHONY += clang-tidy clang-analyzer |
---|
| 1986 | + |
---|
| 1987 | +ifdef CONFIG_CC_IS_CLANG |
---|
| 1988 | +quiet_cmd_clang_tools = CHECK $< |
---|
| 1989 | + cmd_clang_tools = $(PYTHON3) $(srctree)/scripts/clang-tools/run-clang-tools.py $@ $< |
---|
| 1990 | + |
---|
| 1991 | +clang-tidy clang-analyzer: $(extmod-prefix)compile_commands.json |
---|
| 1992 | + $(call cmd,clang_tools) |
---|
| 1993 | +else |
---|
| 1994 | +clang-tidy clang-analyzer: |
---|
| 1995 | + @echo "$@ requires CC=clang" >&2 |
---|
| 1996 | + @false |
---|
| 1997 | +endif |
---|
| 1998 | + |
---|
1748 | 1999 | # Scripts to check various things for consistency |
---|
1749 | 2000 | # --------------------------------------------------------------------------- |
---|
1750 | 2001 | |
---|
1751 | | -PHONY += includecheck versioncheck coccicheck namespacecheck export_report |
---|
| 2002 | +PHONY += includecheck versioncheck coccicheck export_report |
---|
1752 | 2003 | |
---|
1753 | 2004 | includecheck: |
---|
1754 | 2005 | find $(srctree)/* $(RCS_FIND_IGNORE) \ |
---|
.. | .. |
---|
1761 | 2012 | | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl |
---|
1762 | 2013 | |
---|
1763 | 2014 | coccicheck: |
---|
1764 | | - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@ |
---|
1765 | | - |
---|
1766 | | -namespacecheck: |
---|
1767 | | - $(PERL) $(srctree)/scripts/namespace.pl |
---|
| 2015 | + $(Q)$(BASH) $(srctree)/scripts/$@ |
---|
1768 | 2016 | |
---|
1769 | 2017 | export_report: |
---|
1770 | 2018 | $(PERL) $(srctree)/scripts/export_report.pl |
---|
1771 | | - |
---|
1772 | | -endif #ifeq ($(config-targets),1) |
---|
1773 | | -endif #ifeq ($(mixed-targets),1) |
---|
1774 | 2019 | |
---|
1775 | 2020 | PHONY += checkstack kernelrelease kernelversion image_name |
---|
1776 | 2021 | |
---|
.. | .. |
---|
1785 | 2030 | endif |
---|
1786 | 2031 | checkstack: |
---|
1787 | 2032 | $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ |
---|
1788 | | - $(PERL) $(src)/scripts/checkstack.pl $(CHECKSTACK_ARCH) |
---|
| 2033 | + $(PERL) $(srctree)/scripts/checkstack.pl $(CHECKSTACK_ARCH) |
---|
1789 | 2034 | |
---|
1790 | 2035 | kernelrelease: |
---|
1791 | 2036 | @echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion \ |
---|
.. | .. |
---|
1798 | 2043 | @echo $(KBUILD_IMAGE) |
---|
1799 | 2044 | |
---|
1800 | 2045 | # Clear a bunch of variables before executing the submake |
---|
| 2046 | + |
---|
| 2047 | +ifeq ($(quiet),silent_) |
---|
| 2048 | +tools_silent=s |
---|
| 2049 | +endif |
---|
| 2050 | + |
---|
1801 | 2051 | tools/: FORCE |
---|
1802 | 2052 | $(Q)mkdir -p $(objtree)/tools |
---|
1803 | | - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ |
---|
| 2053 | + $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ |
---|
1804 | 2054 | |
---|
1805 | 2055 | tools/%: FORCE |
---|
1806 | 2056 | $(Q)mkdir -p $(objtree)/tools |
---|
1807 | | - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ $* |
---|
1808 | | - |
---|
1809 | | -# Single targets |
---|
1810 | | -# --------------------------------------------------------------------------- |
---|
1811 | | -# Single targets are compatible with: |
---|
1812 | | -# - build with mixed source and output |
---|
1813 | | -# - build with separate output dir 'make O=...' |
---|
1814 | | -# - external modules |
---|
1815 | | -# |
---|
1816 | | -# target-dir => where to store outputfile |
---|
1817 | | -# build-dir => directory in kernel source tree to use |
---|
1818 | | - |
---|
1819 | | -ifeq ($(KBUILD_EXTMOD),) |
---|
1820 | | - build-dir = $(patsubst %/,%,$(dir $@)) |
---|
1821 | | - target-dir = $(dir $@) |
---|
1822 | | -else |
---|
1823 | | - zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) |
---|
1824 | | - build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) |
---|
1825 | | - target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) |
---|
1826 | | -endif |
---|
1827 | | - |
---|
1828 | | -%.s: %.c prepare scripts FORCE |
---|
1829 | | - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
---|
1830 | | -%.i: %.c prepare scripts FORCE |
---|
1831 | | - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
---|
1832 | | -%.o: %.c prepare scripts FORCE |
---|
1833 | | - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
---|
1834 | | -%.lst: %.c prepare scripts FORCE |
---|
1835 | | - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
---|
1836 | | -%.s: %.S prepare scripts FORCE |
---|
1837 | | - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
---|
1838 | | -%.o: %.S prepare scripts FORCE |
---|
1839 | | - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
---|
1840 | | -%.symtypes: %.c prepare scripts FORCE |
---|
1841 | | - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
---|
1842 | | -%.ll: %.c prepare scripts FORCE |
---|
1843 | | - $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) |
---|
1844 | | - |
---|
1845 | | -# Modules |
---|
1846 | | -/: prepare scripts FORCE |
---|
1847 | | - $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ |
---|
1848 | | - $(build)=$(build-dir) |
---|
1849 | | -# Make sure the latest headers are built for Documentation |
---|
1850 | | -Documentation/ samples/: headers_install |
---|
1851 | | -%/: prepare scripts FORCE |
---|
1852 | | - $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ |
---|
1853 | | - $(build)=$(build-dir) |
---|
1854 | | -%.ko: prepare scripts FORCE |
---|
1855 | | - $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ |
---|
1856 | | - $(build)=$(build-dir) $(@:.ko=.o) |
---|
1857 | | - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost |
---|
1858 | | - |
---|
1859 | | -# FIXME Should go into a make.lib or something |
---|
1860 | | -# =========================================================================== |
---|
1861 | | - |
---|
1862 | | -quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) |
---|
1863 | | - cmd_rmdirs = rm -rf $(rm-dirs) |
---|
| 2057 | + $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(srctree)/tools/ $* |
---|
1864 | 2058 | |
---|
1865 | 2059 | quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) |
---|
1866 | | - cmd_rmfiles = rm -f $(rm-files) |
---|
| 2060 | + cmd_rmfiles = rm -rf $(rm-files) |
---|
1867 | 2061 | |
---|
1868 | | -# Run depmod only if we have System.map and depmod is executable |
---|
1869 | | -quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) |
---|
1870 | | - cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ |
---|
1871 | | - $(KERNELRELEASE) |
---|
| 2062 | +# read saved command lines for existing targets |
---|
| 2063 | +existing-targets := $(wildcard $(sort $(targets))) |
---|
1872 | 2064 | |
---|
1873 | | -# Create temporary dir for module support files |
---|
1874 | | -# clean it up only when building all modules |
---|
1875 | | -cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ |
---|
1876 | | - $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) |
---|
| 2065 | +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) |
---|
1877 | 2066 | |
---|
1878 | | -# read all saved command lines |
---|
1879 | | - |
---|
1880 | | -cmd_files := $(wildcard .*.cmd $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) |
---|
1881 | | - |
---|
1882 | | -ifneq ($(cmd_files),) |
---|
1883 | | - $(cmd_files): ; # Do not try to update included dependency files |
---|
1884 | | - include $(cmd_files) |
---|
1885 | | -endif |
---|
1886 | | - |
---|
1887 | | -endif # skip-makefile |
---|
| 2067 | +endif # config-build |
---|
| 2068 | +endif # mixed-build |
---|
| 2069 | +endif # need-sub-make |
---|
1888 | 2070 | |
---|
1889 | 2071 | PHONY += FORCE |
---|
1890 | 2072 | FORCE: |
---|