From a86fe3537350613c0181ce936884036a9695ceea Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 14 Apr 2014 18:27:10 +0900 Subject: kbuild: move extra gcc checks to scripts/Makefile.extrawarn W=... provides extra gcc checks. Having such code in scripts/Makefile.build results in the same flags being added to KBUILD_CFLAGS multiple times becuase scripts/Makefile.build is invoked every time Kbuild descends into the subdirectories. Since the top Makefile is already too cluttered, this commit moves all of extra gcc check stuff to a new file scripts/Makefile.extrawarn, which is included from the top Makefile. Signed-off-by: Masahiro Yamada CC: Sam Ravnborg Signed-off-by: Michal Marek --- Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 60ccbfe750a2..8cc826a504ec 100644 --- a/Makefile +++ b/Makefile @@ -105,10 +105,6 @@ ifeq ("$(origin O)", "command line") KBUILD_OUTPUT := $(O) endif -ifeq ("$(origin W)", "command line") - export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W) -endif - # That's our default target when none is given on the command line PHONY := _all _all: @@ -731,6 +727,8 @@ ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y) KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO endif +include $(srctree)/scripts/Makefile.extrawarn + # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments KBUILD_CPPFLAGS += $(KCPPFLAGS) KBUILD_AFLAGS += $(KAFLAGS) -- cgit v1.2.3 From 9319f4539c18ada539d37a1b4398c636b877c027 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 9 Apr 2014 15:51:35 +0900 Subject: kbuild: support simultaneous "make %config" and "make all" Kbuild is supposed to support mixed targets. (%config and build targets) But "make all" did nothing if it was run with configuration targets. For example, $ LANG=C make defconfig all HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/zconf.lex.c SHIPPED scripts/kconfig/zconf.hash.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf *** Default configuration is based on 'x86_64_defconfig' # # configuration written to .config # make: Nothing to be done for `all'. This commits allows "make %config all" and makes sure mixed targets are built one by one in the given order. Signed-off-by: Masahiro Yamada Cc: Michal Marek CC: Sam Ravnborg Signed-off-by: Michal Marek --- Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 8cc826a504ec..c7381ed4b690 100644 --- a/Makefile +++ b/Makefile @@ -500,8 +500,16 @@ ifeq ($(mixed-targets),1) # We're called with mixed targets (*config and build targets). # Handle them one by one. -%:: FORCE - $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= $@ +PHONY += $(MAKECMDGOALS) __build_one_by_one + +$(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one + @: + +__build_one_by_one: + $(Q)set -e; \ + for i in $(MAKECMDGOALS); do \ + $(MAKE) -f $(srctree)/Makefile $$i; \ + done else ifeq ($(config-targets),1) -- cgit v1.2.3 From 38385f8f0180322513a6350234737fbc02172d06 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 28 Apr 2014 16:26:18 +0900 Subject: kbuild: trivial - remove trailing spaces Signed-off-by: Masahiro Yamada Signed-off-by: Michal Marek --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c7381ed4b690..1571fdfaf154 100644 --- a/Makefile +++ b/Makefile @@ -162,7 +162,7 @@ export srctree objtree VPATH # SUBARCH tells the usermode build what the underlying arch is. That is set # first, and if a usermode build is happening, the "ARCH=um" on the command # line overrides the setting of ARCH below. If a native build is happening, -# then ARCH is assigned, getting whatever value it gets normally, and +# then ARCH is assigned, getting whatever value it gets normally, and # SUBARCH is subsequently ignored. SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ @@ -290,7 +290,7 @@ export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< # # If $(quiet) is empty, the whole command will be printed. -# If it is set to "quiet_", only the short version will be printed. +# If it is set to "quiet_", only the short version will be printed. # If it is set to "silent_", nothing will be printed at all, since # the variable $(silent_cmd_cc_o_c) doesn't exist. # @@ -869,7 +869,7 @@ ifdef CONFIG_BUILD_DOCSRC endif +$(call if_changed,link-vmlinux) -# The actual objects are generated when descending, +# The actual objects are generated when descending, # make sure no implicit rule kicks in $(sort $(vmlinux-deps)): $(vmlinux-dirs) ; @@ -1484,7 +1484,7 @@ endif $(build)=$(build-dir) $(@:.ko=.o) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost -# FIXME Should go into a make.lib or something +# FIXME Should go into a make.lib or something # =========================================================================== quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) -- cgit v1.2.3 From 3fbb43df983acf6f10a122e43e73daf6528ad7ed Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 28 Apr 2014 16:32:43 +0900 Subject: kbuild: trivial - fix comment block indent Signed-off-by: Masahiro Yamada Signed-off-by: Michal Marek --- Makefile | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 1571fdfaf154..d25c7de06d59 100644 --- a/Makefile +++ b/Makefile @@ -255,18 +255,18 @@ endif KBUILD_MODULES := KBUILD_BUILTIN := 1 -# If we have only "make modules", don't compile built-in objects. -# When we're building modules with modversions, we need to consider -# the built-in objects during the descend as well, in order to -# make sure the checksums are up to date before we record them. +# If we have only "make modules", don't compile built-in objects. +# When we're building modules with modversions, we need to consider +# the built-in objects during the descend as well, in order to +# make sure the checksums are up to date before we record them. ifeq ($(MAKECMDGOALS),modules) KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) endif -# If we have "make modules", compile modules -# in addition to whatever we do anyway. -# Just "make" or "make all" shall build modules as well +# If we have "make modules", compile modules +# in addition to whatever we do anyway. +# Just "make" or "make all" shall build modules as well ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) KBUILD_MODULES := 1 @@ -342,7 +342,6 @@ $(srctree)/scripts/Kbuild.include: ; include $(srctree)/scripts/Kbuild.include # Make variables (CC, etc...) - AS = $(CROSS_COMPILE)as LD = $(CROSS_COMPILE)ld CC = $(CROSS_COMPILE)gcc @@ -781,10 +780,10 @@ MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) export MODLIB # -# INSTALL_MOD_STRIP, if defined, will cause modules to be -# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then -# the default option --strip-debug will be used. Otherwise, -# INSTALL_MOD_STRIP value will be used as the options to the strip command. +# INSTALL_MOD_STRIP, if defined, will cause modules to be +# stripped after they are installed. If INSTALL_MOD_STRIP is '1', then +# the default option --strip-debug will be used. Otherwise, +# INSTALL_MOD_STRIP value will be used as the options to the strip command. ifdef INSTALL_MOD_STRIP ifeq ($(INSTALL_MOD_STRIP),1) @@ -1027,11 +1026,11 @@ ifdef CONFIG_MODULES all: modules -# Build modules +# Build modules # -# A module can be listed more than once in obj-m resulting in -# duplicate lines in modules.order files. Those are removed -# using awk while concatenating to the final file. +# A module can be listed more than once in obj-m resulting in +# duplicate lines in modules.order files. Those are removed +# using awk while concatenating to the final file. PHONY += modules modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin @@ -1110,7 +1109,7 @@ CLEAN_DIRS += $(MODVERDIR) # Directories & files removed with 'make mrproper' 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) \ Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ signing_key.priv signing_key.x509 x509.genkey \ -- cgit v1.2.3 From 7e1c04779efd51154baf652e653ceb24ce68939b Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Fri, 25 Apr 2014 17:29:45 +0200 Subject: kbuild: Use relative path for $(objtree) The main Makefile sets its working directory to the object tree and never changes it again. Therefore, we can use '.' instead of the absolute path. The only case where we need the absolute path is when creating the 'build' symlink in /lib/modules. Acked-by: Sam Ravnborg Signed-off-by: Michal Marek --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index d25c7de06d59..dec0845c07af 100644 --- a/Makefile +++ b/Makefile @@ -150,7 +150,7 @@ _all: modules endif srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) -objtree := $(CURDIR) +objtree := . src := $(srctree) obj := $(objtree) @@ -1062,7 +1062,7 @@ _modinst_: @ln -s $(srctree) $(MODLIB)/source @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ rm -f $(MODLIB)/build ; \ - ln -s $(objtree) $(MODLIB)/build ; \ + ln -s $(CURDIR) $(MODLIB)/build ; \ fi @cp -f $(objtree)/modules.order $(MODLIB)/ @cp -f $(objtree)/modules.builtin $(MODLIB)/ -- cgit v1.2.3 From 890676c65d699db3ad82e7dddd0cf8fb449031af Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Fri, 25 Apr 2014 17:36:14 +0200 Subject: kbuild: Use relative path when building in the source tree When not using O=, $(srctree) refers to the same directory as $(objtree), so we can set it to '.' as well. This makes the default include path more compact and results in more readable messages from the compiler. The only case where we need the absolute path is when creating the 'source' symlink in /lib/modules. Acked-by: Sam Ravnborg Signed-off-by: Michal Marek --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index dec0845c07af..3e134ec4c3d3 100644 --- a/Makefile +++ b/Makefile @@ -149,7 +149,7 @@ else _all: modules endif -srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) +srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),.) objtree := . src := $(srctree) obj := $(objtree) @@ -1059,7 +1059,7 @@ _modinst_: @rm -rf $(MODLIB)/kernel @rm -f $(MODLIB)/source @mkdir -p $(MODLIB)/kernel - @ln -s $(srctree) $(MODLIB)/source + @ln -s `cd $(srctree) && /bin/pwd` $(MODLIB)/source @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ rm -f $(MODLIB)/build ; \ ln -s $(CURDIR) $(MODLIB)/build ; \ -- cgit v1.2.3 From 9da0763bdd82572be243fcf5161734f11568960f Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Fri, 25 Apr 2014 23:25:18 +0200 Subject: kbuild: Use relative path when building in a subdir of the source tree When doing make O=, use '..' to refer to the source tree. This allows for more readable compiler messages, and, more importantly, it sets the VPATH to '..', so filenames in WARN_ON() etc. will be shorter. Acked-by: Sam Ravnborg Signed-off-by: Michal Marek --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3e134ec4c3d3..f4702c10b2b8 100644 --- a/Makefile +++ b/Makefile @@ -149,7 +149,17 @@ else _all: modules endif -srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),.) +ifeq ($(KBUILD_SRC),) + # building in the source tree + srctree := . +else + ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR))) + # building in a subdirectory of the source tree + srctree := .. + else + srctree := $(KBUILD_SRC) + endif +endif objtree := . src := $(srctree) obj := $(objtree) -- cgit v1.2.3 From a1c48bb160f8368ea9668a1ff98513631fa0d87a Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 27 May 2014 09:54:12 +0200 Subject: Makefile: Fix unrecognized cross-compiler command line options On architectures that setup CROSS_COMPILE in their arch/*/Makefile (arc, blackfin, m68k, mips, parisc, score, sh, tile, unicore32, xtensa), cc-option and cc-disable-warning may check against the wrong compiler, causing errors like cc1: error: unrecognized command line option "-Wno-maybe-uninitialized" if the host gcc supports a compiler option, while the cross compiler doesn't support that option. Move all logic using cc-option or cc-disable-warning below the inclusion of the arch's Makefile to fix this. Introduced by - commit e74fc973b6e531fef1fce8b101ffff05ecfb774c ("Turn off -Wmaybe-uninitialized when building with -Os"), - commit 61163efae02040f66a95c8ed17f4407951ba58fa ("kbuild: LLVMLinux: Add Kbuild support for building kernel with Clang"). As -Wno-maybe-uninitialized requires a quite recent gcc (gcc 4.6.3 on Ubuntu 12.04 LTS doesn't support it), this only showed up recently (gcc 4.8.2 on Ubuntu 14.04 LTS does support it). Signed-off-by: Geert Uytterhoeven Signed-off-by: Michal Marek --- Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f4702c10b2b8..8a0de808bafc 100644 --- a/Makefile +++ b/Makefile @@ -400,8 +400,8 @@ KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ -fno-strict-aliasing -fno-common \ -Werror-implicit-function-declaration \ - -Wno-format-security \ - $(call cc-option,-fno-delete-null-pointer-checks,) + -Wno-format-security + KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := KBUILD_AFLAGS := -D__ASSEMBLY__ @@ -607,14 +607,16 @@ endif # $(dot-config) # Defaults to vmlinux, but the arch makefile usually adds further targets all: vmlinux +include $(srctree)/arch/$(SRCARCH)/Makefile + +KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) + ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) else KBUILD_CFLAGS += -O2 endif -include $(srctree)/arch/$(SRCARCH)/Makefile - ifdef CONFIG_READABLE_ASM # Disable optimizations that make assembler listings hard to read. # reorder blocks reorders the control in the function -- cgit v1.2.3 From 356db564fbdfb1aa82f9c1c842947c1e0127d12f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 29 May 2014 14:33:02 +0900 Subject: kbuild: do not create include/linux directory There are no generated files under include/linux directory. Signed-off-by: Masahiro Yamada Signed-off-by: Michal Marek --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 8a0de808bafc..c126a2f4eb5e 100644 --- a/Makefile +++ b/Makefile @@ -533,11 +533,11 @@ include $(srctree)/arch/$(SRCARCH)/Makefile export KBUILD_DEFCONFIG KBUILD_KCONFIG config: scripts_basic outputmakefile FORCE - $(Q)mkdir -p include/linux include/config + $(Q)mkdir -p include/config $(Q)$(MAKE) $(build)=scripts/kconfig $@ %config: scripts_basic outputmakefile FORCE - $(Q)mkdir -p include/linux include/config + $(Q)mkdir -p include/config $(Q)$(MAKE) $(build)=scripts/kconfig $@ else -- cgit v1.2.3 From 9815594a780404810c2a6280de1a268dcfcb0729 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 29 May 2014 14:33:03 +0900 Subject: kbuild: create include/config directory in scripts/kconfig/Makefile The directory include/config is used only for silentoldconfig, localmodconfig, localyesconfig. Signed-off-by: Masahiro Yamada Signed-off-by: Michal Marek --- Makefile | 2 -- 1 file changed, 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index c126a2f4eb5e..20c3379ac1ec 100644 --- a/Makefile +++ b/Makefile @@ -533,11 +533,9 @@ include $(srctree)/arch/$(SRCARCH)/Makefile export KBUILD_DEFCONFIG KBUILD_KCONFIG config: scripts_basic outputmakefile FORCE - $(Q)mkdir -p include/config $(Q)$(MAKE) $(build)=scripts/kconfig $@ %config: scripts_basic outputmakefile FORCE - $(Q)mkdir -p include/config $(Q)$(MAKE) $(build)=scripts/kconfig $@ else -- cgit v1.2.3