[lkml]   [2021]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 3/3] kbuild: Add a build check for missing gitignore entries
Any non-phony targets need to be in gitignore. The normal way to check
this is doing an in-tree build and running git-status which is easy to
miss. Git provides an easy way to check whether a file is ignored with
git-check-ignore. Let's add a build time check using it. If the build is
not in a git tree, the check will silently fail.

This also has the side effect of a sanity check for 'always-y',
'extra-y' and 'targets' entries which are not correctly marked as PHONY
or have the wrong path.

Cc: Masahiro Yamada <>
Cc: Michal Marek <>
Signed-off-by: Rob Herring <>
scripts/Makefile.lib | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index b00855b247e0..84ac8b74bbe9 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -103,6 +103,10 @@ real-obj-m := $(addprefix $(obj)/,$(real-obj-m))
multi-used-m := $(addprefix $(obj)/,$(multi-used-m))
subdir-ym := $(addprefix $(obj)/,$(subdir-ym))

+$(foreach f, $(filter-out $(patsubst %,$(obj)/%,$(PHONY)),$(extra-y) $(always-y) $(targets)), \
+ $(if $(shell git -C $(srctree) check-ignore -q $(f) 2> /dev/null || echo $(f)), \
+ $(warning $(f) is missing gitignore entry)))
# Finds the multi-part object the current object will be linked into.
# If the object belongs to two or more multi-part objects, list them all.
modname-multi = $(sort $(foreach m,$(multi-used),\
 \ /
  Last update: 2021-02-23 19:17    [W:0.066 / U:70.572 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site