Skip to contentSkip to conversation

Makefile: Don't find and delete when $(DSOSUF) is empty in "make clean"

PATCH In review Fam Zheng 6 participants 9 messages Mar 14, 2014 – Mar 18, 2014 Kbuild

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 Makefile: Don't find and delete when $(DSOSUF) is empty in "make clean"

DANGEROUS: don't try it before you read to the end.

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

Including all the files in the .git directory!

Fix it by only do it when $(DSOSUF) is not empty.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index bd9cd4f..0666d6e 100644
@@ -267,7 +267,7 @@ clean:
 	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 {} +
+	if test -n "$(DSOSUF)"; then find . -name '*$(DSOSUF)' -type f -exec rm -f {} +; fi
 	find . -name '*.mo' -type f -exec rm -f {} +
 	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
 	rm -f fsdev/*.pod
Signature · 1 line
1.9.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Fam Zheng

DANGEROUS: don't try it before you read to the end.

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

Quoted 8 lines

Including all the files in the .git directory!

Fix it by only do it when $(DSOSUF) is not empty.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#2 lore raw
In reply to Fam Zheng

Am 14.03.2014 09:38, schrieb Fam Zheng:

Quoted 6 lines

DANGEROUS: don't try it before you read to the end.

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

Including all the files in the .git directory!

If you only use out-of-tree build, you are safe here. Maybe we should no longer support in-tree builds. Personally, I nearly never use them.

Quoted 1 line

Fix it by only do it when $(DSOSUF) is not empty.

s/do/doing/

Quoted 10 lines
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index bd9cd4f..0666d6e 100644

Makefile clean: · line 273

Quoted 8 lines
Makefile +1 -1
@@ -267,7 +267,7 @@ clean:
 	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 {} +
+	if test -n "$(DSOSUF)"; then find . -name '*$(DSOSUF)' -type f -exec rm -f {} +; fi
 	find . -name '*.mo' -type f -exec rm -f {} +
 	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
 	rm -f fsdev/*.pod

No, I think it is still too dangerous to use a macro here. There are only two valid possibilities, so it's easy to name them explicitly:

        find -name "*.dll" -o -name "*.so"

Is there a good reason why rm is called with option -f? Normally, -f should not be needed when cleaning generated files because those files are not write protected. The only other reason for -f would be suppressing an error message if rm tries to remove a non existing files, but that does not apply here.

I'd also combine all find statements in a single statement. It is not necessary to parse the directory tree several times. That can be done in a separate patch.

Regards,
Stefan

author
#3 lore raw
Quoted 45 lines · Stefan Weil

Am 14.03.2014 09:38, schrieb Fam Zheng:

Quoted 6 lines

DANGEROUS: don't try it before you read to the end.

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

Including all the files in the .git directory!

If you only use out-of-tree build, you are safe here. Maybe we should no longer support in-tree builds. Personally, I nearly never use them.

Quoted 1 line

Fix it by only do it when $(DSOSUF) is not empty.

s/do/doing/

Quoted 10 lines
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index bd9cd4f..0666d6e 100644

Makefile clean: · line 273

Quoted 8 lines
Makefile +1 -1
@@ -267,7 +267,7 @@ clean:
 	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 {} +
+	if test -n "$(DSOSUF)"; then find . -name '*$(DSOSUF)' -type f -exec rm -f {} +; fi
 	find . -name '*.mo' -type f -exec rm -f {} +
 	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
 	rm -f fsdev/*.pod

No, I think it is still too dangerous to use a macro here. There are only two valid possibilities, so it's easy to name them explicitly:

        find -name "*.dll" -o -name "*.so"

Is there a good reason why rm is called with option -f? Normally, -f should not be needed when cleaning generated files because those files are not write protected. The only other reason for -f would be suppressing an error message if rm tries to remove a non existing files, but that does not apply here.

Quoted 4 lines

I'd also combine all find statements in a single statement. It is not necessary to parse the directory tree several times. That can be done in a separate patch.

Sounds good to me. I'll respin.

Thanks,
Fam

#4 lore raw
In reply to Stefan Weil
Quoted 10 lines · Stefan Weil

Am 14.03.2014 09:38, schrieb Fam Zheng:

Quoted 6 lines

DANGEROUS: don't try it before you read to the end.

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

Including all the files in the .git directory!

If you only use out-of-tree build, you are safe here. Maybe we should no longer support in-tree builds. Personally, I nearly never use them.

Same here. Building in-tree is calling for trouble. I'd support a patch that prevents it.

[...]

#5 lore raw

Am 17.03.2014 09:30, schrieb Markus Armbruster:

Quoted 8 lines
Quoted 6 lines · Stefan Weil

Am 14.03.2014 09:38, schrieb Fam Zheng:

Quoted 5 lines

DANGEROUS: don't try it before you read to the end.

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

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Including all the files in the .git directory!

If you only use out-of-tree build, you are safe here. Maybe we should no longer support in-tree builds. Personally, I nearly never use them.

Same here. Building in-tree is calling for trouble. I'd support a patch that prevents it.

What about disabling it only when .git/ is available? There seems nothing wrong with doing one-time builds inside an extracted tarball on central build servers; most of the problems arise when building inside the developer's git checkout.

If we do drop support for building in-tree (always or with Git), we could also drop most of the .gitignore clutter. :)

Cheers,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#6 lore raw
Quoted 11 lines · Andreas Färber

Am 17.03.2014 09:30, schrieb Markus Armbruster:

Quoted 10 lines
Quoted 8 lines · Stefan Weil

Am 14.03.2014 09:38, schrieb Fam Zheng:

Quoted 6 lines

DANGEROUS: don't try it before you read to the end.

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

Including all the files in the .git directory!

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

If you only use out-of-tree build, you are safe here. Maybe we should no longer support in-tree builds. Personally, I nearly never use them.

Same here. Building in-tree is calling for trouble. I'd support a patch that prevents it.

What about disabling it only when .git/ is available?

The other idea that's been suggested in the past is to have the makefile/configure simply map attempts to build in-tree into 'create builddir and build in it'. This is probably easier to suggest than to get right in all situations :-)

thanks
-- PMM

#7 lore raw
Quoted 18 lines · Peter Maydell
Quoted 17 lines · Andreas Färber

Am 17.03.2014 09:30, schrieb Markus Armbruster:

Quoted 15 lines
Quoted 10 lines · Stefan Weil

Am 14.03.2014 09:38, schrieb Fam Zheng:

Quoted 6 lines

DANGEROUS: don't try it before you read to the end.

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

Including all the files in the .git directory!

If you only use out-of-tree build, you are safe here. Maybe we should no longer support in-tree builds. Personally, I nearly never use them.

Same here. Building in-tree is calling for trouble. I'd support a patch that prevents it.

Quoted 7 lines
Quoted 1 line

What about disabling it only when .git/ is available?

The other idea that's been suggested in the past is to have the makefile/configure simply map attempts to build in-tree into 'create builddir and build in it'. This is probably easier to suggest than to get right in all situations :-)

Perfect is the enemy of good enough.

all:

%: force

	@$(MAKE) -C bld $@

force: ;

#8 lore raw
In reply to Andreas Färber
Quoted 14 lines · Andreas Färber

Am 17.03.2014 09:30, schrieb Markus Armbruster:

Quoted 13 lines
Quoted 10 lines · Stefan Weil

Am 14.03.2014 09:38, schrieb Fam Zheng:

Quoted 6 lines

DANGEROUS: don't try it before you read to the end.

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

Including all the files in the .git directory!

If you only use out-of-tree build, you are safe here. Maybe we should no longer support in-tree builds. Personally, I nearly never use them.

Quoted 6 lines
Quoted 2 lines

Same here. Building in-tree is calling for trouble. I'd support a patch that prevents it.

What about disabling it only when .git/ is available? There seems nothing wrong with doing one-time builds inside an extracted tarball on central build servers;

Except for this one: in-tree build will rot even faster.

Quoted 5 lines

most of the problems arise when building inside
the developer's git checkout.

If we do drop support for building in-tree (always or with Git), we could also drop most of the .gitignore clutter. :)

Bonus!