aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/Makefile2
-rw-r--r--Documentation/kbuild/kbuild.txt15
-rw-r--r--Documentation/kbuild/makefiles.txt26
-rw-r--r--Documentation/kbuild/modules.txt2
-rw-r--r--Kbuild29
-rw-r--r--Makefile219
-rw-r--r--arch/mips/boot/Makefile2
-rw-r--r--arch/powerpc/boot/Makefile2
-rw-r--r--arch/s390/boot/Makefile6
-rw-r--r--arch/s390/boot/compressed/Makefile4
-rw-r--r--arch/s390/scripts/Makefile.chkbss25
-rw-r--r--arch/x86/realmode/rm/Makefile3
-rw-r--r--init/Kconfig19
-rw-r--r--kernel/trace/Kconfig1
-rw-r--r--lib/Kconfig.debug2
-rw-r--r--scripts/Kbuild.include21
-rw-r--r--scripts/Kconfig.include2
-rw-r--r--scripts/Makefile3
-rw-r--r--scripts/Makefile.build29
-rw-r--r--scripts/Makefile.host6
-rw-r--r--scripts/Makefile.lib42
-rw-r--r--scripts/Makefile.modpost2
-rwxr-xr-xscripts/clang-version.sh10
-rwxr-xr-xscripts/gcc-version.sh27
-rw-r--r--scripts/gdb/linux/Makefile25
-rw-r--r--scripts/kallsyms.c13
-rw-r--r--scripts/kconfig/conf.c13
-rwxr-xr-xscripts/link-vmlinux.sh46
-rwxr-xr-xscripts/mkcompile_h4
-rw-r--r--scripts/package/Makefile8
-rwxr-xr-xscripts/package/builddeb10
-rwxr-xr-xscripts/package/buildtar2
-rwxr-xr-xscripts/package/mkdebian6
33 files changed, 263 insertions, 363 deletions
diff --git a/Documentation/devicetree/bindings/Makefile b/Documentation/devicetree/bindings/Makefile
index 50daa0b3b032..63b139f9ae28 100644
--- a/Documentation/devicetree/bindings/Makefile
+++ b/Documentation/devicetree/bindings/Makefile
@@ -15,7 +15,7 @@ DT_TMP_SCHEMA := processed-schema.yaml
15extra-y += $(DT_TMP_SCHEMA) 15extra-y += $(DT_TMP_SCHEMA)
16 16
17quiet_cmd_mk_schema = SCHEMA $@ 17quiet_cmd_mk_schema = SCHEMA $@
18 cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(filter-out FORCE, $^) 18 cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(real-prereqs)
19 19
20DT_DOCS = $(shell \ 20DT_DOCS = $(shell \
21 cd $(srctree)/$(src) && \ 21 cd $(srctree)/$(src) && \
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index c9e3d93e7a89..8a3830b39c7d 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -232,17 +232,12 @@ KBUILD_LDS
232-------------------------------------------------- 232--------------------------------------------------
233The linker script with full path. Assigned by the top-level Makefile. 233The linker script with full path. Assigned by the top-level Makefile.
234 234
235KBUILD_VMLINUX_INIT 235KBUILD_VMLINUX_OBJS
236-------------------------------------------------- 236--------------------------------------------------
237All object files for the init (first) part of vmlinux. 237All object files for vmlinux. They are linked to vmlinux in the same
238Files specified with KBUILD_VMLINUX_INIT are linked first. 238order as listed in KBUILD_VMLINUX_OBJS.
239
240KBUILD_VMLINUX_MAIN
241--------------------------------------------------
242All object files for the main part of vmlinux.
243 239
244KBUILD_VMLINUX_LIBS 240KBUILD_VMLINUX_LIBS
245-------------------------------------------------- 241--------------------------------------------------
246All .a "lib" files for vmlinux. 242All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS
247KBUILD_VMLINUX_INIT, KBUILD_VMLINUX_MAIN, and KBUILD_VMLINUX_LIBS together 243together specify all the object files used to link vmlinux.
248specify all the object files used to link vmlinux.
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index bf28c47bfd72..f124be6e4c3a 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -154,13 +154,8 @@ more details, with real examples.
154 154
155 Kbuild compiles all the $(obj-y) files. It then calls 155 Kbuild compiles all the $(obj-y) files. It then calls
156 "$(AR) rcSTP" to merge these files into one built-in.a file. 156 "$(AR) rcSTP" to merge these files into one built-in.a file.
157 This is a thin archive without a symbol table, which makes it 157 This is a thin archive without a symbol table. It will be later
158 unsuitable as a linker input. 158 linked into vmlinux by scripts/link-vmlinux.sh
159
160 The scripts/link-vmlinux.sh script later makes an aggregate
161 built-in.a with "${AR} rcsTP", which creates the thin archive
162 with a symbol table and an index, making it a valid input for
163 the final vmlinux link passes.
164 159
165 The order of files in $(obj-y) is significant. Duplicates in 160 The order of files in $(obj-y) is significant. Duplicates in
166 the lists are allowed: the first instance will be linked into 161 the lists are allowed: the first instance will be linked into
@@ -504,23 +499,6 @@ more details, with real examples.
504 In the above example, -Wno-unused-but-set-variable will be added to 499 In the above example, -Wno-unused-but-set-variable will be added to
505 KBUILD_CFLAGS only if gcc really accepts it. 500 KBUILD_CFLAGS only if gcc really accepts it.
506 501
507 cc-version
508 cc-version returns a numerical version of the $(CC) compiler version.
509 The format is <major><minor> where both are two digits. So for example
510 gcc 3.41 would return 0341.
511 cc-version is useful when a specific $(CC) version is faulty in one
512 area, for example -mregparm=3 was broken in some gcc versions
513 even though the option was accepted by gcc.
514
515 Example:
516 #arch/x86/Makefile
517 cflags-y += $(shell \
518 if [ $(cc-version) -ge 0300 ] ; then \
519 echo "-mregparm=3"; fi ;)
520
521 In the above example, -mregparm=3 is only used for gcc version greater
522 than or equal to gcc 3.0.
523
524 cc-ifversion 502 cc-ifversion
525 cc-ifversion tests the version of $(CC) and equals the fourth parameter 503 cc-ifversion tests the version of $(CC) and equals the fourth parameter
526 if version expression is true, or the fifth (if given) if the version 504 if version expression is true, or the fifth (if given) if the version
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt
index 3fb39e0116b4..80295c613e37 100644
--- a/Documentation/kbuild/modules.txt
+++ b/Documentation/kbuild/modules.txt
@@ -140,7 +140,7 @@ executed to make module versioning work.
140 make -C $KDIR M=$PWD bar.lst 140 make -C $KDIR M=$PWD bar.lst
141 make -C $KDIR M=$PWD baz.o 141 make -C $KDIR M=$PWD baz.o
142 make -C $KDIR M=$PWD foo.ko 142 make -C $KDIR M=$PWD foo.ko
143 make -C $KDIR M=$PWD / 143 make -C $KDIR M=$PWD ./
144 144
145 145
146=== 3. Creating a Kbuild File for an External Module 146=== 3. Creating a Kbuild File for an External Module
diff --git a/Kbuild b/Kbuild
index 4a4c47c38d1d..8637fd14135f 100644
--- a/Kbuild
+++ b/Kbuild
@@ -1,16 +1,9 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2# 2#
3# Kbuild for top-level directory of the kernel 3# Kbuild for top-level directory of the kernel
4# This file takes care of the following:
5# 1) Generate bounds.h
6# 2) Generate timeconst.h
7# 3) Generate asm-offsets.h (may need bounds.h and timeconst.h)
8# 4) Check for missing system calls
9# 5) check atomics headers are up-to-date
10# 6) Generate constants.py (may need bounds.h)
11 4
12##### 5#####
13# 1) Generate bounds.h 6# Generate bounds.h
14 7
15bounds-file := include/generated/bounds.h 8bounds-file := include/generated/bounds.h
16 9
@@ -21,7 +14,7 @@ $(bounds-file): kernel/bounds.s FORCE
21 $(call filechk,offsets,__LINUX_BOUNDS_H__) 14 $(call filechk,offsets,__LINUX_BOUNDS_H__)
22 15
23##### 16#####
24# 2) Generate timeconst.h 17# Generate timeconst.h
25 18
26timeconst-file := include/generated/timeconst.h 19timeconst-file := include/generated/timeconst.h
27 20
@@ -33,8 +26,7 @@ $(timeconst-file): kernel/time/timeconst.bc FORCE
33 $(call filechk,gentimeconst) 26 $(call filechk,gentimeconst)
34 27
35##### 28#####
36# 3) Generate asm-offsets.h 29# Generate asm-offsets.h
37#
38 30
39offsets-file := include/generated/asm-offsets.h 31offsets-file := include/generated/asm-offsets.h
40 32
@@ -47,8 +39,7 @@ $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
47 $(call filechk,offsets,__ASM_OFFSETS_H__) 39 $(call filechk,offsets,__ASM_OFFSETS_H__)
48 40
49##### 41#####
50# 4) Check for missing system calls 42# Check for missing system calls
51#
52 43
53always += missing-syscalls 44always += missing-syscalls
54targets += missing-syscalls 45targets += missing-syscalls
@@ -60,8 +51,7 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
60 $(call cmd,syscalls) 51 $(call cmd,syscalls)
61 52
62##### 53#####
63# 5) Check atomic headers are up-to-date 54# Check atomic headers are up-to-date
64#
65 55
66always += old-atomics 56always += old-atomics
67targets += old-atomics 57targets += old-atomics
@@ -72,14 +62,5 @@ quiet_cmd_atomics = CALL $<
72old-atomics: scripts/atomic/check-atomics.sh FORCE 62old-atomics: scripts/atomic/check-atomics.sh FORCE
73 $(call cmd,atomics) 63 $(call cmd,atomics)
74 64
75#####
76# 6) Generate constants for Python GDB integration
77#
78
79extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
80
81build_constants_py: $(timeconst-file) $(bounds-file)
82 @$(MAKE) $(build)=scripts/gdb/linux $@
83
84# Keep these three files during make clean 65# Keep these three files during make clean
85no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file) 66no-clean-files := $(bounds-file) $(offsets-file) $(timeconst-file)
diff --git a/Makefile b/Makefile
index f070e0d65186..9ef547fc7ffe 100644
--- a/Makefile
+++ b/Makefile
@@ -15,19 +15,6 @@ NAME = Shy Crocodile
15PHONY := _all 15PHONY := _all
16_all: 16_all:
17 17
18# Do not use make's built-in rules and variables
19# (this increases performance and avoids hard-to-debug behaviour)
20MAKEFLAGS += -rR
21
22# Avoid funny character set dependencies
23unexport LC_ALL
24LC_COLLATE=C
25LC_NUMERIC=C
26export LC_COLLATE LC_NUMERIC
27
28# Avoid interference with shell env settings
29unexport GREP_OPTIONS
30
31# We are using a recursive build, so we need to do a little thinking 18# We are using a recursive build, so we need to do a little thinking
32# to get the ordering right. 19# to get the ordering right.
33# 20#
@@ -44,6 +31,25 @@ unexport GREP_OPTIONS
44# descending is started. They are now explicitly listed as the 31# descending is started. They are now explicitly listed as the
45# prepare rule. 32# prepare rule.
46 33
34ifneq ($(sub-make-done),1)
35
36# Do not use make's built-in rules and variables
37# (this increases performance and avoids hard-to-debug behaviour)
38MAKEFLAGS += -rR
39
40# 'MAKEFLAGS += -rR' does not become immediately effective for old
41# GNU Make versions. Cancel implicit rules for this Makefile.
42$(lastword $(MAKEFILE_LIST)): ;
43
44# Avoid funny character set dependencies
45unexport LC_ALL
46LC_COLLATE=C
47LC_NUMERIC=C
48export LC_COLLATE LC_NUMERIC
49
50# Avoid interference with shell env settings
51unexport GREP_OPTIONS
52
47# Beautify output 53# Beautify output
48# --------------------------------------------------------------------------- 54# ---------------------------------------------------------------------------
49# 55#
@@ -90,7 +96,6 @@ endif
90 96
91ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) 97ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
92 quiet=silent_ 98 quiet=silent_
93 tools_silent=s
94endif 99endif
95 100
96export quiet Q KBUILD_VERBOSE 101export quiet Q KBUILD_VERBOSE
@@ -112,7 +117,6 @@ export quiet Q KBUILD_VERBOSE
112 117
113# KBUILD_SRC is not intended to be used by the regular user (for now), 118# KBUILD_SRC is not intended to be used by the regular user (for now),
114# it is set on invocation of make with KBUILD_OUTPUT or O= specified. 119# it is set on invocation of make with KBUILD_OUTPUT or O= specified.
115ifeq ($(KBUILD_SRC),)
116 120
117# OK, Make called in directory where kernel src resides 121# OK, Make called in directory where kernel src resides
118# Do we want to locate output files in a separate directory? 122# Do we want to locate output files in a separate directory?
@@ -120,9 +124,6 @@ ifeq ("$(origin O)", "command line")
120 KBUILD_OUTPUT := $(O) 124 KBUILD_OUTPUT := $(O)
121endif 125endif
122 126
123# Cancel implicit rules on top Makefile
124$(CURDIR)/Makefile Makefile: ;
125
126ifneq ($(words $(subst :, ,$(CURDIR))), 1) 127ifneq ($(words $(subst :, ,$(CURDIR))), 1)
127 $(error main directory cannot contain spaces nor colons) 128 $(error main directory cannot contain spaces nor colons)
128endif 129endif
@@ -142,6 +143,13 @@ $(if $(KBUILD_OUTPUT),, \
142# 'sub-make' below. 143# 'sub-make' below.
143MAKEFLAGS += --include-dir=$(CURDIR) 144MAKEFLAGS += --include-dir=$(CURDIR)
144 145
146else
147
148# Do not print "Entering directory ..." at all for in-tree build.
149MAKEFLAGS += --no-print-directory
150
151endif # ifneq ($(KBUILD_OUTPUT),)
152
145PHONY += $(MAKECMDGOALS) sub-make 153PHONY += $(MAKECMDGOALS) sub-make
146 154
147$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make 155$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
@@ -149,16 +157,12 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
149 157
150# Invoke a second make in the output directory, passing relevant variables 158# Invoke a second make in the output directory, passing relevant variables
151sub-make: 159sub-make:
152 $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ 160 $(Q)$(MAKE) sub-make-done=1 \
161 $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \
153 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) 162 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
154 163
155# Leave processing to above invocation of make 164else # sub-make-done
156skip-makefile := 1
157endif # ifneq ($(KBUILD_OUTPUT),)
158endif # ifeq ($(KBUILD_SRC),)
159
160# We process the rest of the Makefile if this is the final invocation of make 165# We process the rest of the Makefile if this is the final invocation of make
161ifeq ($(skip-makefile),)
162 166
163# Do not print "Entering directory ...", 167# Do not print "Entering directory ...",
164# but we want to display it when entering to the output directory 168# but we want to display it when entering to the output directory
@@ -215,7 +219,7 @@ objtree := .
215src := $(srctree) 219src := $(srctree)
216obj := $(objtree) 220obj := $(objtree)
217 221
218VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD)) 222VPATH := $(srctree)
219 223
220export srctree objtree VPATH 224export srctree objtree VPATH
221 225
@@ -300,8 +304,6 @@ __build_one_by_one:
300 304
301else 305else
302 306
303# We need some generic definitions (do not try to remake the file).
304scripts/Kbuild.include: ;
305include scripts/Kbuild.include 307include scripts/Kbuild.include
306 308
307# Read KERNELRELEASE from include/config/kernel.release (if it exists) 309# Read KERNELRELEASE from include/config/kernel.release (if it exists)
@@ -390,7 +392,6 @@ OBJDUMP = $(CROSS_COMPILE)objdump
390LEX = flex 392LEX = flex
391YACC = bison 393YACC = bison
392AWK = awk 394AWK = awk
393GENKSYMS = scripts/genksyms/genksyms
394INSTALLKERNEL := installkernel 395INSTALLKERNEL := installkernel
395DEPMOD = /sbin/depmod 396DEPMOD = /sbin/depmod
396PERL = perl 397PERL = perl
@@ -429,7 +430,7 @@ LINUXINCLUDE := \
429KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE 430KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
430KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ 431KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
431 -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ 432 -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
432 -Werror-implicit-function-declaration -Werror=implicit-int \ 433 -Werror=implicit-function-declaration -Werror=implicit-int \
433 -Wno-format-security \ 434 -Wno-format-security \
434 -std=gnu89 435 -std=gnu89
435KBUILD_CPPFLAGS := -D__KERNEL__ 436KBUILD_CPPFLAGS := -D__KERNEL__
@@ -443,7 +444,7 @@ GCC_PLUGINS_CFLAGS :=
443 444
444export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC 445export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
445export CPP AR NM STRIP OBJCOPY OBJDUMP KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS 446export CPP AR NM STRIP OBJCOPY OBJDUMP KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS
446export MAKE LEX YACC AWK GENKSYMS INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE 447export MAKE LEX YACC AWK INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE
447export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS 448export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
448 449
449export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS 450export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS
@@ -476,23 +477,23 @@ scripts_basic:
476 $(Q)$(MAKE) $(build)=scripts/basic 477 $(Q)$(MAKE) $(build)=scripts/basic
477 $(Q)rm -f .tmp_quiet_recordmcount 478 $(Q)rm -f .tmp_quiet_recordmcount
478 479
479# To avoid any implicit rule to kick in, define an empty command.
480scripts/basic/%: scripts_basic ;
481
482PHONY += outputmakefile 480PHONY += outputmakefile
483# outputmakefile generates a Makefile in the output directory, if using a 481# outputmakefile generates a Makefile in the output directory, if using a
484# separate output directory. This allows convenient use of make in the 482# separate output directory. This allows convenient use of make in the
485# output directory. 483# output directory.
484# At the same time when output Makefile generated, generate .gitignore to
485# ignore whole output directory
486outputmakefile: 486outputmakefile:
487ifneq ($(KBUILD_SRC),) 487ifneq ($(KBUILD_SRC),)
488 $(Q)ln -fsn $(srctree) source 488 $(Q)ln -fsn $(srctree) source
489 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) 489 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree)
490 $(Q){ echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
490endif 491endif
491 492
492ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) 493ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
493ifneq ($(CROSS_COMPILE),) 494ifneq ($(CROSS_COMPILE),)
494CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%)) 495CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
495GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD))) 496GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
496CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR) 497CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
497GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) 498GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
498endif 499endif
@@ -624,13 +625,22 @@ ifeq ($(may-sync-config),1)
624# because some architectures define CROSS_COMPILE there. 625# because some architectures define CROSS_COMPILE there.
625-include include/config/auto.conf.cmd 626-include include/config/auto.conf.cmd
626 627
627# To avoid any implicit rule to kick in, define an empty command 628$(KCONFIG_CONFIG):
628$(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; 629 @echo >&2 '***'
630 @echo >&2 '*** Configuration file "$@" not found!'
631 @echo >&2 '***'
632 @echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or'
633 @echo >&2 '*** "make menuconfig" or "make xconfig").'
634 @echo >&2 '***'
635 @/bin/false
629 636
630# The actual configuration files used during the build are stored in 637# The actual configuration files used during the build are stored in
631# include/generated/ and include/config/. Update them if .config is newer than 638# include/generated/ and include/config/. Update them if .config is newer than
632# include/config/auto.conf (which mirrors .config). 639# include/config/auto.conf (which mirrors .config).
633include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd 640#
641# This exploits the 'multi-target pattern rule' trick.
642# The syncconfig should be executed only once to make all the targets.
643%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
634 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig 644 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
635else 645else
636# External modules and some install targets need include/generated/autoconf.h 646# External modules and some install targets need include/generated/autoconf.h
@@ -658,17 +668,13 @@ KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context)
658 668
659ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 669ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
660KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) 670KBUILD_CFLAGS += $(call cc-option,-Oz,-Os)
661KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
662else
663ifdef CONFIG_PROFILE_ALL_BRANCHES
664KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,)
665else 671else
666KBUILD_CFLAGS += -O2 672KBUILD_CFLAGS += -O2
667endif 673endif
668endif
669 674
670KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \ 675ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED
671 $(call cc-disable-warning,maybe-uninitialized,)) 676KBUILD_CFLAGS += -Wno-maybe-uninitialized
677endif
672 678
673# Tell gcc to never replace conditional load with a non-conditional one 679# Tell gcc to never replace conditional load with a non-conditional one
674KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) 680KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
@@ -729,25 +735,28 @@ KBUILD_CFLAGS += -fomit-frame-pointer
729endif 735endif
730endif 736endif
731 737
732KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments) 738DEBUG_CFLAGS := $(call cc-option, -fno-var-tracking-assignments)
733 739
734ifdef CONFIG_DEBUG_INFO 740ifdef CONFIG_DEBUG_INFO
735ifdef CONFIG_DEBUG_INFO_SPLIT 741ifdef CONFIG_DEBUG_INFO_SPLIT
736KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) 742DEBUG_CFLAGS += -gsplit-dwarf
737else 743else
738KBUILD_CFLAGS += -g 744DEBUG_CFLAGS += -g
739endif 745endif
740KBUILD_AFLAGS += -Wa,-gdwarf-2 746KBUILD_AFLAGS += -Wa,-gdwarf-2
741endif 747endif
742ifdef CONFIG_DEBUG_INFO_DWARF4 748ifdef CONFIG_DEBUG_INFO_DWARF4
743KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,) 749DEBUG_CFLAGS += -gdwarf-4
744endif 750endif
745 751
746ifdef CONFIG_DEBUG_INFO_REDUCED 752ifdef CONFIG_DEBUG_INFO_REDUCED
747KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ 753DEBUG_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
748 $(call cc-option,-fno-var-tracking) 754 $(call cc-option,-fno-var-tracking)
749endif 755endif
750 756
757KBUILD_CFLAGS += $(DEBUG_CFLAGS)
758export DEBUG_CFLAGS
759
751ifdef CONFIG_FUNCTION_TRACER 760ifdef CONFIG_FUNCTION_TRACER
752ifdef CONFIG_FTRACE_MCOUNT_RECORD 761ifdef CONFIG_FTRACE_MCOUNT_RECORD
753 # gcc 5 supports generating the mcount tables directly 762 # gcc 5 supports generating the mcount tables directly
@@ -922,19 +931,6 @@ ifdef CONFIG_MODULE_COMPRESS
922endif # CONFIG_MODULE_COMPRESS 931endif # CONFIG_MODULE_COMPRESS
923export mod_compress_cmd 932export mod_compress_cmd
924 933
925# Select initial ramdisk compression format, default is gzip(1).
926# This shall be used by the dracut(8) tool while creating an initramfs image.
927#
928INITRD_COMPRESS-y := gzip
929INITRD_COMPRESS-$(CONFIG_RD_BZIP2) := bzip2
930INITRD_COMPRESS-$(CONFIG_RD_LZMA) := lzma
931INITRD_COMPRESS-$(CONFIG_RD_XZ) := xz
932INITRD_COMPRESS-$(CONFIG_RD_LZO) := lzo
933INITRD_COMPRESS-$(CONFIG_RD_LZ4) := lz4
934# do not export INITRD_COMPRESS, since we didn't actually
935# choose a sane default compression above.
936# export INITRD_COMPRESS := $(INITRD_COMPRESS-y)
937
938ifdef CONFIG_MODULE_SIG_ALL 934ifdef CONFIG_MODULE_SIG_ALL
939$(eval $(call config_filename,MODULE_SIG_KEY)) 935$(eval $(call config_filename,MODULE_SIG_KEY))
940 936
@@ -976,15 +972,15 @@ libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y)))
976virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) 972virt-y := $(patsubst %/, %/built-in.a, $(virt-y))
977 973
978# Externally visible symbols (used by link-vmlinux.sh) 974# Externally visible symbols (used by link-vmlinux.sh)
979export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) 975export KBUILD_VMLINUX_OBJS := $(head-y) $(init-y) $(core-y) $(libs-y2) \
980export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y2) $(drivers-y) $(net-y) $(virt-y) 976 $(drivers-y) $(net-y) $(virt-y)
981export KBUILD_VMLINUX_LIBS := $(libs-y1) 977export KBUILD_VMLINUX_LIBS := $(libs-y1)
982export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds 978export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
983export LDFLAGS_vmlinux 979export LDFLAGS_vmlinux
984# used by scripts/package/Makefile 980# used by scripts/package/Makefile
985export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools) 981export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Documentation include samples scripts tools)
986 982
987vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) 983vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS)
988 984
989# Recurse until adjust_autoksyms.sh is satisfied 985# Recurse until adjust_autoksyms.sh is satisfied
990PHONY += autoksyms_recursive 986PHONY += autoksyms_recursive
@@ -1015,9 +1011,6 @@ cmd_link-vmlinux = \
1015 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 1011 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
1016 1012
1017vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE 1013vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
1018ifdef CONFIG_GDB_SCRIPTS
1019 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1020endif
1021 +$(call if_changed,link-vmlinux) 1014 +$(call if_changed,link-vmlinux)
1022 1015
1023targets := vmlinux 1016targets := vmlinux
@@ -1062,7 +1055,7 @@ scripts: scripts_basic scripts_dtc
1062# archprepare is used in arch Makefiles and when processed asm symlink, 1055# archprepare is used in arch Makefiles and when processed asm symlink,
1063# version.h and scripts_basic is processed / created. 1056# version.h and scripts_basic is processed / created.
1064 1057
1065PHONY += prepare archprepare prepare1 prepare2 prepare3 1058PHONY += prepare archprepare prepare1 prepare3
1066 1059
1067# prepare3 is used to check if we are building in a separate output directory, 1060# prepare3 is used to check if we are building in a separate output directory,
1068# and if so do: 1061# and if so do:
@@ -1077,12 +1070,8 @@ ifneq ($(KBUILD_SRC),)
1077 fi; 1070 fi;
1078endif 1071endif
1079 1072
1080# prepare2 creates a makefile if using a separate output directory. 1073prepare1: prepare3 outputmakefile asm-generic $(version_h) $(autoksyms_h) \
1081# From this point forward, .config has been reprocessed, so any rules 1074 include/generated/utsrelease.h
1082# that need to depend on updated CONFIG_* values can be checked here.
1083prepare2: prepare3 outputmakefile asm-generic
1084
1085prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h
1086 $(cmd_crmodverdir) 1075 $(cmd_crmodverdir)
1087 1076
1088archprepare: archheaders archscripts prepare1 scripts 1077archprepare: archheaders archscripts prepare1 scripts
@@ -1517,6 +1506,18 @@ PHONY += $(DOC_TARGETS)
1517$(DOC_TARGETS): scripts_basic FORCE 1506$(DOC_TARGETS): scripts_basic FORCE
1518 $(Q)$(MAKE) $(build)=Documentation $@ 1507 $(Q)$(MAKE) $(build)=Documentation $@
1519 1508
1509# Misc
1510# ---------------------------------------------------------------------------
1511
1512PHONY += scripts_gdb
1513scripts_gdb: prepare
1514 $(Q)$(MAKE) $(build)=scripts/gdb
1515 $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
1516
1517ifdef CONFIG_GDB_SCRIPTS
1518all: scripts_gdb
1519endif
1520
1520else # KBUILD_EXTMOD 1521else # KBUILD_EXTMOD
1521 1522
1522### 1523###
@@ -1668,6 +1669,11 @@ image_name:
1668 @echo $(KBUILD_IMAGE) 1669 @echo $(KBUILD_IMAGE)
1669 1670
1670# Clear a bunch of variables before executing the submake 1671# Clear a bunch of variables before executing the submake
1672
1673ifeq ($(quiet),silent_)
1674tools_silent=s
1675endif
1676
1671tools/: FORCE 1677tools/: FORCE
1672 $(Q)mkdir -p $(objtree)/tools 1678 $(Q)mkdir -p $(objtree)/tools
1673 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ 1679 $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/
@@ -1686,45 +1692,32 @@ tools/%: FORCE
1686# target-dir => where to store outputfile 1692# target-dir => where to store outputfile
1687# build-dir => directory in kernel source tree to use 1693# build-dir => directory in kernel source tree to use
1688 1694
1689ifeq ($(KBUILD_EXTMOD),) 1695build-target = $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD)/)$@
1690 build-dir = $(patsubst %/,%,$(dir $@)) 1696build-dir = $(patsubst %/,%,$(dir $(build-target)))
1691 target-dir = $(dir $@) 1697
1692else 1698%.i: prepare FORCE
1693 zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@))) 1699 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1694 build-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash)) 1700%.ll: prepare FORCE
1695 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) 1701 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1696endif 1702%.lst: prepare FORCE
1697 1703 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1698%.s: %.c prepare FORCE 1704%.o: prepare FORCE
1699 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1705 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1700%.i: %.c prepare FORCE 1706%.s: prepare FORCE
1701 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1707 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1702%.o: %.c prepare FORCE 1708%.symtypes: prepare FORCE
1703 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1709 $(Q)$(MAKE) $(build)=$(build-dir) $(build-target)
1704%.lst: %.c prepare FORCE 1710%.ko: %.o
1705 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) 1711 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1706%.s: %.S prepare FORCE
1707 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1708%.o: %.S prepare FORCE
1709 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1710%.symtypes: %.c prepare FORCE
1711 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1712%.ll: %.c prepare FORCE
1713 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
1714 1712
1715# Modules 1713# Modules
1716/: prepare FORCE 1714PHONY += /
1717 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1715/: ./
1718 $(build)=$(build-dir) 1716
1719# Make sure the latest headers are built for Documentation 1717# Make sure the latest headers are built for Documentation
1720Documentation/ samples/: headers_install 1718Documentation/ samples/: headers_install
1721%/: prepare FORCE 1719%/: prepare FORCE
1722 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1720 $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir)
1723 $(build)=$(build-dir)
1724%.ko: prepare FORCE
1725 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1726 $(build)=$(build-dir) $(@:.ko=.o)
1727 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1728 1721
1729# FIXME Should go into a make.lib or something 1722# FIXME Should go into a make.lib or something
1730# =========================================================================== 1723# ===========================================================================
@@ -1748,13 +1741,11 @@ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \
1748# read saved command lines for existing targets 1741# read saved command lines for existing targets
1749existing-targets := $(wildcard $(sort $(targets))) 1742existing-targets := $(wildcard $(sort $(targets)))
1750 1743
1751cmd_files := $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 1744-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
1752$(cmd_files): ; # Do not try to update included dependency files
1753-include $(cmd_files)
1754 1745
1755endif # ifeq ($(config-targets),1) 1746endif # ifeq ($(config-targets),1)
1756endif # ifeq ($(mixed-targets),1) 1747endif # ifeq ($(mixed-targets),1)
1757endif # skip-makefile 1748endif # sub-make-done
1758 1749
1759PHONY += FORCE 1750PHONY += FORCE
1760FORCE: 1751FORCE:
diff --git a/arch/mips/boot/Makefile b/arch/mips/boot/Makefile
index 35704c28a28b..3ce4dd578370 100644
--- a/arch/mips/boot/Makefile
+++ b/arch/mips/boot/Makefile
@@ -115,7 +115,7 @@ endif
115targets += vmlinux.its.S 115targets += vmlinux.its.S
116 116
117quiet_cmd_its_cat = CAT $@ 117quiet_cmd_its_cat = CAT $@
118 cmd_its_cat = cat $(filter-out $(PHONY), $^) >$@ 118 cmd_its_cat = cat $(real-prereqs) >$@
119 119
120$(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE 120$(obj)/vmlinux.its.S: $(addprefix $(srctree)/arch/mips/$(PLATFORM)/,$(ITS_INPUTS)) FORCE
121 $(call if_changed,its_cat) 121 $(call if_changed,its_cat)
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 0e8dadd011bc..73d1f3562978 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -218,7 +218,7 @@ quiet_cmd_bootas = BOOTAS $@
218 cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< 218 cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
219 219
220quiet_cmd_bootar = BOOTAR $@ 220quiet_cmd_bootar = BOOTAR $@
221 cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ 221 cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(real-prereqs); mv $@.$$$$ $@
222 222
223$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE 223$(obj-libfdt): $(obj)/%.o: $(srctree)/scripts/dtc/libfdt/%.c FORCE
224 $(call if_changed_dep,bootcc) 224 $(call if_changed_dep,bootcc)
diff --git a/arch/s390/boot/Makefile b/arch/s390/boot/Makefile
index d5ad724f5c96..11ca8795b74a 100644
--- a/arch/s390/boot/Makefile
+++ b/arch/s390/boot/Makefile
@@ -58,7 +58,7 @@ $(obj)/compressed/vmlinux: $(obj)/startup.a FORCE
58 $(Q)$(MAKE) $(build)=$(obj)/compressed $@ 58 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
59 59
60quiet_cmd_ar = AR $@ 60quiet_cmd_ar = AR $@
61 cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(filter $(OBJECTS), $^) 61 cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
62 62
63$(obj)/startup.a: $(OBJECTS) FORCE 63$(obj)/startup.a: $(OBJECTS) FORCE
64 $(call if_changed,ar) 64 $(call if_changed,ar)
@@ -67,6 +67,6 @@ install: $(CONFIGURE) $(obj)/bzImage
67 sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \ 67 sh -x $(srctree)/$(obj)/install.sh $(KERNELRELEASE) $(obj)/bzImage \
68 System.map "$(INSTALL_PATH)" 68 System.map "$(INSTALL_PATH)"
69 69
70chkbss := $(OBJECTS) 70chkbss := $(obj-y)
71chkbss-target := $(obj)/startup.a 71chkbss-target := startup.a
72include $(srctree)/arch/s390/scripts/Makefile.chkbss 72include $(srctree)/arch/s390/scripts/Makefile.chkbss
diff --git a/arch/s390/boot/compressed/Makefile b/arch/s390/boot/compressed/Makefile
index b1bdd15e3429..fa529c5b4486 100644
--- a/arch/s390/boot/compressed/Makefile
+++ b/arch/s390/boot/compressed/Makefile
@@ -63,6 +63,6 @@ OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section
63$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE 63$(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE
64 $(call if_changed,objcopy) 64 $(call if_changed,objcopy)
65 65
66chkbss := $(filter-out $(obj)/piggy.o $(obj)/info.o,$(OBJECTS)) 66chkbss := $(filter-out piggy.o info.o, $(obj-y))
67chkbss-target := $(obj)/vmlinux.bin 67chkbss-target := vmlinux.bin
68include $(srctree)/arch/s390/scripts/Makefile.chkbss 68include $(srctree)/arch/s390/scripts/Makefile.chkbss
diff --git a/arch/s390/scripts/Makefile.chkbss b/arch/s390/scripts/Makefile.chkbss
index 9bba2c14e0ca..cd7e8f4419f5 100644
--- a/arch/s390/scripts/Makefile.chkbss
+++ b/arch/s390/scripts/Makefile.chkbss
@@ -1,23 +1,20 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2 2
3chkbss-target ?= built-in.a
4$(obj)/$(chkbss-target): chkbss
5
6chkbss-files := $(addsuffix .chkbss, $(chkbss))
7clean-files += $(chkbss-files)
8
9PHONY += chkbss
10chkbss: $(addprefix $(obj)/, $(chkbss-files))
11
3quiet_cmd_chkbss = CHKBSS $< 12quiet_cmd_chkbss = CHKBSS $<
4define cmd_chkbss 13 cmd_chkbss = \
5 rm -f $@; \
6 if ! $(OBJDUMP) -j .bss -w -h $< | awk 'END { if ($$3) exit 1 }'; then \ 14 if ! $(OBJDUMP) -j .bss -w -h $< | awk 'END { if ($$3) exit 1 }'; then \
7 echo "error: $< .bss section is not empty" >&2; exit 1; \ 15 echo "error: $< .bss section is not empty" >&2; exit 1; \
8 fi; \ 16 fi; \
9 touch $@; 17 touch $@;
10endef
11
12chkbss-target ?= $(obj)/built-in.a
13ifneq (,$(findstring /,$(chkbss)))
14chkbss-files := $(patsubst %, %.chkbss, $(chkbss))
15else
16chkbss-files := $(patsubst %, $(obj)/%.chkbss, $(chkbss))
17endif
18
19$(chkbss-target): $(chkbss-files)
20targets += $(notdir $(chkbss-files))
21 18
22%.o.chkbss: %.o 19$(obj)/%.o.chkbss: $(obj)/%.o
23 $(call cmd,chkbss) 20 $(call cmd,chkbss)
diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
index 96cb20de08af..f60501a384f9 100644
--- a/arch/x86/realmode/rm/Makefile
+++ b/arch/x86/realmode/rm/Makefile
@@ -37,8 +37,7 @@ REALMODE_OBJS = $(addprefix $(obj)/,$(realmode-y))
37sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p' 37sed-pasyms := -n -r -e 's/^([0-9a-fA-F]+) [ABCDGRSTVW] (.+)$$/pa_\2 = \2;/p'
38 38
39quiet_cmd_pasyms = PASYMS $@ 39quiet_cmd_pasyms = PASYMS $@
40 cmd_pasyms = $(NM) $(filter-out FORCE,$^) | \ 40 cmd_pasyms = $(NM) $(real-prereqs) | sed $(sed-pasyms) | sort | uniq > $@
41 sed $(sed-pasyms) | sort | uniq > $@
42 41
43targets += pasyms.h 42targets += pasyms.h
44$(obj)/pasyms.h: $(REALMODE_OBJS) FORCE 43$(obj)/pasyms.h: $(REALMODE_OBJS) FORCE
diff --git a/init/Kconfig b/init/Kconfig
index 811641cc81e8..4592bf7997c0 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -13,7 +13,7 @@ config CC_IS_GCC
13 13
14config GCC_VERSION 14config GCC_VERSION
15 int 15 int
16 default $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') if CC_IS_GCC 16 default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC
17 default 0 17 default 0
18 18
19config CC_IS_CLANG 19config CC_IS_CLANG
@@ -26,6 +26,22 @@ config CLANG_VERSION
26config CC_HAS_ASM_GOTO 26config CC_HAS_ASM_GOTO
27 def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) 27 def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
28 28
29config CC_HAS_WARN_MAYBE_UNINITIALIZED
30 def_bool $(cc-option,-Wmaybe-uninitialized)
31 help
32 GCC >= 4.7 supports this option.
33
34config CC_DISABLE_WARN_MAYBE_UNINITIALIZED
35 bool
36 depends on CC_HAS_WARN_MAYBE_UNINITIALIZED
37 default CC_IS_GCC && GCC_VERSION < 40900 # unreliable for GCC < 4.9
38 help
39 GCC's -Wmaybe-uninitialized is not reliable by definition.
40 Lots of false positive warnings are produced in some cases.
41
42 If this option is enabled, -Wno-maybe-uninitialzed is passed
43 to the compiler to suppress maybe-uninitialized warnings.
44
29config CONSTRUCTORS 45config CONSTRUCTORS
30 bool 46 bool
31 depends on !UML 47 depends on !UML
@@ -1114,6 +1130,7 @@ config CC_OPTIMIZE_FOR_PERFORMANCE
1114 1130
1115config CC_OPTIMIZE_FOR_SIZE 1131config CC_OPTIMIZE_FOR_SIZE
1116 bool "Optimize for size" 1132 bool "Optimize for size"
1133 imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
1117 help 1134 help
1118 Enabling this option will pass "-Os" instead of "-O2" to 1135 Enabling this option will pass "-Os" instead of "-O2" to
1119 your compiler resulting in a smaller kernel. 1136 your compiler resulting in a smaller kernel.
diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig
index fa8b1fe824f3..8bd1d6d001d7 100644
--- a/kernel/trace/Kconfig
+++ b/kernel/trace/Kconfig
@@ -370,6 +370,7 @@ config PROFILE_ANNOTATED_BRANCHES
370config PROFILE_ALL_BRANCHES 370config PROFILE_ALL_BRANCHES
371 bool "Profile all if conditionals" if !FORTIFY_SOURCE 371 bool "Profile all if conditionals" if !FORTIFY_SOURCE
372 select TRACE_BRANCH_PROFILING 372 select TRACE_BRANCH_PROFILING
373 imply CC_DISABLE_WARN_MAYBE_UNINITIALIZED # avoid false positives
373 help 374 help
374 This tracer profiles all branch conditions. Every if () 375 This tracer profiles all branch conditions. Every if ()
375 taken in the kernel is recorded whether it hit or miss. 376 taken in the kernel is recorded whether it hit or miss.
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index bd62be80228e..0d9e81779e37 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -196,6 +196,7 @@ config DEBUG_INFO_REDUCED
196config DEBUG_INFO_SPLIT 196config DEBUG_INFO_SPLIT
197 bool "Produce split debuginfo in .dwo files" 197 bool "Produce split debuginfo in .dwo files"
198 depends on DEBUG_INFO 198 depends on DEBUG_INFO
199 depends on $(cc-option,-gsplit-dwarf)
199 help 200 help
200 Generate debug info into separate .dwo files. This significantly 201 Generate debug info into separate .dwo files. This significantly
201 reduces the build directory size for builds with DEBUG_INFO, 202 reduces the build directory size for builds with DEBUG_INFO,
@@ -211,6 +212,7 @@ config DEBUG_INFO_SPLIT
211config DEBUG_INFO_DWARF4 212config DEBUG_INFO_DWARF4
212 bool "Generate dwarf4 debuginfo" 213 bool "Generate dwarf4 debuginfo"
213 depends on DEBUG_INFO 214 depends on DEBUG_INFO
215 depends on $(cc-option,-gdwarf-4)
214 help 216 help
215 Generate dwarf4 debug info. This requires recent versions 217 Generate dwarf4 debug info. This requires recent versions
216 of gcc and gdb. It makes the debug information larger. 218 of gcc and gdb. It makes the debug information larger.
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 30816037036e..7484b9d8272f 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -24,6 +24,10 @@ depfile = $(subst $(comma),_,$(dot-target).d)
24basetarget = $(basename $(notdir $@)) 24basetarget = $(basename $(notdir $@))
25 25
26### 26###
27# real prerequisites without phony targets
28real-prereqs = $(filter-out $(PHONY), $^)
29
30###
27# Escape single quote for use in echo statements 31# Escape single quote for use in echo statements
28escsq = $(subst $(squote),'\$(squote)',$1) 32escsq = $(subst $(squote),'\$(squote)',$1)
29 33
@@ -67,14 +71,10 @@ endef
67 71
68# cc-cross-prefix 72# cc-cross-prefix
69# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) 73# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
70# Return first prefix where a prefix$(CC) is found in PATH. 74# Return first <prefix> where a <prefix>gcc is found in PATH.
71# If no $(CC) found in PATH with listed prefixes return nothing 75# If no gcc found in PATH with listed prefixes return nothing
72cc-cross-prefix = \ 76cc-cross-prefix = $(firstword $(foreach c, $(filter-out -%, $(1)), \
73 $(word 1, $(foreach c,$(1), \ 77 $(if $(shell which $(c)gcc), $(c))))
74 $(shell set -e; \
75 if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \
76 echo $(c); \
77 fi)))
78 78
79# output directory for tests below 79# output directory for tests below
80TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) 80TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
@@ -134,12 +134,9 @@ cc-option-yn = $(call try-run,\
134cc-disable-warning = $(call try-run,\ 134cc-disable-warning = $(call try-run,\
135 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) 135 $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
136 136
137# cc-version
138cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
139
140# cc-ifversion 137# cc-ifversion
141# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) 138# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
142cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4)) 139cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4))
143 140
144# cc-ldoption 141# cc-ldoption
145# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) 142# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
index dad5583451af..87ff1dcc6bd5 100644
--- a/scripts/Kconfig.include
+++ b/scripts/Kconfig.include
@@ -27,4 +27,4 @@ cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null)
27ld-option = $(success,$(LD) -v $(1)) 27ld-option = $(success,$(LD) -v $(1))
28 28
29# gcc version including patch level 29# gcc version including patch level
30gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') 30gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC))
diff --git a/scripts/Makefile b/scripts/Makefile
index feb1f71381d7..9d442ee050bd 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -39,7 +39,6 @@ build_unifdef: $(obj)/unifdef
39subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins 39subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins
40subdir-$(CONFIG_MODVERSIONS) += genksyms 40subdir-$(CONFIG_MODVERSIONS) += genksyms
41subdir-$(CONFIG_SECURITY_SELINUX) += selinux 41subdir-$(CONFIG_SECURITY_SELINUX) += selinux
42subdir-$(CONFIG_GDB_SCRIPTS) += gdb
43 42
44# Let clean descend into subdirs 43# Let clean descend into subdirs
45subdir- += basic dtc kconfig mod package 44subdir- += basic dtc gdb kconfig mod package
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index fd03d60f6c5a..850b611f4aba 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -63,7 +63,9 @@ ifneq ($(strip $(real-obj-y) $(need-builtin)),)
63builtin-target := $(obj)/built-in.a 63builtin-target := $(obj)/built-in.a
64endif 64endif
65 65
66ifdef CONFIG_MODULES
66modorder-target := $(obj)/modules.order 67modorder-target := $(obj)/modules.order
68endif
67 69
68# We keep a list of all modules in $(MODVERDIR) 70# We keep a list of all modules in $(MODVERDIR)
69 71
@@ -104,7 +106,7 @@ modkern_cflags = \
104quiet_modtag = $(if $(part-of-module),[M], ) 106quiet_modtag = $(if $(part-of-module),[M], )
105 107
106quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ 108quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
107cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< 109 cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
108 110
109$(obj)/%.s: $(src)/%.c FORCE 111$(obj)/%.s: $(src)/%.c FORCE
110 $(call if_changed_dep,cc_s_c) 112 $(call if_changed_dep,cc_s_c)
@@ -118,7 +120,7 @@ $(obj)/%.i: $(src)/%.c FORCE
118# These mirror gensymtypes_S and co below, keep them in synch. 120# These mirror gensymtypes_S and co below, keep them in synch.
119cmd_gensymtypes_c = \ 121cmd_gensymtypes_c = \
120 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ 122 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \
121 $(GENKSYMS) $(if $(1), -T $(2)) \ 123 scripts/genksyms/genksyms $(if $(1), -T $(2)) \
122 $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ 124 $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \
123 $(if $(KBUILD_PRESERVE),-p) \ 125 $(if $(KBUILD_PRESERVE),-p) \
124 -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) 126 -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
@@ -312,13 +314,13 @@ $(real-obj-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
312# 314#
313# These mirror gensymtypes_c and co above, keep them in synch. 315# These mirror gensymtypes_c and co above, keep them in synch.
314cmd_gensymtypes_S = \ 316cmd_gensymtypes_S = \
315 (echo "\#include <linux/kernel.h>" ; \ 317 { echo "\#include <linux/kernel.h>" ; \
316 echo "\#include <asm/asm-prototypes.h>" ; \ 318 echo "\#include <asm/asm-prototypes.h>" ; \
317 $(CPP) $(a_flags) $< | \ 319 $(CPP) $(a_flags) $< | \
318 grep "\<___EXPORT_SYMBOL\>" | \ 320 grep "\<___EXPORT_SYMBOL\>" | \
319 sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ) | \ 321 sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \
320 $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ 322 $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \
321 $(GENKSYMS) $(if $(1), -T $(2)) \ 323 scripts/genksyms/genksyms $(if $(1), -T $(2)) \
322 $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ 324 $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \
323 $(if $(KBUILD_PRESERVE),-p) \ 325 $(if $(KBUILD_PRESERVE),-p) \
324 -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) 326 -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
@@ -394,17 +396,12 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
394$(sort $(subdir-obj-y)): $(subdir-ym) ; 396$(sort $(subdir-obj-y)): $(subdir-ym) ;
395 397
396# 398#
397# Rule to compile a set of .o files into one .o file 399# Rule to compile a set of .o files into one .a file (without symbol table)
398# 400#
399ifdef builtin-target 401ifdef builtin-target
400 402
401# built-in.a archives are made with no symbol table or index which
402# makes them small and fast, but unable to be used by the linker.
403# scripts/link-vmlinux.sh builds an aggregate built-in.a with a symbol
404# table and index.
405quiet_cmd_ar_builtin = AR $@ 403quiet_cmd_ar_builtin = AR $@
406 cmd_ar_builtin = rm -f $@; \ 404 cmd_ar_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
407 $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(filter $(real-obj-y), $^)
408 405
409$(builtin-target): $(real-obj-y) FORCE 406$(builtin-target): $(real-obj-y) FORCE
410 $(call if_changed,ar_builtin) 407 $(call if_changed,ar_builtin)
@@ -426,13 +423,13 @@ $(modorder-target): $(subdir-ym) FORCE
426 $(Q)(cat /dev/null; $(modorder-cmds)) > $@ 423 $(Q)(cat /dev/null; $(modorder-cmds)) > $@
427 424
428# 425#
429# Rule to compile a set of .o files into one .a file 426# Rule to compile a set of .o files into one .a file (with symbol table)
430# 427#
431ifdef lib-target 428ifdef lib-target
432quiet_cmd_link_l_target = AR $@ 429quiet_cmd_link_l_target = AR $@
433 430
434# lib target archives do get a symbol table and index 431# lib target archives do get a symbol table and index
435cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y) 432cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs)
436 433
437$(lib-target): $(lib-y) FORCE 434$(lib-target): $(lib-y) FORCE
438 $(call if_changed,link_l_target) 435 $(call if_changed,link_l_target)
@@ -457,6 +454,10 @@ targets += $(obj)/lib-ksyms.o
457 454
458endif 455endif
459 456
457# NOTE:
458# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
459# module is turned into a multi object module, $^ will contain header file
460# dependencies recorded in the .*.cmd file.
460quiet_cmd_link_multi-m = LD [M] $@ 461quiet_cmd_link_multi-m = LD [M] $@
461cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis) 462cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis)
462 463
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 0393f75db4d4..a115259b57e7 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -67,13 +67,15 @@ _hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
67_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ 67_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
68 $(HOSTCXXFLAGS_$(basetarget).o) 68 $(HOSTCXXFLAGS_$(basetarget).o)
69 69
70ifeq ($(KBUILD_SRC),)
71__hostc_flags = $(_hostc_flags) 70__hostc_flags = $(_hostc_flags)
72__hostcxx_flags = $(_hostcxx_flags) 71__hostcxx_flags = $(_hostcxx_flags)
73else 72
73ifeq ($(KBUILD_EXTMOD),)
74ifneq ($(KBUILD_SRC),)
74__hostc_flags = -I$(obj) $(call flags,_hostc_flags) 75__hostc_flags = -I$(obj) $(call flags,_hostc_flags)
75__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) 76__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags)
76endif 77endif
78endif
77 79
78hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) 80hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags)
79hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) 81hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 12b88d09c3a4..c0abd9a779c3 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -137,14 +137,14 @@ _c_flags += $(if $(patsubst n%,, \
137 $(CFLAGS_KCOV)) 137 $(CFLAGS_KCOV))
138endif 138endif
139 139
140# If building the kernel in a separate objtree expand all occurrences
141# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
142
143ifeq ($(KBUILD_SRC),)
144__c_flags = $(_c_flags) 140__c_flags = $(_c_flags)
145__a_flags = $(_a_flags) 141__a_flags = $(_a_flags)
146__cpp_flags = $(_cpp_flags) 142__cpp_flags = $(_cpp_flags)
147else 143
144# If building the kernel in a separate objtree expand all occurrences
145# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
146ifeq ($(KBUILD_EXTMOD),)
147ifneq ($(KBUILD_SRC),)
148 148
149# -I$(obj) locates generated .h files 149# -I$(obj) locates generated .h files
150# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files 150# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
@@ -155,6 +155,7 @@ __c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \
155__a_flags = $(call flags,_a_flags) 155__a_flags = $(call flags,_a_flags)
156__cpp_flags = $(call flags,_cpp_flags) 156__cpp_flags = $(call flags,_cpp_flags)
157endif 157endif
158endif
158 159
159c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ 160c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
160 -include $(srctree)/include/linux/compiler_types.h \ 161 -include $(srctree)/include/linux/compiler_types.h \
@@ -230,7 +231,7 @@ $(obj)/%: $(src)/%_shipped
230# --------------------------------------------------------------------------- 231# ---------------------------------------------------------------------------
231 232
232quiet_cmd_ld = LD $@ 233quiet_cmd_ld = LD $@
233cmd_ld = $(LD) $(ld_flags) $(filter-out FORCE,$^) -o $@ 234 cmd_ld = $(LD) $(ld_flags) $(real-prereqs) -o $@
234 235
235# Objcopy 236# Objcopy
236# --------------------------------------------------------------------------- 237# ---------------------------------------------------------------------------
@@ -242,7 +243,7 @@ cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
242# --------------------------------------------------------------------------- 243# ---------------------------------------------------------------------------
243 244
244quiet_cmd_gzip = GZIP $@ 245quiet_cmd_gzip = GZIP $@
245 cmd_gzip = cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@ 246 cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@
246 247
247# DTC 248# DTC
248# --------------------------------------------------------------------------- 249# ---------------------------------------------------------------------------
@@ -270,7 +271,7 @@ DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
270# Generate an assembly file to wrap the output of the device tree compiler 271# Generate an assembly file to wrap the output of the device tree compiler
271quiet_cmd_dt_S_dtb= DTB $@ 272quiet_cmd_dt_S_dtb= DTB $@
272cmd_dt_S_dtb= \ 273cmd_dt_S_dtb= \
273( \ 274{ \
274 echo '\#include <asm-generic/vmlinux.lds.h>'; \ 275 echo '\#include <asm-generic/vmlinux.lds.h>'; \
275 echo '.section .dtb.init.rodata,"a"'; \ 276 echo '.section .dtb.init.rodata,"a"'; \
276 echo '.balign STRUCT_ALIGNMENT'; \ 277 echo '.balign STRUCT_ALIGNMENT'; \
@@ -280,7 +281,7 @@ cmd_dt_S_dtb= \
280 echo '__dtb_$(subst -,_,$(*F))_end:'; \ 281 echo '__dtb_$(subst -,_,$(*F))_end:'; \
281 echo '.global __dtb_$(subst -,_,$(*F))_end'; \ 282 echo '.global __dtb_$(subst -,_,$(*F))_end'; \
282 echo '.balign STRUCT_ALIGNMENT'; \ 283 echo '.balign STRUCT_ALIGNMENT'; \
283) > $@ 284} > $@
284 285
285$(obj)/%.dtb.S: $(obj)/%.dtb FORCE 286$(obj)/%.dtb.S: $(obj)/%.dtb FORCE
286 $(call if_changed,dt_S_dtb) 287 $(call if_changed,dt_S_dtb)
@@ -320,7 +321,7 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
320# append the size as a 32-bit littleendian number as gzip does. 321# append the size as a 32-bit littleendian number as gzip does.
321size_append = printf $(shell \ 322size_append = printf $(shell \
322dec_size=0; \ 323dec_size=0; \
323for F in $1; do \ 324for F in $(real-prereqs); do \
324 fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \ 325 fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \
325 dec_size=$$(expr $$dec_size + $$fsize); \ 326 dec_size=$$(expr $$dec_size + $$fsize); \
326done; \ 327done; \
@@ -334,23 +335,20 @@ printf "%08x\n" $$dec_size | \
334) 335)
335 336
336quiet_cmd_bzip2 = BZIP2 $@ 337quiet_cmd_bzip2 = BZIP2 $@
337cmd_bzip2 = (cat $(filter-out FORCE,$^) | \ 338 cmd_bzip2 = { cat $(real-prereqs) | bzip2 -9 && $(size_append); } > $@
338 bzip2 -9 && $(call size_append, $(filter-out FORCE,$^))) > $@
339 339
340# Lzma 340# Lzma
341# --------------------------------------------------------------------------- 341# ---------------------------------------------------------------------------
342 342
343quiet_cmd_lzma = LZMA $@ 343quiet_cmd_lzma = LZMA $@
344cmd_lzma = (cat $(filter-out FORCE,$^) | \ 344 cmd_lzma = { cat $(real-prereqs) | lzma -9 && $(size_append); } > $@
345 lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@
346 345
347quiet_cmd_lzo = LZO $@ 346quiet_cmd_lzo = LZO $@
348cmd_lzo = (cat $(filter-out FORCE,$^) | \ 347 cmd_lzo = { cat $(real-prereqs) | lzop -9 && $(size_append); } > $@
349 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@
350 348
351quiet_cmd_lz4 = LZ4 $@ 349quiet_cmd_lz4 = LZ4 $@
352cmd_lz4 = (cat $(filter-out FORCE,$^) | \ 350 cmd_lz4 = { cat $(real-prereqs) | lz4c -l -c1 stdin stdout && \
353 lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ 351 $(size_append); } > $@
354 352
355# U-Boot mkimage 353# U-Boot mkimage
356# --------------------------------------------------------------------------- 354# ---------------------------------------------------------------------------
@@ -392,13 +390,11 @@ quiet_cmd_uimage = UIMAGE $@
392# big dictionary would increase the memory usage too much in the multi-call 390# big dictionary would increase the memory usage too much in the multi-call
393# decompression mode. A BCJ filter isn't used either. 391# decompression mode. A BCJ filter isn't used either.
394quiet_cmd_xzkern = XZKERN $@ 392quiet_cmd_xzkern = XZKERN $@
395cmd_xzkern = (cat $(filter-out FORCE,$^) | \ 393 cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh && \
396 sh $(srctree)/scripts/xz_wrap.sh && \ 394 $(size_append); } > $@
397 $(call size_append, $(filter-out FORCE,$^))) > $@
398 395
399quiet_cmd_xzmisc = XZMISC $@ 396quiet_cmd_xzmisc = XZMISC $@
400cmd_xzmisc = (cat $(filter-out FORCE,$^) | \ 397 cmd_xzmisc = cat $(real-prereqs) | xz --check=crc32 --lzma2=dict=1MiB > $@
401 xz --check=crc32 --lzma2=dict=1MiB) > $@
402 398
403# ASM offsets 399# ASM offsets
404# --------------------------------------------------------------------------- 400# ---------------------------------------------------------------------------
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 7d4af0d0accb..c0b7f526f95e 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -122,7 +122,7 @@ quiet_cmd_ld_ko_o = LD [M] $@
122 cmd_ld_ko_o = \ 122 cmd_ld_ko_o = \
123 $(LD) -r $(KBUILD_LDFLAGS) \ 123 $(LD) -r $(KBUILD_LDFLAGS) \
124 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ 124 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
125 -o $@ $(filter-out FORCE,$^) ; \ 125 -o $@ $(real-prereqs) ; \
126 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 126 $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
127 127
128$(modules): %.ko :%.o %.mod.o FORCE 128$(modules): %.ko :%.o %.mod.o FORCE
diff --git a/scripts/clang-version.sh b/scripts/clang-version.sh
index e65fbc3079d4..6fabf0695761 100755
--- a/scripts/clang-version.sh
+++ b/scripts/clang-version.sh
@@ -1,14 +1,10 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0 2# SPDX-License-Identifier: GPL-2.0
3# 3#
4# clang-version [-p] clang-command 4# clang-version clang-command
5#
6# Prints the compiler version of `clang-command' in a canonical 4-digit form
7# such as `0500' for clang-5.0 etc.
8#
9# With the -p option, prints the patchlevel as well, for example `050001' for
10# clang-5.0.1 etc.
11# 5#
6# Print the compiler version of `clang-command' in a 5 or 6-digit form
7# such as `50001' for clang-5.0.1 etc.
12 8
13compiler="$*" 9compiler="$*"
14 10
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh
index 11bb909845e7..ae353432539b 100755
--- a/scripts/gcc-version.sh
+++ b/scripts/gcc-version.sh
@@ -1,33 +1,20 @@
1#!/bin/sh 1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0 2# SPDX-License-Identifier: GPL-2.0
3# 3#
4# gcc-version [-p] gcc-command 4# gcc-version gcc-command
5#
6# Prints the gcc version of `gcc-command' in a canonical 4-digit form
7# such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc.
8#
9# With the -p option, prints the patchlevel as well, for example `029503' for
10# gcc-2.95.3, `030301' for gcc-3.3.1, etc.
11# 5#
12 6# Print the gcc version of `gcc-command' in a 5 or 6-digit form
13if [ "$1" = "-p" ] ; then 7# such as `29503' for gcc-2.95.3, `30301' for gcc-3.3.1, etc.
14 with_patchlevel=1;
15 shift;
16fi
17 8
18compiler="$*" 9compiler="$*"
19 10
20if [ ${#compiler} -eq 0 ]; then 11if [ ${#compiler} -eq 0 ]; then
21 echo "Error: No compiler specified." 12 echo "Error: No compiler specified." >&2
22 printf "Usage:\n\t$0 <gcc-command>\n" 13 printf "Usage:\n\t$0 <gcc-command>\n" >&2
23 exit 1 14 exit 1
24fi 15fi
25 16
26MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1) 17MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1)
27MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1) 18MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1)
28if [ "x$with_patchlevel" != "x" ] ; then 19PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1)
29 PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1) 20printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
30 printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
31else
32 printf "%02d%02d\\n" $MAJOR $MINOR
33fi
diff --git a/scripts/gdb/linux/Makefile b/scripts/gdb/linux/Makefile
index aba23be985e4..3df395a9c2ce 100644
--- a/scripts/gdb/linux/Makefile
+++ b/scripts/gdb/linux/Makefile
@@ -1,24 +1,25 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2always := gdb-scripts
3 2
4SRCTREE := $(abspath $(srctree))
5
6$(obj)/gdb-scripts:
7ifneq ($(KBUILD_SRC),) 3ifneq ($(KBUILD_SRC),)
8 $(Q)ln -fsn $(SRCTREE)/$(obj)/*.py $(objtree)/$(obj) 4
5symlinks := $(patsubst $(srctree)/$(src)/%,%,$(wildcard $(srctree)/$(src)/*.py))
6
7quiet_cmd_symlink = SYMLINK $@
8 cmd_symlink = ln -fsn $(patsubst $(obj)/%,$(abspath $(srctree))/$(src)/%,$@) $@
9
10extra-y += $(symlinks)
11$(addprefix $(obj)/, $(symlinks)): FORCE
12 $(call if_changed,symlink)
13
9endif 14endif
10 @:
11 15
12quiet_cmd_gen_constants_py = GEN $@ 16quiet_cmd_gen_constants_py = GEN $@
13 cmd_gen_constants_py = \ 17 cmd_gen_constants_py = \
14 $(CPP) -E -x c -P $(c_flags) $< > $@ ;\ 18 $(CPP) -E -x c -P $(c_flags) $< > $@ ;\
15 sed -i '1,/<!-- end-c-headers -->/d;' $@ 19 sed -i '1,/<!-- end-c-headers -->/d;' $@
16 20
17targets += constants.py 21extra-y += constants.py
18$(obj)/constants.py: $(SRCTREE)/$(obj)/constants.py.in FORCE 22$(obj)/constants.py: $(src)/constants.py.in FORCE
19 $(call if_changed_dep,gen_constants_py) 23 $(call if_changed_dep,gen_constants_py)
20 24
21build_constants_py: $(obj)/constants.py 25clean-files := *.pyc *.pyo
22 @:
23
24clean-files := *.pyc *.pyo $(if $(KBUILD_SRC),*.py) $(obj)/constants.py
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index f75e7bda4889..e17837f1d3f2 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -62,11 +62,11 @@ static int all_symbols = 0;
62static int absolute_percpu = 0; 62static int absolute_percpu = 0;
63static int base_relative = 0; 63static int base_relative = 0;
64 64
65int token_profit[0x10000]; 65static int token_profit[0x10000];
66 66
67/* the table that holds the result of the compression */ 67/* the table that holds the result of the compression */
68unsigned char best_table[256][2]; 68static unsigned char best_table[256][2];
69unsigned char best_table_len[256]; 69static unsigned char best_table_len[256];
70 70
71 71
72static void usage(void) 72static void usage(void)
@@ -80,7 +80,7 @@ static void usage(void)
80 * This ignores the intensely annoying "mapping symbols" found 80 * This ignores the intensely annoying "mapping symbols" found
81 * in ARM ELF files: $a, $t and $d. 81 * in ARM ELF files: $a, $t and $d.
82 */ 82 */
83static inline int is_arm_mapping_symbol(const char *str) 83static int is_arm_mapping_symbol(const char *str)
84{ 84{
85 return str[0] == '$' && strchr("axtd", str[1]) 85 return str[0] == '$' && strchr("axtd", str[1])
86 && (str[2] == '\0' || str[2] == '.'); 86 && (str[2] == '\0' || str[2] == '.');
@@ -331,7 +331,7 @@ static void write_src(void)
331 unsigned int *markers; 331 unsigned int *markers;
332 char buf[KSYM_NAME_LEN]; 332 char buf[KSYM_NAME_LEN];
333 333
334 printf("#include <asm/types.h>\n"); 334 printf("#include <asm/bitsperlong.h>\n");
335 printf("#if BITS_PER_LONG == 64\n"); 335 printf("#if BITS_PER_LONG == 64\n");
336 printf("#define PTR .quad\n"); 336 printf("#define PTR .quad\n");
337 printf("#define ALGN .balign 8\n"); 337 printf("#define ALGN .balign 8\n");
@@ -596,9 +596,6 @@ static void insert_real_symbols_in_table(void)
596{ 596{
597 unsigned int i, j, c; 597 unsigned int i, j, c;
598 598
599 memset(best_table, 0, sizeof(best_table));
600 memset(best_table_len, 0, sizeof(best_table_len));
601
602 for (i = 0; i < table_cnt; i++) { 599 for (i = 0; i < table_cnt; i++) {
603 for (j = 0; j < table[i].len; j++) { 600 for (j = 0; j < table[i].len; j++) {
604 c = table[i].sym[j]; 601 c = table[i].sym[j];
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index da89ef788a8d..ef3678c24bab 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -488,7 +488,6 @@ int main(int ac, char **av)
488 const char *progname = av[0]; 488 const char *progname = av[0];
489 int opt; 489 int opt;
490 const char *name, *defconfig_file = NULL /* gcc uninit */; 490 const char *name, *defconfig_file = NULL /* gcc uninit */;
491 struct stat tmpstat;
492 int no_conf_write = 0; 491 int no_conf_write = 0;
493 492
494 tty_stdio = isatty(0) && isatty(1); 493 tty_stdio = isatty(0) && isatty(1);
@@ -560,18 +559,6 @@ int main(int ac, char **av)
560 name = av[optind]; 559 name = av[optind];
561 conf_parse(name); 560 conf_parse(name);
562 //zconfdump(stdout); 561 //zconfdump(stdout);
563 if (sync_kconfig) {
564 name = conf_get_configname();
565 if (stat(name, &tmpstat)) {
566 fprintf(stderr, "***\n"
567 "*** Configuration file \"%s\" not found!\n"
568 "***\n"
569 "*** Please run some configurator (e.g. \"make oldconfig\" or\n"
570 "*** \"make menuconfig\" or \"make xconfig\").\n"
571 "***\n", name);
572 exit(1);
573 }
574 }
575 562
576 switch (input_mode) { 563 switch (input_mode) {
577 case defconfig: 564 case defconfig:
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index c8cf45362bd6..bc7f1fc1f55b 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -3,22 +3,17 @@
3# 3#
4# link vmlinux 4# link vmlinux
5# 5#
6# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_INIT) and 6# vmlinux is linked from the objects selected by $(KBUILD_VMLINUX_OBJS) and
7# $(KBUILD_VMLINUX_MAIN) and $(KBUILD_VMLINUX_LIBS). Most are built-in.a files 7# $(KBUILD_VMLINUX_LIBS). Most are built-in.a files from top-level directories
8# from top-level directories in the kernel tree, others are specified in 8# in the kernel tree, others are specified in arch/$(ARCH)/Makefile.
9# arch/$(ARCH)/Makefile. Ordering when linking is important, and 9# $(KBUILD_VMLINUX_LIBS) are archives which are linked conditionally
10# $(KBUILD_VMLINUX_INIT) must be first. $(KBUILD_VMLINUX_LIBS) are archives 10# (not within --whole-archive), and do not require symbol indexes added.
11# which are linked conditionally (not within --whole-archive), and do not
12# require symbol indexes added.
13# 11#
14# vmlinux 12# vmlinux
15# ^ 13# ^
16# | 14# |
17# +-< $(KBUILD_VMLINUX_INIT) 15# +--< $(KBUILD_VMLINUX_OBJS)
18# | +--< init/version.o + more 16# | +--< init/built-in.a drivers/built-in.a mm/built-in.a + more
19# |
20# +--< $(KBUILD_VMLINUX_MAIN)
21# | +--< drivers/built-in.a mm/built-in.a + more
22# | 17# |
23# +--< $(KBUILD_VMLINUX_LIBS) 18# +--< $(KBUILD_VMLINUX_LIBS)
24# | +--< lib/lib.a + more 19# | +--< lib/lib.a + more
@@ -44,24 +39,6 @@ info()
44 fi 39 fi
45} 40}
46 41
47# Thin archive build here makes a final archive with symbol table and indexes
48# from vmlinux objects INIT and MAIN, which can be used as input to linker.
49# KBUILD_VMLINUX_LIBS archives should already have symbol table and indexes
50# added.
51#
52# Traditional incremental style of link does not require this step
53#
54# built-in.a output file
55#
56archive_builtin()
57{
58 info AR built-in.a
59 rm -f built-in.a;
60 ${AR} rcsTP${KBUILD_ARFLAGS} built-in.a \
61 ${KBUILD_VMLINUX_INIT} \
62 ${KBUILD_VMLINUX_MAIN}
63}
64
65# Link of vmlinux.o used for section mismatch analysis 42# Link of vmlinux.o used for section mismatch analysis
66# ${1} output file 43# ${1} output file
67modpost_link() 44modpost_link()
@@ -69,7 +46,7 @@ modpost_link()
69 local objects 46 local objects
70 47
71 objects="--whole-archive \ 48 objects="--whole-archive \
72 built-in.a \ 49 ${KBUILD_VMLINUX_OBJS} \
73 --no-whole-archive \ 50 --no-whole-archive \
74 --start-group \ 51 --start-group \
75 ${KBUILD_VMLINUX_LIBS} \ 52 ${KBUILD_VMLINUX_LIBS} \
@@ -88,7 +65,7 @@ vmlinux_link()
88 65
89 if [ "${SRCARCH}" != "um" ]; then 66 if [ "${SRCARCH}" != "um" ]; then
90 objects="--whole-archive \ 67 objects="--whole-archive \
91 built-in.a \ 68 ${KBUILD_VMLINUX_OBJS} \
92 --no-whole-archive \ 69 --no-whole-archive \
93 --start-group \ 70 --start-group \
94 ${KBUILD_VMLINUX_LIBS} \ 71 ${KBUILD_VMLINUX_LIBS} \
@@ -99,7 +76,7 @@ vmlinux_link()
99 -T ${lds} ${objects} 76 -T ${lds} ${objects}
100 else 77 else
101 objects="-Wl,--whole-archive \ 78 objects="-Wl,--whole-archive \
102 built-in.a \ 79 ${KBUILD_VMLINUX_OBJS} \
103 -Wl,--no-whole-archive \ 80 -Wl,--no-whole-archive \
104 -Wl,--start-group \ 81 -Wl,--start-group \
105 ${KBUILD_VMLINUX_LIBS} \ 82 ${KBUILD_VMLINUX_LIBS} \
@@ -160,7 +137,6 @@ cleanup()
160 rm -f .tmp_System.map 137 rm -f .tmp_System.map
161 rm -f .tmp_kallsyms* 138 rm -f .tmp_kallsyms*
162 rm -f .tmp_vmlinux* 139 rm -f .tmp_vmlinux*
163 rm -f built-in.a
164 rm -f System.map 140 rm -f System.map
165 rm -f vmlinux 141 rm -f vmlinux
166 rm -f vmlinux.o 142 rm -f vmlinux.o
@@ -217,8 +193,6 @@ fi;
217# final build of init/ 193# final build of init/
218${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init 194${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
219 195
220archive_builtin
221
222#link vmlinux.o 196#link vmlinux.o
223info LD vmlinux.o 197info LD vmlinux.o
224modpost_link vmlinux.o 198modpost_link vmlinux.o
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index 87f1fc9801d7..2339f86126cb 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -62,7 +62,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
62 62
63# Generate a temporary compile.h 63# Generate a temporary compile.h
64 64
65( echo /\* This file is auto generated, version $VERSION \*/ 65{ echo /\* This file is auto generated, version $VERSION \*/
66 if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi 66 if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi
67 67
68 echo \#define UTS_MACHINE \"$ARCH\" 68 echo \#define UTS_MACHINE \"$ARCH\"
@@ -73,7 +73,7 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
73 echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\" 73 echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
74 74
75 echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\" 75 echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version ' | sed 's/[[:space:]]*$//'`\"
76) > .tmpcompile 76} > .tmpcompile
77 77
78# Only replace the real compile.h if the new one is different, 78# Only replace the real compile.h if the new one is different,
79# in order to preserve the timestamp and avoid unnecessary 79# in order to preserve the timestamp and avoid unnecessary
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 453fecee62f0..2c6de21e5152 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -59,7 +59,7 @@ rpm-pkg: FORCE
59# binrpm-pkg 59# binrpm-pkg
60# --------------------------------------------------------------------------- 60# ---------------------------------------------------------------------------
61binrpm-pkg: FORCE 61binrpm-pkg: FORCE
62 $(MAKE) KBUILD_SRC= 62 $(MAKE) -f $(srctree)/Makefile
63 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec 63 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
64 +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \ 64 +rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
65 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec 65 $(UTS_MACHINE) -bb $(objtree)/binkernel.spec
@@ -72,11 +72,11 @@ deb-pkg: FORCE
72 $(call cmd,src_tar,$(KDEB_SOURCENAME)) 72 $(call cmd,src_tar,$(KDEB_SOURCENAME))
73 origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\ 73 origversion=$$(dpkg-parsechangelog -SVersion |sed 's/-[^-]*$$//');\
74 mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz 74 mv $(KDEB_SOURCENAME).tar.gz ../$(KDEB_SOURCENAME)_$${origversion}.orig.tar.gz
75 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -i.git -us -uc 75 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -i.git -us -uc
76 76
77bindeb-pkg: FORCE 77bindeb-pkg: FORCE
78 $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian 78 $(CONFIG_SHELL) $(srctree)/scripts/package/mkdebian
79 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) -b -nc -uc 79 +dpkg-buildpackage -r$(KBUILD_PKG_ROOTCMD) -a$$(cat debian/arch) $(DPKG_FLAGS) -b -nc -uc
80 80
81intdeb-pkg: FORCE 81intdeb-pkg: FORCE
82 +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 82 +$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
@@ -102,7 +102,7 @@ clean-dirs += $(objtree)/snap/
102# tarball targets 102# tarball targets
103# --------------------------------------------------------------------------- 103# ---------------------------------------------------------------------------
104tar%pkg: FORCE 104tar%pkg: FORCE
105 $(MAKE) KBUILD_SRC= 105 $(MAKE) -f $(srctree)/Makefile
106 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ 106 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
107 107
108clean-dirs += $(objtree)/tar-install/ 108clean-dirs += $(objtree)/tar-install/
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index f43a274f4f1d..8ac25d10a6ad 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -86,12 +86,12 @@ cp "$($MAKE -s -f $srctree/Makefile image_name)" "$tmpdir/$installed_image_path"
86if grep -q "^CONFIG_OF_EARLY_FLATTREE=y" $KCONFIG_CONFIG ; then 86if grep -q "^CONFIG_OF_EARLY_FLATTREE=y" $KCONFIG_CONFIG ; then
87 # Only some architectures with OF support have this target 87 # Only some architectures with OF support have this target
88 if [ -d "${srctree}/arch/$SRCARCH/boot/dts" ]; then 88 if [ -d "${srctree}/arch/$SRCARCH/boot/dts" ]; then
89 $MAKE KBUILD_SRC= INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install 89 $MAKE -f $srctree/Makefile INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install
90 fi 90 fi
91fi 91fi
92 92
93if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then 93if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then
94 INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install 94 INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_install
95 rm -f "$tmpdir/lib/modules/$version/build" 95 rm -f "$tmpdir/lib/modules/$version/build"
96 rm -f "$tmpdir/lib/modules/$version/source" 96 rm -f "$tmpdir/lib/modules/$version/source"
97 if [ "$ARCH" = "um" ] ; then 97 if [ "$ARCH" = "um" ] ; then
@@ -113,14 +113,14 @@ if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then
113 # resign stripped modules 113 # resign stripped modules
114 MODULE_SIG_ALL="$(grep -s '^CONFIG_MODULE_SIG_ALL=y' $KCONFIG_CONFIG || true)" 114 MODULE_SIG_ALL="$(grep -s '^CONFIG_MODULE_SIG_ALL=y' $KCONFIG_CONFIG || true)"
115 if [ -n "$MODULE_SIG_ALL" ]; then 115 if [ -n "$MODULE_SIG_ALL" ]; then
116 INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_sign 116 INSTALL_MOD_PATH="$tmpdir" $MAKE -f $srctree/Makefile modules_sign
117 fi 117 fi
118 fi 118 fi
119fi 119fi
120 120
121if [ "$ARCH" != "um" ]; then 121if [ "$ARCH" != "um" ]; then
122 $MAKE headers_check KBUILD_SRC= 122 $MAKE -f $srctree/Makefile headers_check
123 $MAKE headers_install KBUILD_SRC= INSTALL_HDR_PATH="$libc_headers_dir/usr" 123 $MAKE -f $srctree/Makefile headers_install INSTALL_HDR_PATH="$libc_headers_dir/usr"
124fi 124fi
125 125
126# Install the maintainer scripts 126# Install the maintainer scripts
diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index d624a07a4e77..cfd2a4a3fe42 100755
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -57,7 +57,7 @@ dirs=boot
57# Try to install modules 57# Try to install modules
58# 58#
59if grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then 59if grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then
60 make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install 60 make ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_MOD_PATH="${tmpdir}" modules_install
61 dirs="$dirs lib" 61 dirs="$dirs lib"
62fi 62fi
63 63
diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
index edcad61fe3cd..f030961c5165 100755
--- a/scripts/package/mkdebian
+++ b/scripts/package/mkdebian
@@ -205,13 +205,15 @@ EOF
205cat <<EOF > debian/rules 205cat <<EOF > debian/rules
206#!$(command -v $MAKE) -f 206#!$(command -v $MAKE) -f
207 207
208srctree ?= .
209
208build: 210build:
209 \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ 211 \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \
210 KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= 212 KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile
211 213
212binary-arch: 214binary-arch:
213 \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \ 215 \$(MAKE) KERNELRELEASE=${version} ARCH=${ARCH} \
214 KBUILD_BUILD_VERSION=${revision} KBUILD_SRC= intdeb-pkg 216 KBUILD_BUILD_VERSION=${revision} -f \$(srctree)/Makefile intdeb-pkg
215 217
216clean: 218clean:
217 rm -rf debian/*tmp debian/files 219 rm -rf debian/*tmp debian/files