Commit 27a22ee4 authored by Linus Torvalds's avatar Linus Torvalds

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
parents b2b89ebf a75f8b8d
...@@ -524,15 +524,16 @@ more details, with real examples. ...@@ -524,15 +524,16 @@ more details, with real examples.
Example: Example:
#arch/x86/Makefile #arch/x86/Makefile
cflags-y += $(shell \ cflags-y += $(shell \
if [ $(call cc-version) -ge 0300 ] ; then \ if [ $(cc-version) -ge 0300 ] ; then \
echo "-mregparm=3"; fi ;) echo "-mregparm=3"; fi ;)
In the above example, -mregparm=3 is only used for gcc version greater In the above example, -mregparm=3 is only used for gcc version greater
than or equal to gcc 3.0. than or equal to gcc 3.0.
cc-ifversion cc-ifversion
cc-ifversion tests the version of $(CC) and equals last argument if cc-ifversion tests the version of $(CC) and equals the fourth parameter
version expression is true. if version expression is true, or the fifth (if given) if the version
expression is false.
Example: Example:
#fs/reiserfs/Makefile #fs/reiserfs/Makefile
...@@ -552,7 +553,7 @@ more details, with real examples. ...@@ -552,7 +553,7 @@ more details, with real examples.
Example: Example:
#arch/powerpc/Makefile #arch/powerpc/Makefile
$(Q)if test "$(call cc-fullversion)" = "040200" ; then \ $(Q)if test "$(cc-fullversion)" = "040200" ; then \
echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \ echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \
false ; \ false ; \
fi fi
......
...@@ -5,24 +5,23 @@ ...@@ -5,24 +5,23 @@
# 2) Generate asm-offsets.h (may need bounds.h) # 2) Generate asm-offsets.h (may need bounds.h)
# 3) Check for missing system calls # 3) Check for missing system calls
##### # Default sed regexp - multiline due to syntax constraints
# 1) Generate bounds.h define sed-y
"/^->/{s:->#\(.*\):/* \1 */:; \
bounds-file := include/generated/bounds.h s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
always := $(bounds-file) s:->::; p;}"
targets := $(bounds-file) kernel/bounds.s endef
quiet_cmd_bounds = GEN $@ quiet_cmd_offsets = GEN $@
define cmd_bounds define cmd_offsets
(set -e; \ (set -e; \
echo "#ifndef __LINUX_BOUNDS_H__"; \ echo "#ifndef $2"; \
echo "#define __LINUX_BOUNDS_H__"; \ echo "#define $2"; \
echo "/*"; \ echo "/*"; \
echo " * DO NOT MODIFY."; \ echo " * DO NOT MODIFY."; \
echo " *"; \ echo " *"; \
echo " * This file was generated by Kbuild"; \ echo " * This file was generated by Kbuild"; \
echo " *"; \
echo " */"; \ echo " */"; \
echo ""; \ echo ""; \
sed -ne $(sed-y) $<; \ sed -ne $(sed-y) $<; \
...@@ -30,6 +29,14 @@ define cmd_bounds ...@@ -30,6 +29,14 @@ define cmd_bounds
echo "#endif" ) > $@ echo "#endif" ) > $@
endef endef
#####
# 1) Generate bounds.h
bounds-file := include/generated/bounds.h
always := $(bounds-file)
targets := $(bounds-file) kernel/bounds.s
# We use internal kbuild rules to avoid the "is up to date" message from make # We use internal kbuild rules to avoid the "is up to date" message from make
kernel/bounds.s: kernel/bounds.c FORCE kernel/bounds.s: kernel/bounds.c FORCE
$(Q)mkdir -p $(dir $@) $(Q)mkdir -p $(dir $@)
...@@ -37,7 +44,7 @@ kernel/bounds.s: kernel/bounds.c FORCE ...@@ -37,7 +44,7 @@ kernel/bounds.s: kernel/bounds.c FORCE
$(obj)/$(bounds-file): kernel/bounds.s Kbuild $(obj)/$(bounds-file): kernel/bounds.s Kbuild
$(Q)mkdir -p $(dir $@) $(Q)mkdir -p $(dir $@)
$(call cmd,bounds) $(call cmd,offsets,__LINUX_BOUNDS_H__)
##### #####
# 2) Generate asm-offsets.h # 2) Generate asm-offsets.h
...@@ -49,32 +56,6 @@ always += $(offsets-file) ...@@ -49,32 +56,6 @@ always += $(offsets-file)
targets += $(offsets-file) targets += $(offsets-file)
targets += arch/$(SRCARCH)/kernel/asm-offsets.s targets += arch/$(SRCARCH)/kernel/asm-offsets.s
# Default sed regexp - multiline due to syntax constraints
define sed-y
"/^->/{s:->#\(.*\):/* \1 */:; \
s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
s:->::; p;}"
endef
quiet_cmd_offsets = GEN $@
define cmd_offsets
(set -e; \
echo "#ifndef __ASM_OFFSETS_H__"; \
echo "#define __ASM_OFFSETS_H__"; \
echo "/*"; \
echo " * DO NOT MODIFY."; \
echo " *"; \
echo " * This file was generated by Kbuild"; \
echo " *"; \
echo " */"; \
echo ""; \
sed -ne $(sed-y) $<; \
echo ""; \
echo "#endif" ) > $@
endef
# We use internal kbuild rules to avoid the "is up to date" message from make # We use internal kbuild rules to avoid the "is up to date" message from make
arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
$(obj)/$(bounds-file) FORCE $(obj)/$(bounds-file) FORCE
...@@ -82,7 +63,7 @@ arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \ ...@@ -82,7 +63,7 @@ arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
$(call if_changed_dep,cc_s_c) $(call if_changed_dep,cc_s_c)
$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild
$(call cmd,offsets) $(call cmd,offsets,__ASM_OFFSETS_H__)
##### #####
# 3) Check for missing system calls # 3) Check for missing system calls
......
...@@ -502,7 +502,7 @@ endif ...@@ -502,7 +502,7 @@ endif
ifeq ($(KBUILD_EXTMOD),) ifeq ($(KBUILD_EXTMOD),)
ifneq ($(filter config %config,$(MAKECMDGOALS)),) ifneq ($(filter config %config,$(MAKECMDGOALS)),)
config-targets := 1 config-targets := 1
ifneq ($(filter-out config %config,$(MAKECMDGOALS)),) ifneq ($(words $(MAKECMDGOALS)),1)
mixed-targets := 1 mixed-targets := 1
endif endif
endif endif
...@@ -1180,7 +1180,7 @@ CLEAN_DIRS += $(MODVERDIR) ...@@ -1180,7 +1180,7 @@ CLEAN_DIRS += $(MODVERDIR)
# Directories & files removed with 'make mrproper' # Directories & files removed with 'make mrproper'
MRPROPER_DIRS += include/config usr/include include/generated \ MRPROPER_DIRS += include/config usr/include include/generated \
arch/*/include/generated .tmp_objdiff arch/*/include/generated .tmp_objdiff
MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \ MRPROPER_FILES += .config .config.old .version .old_version \
Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
signing_key.priv signing_key.x509 x509.genkey \ signing_key.priv signing_key.x509 x509.genkey \
extra_certificates signing_key.x509.keyid \ extra_certificates signing_key.x509.keyid \
......
...@@ -148,7 +148,7 @@ endef ...@@ -148,7 +148,7 @@ endef
# we require gcc 3.3 or above to compile the kernel # we require gcc 3.3 or above to compile the kernel
archprepare: checkbin archprepare: checkbin
checkbin: checkbin:
@if test "$(call cc-version)" -lt "0303"; then \ @if test "$(cc-version)" -lt "0303"; then \
echo -n "Sorry, GCC v3.3 or above is required to build " ; \ echo -n "Sorry, GCC v3.3 or above is required to build " ; \
echo "the kernel." ; \ echo "the kernel." ; \
false ; \ false ; \
......
...@@ -314,7 +314,7 @@ TOUT := .tmp_gas_check ...@@ -314,7 +314,7 @@ TOUT := .tmp_gas_check
# - Require gcc 4.0 or above on 64-bit # - Require gcc 4.0 or above on 64-bit
# - gcc-4.2.0 has issues compiling modules on 64-bit # - gcc-4.2.0 has issues compiling modules on 64-bit
checkbin: checkbin:
@if test "$(call cc-version)" = "0304" ; then \ @if test "$(cc-version)" = "0304" ; then \
if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \ if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \
echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \ echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \
echo 'correctly with gcc-3.4 and your version of binutils.'; \ echo 'correctly with gcc-3.4 and your version of binutils.'; \
...@@ -322,13 +322,13 @@ checkbin: ...@@ -322,13 +322,13 @@ checkbin:
false; \ false; \
fi ; \ fi ; \
fi fi
@if test "$(call cc-version)" -lt "0400" \ @if test "$(cc-version)" -lt "0400" \
&& test "x${CONFIG_PPC64}" = "xy" ; then \ && test "x${CONFIG_PPC64}" = "xy" ; then \
echo -n "Sorry, GCC v4.0 or above is required to build " ; \ echo -n "Sorry, GCC v4.0 or above is required to build " ; \
echo "the 64-bit powerpc kernel." ; \ echo "the 64-bit powerpc kernel." ; \
false ; \ false ; \
fi fi
@if test "$(call cc-fullversion)" = "040200" \ @if test "$(cc-fullversion)" = "040200" \
&& test "x${CONFIG_MODULES}${CONFIG_PPC64}" = "xyy" ; then \ && test "x${CONFIG_MODULES}${CONFIG_PPC64}" = "xyy" ; then \
echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \ echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \
echo 'kernel with modules enabled.' ; \ echo 'kernel with modules enabled.' ; \
......
...@@ -30,7 +30,7 @@ cflags-y += -ffreestanding ...@@ -30,7 +30,7 @@ cflags-y += -ffreestanding
# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
# a lot more stack due to the lack of sharing of stacklots. Also, gcc # a lot more stack due to the lack of sharing of stacklots. Also, gcc
# 4.3.0 needs -funit-at-a-time for extern inline functions. # 4.3.0 needs -funit-at-a-time for extern inline functions.
KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then \ KBUILD_CFLAGS += $(shell if [ $(cc-version) -lt 0400 ] ; then \
echo $(call cc-option,-fno-unit-at-a-time); \ echo $(call cc-option,-fno-unit-at-a-time); \
else echo $(call cc-option,-funit-at-a-time); fi ;) else echo $(call cc-option,-funit-at-a-time); fi ;)
......
ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"' ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"'
# if-lt obj-y := base.o fs.o
# Usage VAR := $(call if-lt, $(a), $(b)) obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_3_4.o
# Returns 1 if (a < b) obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_4_7.o
if-lt = $(shell [ $(1) -lt $(2) ] && echo 1) obj-$(CONFIG_GCOV_FORMAT_AUTODETECT) += $(call cc-ifversion, -lt, 0407, \
gcc_3_4.o, gcc_4_7.o)
ifeq ($(CONFIG_GCOV_FORMAT_3_4),y)
cc-ver := 0304
else ifeq ($(CONFIG_GCOV_FORMAT_4_7),y)
cc-ver := 0407
else
# Use cc-version if available, otherwise set 0
#
# scripts/Kbuild.include, which contains cc-version function, is not included
# during make clean "make -f scripts/Makefile.clean obj=kernel/gcov"
# Meaning cc-ver is empty causing if-lt test to fail with
# "/bin/sh: line 0: [: -lt: unary operator expected" error mesage.
# This has no affect on the clean phase, but the error message could be
# confusing/annoying. So this dummy workaround sets cc-ver to zero if cc-version
# is not available. We can probably move if-lt to Kbuild.include, so it's also
# not defined during clean or to include Kbuild.include in
# scripts/Makefile.clean. But the following workaround seems least invasive.
cc-ver := $(if $(call cc-version),$(call cc-version),0)
endif
obj-$(CONFIG_GCOV_KERNEL) := base.o fs.o
ifeq ($(call if-lt, $(cc-ver), 0407),1)
obj-$(CONFIG_GCOV_KERNEL) += gcc_3_4.o
else
obj-$(CONFIG_GCOV_KERNEL) += gcc_4_7.o
endif
...@@ -129,17 +129,15 @@ cc-disable-warning = $(call try-run,\ ...@@ -129,17 +129,15 @@ cc-disable-warning = $(call try-run,\
$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
# cc-version # cc-version
# Usage gcc-ver := $(call cc-version)
cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
# cc-fullversion # cc-fullversion
# Usage gcc-ver := $(call cc-fullversion)
cc-fullversion = $(shell $(CONFIG_SHELL) \ cc-fullversion = $(shell $(CONFIG_SHELL) \
$(srctree)/scripts/gcc-version.sh -p $(CC)) $(srctree)/scripts/gcc-version.sh -p $(CC))
# cc-ifversion # cc-ifversion
# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3)) cc-ifversion = $(shell [ $(cc-version) $(1) $(2) ] && echo $(3) || echo $(4))
# cc-ldoption # cc-ldoption
# Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both) # Usage: ldflags += $(call cc-ldoption, -Wl$(comma)--hash-style=both)
...@@ -157,13 +155,12 @@ ld-option = $(call try-run,\ ...@@ -157,13 +155,12 @@ ld-option = $(call try-run,\
ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
# ld-version # ld-version
# Usage: $(call ld-version)
# Note this is mainly for HJ Lu's 3 number binutil versions # Note this is mainly for HJ Lu's 3 number binutil versions
ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)
# ld-ifversion # ld-ifversion
# Usage: $(call ld-ifversion, -ge, 22252, y) # Usage: $(call ld-ifversion, -ge, 22252, y)
ld-ifversion = $(shell [ $(call ld-version) $(1) $(2) ] && echo $(3)) ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4))
###### ######
......
...@@ -70,9 +70,6 @@ ifneq ($(strip $(__clean-files)),) ...@@ -70,9 +70,6 @@ ifneq ($(strip $(__clean-files)),)
endif endif
ifneq ($(strip $(__clean-dirs)),) ifneq ($(strip $(__clean-dirs)),)
+$(call cmd,cleandir) +$(call cmd,cleandir)
endif
ifneq ($(strip $(clean-rule)),)
+$(clean-rule)
endif endif
@: @:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment