Skip to contentSkip to conversation

kbuild: make distclean work against $(objtree) instead of $(srctree)

PATCH New Masahiro Yamada 1 participant 3 messages May 4, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 kbuild: make distclean work against $(objtree) instead of $(srctree)

This reverts the old commit [1], which seems questionable to me.

It claimed 'make distclean' could not remove editor backup files, but I believe KBUILD_OUTPUT or O= was set.

When O= is given, Kbuild should always work against $(objtree). If O= is not given, $(objtree) and $(srctree) are the same, therefore $(srctree) is cleaned up.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=dd47df980c02eb33833b2690b033c34fba2fa80d

---

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index cbf4b18cf51c..560408808c33 100644
@@ -1546,7 +1546,7 @@ PHONY += distclean
 
 distclean: mrproper
 	$(call cmd,rmfiles)
-	@find $(srctree) $(RCS_FIND_IGNORE) \
+	@find . $(RCS_FIND_IGNORE) \
 		\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
 		-o -name '*.bak' -o -name '#*#' -o -name '*%' \
 		-o -name 'core' \) \
Signature · 1 line
2.27.0
#1 lore raw

PATCH 2/3 kbuild: make distclean remove tag files in sub-directories

'make tags' and friends create tag files in the top directory, but people may manually create tag files in sub-directories.

---

 Makefile | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
Makefile +2 -7
index 560408808c33..2cbf68dc40b7 100644
@@ -1511,9 +1511,6 @@ MRPROPER_FILES += include/config include/generated          \
 		  signing_key.x509.signer vmlinux-gdb.py \
 		  *.spec
 
-# Directories & files removed with 'make distclean'
-DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
-
 # clean - Delete most, but leave enough to build external modules
 #
 clean: rm-files := $(CLEAN_FILES)
@@ -1540,16 +1537,14 @@ mrproper: clean $(mrproper-dirs)
 
 # distclean
 #
-distclean: rm-files := $(wildcard $(DISTCLEAN_FILES))
-
 PHONY += distclean
 
 distclean: mrproper
-	$(call cmd,rmfiles)
 	@find . $(RCS_FIND_IGNORE) \
 		\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
 		-o -name '*.bak' -o -name '#*#' -o -name '*%' \
-		-o -name 'core' \) \
+		-o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \
+		-o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \
 		-type f -print | xargs rm -f
 
 
Signature · 1 line
2.27.0
#2 lore raw

PATCH 3/3 kbuild: remove the unneeded comments for external module builds

In reply to Masahiro Yamada

The supported targets for external modules are listed in the help target a few lines below. Let's not have duplicated information in two places.

---

 Makefile | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
Makefile +1 -11
index 2cbf68dc40b7..9b9a003bd88f 100644
@@ -1711,17 +1711,7 @@ else # KBUILD_EXTMOD
 # When building external modules the kernel used as basis is considered
 # read-only, and no consistency checks are made and the make
 # system is not used on the basis kernel. If updates are required
-# in the basis kernel ordinary make commands (without M=...) must
-# be used.
-#
-# The following are the only valid targets when building external
-# modules.
-# make M=dir clean     Delete all automatically generated files
-# make M=dir modules   Make all modules in specified dir
-# make M=dir	       Same as 'make M=dir modules'
-# make M=dir modules_install
-#                      Install the modules built in the module directory
-#                      Assumes install directory is already created
+# in the basis kernel ordinary make commands (without M=...) must be used.
 
 # We are always building only modules.
 KBUILD_BUILTIN :=
Signature · 1 line
2.27.0