Skip to content

Commit 1634f2b

Browse files
committed
kbuild: remove clean-dirs syntax
The only the difference between clean-files and clean-dirs is the -r option passed to the 'rm' command. You can always pass -r, and then remove the clean-dirs syntax. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent 36de077 commit 1634f2b

4 files changed

Lines changed: 8 additions & 30 deletions

File tree

‎Documentation/kbuild/makefiles.rst‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,8 @@ Files matching the patterns "*.[oas]", "*.ko", plus some additional files
750750
generated by kbuild are deleted all over the kernel src tree when
751751
"make clean" is executed.
752752

753-
Additional files can be specified in kbuild makefiles by use of $(clean-files).
753+
Additional files or directories can be specified in kbuild makefiles by use of
754+
$(clean-files).
754755

755756
Example::
756757

@@ -761,17 +762,8 @@ When executing "make clean", the file "crc32table.h" will be deleted.
761762
Kbuild will assume files to be in the same relative directory as the
762763
Makefile, except if prefixed with $(objtree).
763764

764-
To delete a directory hierarchy use:
765-
766-
Example::
767-
768-
#scripts/package/Makefile
769-
clean-dirs := $(objtree)/debian/
770-
771-
This will delete the directory debian in the toplevel directory, including all
772-
subdirectories.
773-
774-
To exclude certain files from make clean, use the $(no-clean-files) variable.
765+
To exclude certain files or directories from make clean, use the
766+
$(no-clean-files) variable.
775767

776768
Usually kbuild descends down in subdirectories due to "obj-* := dir/",
777769
but in the architecture makefiles where the kbuild infrastructure

‎scripts/Makefile.clean‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,14 @@ __clean-files := $(wildcard \
5252
$(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \
5353
$(filter $(objtree)/%, $(__clean-files)))
5454

55-
# same as clean-files
56-
57-
__clean-dirs := $(wildcard \
58-
$(addprefix $(obj)/, $(filter-out $(objtree)/%, $(clean-dirs))) \
59-
$(filter $(objtree)/%, $(clean-dirs)))
60-
6155
# ==========================================================================
6256

63-
quiet_cmd_clean = CLEAN $(obj)
64-
cmd_clean = rm -f $(__clean-files)
65-
quiet_cmd_cleandir = CLEAN $(__clean-dirs)
66-
cmd_cleandir = rm -rf $(__clean-dirs)
67-
57+
quiet_cmd_clean = CLEAN $(obj)
58+
cmd_clean = rm -rf $(__clean-files)
6859

6960
__clean: $(subdir-ymn)
7061
ifneq ($(strip $(__clean-files)),)
7162
+$(call cmd,clean)
72-
endif
73-
ifneq ($(strip $(__clean-dirs)),)
74-
+$(call cmd,cleandir)
7563
endif
7664
@:
7765

‎scripts/kconfig/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ testconfig: $(obj)/conf
114114
$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
115115
-o cache_dir=$(abspath $(obj)/tests/.cache) \
116116
$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
117-
clean-dirs += tests/.cache
117+
clean-files += tests/.cache
118118

119119
# Help text used by make help
120120
help:

‎usr/include/Makefile‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,4 @@ header-test-y += $(filter-out $(header-test-), \
115115
$(patsubst $(obj)/%,%, $(wildcard \
116116
$(addprefix $(obj)/, *.h */*.h */*/*.h */*/*/*.h))))
117117

118-
# For GNU Make <= 4.2.1, $(wildcard $(obj)/*/) matches to not only directories
119-
# but also regular files. Use $(filter %/, ...) just in case.
120-
clean-dirs += $(patsubst $(obj)/%/,%,$(filter %/, $(wildcard $(obj)/*/)))
118+
clean-files += $(filter-out Makefile, $(notdir $(wildcard $(obj)/*)))

0 commit comments

Comments
 (0)