aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/kbuild/makefiles.txt7
-rw-r--r--Kbuild4
-rw-r--r--Makefile33
-rw-r--r--scripts/Makefile.clean2
4 files changed, 24 insertions, 22 deletions
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 5c878cc6c0b4..c899192b37bb 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -779,6 +779,13 @@ This will delete the directory debian, including all subdirectories.
779Kbuild will assume the directories to be in the same relative path as the 779Kbuild will assume the directories to be in the same relative path as the
780Makefile if no absolute path is specified (path does not start with '/'). 780Makefile if no absolute path is specified (path does not start with '/').
781 781
782To exclude certain files from make clean, use the $(no-clean-files) variable.
783This is only a special case used in the top level Kbuild file:
784
785 Example:
786 #Kbuild
787 no-clean-files := $(bounds-file) $(offsets-file)
788
782Usually kbuild descends down in subdirectories due to "obj-* := dir/", 789Usually kbuild descends down in subdirectories due to "obj-* := dir/",
783but in the architecture makefiles where the kbuild infrastructure 790but in the architecture makefiles where the kbuild infrastructure
784is not sufficient this sometimes needs to be explicit. 791is not sufficient this sometimes needs to be explicit.
diff --git a/Kbuild b/Kbuild
index e3737ad72b5a..18a8bfbb353b 100644
--- a/Kbuild
+++ b/Kbuild
@@ -94,5 +94,5 @@ PHONY += missing-syscalls
94missing-syscalls: scripts/checksyscalls.sh FORCE 94missing-syscalls: scripts/checksyscalls.sh FORCE
95 $(call cmd,syscalls) 95 $(call cmd,syscalls)
96 96
97# Delete all targets during make clean 97# Keep these two files during make clean
98clean-files := $(addprefix $(objtree)/,$(filter-out $(bounds-file) $(offsets-file),$(targets))) 98no-clean-files := $(bounds-file) $(offsets-file)
diff --git a/Makefile b/Makefile
index f78450e299a2..edfa6cf7cb94 100644
--- a/Makefile
+++ b/Makefile
@@ -1119,21 +1119,13 @@ MRPROPER_FILES += .config .config.old .version .old_version \
1119# 1119#
1120clean: rm-dirs := $(CLEAN_DIRS) 1120clean: rm-dirs := $(CLEAN_DIRS)
1121clean: rm-files := $(CLEAN_FILES) 1121clean: rm-files := $(CLEAN_FILES)
1122clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs) Documentation) 1122clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs) Documentation)
1123 1123
1124PHONY += $(clean-dirs) clean archclean 1124PHONY += $(clean-dirs) clean archclean
1125$(clean-dirs): 1125$(clean-dirs):
1126 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1126 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1127 1127
1128clean: archclean $(clean-dirs) 1128clean: archclean
1129 $(call cmd,rmdirs)
1130 $(call cmd,rmfiles)
1131 @find . $(RCS_FIND_IGNORE) \
1132 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1133 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1134 -o -name '*.symtypes' -o -name 'modules.order' \
1135 -o -name modules.builtin -o -name '.tmp_*.o.*' \
1136 -o -name '*.gcno' \) -type f -print | xargs rm -f
1137 1129
1138# mrproper - Delete all generated files, including .config 1130# mrproper - Delete all generated files, including .config
1139# 1131#
@@ -1331,16 +1323,7 @@ $(clean-dirs):
1331 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1323 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1332 1324
1333clean: rm-dirs := $(MODVERDIR) 1325clean: rm-dirs := $(MODVERDIR)
1334clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers \ 1326clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers
1335 $(KBUILD_EXTMOD)/modules.order \
1336 $(KBUILD_EXTMOD)/modules.builtin
1337clean: $(clean-dirs)
1338 $(call cmd,rmdirs)
1339 $(call cmd,rmfiles)
1340 @find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
1341 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1342 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1343 -o -name '*.gcno' \) -type f -print | xargs rm -f
1344 1327
1345help: 1328help:
1346 @echo ' Building external modules.' 1329 @echo ' Building external modules.'
@@ -1357,6 +1340,16 @@ prepare: ;
1357scripts: ; 1340scripts: ;
1358endif # KBUILD_EXTMOD 1341endif # KBUILD_EXTMOD
1359 1342
1343clean: $(clean-dirs)
1344 $(call cmd,rmdirs)
1345 $(call cmd,rmfiles)
1346 @find $(or $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
1347 \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
1348 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1349 -o -name '*.symtypes' -o -name 'modules.order' \
1350 -o -name modules.builtin -o -name '.tmp_*.o.*' \
1351 -o -name '*.gcno' \) -type f -print | xargs rm -f
1352
1360# Generate tags for editors 1353# Generate tags for editors
1361# --------------------------------------------------------------------------- 1354# ---------------------------------------------------------------------------
1362quiet_cmd_tags = GEN $@ 1355quiet_cmd_tags = GEN $@
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 6f89fbb56256..686cb0d31c7c 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -45,6 +45,8 @@ __clean-files := $(extra-y) $(always) \
45 $(host-progs) \ 45 $(host-progs) \
46 $(hostprogs-y) $(hostprogs-m) $(hostprogs-) 46 $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
47 47
48__clean-files := $(filter-out $(no-clean-files), $(__clean-files))
49
48# as clean-files is given relative to the current directory, this adds 50# as clean-files is given relative to the current directory, this adds
49# a $(obj) prefix, except for absolute paths 51# a $(obj) prefix, except for absolute paths
50 52