Skip to contentSkip to conversation

GNU Make shell application

U-Boot New Peter Tyser 5 participants 8 messages Nov 12, 2008 Kbuild

lore
Share & tools
lore
#0 lore raw

Hello,
I noticed on my Ubuntu 7.04 system that when I did a 'make clobber' the tools directory was still littered with symlinks that should have been removed. It looks like commands such as the following in the Makefiles fail:

	@rm -f $(obj)tools/{crc32.c,env_embedded.c,env/crc32.c,md5.c,sha1.c,inca-swap-bytes}
	@rm -f(obj)tools/{image.c,fdt.c,fdt_ro.c,fdt_rw.c,fdt_strerror.c,zlib.h}
	@rm -f $(obj)tools/{fdt_wip.c,libfdt_internal.h}

On Ubuntu 7.04 /bin/sh is a symlink to /bin/dash ordinarily. By default Make uses /bin/sh as its shell. Dash doesn't support the {abc,xyz} convention so all the symlinks in the above Make commands fail silently.

As a fix, would people prefer that bash be used by Make by default? Adding something like this (stolen from Linux) to the top-level Makefile should work:
# Set shell to bash if possible, otherwise fall back to sh

SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
	else if [ -x /bin/bash ]; then echo /bin/bash; \
	else echo sh; fi; fi)

Or would they prefer the Make commands are updated not to use the {abc,xyz} convention?

Thanks,
Peter

#1 lore raw

PATCH 1/1 Makefile: use find to simplify clobber and avoid some bash problem

---
please try this on ubuntu

Best Regards,
J.

 Makefile |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
Makefile +2 -3
index 884b634..212451f 100644
@@ -3280,9 +3280,8 @@ clobber:	clean
 	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
 		$(obj)cscope.* $(obj)*.*~
 	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
-	@rm -f $(obj)tools/{crc32.c,env_embedded.c,env/crc32.c,md5.c,sha1.c,inca-swap-bytes}
-	@rm -f $(obj)tools/{image.c,fdt.c,fdt_ro.c,fdt_rw.c,fdt_strerror.c,zlib.h}
-	@rm -f $(obj)tools/{fdt_wip.c,libfdt_internal.h}
+	@find $(obj)tools -name "*" -type l -print | xargs rm -f
+	@rm -f $(obj)tools/inca-swap-bytes
 	@rm -f $(obj)cpu/mpc824x/bedbug_603e.c
 	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
 	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
Signature · 1 line
1.5.6.5
#2 lore raw

PATCH 1/1 Makefile: use find to simplify clobber and avoid some bash problem

Makefile clobber: clean · line 3284

Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Makefile +2 -3
-       @rm -f $(obj)tools/{crc32.c,env_embedded.c,env/crc32.c,md5.c,sha1.c,inca-swap-bytes}
-       @rm -f $(obj)tools/{image.c,fdt.c,fdt_ro.c,fdt_rw.c,fdt_strerror.c,zlib.h}
-       @rm -f $(obj)tools/{fdt_wip.c,libfdt_internal.h}
+       @find $(obj)tools -name "*" -type l -print | xargs rm -f
+       @rm -f $(obj)tools/inca-swap-bytes

your changelog makes no sense. the problem is that brace expansion is not in POSIX and so it'll fail on systems that do not use bash by default (like Ubuntu). please put a real explanation into your changelog.

you should use find ... -print0 | xargs -0 ... or find ... -exec ... {} +. using find ... -print | xargs ... is broken. -mike

#3 lore raw

PATCH 1/1 Makefile: use find to simplify clobber and avoid some bash problem

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 15 lines · Jean-Christophe PLAGNIOL-VILLARD

---
please try this on ubuntu

Best Regards,
J.

 Makefile |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
Makefile +0 -0
index 884b634..212451f 100644
@@ -3280,9 +3280,8 @@ clobber:	clean
 	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \

Makefile clobber: clean · line 3287

Quoted 10 lines
Makefile +2 -3
 		$(obj)cscope.* $(obj)*.*~
 	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
-	@rm -f $(obj)tools/{crc32.c,env_embedded.c,env/crc32.c,md5.c,sha1.c,inca-swap-bytes}
-	@rm -f $(obj)tools/{image.c,fdt.c,fdt_ro.c,fdt_rw.c,fdt_strerror.c,zlib.h}
-	@rm -f $(obj)tools/{fdt_wip.c,libfdt_internal.h}
+	@find $(obj)tools -name "*" -type l -print | xargs rm -f
+	@rm -f $(obj)tools/inca-swap-bytes
 	@rm -f $(obj)cpu/mpc824x/bedbug_603e.c
 	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
 	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f

Oooo, you have a risk of removing symlinks that you didn't mean to. Works today, what about tomorrow?

This was discussed previously, but not pushed to fruition:
<http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/48047/focus=48048>

My vote is (a) use bash specifically and keep the bashisms.

Best regards,
gvb

#4 lore raw

PATCH 1/1 Makefile: use find to simplify clobber and avoid some bash problem

Quoted 8 lines · Jerry Van Baren

Makefile clobber: clean · line 3284

