Merge tag 'kbuild-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada:

- Use Make-builtin $(abspath ...) helper to get absolute path

- Add W=2 extra warning option to detect unused macros

- Use more KCONFIG_CONFIG instead hard-coded .config

- Fix bugs of tar*-pkg targets

* tag 'kbuild-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
kbuild: buildtar: do not print successful message if tar returns error
kbuild: buildtar: fix tar error when CONFIG_MODULES is disabled
kbuild: Use KCONFIG_CONFIG in buildtar
Kbuild: enable -Wunused-macros warning for "make W=2"
kbuild: use $(abspath ...) instead of $(shell cd ... && /bin/pwd)

+29 -30
+6 -6
Makefile
··· 130 ifneq ($(KBUILD_OUTPUT),) 131 # check that the output directory actually exists 132 saved-output := $(KBUILD_OUTPUT) 133 - KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ 134 - && /bin/pwd) 135 $(if $(KBUILD_OUTPUT),, \ 136 $(error failed to create output directory "$(saved-output)")) 137 ··· 978 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check 979 endif 980 ifdef CONFIG_GDB_SCRIPTS 981 - $(Q)ln -fsn `cd $(srctree) && /bin/pwd`/scripts/gdb/vmlinux-gdb.py 982 endif 983 ifdef CONFIG_TRIM_UNUSED_KSYMS 984 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ ··· 1238 @rm -rf $(MODLIB)/kernel 1239 @rm -f $(MODLIB)/source 1240 @mkdir -p $(MODLIB)/kernel 1241 - @ln -s `cd $(srctree) && /bin/pwd` $(MODLIB)/source 1242 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ 1243 rm -f $(MODLIB)/build ; \ 1244 ln -s $(CURDIR) $(MODLIB)/build ; \ ··· 1630 # Clear a bunch of variables before executing the submake 1631 tools/: FORCE 1632 $(Q)mkdir -p $(objtree)/tools 1633 - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ 1634 1635 tools/%: FORCE 1636 $(Q)mkdir -p $(objtree)/tools 1637 - $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(shell cd $(objtree) && /bin/pwd) subdir=tools -C $(src)/tools/ $* 1638 1639 # Single targets 1640 # ---------------------------------------------------------------------------
··· 130 ifneq ($(KBUILD_OUTPUT),) 131 # check that the output directory actually exists 132 saved-output := $(KBUILD_OUTPUT) 133 + $(shell [ -d $(KBUILD_OUTPUT) ] || mkdir -p $(KBUILD_OUTPUT)) 134 + KBUILD_OUTPUT := $(realpath $(KBUILD_OUTPUT)) 135 $(if $(KBUILD_OUTPUT),, \ 136 $(error failed to create output directory "$(saved-output)")) 137 ··· 978 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check 979 endif 980 ifdef CONFIG_GDB_SCRIPTS 981 + $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) 982 endif 983 ifdef CONFIG_TRIM_UNUSED_KSYMS 984 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ ··· 1238 @rm -rf $(MODLIB)/kernel 1239 @rm -f $(MODLIB)/source 1240 @mkdir -p $(MODLIB)/kernel 1241 + @ln -s $(abspath $(srctree)) $(MODLIB)/source 1242 @if [ ! $(objtree) -ef $(MODLIB)/build ]; then \ 1243 rm -f $(MODLIB)/build ; \ 1244 ln -s $(CURDIR) $(MODLIB)/build ; \ ··· 1630 # Clear a bunch of variables before executing the submake 1631 tools/: FORCE 1632 $(Q)mkdir -p $(objtree)/tools 1633 + $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ 1634 1635 tools/%: FORCE 1636 $(Q)mkdir -p $(objtree)/tools 1637 + $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ $* 1638 1639 # Single targets 1640 # ---------------------------------------------------------------------------
+1
scripts/Makefile.extrawarn
··· 37 warning-2 += $(call cc-option, -Wmissing-field-initializers) 38 warning-2 += $(call cc-option, -Wsign-compare) 39 warning-2 += $(call cc-option, -Wmaybe-uninitialized) 40 41 warning-3 := -Wbad-function-cast 42 warning-3 += -Wcast-qual
··· 37 warning-2 += $(call cc-option, -Wmissing-field-initializers) 38 warning-2 += $(call cc-option, -Wsign-compare) 39 warning-2 += $(call cc-option, -Wmaybe-uninitialized) 40 + warning-2 += $(call cc-option, -Wunused-macros) 41 42 warning-3 := -Wbad-function-cast 43 warning-3 += -Wcast-qual
+1 -1
scripts/gdb/linux/Makefile
··· 1 always := gdb-scripts 2 3 - SRCTREE := $(shell cd $(srctree) && /bin/pwd) 4 5 $(obj)/gdb-scripts: 6 ifneq ($(KBUILD_SRC),)
··· 1 always := gdb-scripts 2 3 + SRCTREE := $(abspath $(srctree)) 4 5 $(obj)/gdb-scripts: 6 ifneq ($(KBUILD_SRC),)
+17 -19
scripts/package/buildtar
··· 24 # 25 case "${1}" in 26 tar-pkg) 27 - compress="cat" 28 - file_ext="" 29 ;; 30 targz-pkg) 31 - compress="gzip" 32 - file_ext=".gz" 33 ;; 34 tarbz2-pkg) 35 - compress="bzip2" 36 - file_ext=".bz2" 37 ;; 38 tarxz-pkg) 39 - compress="xz" 40 - file_ext=".xz" 41 ;; 42 *) 43 echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2 ··· 50 # 51 rm -rf -- "${tmpdir}" 52 mkdir -p -- "${tmpdir}/boot" 53 - 54 55 # 56 # Try to install modules 57 # 58 - if grep -q '^CONFIG_MODULES=y' "${objtree}/.config"; then 59 make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install 60 fi 61 62 ··· 65 # Install basic kernel files 66 # 67 cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}" 68 - cp -v -- "${objtree}/.config" "${tmpdir}/boot/config-${KERNELRELEASE}" 69 cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 70 71 ··· 124 # 125 # Create the tarball 126 # 127 - ( 128 - opts= 129 - if tar --owner=root --group=root --help >/dev/null 2>&1; then 130 - opts="--owner=root --group=root" 131 - fi 132 - tar cf - -C "$tmpdir" boot/ lib/ $opts | ${compress} > "${tarball}${file_ext}" 133 - ) 134 135 - echo "Tarball successfully created in ${tarball}${file_ext}" 136 137 exit 0
··· 24 # 25 case "${1}" in 26 tar-pkg) 27 + opts= 28 ;; 29 targz-pkg) 30 + opts=--gzip 31 + tarball=${tarball}.gz 32 ;; 33 tarbz2-pkg) 34 + opts=--bzip2 35 + tarball=${tarball}.bz2 36 ;; 37 tarxz-pkg) 38 + opts=--xz 39 + tarball=${tarball}.xz 40 ;; 41 *) 42 echo "Unknown tarball target \"${1}\" requested, please add it to ${0}." >&2 ··· 51 # 52 rm -rf -- "${tmpdir}" 53 mkdir -p -- "${tmpdir}/boot" 54 + dirs=boot 55 56 # 57 # Try to install modules 58 # 59 + if grep -q '^CONFIG_MODULES=y' "${KCONFIG_CONFIG}"; then 60 make ARCH="${ARCH}" O="${objtree}" KBUILD_SRC= INSTALL_MOD_PATH="${tmpdir}" modules_install 61 + dirs="$dirs lib" 62 fi 63 64 ··· 65 # Install basic kernel files 66 # 67 cp -v -- "${objtree}/System.map" "${tmpdir}/boot/System.map-${KERNELRELEASE}" 68 + cp -v -- "${KCONFIG_CONFIG}" "${tmpdir}/boot/config-${KERNELRELEASE}" 69 cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}" 70 71 ··· 124 # 125 # Create the tarball 126 # 127 + if tar --owner=root --group=root --help >/dev/null 2>&1; then 128 + opts="$opts --owner=root --group=root" 129 + fi 130 131 + tar cf $tarball -C $tmpdir $opts $dirs 132 + 133 + echo "Tarball successfully created in $tarball" 134 135 exit 0
+1 -1
tools/power/cpupower/Makefile
··· 26 27 ifneq ($(OUTPUT),) 28 # check that the output directory actually exists 29 - OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd) 30 $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) 31 endif 32
··· 26 27 ifneq ($(OUTPUT),) 28 # check that the output directory actually exists 29 + OUTDIR := $(realpath $(OUTPUT)) 30 $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) 31 endif 32
+3 -3
tools/scripts/Makefile.include
··· 1 ifneq ($(O),) 2 ifeq ($(origin O), command line) 3 - dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),) 4 - ABSOLUTE_O := $(shell cd $(O) ; pwd) 5 OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/) 6 COMMAND_O := O=$(ABSOLUTE_O) 7 ifeq ($(objtree),) ··· 12 13 # check that the output directory actually exists 14 ifneq ($(OUTPUT),) 15 - OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd) 16 $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) 17 endif 18
··· 1 ifneq ($(O),) 2 ifeq ($(origin O), command line) 3 + ABSOLUTE_O := $(realpath $(O)) 4 + dummy := $(if $(ABSOLUTE_O),,$(error O=$(O) does not exist)) 5 OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/) 6 COMMAND_O := O=$(ABSOLUTE_O) 7 ifeq ($(objtree),) ··· 12 13 # check that the output directory actually exists 14 ifneq ($(OUTPUT),) 15 + OUTDIR := $(realpath $(OUTPUT)) 16 $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) 17 endif 18