aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-02-19 13:07:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-19 13:07:08 -0500
commit27a22ee4c7d5839fd7e3e441c9d675c8a5c4c22c (patch)
tree309fd7788b0695c5273416840d7a7a08dcecda5c
parentb2b89ebfc0f0287e20516a5443d93af309b800cf (diff)
parenta75f8b8dab0f73459fa47a1daa10c84c4e8400a8 (diff)
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kbuild updates from Michal Marek: - several cleanups in kbuild - serialize multiple *config targets so that 'make defconfig kvmconfig' works - The cc-ifversion macro got support for an else-branch * 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: kbuild,gcov: simplify kernel/gcov/Makefile more kbuild: allow cc-ifversion to have the argument for false condition kbuild,gcov: simplify kernel/gcov/Makefile kbuild,gcov: remove unnecessary workaround kbuild: do not add $(call ...) to invoke cc-version or cc-fullversion kbuild: fix cc-ifversion macro kbuild: drop $(version_h) from MRPROPER_FILES kbuild: use mixed-targets when two or more config targets are given kbuild: remove redundant line from bounds.h/asm-offsets.h kbuild: merge bounds.h and asm-offsets.h rules kbuild: Drop support for clean-rule
-rw-r--r--Documentation/kbuild/makefiles.txt9
-rw-r--r--Kbuild61
-rw-r--r--Makefile4
-rw-r--r--arch/parisc/Makefile2
-rw-r--r--arch/powerpc/Makefile6
-rw-r--r--arch/x86/Makefile.um2
-rw-r--r--kernel/gcov/Makefile36
-rw-r--r--scripts/Kbuild.include7
-rw-r--r--scripts/Makefile.clean3
9 files changed, 40 insertions, 90 deletions
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index a311db829e9b..a64f3c6e2012 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -524,15 +524,16 @@ more details, with real examples.
524 Example: 524 Example:
525 #arch/x86/Makefile 525 #arch/x86/Makefile
526 cflags-y += $(shell \ 526 cflags-y += $(shell \
527 if [ $(call cc-version) -ge 0300 ] ; then \ 527 if [ $(cc-version) -ge 0300 ] ; then \
528 echo "-mregparm=3"; fi ;) 528 echo "-mregparm=3"; fi ;)
529 529
530 In the above example, -mregparm=3 is only used for gcc version greater 530 In the above example, -mregparm=3 is only used for gcc version greater
531 than or equal to gcc 3.0. 531 than or equal to gcc 3.0.
532 532
533 cc-ifversion 533 cc-ifversion
534 cc-ifversion tests the version of $(CC) and equals last argument if 534 cc-ifversion tests the version of $(CC) and equals the fourth parameter
535 version expression is true. 535 if version expression is true, or the fifth (if given) if the version
536 expression is false.
536 537
537 Example: 538 Example:
538 #fs/reiserfs/Makefile 539 #fs/reiserfs/Makefile
@@ -552,7 +553,7 @@ more details, with real examples.
552 553
553 Example: 554 Example:
554 #arch/powerpc/Makefile 555 #arch/powerpc/Makefile
555 $(Q)if test "$(call cc-fullversion)" = "040200" ; then \ 556 $(Q)if test "$(cc-fullversion)" = "040200" ; then \
556 echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \ 557 echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \
557 false ; \ 558 false ; \
558 fi 559 fi
diff --git a/Kbuild b/Kbuild
index b8b708ad6dc3..ab8ded92e870 100644
--- a/Kbuild
+++ b/Kbuild
@@ -5,24 +5,23 @@
5# 2) Generate asm-offsets.h (may need bounds.h) 5# 2) Generate asm-offsets.h (may need bounds.h)
6# 3) Check for missing system calls 6# 3) Check for missing system calls
7 7
8##### 8# Default sed regexp - multiline due to syntax constraints
9# 1) Generate bounds.h 9define sed-y
10 10 "/^->/{s:->#\(.*\):/* \1 */:; \
11bounds-file := include/generated/bounds.h 11 s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
12 12 s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
13always := $(bounds-file) 13 s:->::; p;}"
14targets := $(bounds-file) kernel/bounds.s 14endef
15 15
16quiet_cmd_bounds = GEN $@ 16quiet_cmd_offsets = GEN $@
17define cmd_bounds 17define cmd_offsets
18 (set -e; \ 18 (set -e; \
19 echo "#ifndef __LINUX_BOUNDS_H__"; \ 19 echo "#ifndef $2"; \
20 echo "#define __LINUX_BOUNDS_H__"; \ 20 echo "#define $2"; \
21 echo "/*"; \ 21 echo "/*"; \
22 echo " * DO NOT MODIFY."; \ 22 echo " * DO NOT MODIFY."; \
23 echo " *"; \ 23 echo " *"; \
24 echo " * This file was generated by Kbuild"; \ 24 echo " * This file was generated by Kbuild"; \
25 echo " *"; \
26 echo " */"; \ 25 echo " */"; \
27 echo ""; \ 26 echo ""; \
28 sed -ne $(sed-y) $<; \ 27 sed -ne $(sed-y) $<; \
@@ -30,6 +29,14 @@ define cmd_bounds
30 echo "#endif" ) > $@ 29 echo "#endif" ) > $@
31endef 30endef
32 31
32#####
33# 1) Generate bounds.h
34
35bounds-file := include/generated/bounds.h
36
37always := $(bounds-file)
38targets := $(bounds-file) kernel/bounds.s
39
33# We use internal kbuild rules to avoid the "is up to date" message from make 40# We use internal kbuild rules to avoid the "is up to date" message from make
34kernel/bounds.s: kernel/bounds.c FORCE 41kernel/bounds.s: kernel/bounds.c FORCE
35 $(Q)mkdir -p $(dir $@) 42 $(Q)mkdir -p $(dir $@)
@@ -37,7 +44,7 @@ kernel/bounds.s: kernel/bounds.c FORCE
37 44
38$(obj)/$(bounds-file): kernel/bounds.s Kbuild 45$(obj)/$(bounds-file): kernel/bounds.s Kbuild
39 $(Q)mkdir -p $(dir $@) 46 $(Q)mkdir -p $(dir $@)
40 $(call cmd,bounds) 47 $(call cmd,offsets,__LINUX_BOUNDS_H__)
41 48
42##### 49#####
43# 2) Generate asm-offsets.h 50# 2) Generate asm-offsets.h
@@ -49,32 +56,6 @@ always += $(offsets-file)
49targets += $(offsets-file) 56targets += $(offsets-file)
50targets += arch/$(SRCARCH)/kernel/asm-offsets.s 57targets += arch/$(SRCARCH)/kernel/asm-offsets.s
51 58
52
53# Default sed regexp - multiline due to syntax constraints
54define sed-y
55 "/^->/{s:->#\(.*\):/* \1 */:; \
56 s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
57 s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
58 s:->::; p;}"
59endef
60
61quiet_cmd_offsets = GEN $@
62define cmd_offsets
63 (set -e; \
64 echo "#ifndef __ASM_OFFSETS_H__"; \
65 echo "#define __ASM_OFFSETS_H__"; \
66 echo "/*"; \
67 echo " * DO NOT MODIFY."; \
68 echo " *"; \
69 echo " * This file was generated by Kbuild"; \
70 echo " *"; \
71 echo " */"; \
72 echo ""; \
73 sed -ne $(sed-y) $<; \
74 echo ""; \
75 echo "#endif" ) > $@
76endef
77
78# We use internal kbuild rules to avoid the "is up to date" message from make 59# We use internal kbuild rules to avoid the "is up to date" message from make
79arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ 60arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
80 $(obj)/$(bounds-file) FORCE 61 $(obj)/$(bounds-file) FORCE
@@ -82,7 +63,7 @@ arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
82 $(call if_changed_dep,cc_s_c) 63 $(call if_changed_dep,cc_s_c)
83 64
84$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild 65$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild
85 $(call cmd,offsets) 66 $(call cmd,offsets,__ASM_OFFSETS_H__)
86 67
87##### 68#####
88# 3) Check for missing system calls 69# 3) Check for missing system calls
diff --git a/Makefile b/Makefile
index dd8796caa239..19e256ae2679 100644
--- a/Makefile
+++ b/Makefile
@@ -502,7 +502,7 @@ endif
502ifeq ($(KBUILD_EXTMOD),) 502ifeq ($(KBUILD_EXTMOD),)
503 ifneq ($(filter config %config,$(MAKECMDGOALS)),) 503 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
504 config-targets := 1 504 config-targets := 1
505 ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) 505 ifneq ($(words $(MAKECMDGOALS)),1)
506 mixed-targets := 1 506 mixed-targets := 1
507 endif 507 endif
508 endif 508 endif
@@ -1180,7 +1180,7 @@ CLEAN_DIRS += $(MODVERDIR)
1180# Directories & files removed with 'make mrproper' 1180# Directories & files removed with 'make mrproper'
1181MRPROPER_DIRS += include/config usr/include include/generated \ 1181MRPROPER_DIRS += include/config usr/include include/generated \
1182 arch/*/include/generated .tmp_objdiff 1182 arch/*/include/generated .tmp_objdiff
1183MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \ 1183MRPROPER_FILES += .config .config.old .version .old_version \
1184 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ 1184 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
1185 signing_key.priv signing_key.x509 x509.genkey \ 1185 signing_key.priv signing_key.x509 x509.genkey \
1186 extra_certificates signing_key.x509.keyid \ 1186 extra_certificates signing_key.x509.keyid \
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 91fbb6ee702c..965a0999fc4c 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -148,7 +148,7 @@ endef
148# we require gcc 3.3 or above to compile the kernel 148# we require gcc 3.3 or above to compile the kernel
149archprepare: checkbin 149archprepare: checkbin
150checkbin: 150checkbin:
151 @if test "$(call cc-version)" -lt "0303"; then \ 151 @if test "$(cc-version)" -lt "0303"; then \
152 echo -n "Sorry, GCC v3.3 or above is required to build " ; \ 152 echo -n "Sorry, GCC v3.3 or above is required to build " ; \
153 echo "the kernel." ; \ 153 echo "the kernel." ; \
154 false ; \ 154 false ; \
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 132d9c681d6a..fc502e042438 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -314,7 +314,7 @@ TOUT := .tmp_gas_check
314# - Require gcc 4.0 or above on 64-bit 314# - Require gcc 4.0 or above on 64-bit
315# - gcc-4.2.0 has issues compiling modules on 64-bit 315# - gcc-4.2.0 has issues compiling modules on 64-bit
316checkbin: 316checkbin:
317 @if test "$(call cc-version)" = "0304" ; then \ 317 @if test "$(cc-version)" = "0304" ; then \
318 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \ 318 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \
319 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \ 319 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \
320 echo 'correctly with gcc-3.4 and your version of binutils.'; \ 320 echo 'correctly with gcc-3.4 and your version of binutils.'; \
@@ -322,13 +322,13 @@ checkbin:
322 false; \ 322 false; \
323 fi ; \ 323 fi ; \
324 fi 324 fi
325 @if test "$(call cc-version)" -lt "0400" \ 325 @if test "$(cc-version)" -lt "0400" \
326 && test "x${CONFIG_PPC64}" = "xy" ; then \ 326 && test "x${CONFIG_PPC64}" = "xy" ; then \
327 echo -n "Sorry, GCC v4.0 or above is required to build " ; \ 327 echo -n "Sorry, GCC v4.0 or above is required to build " ; \
328 echo "the 64-bit powerpc kernel." ; \ 328 echo "the 64-bit powerpc kernel." ; \
329 false ; \ 329 false ; \
330 fi 330 fi
331 @if test "$(call cc-fullversion)" = "040200" \ 331 @if test "$(cc-fullversion)" = "040200" \
332 && test "x${CONFIG_MODULES}${CONFIG_PPC64}" = "xyy" ; then \ 332 && test "x${CONFIG_MODULES}${CONFIG_PPC64}" = "xyy" ; then \
333 echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \ 333 echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \
334 echo 'kernel with modules enabled.' ; \ 334 echo 'kernel with modules enabled.' ; \
diff --git a/arch/x86/Makefile.um b/arch/x86/Makefile.um
index 36b62bc52638..95eba554baf9 100644
--- a/arch/x86/Makefile.um
+++ b/arch/x86/Makefile.um
@@ -30,7 +30,7 @@ cflags-y += -ffreestanding
30# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use 30# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
31# a lot more stack due to the lack of sharing of stacklots. Also, gcc 31# a lot more stack due to the lack of sharing of stacklots. Also, gcc
32# 4.3.0 needs -funit-at-a-time for extern inline functions. 32# 4.3.0 needs -funit-at-a-time for extern inline functions.
33KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then \ 33KBUILD_CFLAGS += $(shell if [ $(cc-version) -lt 0400 ] ; then \
34 echo $(call cc-option,-fno-unit-at-a-time); \ 34 echo $(call cc-option,-fno-unit-at-a-time); \
35 else echo $(call cc-option,-funit-at-a-time); fi ;) 35 else echo $(call cc-option,-funit-at-a-time); fi ;)
36 36
diff --git a/kernel/gcov/Makefile b/kernel/gcov/Makefile
index 52aa7e8de927..752d6486b67e 100644
--- a/kernel/gcov/Makefile
+++ b/kernel/gcov/Makefile
@@ -1,33 +1,7 @@
1ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"' 1ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"'
2 2
3# if-lt 3obj-y := base.o fs.o
4# Usage VAR := $(call if-lt, $(a), $(b)) 4obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_3_4.o
5# Returns 1 if (a < b) 5obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_4_7.o
6if-lt = $(shell [ $(1) -lt $(2) ] && echo 1) 6obj-$(CONFIG_GCOV_FORMAT_AUTODETECT) += $(call cc-ifversion, -lt, 0407, \
7 7 gcc_3_4.o, gcc_4_7.o)
8ifeq ($(CONFIG_GCOV_FORMAT_3_4),y)
9 cc-ver := 0304
10else ifeq ($(CONFIG_GCOV_FORMAT_4_7),y)
11 cc-ver := 0407
12else
13# Use cc-version if available, otherwise set 0
14#
15# scripts/Kbuild.include, which contains cc-version function, is not included
16# during make clean "make -f scripts/Makefile.clean obj=kernel/gcov"
17# Meaning cc-ver is empty causing if-lt test to fail with
18# "/bin/sh: line 0: [: -lt: unary operator expected" error mesage.
19# This has no affect on the clean phase, but the error message could be
20# confusing/annoying. So this dummy workaround sets cc-ver to zero if cc-version
21# is not available. We can probably move if-lt to Kbuild.include, so it's also
22# not defined during clean or to include Kbuild.include in
23# scripts/Makefile.clean. But the following workaround seems least invasive.
24 cc-ver := $(if $(call cc-version),$(call cc-version),0)
25endif
26
27obj-$(CONFIG_GCOV_KERNEL) := base.o fs.o
28
29ifeq ($(call if-lt, $(cc-ver), 0407),1)
30 obj-$(CONFIG_GCOV_KERNEL) += gcc_3_4.o
31else
32 obj-$(CONFIG_GCOV_KERNEL) += gcc_4_7.o
33endif
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index edd2794569db..d3437b82ac25 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -129,17 +129,15 @@ cc-disable-warning = $(call try-run,\
129 $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) 129 $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
130 130
131# cc-version 131# cc-version
132# Usage gcc-ver := $(call cc-version)
133cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) 132cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
134 133
135# cc-fullversion 134# cc-fullversion
136# Usage gcc-ver := $(call cc-fullversion)
137cc-fullversion = $(shell $(CONFIG_SHELL) \ 135cc-fullversion = $(shell $(CONFIG_SHELL) \
138 $(srctree)/scripts/gcc-version.sh -p $(CC)) 136 $(srctree)/scripts/gcc-version.sh -p $(CC))
139 137
140# cc-ifversion 138# cc-ifversion
141# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) 139# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
142cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3)) 140cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4))
143 141
144# cc-ldoption 142# cc-ldoption
145# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) 143# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
@@ -157,13 +155,12 @@ ld-option = $(call try-run,\
157ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) 155ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
158 156
159# ld-version 157# ld-version
160# Usage: $(call ld-version)
161# Note this is mainly for HJ Lu's 3 number binutil versions 158# Note this is mainly for HJ Lu's 3 number binutil versions
162ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) 159ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)
163 160
164# ld-ifversion 161# ld-ifversion
165# Usage: $(call ld-ifversion, -ge, 22252, y) 162# Usage: $(call ld-ifversion, -ge, 22252, y)
166ld-ifversion = $(shell [ $(call ld-version) $(1) $(2) ] && echo $(3)) 163ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4))
167 164
168###### 165######
169 166
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 627f8cbbedb8..55c96cb8070f 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -71,9 +71,6 @@ endif
71ifneq ($(strip $(__clean-dirs)),) 71ifneq ($(strip $(__clean-dirs)),)
72 +$(call cmd,cleandir) 72 +$(call cmd,cleandir)
73endif 73endif
74ifneq ($(strip $(clean-rule)),)
75 +$(clean-rule)
76endif
77 @: 74 @:
78 75
79 76