Quoted 5 lines · Jean-Christophe PLAGNIOL-VILLARD
Makefile +2 -3
-     @rm -f $(obj)tools/{crc32.c,env_embedded.c,env/crc32.c,md5.c,sha1.c,inca-swap-bytes}
-     @rm -f $(obj)tools/{image.c,fdt.c,fdt_ro.c,fdt_rw.c,fdt_strerror.c,zlib.h}
-     @rm -f $(obj)tools/{fdt_wip.c,libfdt_internal.h}
+     @find $(obj)tools -name "*" -type l -print | xargs rm -f
+     @rm -f $(obj)tools/inca-swap-bytes

My vote is (a) use bash specifically and keep the bashisms.

indeed. brace expansion is prob one of my favorite features of bash ;). -mike

#5 lore raw

PATCH 1/1 Makefile: use find to simplify clobber and avoid some bash problem

In reply to Jerry Van Baren
Quoted 30 lines · Jerry Van Baren
Quoted 15 lines · Jean-Christophe PLAGNIOL-VILLARD

---
please try this on ubuntu

Best Regards,
J.

 Makefile |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
Makefile +0 -0
index 884b634..212451f 100644
@@ -3280,9 +3280,8 @@ clobber:	clean
 	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \

Makefile clobber: clean · line 3287

Quoted 10 lines
Makefile +2 -3
 		$(obj)cscope.* $(obj)*.*~
 	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
-	@rm -f $(obj)tools/{crc32.c,env_embedded.c,env/crc32.c,md5.c,sha1.c,inca-swap-bytes}
-	@rm -f $(obj)tools/{image.c,fdt.c,fdt_ro.c,fdt_rw.c,fdt_strerror.c,zlib.h}
-	@rm -f $(obj)tools/{fdt_wip.c,libfdt_internal.h}
+	@find $(obj)tools -name "*" -type l -print | xargs rm -f
+	@rm -f $(obj)tools/inca-swap-bytes
 	@rm -f $(obj)cpu/mpc824x/bedbug_603e.c
 	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
 	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f

Oooo, you have a risk of removing symlinks that you didn't mean to. Works today, what about tomorrow?

Quoted 4 lines

This was discussed previously, but not pushed to fruition:
<http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/48047/focus=48048>

My vote is (a) use bash specifically and keep the bashisms.

Thanks for the link Jerry, I should have googled before looking into the issue:) Based on your comments and the previous discussion I'll send a patch for option (a) shortly.

Best,
Peter

#6 lore raw

PATCH 1/1 Makefile: use find to simplify clobber and avoid some bash problem

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 15 lines · Jean-Christophe PLAGNIOL-VILLARD

---
please try this on ubuntu

Best Regards,
J.

 Makefile |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
Makefile +0 -0
index 884b634..212451f 100644
@@ -3280,9 +3280,8 @@ clobber:	clean
 	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \

Makefile clobber: clean · line 3287

Quoted 10 lines
Makefile +2 -3
 		$(obj)cscope.* $(obj)*.*~
 	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
-	@rm -f $(obj)tools/{crc32.c,env_embedded.c,env/crc32.c,md5.c,sha1.c,inca-swap-bytes}
-	@rm -f $(obj)tools/{image.c,fdt.c,fdt_ro.c,fdt_rw.c,fdt_strerror.c,zlib.h}
-	@rm -f $(obj)tools/{fdt_wip.c,libfdt_internal.h}
+	@find $(obj)tools -name "*" -type l -print | xargs rm -f
+	@rm -f $(obj)tools/inca-swap-bytes
 	@rm -f $(obj)cpu/mpc824x/bedbug_603e.c
 	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
 	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f

That should work, I had tried the same thing with 'find ./ -lname "*"'. I hesitated to use that in case someone had a symlink in their tools directory that they didn't want cleaned up by make clobber. I'm not sure why someone would have those symlinks hanging around, but who am I to judge what other people do:)

Thanks,
Peter

#7 lore raw

PATCH 1/1 Makefile: use find to simplify clobber and avoid some bash problem

In reply to Jean-Christophe PLAGNIOL-VILLARD

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 15 lines · In message <[email protected]> you wrote:

---
please try this on ubuntu

Best Regards,
J.

 Makefile |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
Makefile +0 -0
index 884b634..212451f 100644
@@ -3280,9 +3280,8 @@ clobber:	clean
 	@rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \

Makefile clobber: clean · line 3287

Quoted 10 lines
Makefile +2 -3
 		$(obj)cscope.* $(obj)*.*~
 	@rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL)
-	@rm -f $(obj)tools/{crc32.c,env_embedded.c,env/crc32.c,md5.c,sha1.c,inca-swap-bytes}
-	@rm -f $(obj)tools/{image.c,fdt.c,fdt_ro.c,fdt_rw.c,fdt_strerror.c,zlib.h}
-	@rm -f $(obj)tools/{fdt_wip.c,libfdt_internal.h}
+	@find $(obj)tools -name "*" -type l -print | xargs rm -f
+	@rm -f $(obj)tools/inca-swap-bytes
 	@rm -f $(obj)cpu/mpc824x/bedbug_603e.c
 	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
 	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f

This will not help, we use the {...} syntax in other places, too.

Use bash.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The human race has one really effective weapon, and that is laughter.
                                                         - Mark Twain