]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
kbuild: reduce output spam when building out of tree
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Thu, 5 Mar 2026 12:04:07 +0000 (13:04 +0100)
committerNicolas Schier <nsc@kernel.org>
Wed, 18 Mar 2026 19:59:00 +0000 (20:59 +0100)
The execution of $(call cmd,makefile) will print 'GEN Makefile' on each
build, even if the Makefile is not effectively changed.

Use a filechk command instead, so a message is only printed on changes.

The Makefile is now created even if the build is aborted due to an
unclean working tree. That should not make a difference in practice.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Link: https://patch.msgid.link/20260305-kbuild-makefile-spam-v1-1-910f6cf218a1@linutronix.de
Signed-off-by: Nicolas Schier <nsc@kernel.org>
Makefile

index 6b8e9fca2752d6967921bae7dc1e8c771433b6f4..a8d8ed711f9b3e3f1f109a34c71fbdbe2e883fde 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -675,14 +675,19 @@ print_env_for_makefile = \
        echo "export KBUILD_OUTPUT = $(CURDIR)"
 endif
 
-quiet_cmd_makefile = GEN     Makefile
-      cmd_makefile = { \
+filechk_makefile = { \
        echo "\# Automatically generated by $(abs_srctree)/Makefile: don't edit"; \
        $(print_env_for_makefile); \
        echo "include $(abs_srctree)/Makefile"; \
-       } > Makefile
+       }
 
-outputmakefile:
+$(objtree)/Makefile: FORCE
+       $(call filechk,makefile)
+
+# Prevent $(srcroot)/Makefile from inhibiting the rule to run.
+PHONY += $(objtree)/Makefile
+
+outputmakefile: $(objtree)/Makefile
 ifeq ($(KBUILD_EXTMOD),)
        @if [ -f $(srctree)/.config -o \
                 -d $(srctree)/include/config -o \
@@ -703,7 +708,6 @@ else
        fi
 endif
        $(Q)ln -fsn $(srcroot) source
-       $(call cmd,makefile)
        $(Q)test -e .gitignore || \
        { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore
 endif