Skip to contentSkip to conversation

Makefile: Fix "make clean"

PATCH In review Fam Zheng 3 participants 3 messages Mar 17, 2014 Kbuild

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH v2 1/1 Makefile: Fix "make clean"

This fixes a dangerous bug: "make clean" after "make distclean" will delete every single file including those under .git, if you do in-tree build!

Rationale: A first "make distclean" will unset $(DSOSUF), a following "make distclean" or "make clean" will find all the files and delete it.

Fix it by explicitly typing the file extensions here, and combine multiple find invocations into one.

---
v2: Improve as Stefan Weil suggested.

---
 Makefile | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
Makefile +1 -4
index bd9cd4f..ec74039 100644
@@ -265,10 +265,7 @@ clean:
 # avoid old build problems by removing potentially incorrect old files
 	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
 	rm -f qemu-options.def
-	find . -name '*.[oda]' -type f -exec rm -f {} +
-	find . -name '*.l[oa]' -type f -exec rm -f {} +
-	find . -name '*$(DSOSUF)' -type f -exec rm -f {} +
-	find . -name '*.mo' -type f -exec rm -f {} +
+	find . \( -name '*.l[oa]' -o -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f -exec rm {} +
 	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
 	rm -f fsdev/*.pod
 	rm -rf .libs */.libs
Signature · 1 line
1.9.0
Reviewed-by on v2 1/1
#1 lore raw

Am 17.03.2014 02:35, schrieb Fam Zheng:

Quoted 27 lines

This fixes a dangerous bug: "make clean" after "make distclean" will delete every single file including those under .git, if you do in-tree build!

Rationale: A first "make distclean" will unset $(DSOSUF), a following "make distclean" or "make clean" will find all the files and delete it.

Fix it by explicitly typing the file extensions here, and combine multiple find invocations into one.

---
v2: Improve as Stefan Weil suggested.

---
 Makefile | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
Makefile +0 -0
index bd9cd4f..ec74039 100644
@@ -265,10 +265,7 @@ clean:
 # avoid old build problems by removing potentially incorrect old files

Makefile clean: · line 271

Quoted 10 lines
Makefile +1 -4
 	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
 	rm -f qemu-options.def
-	find . -name '*.[oda]' -type f -exec rm -f {} +
-	find . -name '*.l[oa]' -type f -exec rm -f {} +
-	find . -name '*$(DSOSUF)' -type f -exec rm -f {} +
-	find . -name '*.mo' -type f -exec rm -f {} +
+	find . \( -name '*.l[oa]' -o -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f -exec rm {} +
 	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
 	rm -f fsdev/*.pod
 	rm -rf .libs */.libs

Hello Peter,

this is a bugfix which fixes a potential danger for a developer's working directory, so I think it should be fixed directly (not via qemu-trivial).

Regards
Stefan

#2 lore raw
Quoted 13 lines · Stefan Weil

Am 17.03.2014 02:35, schrieb Fam Zheng:

Quoted 11 lines

This fixes a dangerous bug: "make clean" after "make distclean" will delete every single file including those under .git, if you do in-tree build!

Rationale: A first "make distclean" will unset $(DSOSUF), a following "make distclean" or "make clean" will find all the files and delete it.

Fix it by explicitly typing the file extensions here, and combine multiple find invocations into one.

Quoted 7 lines

Hello Peter,

this is a bugfix which fixes a potential danger for a developer's working directory, so I think it should be fixed directly (not via qemu-trivial).

Agreed; applied to master, thanks.

-- PMM