diff mbox

[U-Boot] GNU specific sed argument in rules.mk

Message ID 4E0B8F82.4000600@myspectrum.nl
State RFC
Headers show

Commit Message

Jeroen Hofstee June 29, 2011, 8:48 p.m. UTC
Hi Wolfgang / All,

rules.mk uses the GNU specific sed \w leading to not directly obvious 
Make / _depend errors in the build process, like circular dependencies 
warnings / crc32.c not found (some example and (incorrect) fixes), e.g.:
http://lists.denx.de/pipermail/u-boot/2009-May/051931.html
http://lists.denx.de/pipermail/u-boot/2009-June/054662.html
http://lists.denx.de/pipermail/u-boot/2009-November/064655.html
http://lists.denx.de/pipermail/u-boot/2011-March/088884.html

Some test:

Current command (gsed = GNU sed, sed = FreeBSD takes \w as w). The first 
command is not the intention.
[jeroen@blue ~]$ echo some/example/test.c | sed -e 's/\(.*\)\.\w/\1.o/';
some/example/test.c
[jeroen@blue ~]$ echo some/example/test.c | gsed -e 's/\(.*\)\.\w/\1.o/';
some/example/test.o
[jeroen@blue ~]$ echo some/example/test.w | sed -e 's/\(.*\)\.\w/\1.o/';
some/example/test.o
[jeroen@blue ~]$ echo some/example/test.w | gsed -e 's/\(.*\)\.\w/\1.o/';
some/example/test.o

None GNU specific as per GNU docs (fine):
[jeroen@blue ~]$ echo some/example/test.c | sed -e 
's/\(.*\)\.[[:alnum:]_]/\1.o/';
some/example/test.o
[jeroen@blue ~]$ echo some/example/test.c | gsed -e 
's/\(.*\)\.[[:alnum:]_]/\1.o/';
some/example/test.o

or shorter (regex are greedy):
[jeroen@blue ~]$ echo some/example/test.c | sed -e 's/\(.*\)\..*/\1.o/';
some/example/test.o
[jeroen@blue ~]$ echo some/example/test.c | gsed -e 's/\(.*\)\..*/\1.o/';
some/example/test.o

Would you accept a patch for this?

Regards,
Jeroen

----------------------------------------------------

patch would look something like this, GNU man suggested or ...

GNU extension to regex are documented here:
See 
http://www.gnu.org/software/gawk/manual/html_node/GNU-Regexp-Operators.html

Comments

Wolfgang Denk June 29, 2011, 7:38 p.m. UTC | #1
Dear Jeroen Hofstee,

In message <4E0B8F82.4000600@myspectrum.nl> you wrote:
> 
> rules.mk uses the GNU specific sed \w leading to not directly obvious 
> Make / _depend errors in the build process, like circular dependencies 

You should probably mention when such errors result - I have never seen
any of these.

> Current command (gsed = GNU sed, sed = FreeBSD takes \w as w). The first 
> command is not the intention.
> [jeroen@blue ~]$ echo some/example/test.c | sed -e 's/\(.*\)\.\w/\1.o/';
> some/example/test.c
> [jeroen@blue ~]$ echo some/example/test.c | gsed -e 's/\(.*\)\.\w/\1.o/';
> some/example/test.o
> [jeroen@blue ~]$ echo some/example/test.w | sed -e 's/\(.*\)\.\w/\1.o/';
> some/example/test.o
> [jeroen@blue ~]$ echo some/example/test.w | gsed -e 's/\(.*\)\.\w/\1.o/';
> some/example/test.o
> 
> None GNU specific as per GNU docs (fine):
> [jeroen@blue ~]$ echo some/example/test.c | sed -e 
> 's/\(.*\)\.[[:alnum:]_]/\1.o/';
> some/example/test.o
> [jeroen@blue ~]$ echo some/example/test.c | gsed -e 
> 's/\(.*\)\.[[:alnum:]_]/\1.o/';
> some/example/test.o
> 
> or shorter (regex are greedy):
> [jeroen@blue ~]$ echo some/example/test.c | sed -e 's/\(.*\)\..*/\1.o/';
> some/example/test.o
> [jeroen@blue ~]$ echo some/example/test.c | gsed -e 's/\(.*\)\..*/\1.o/';
> some/example/test.o

I don't think this last version is equivalent to the original code.
With GNU sed:

-> echo foo/bar-baz.frob-nitz | sed -e 's/\(.*\)\.\w/\1.o/'
foo/bar-baz.orob-nitz
-> echo foo/bar-baz.frob-nitz | sed -e 's/\(.*\)\..*/\1.o/'
foo/bar-baz.o


> Would you accept a patch for this?

Yes, of course - if the resultinmg code works, and if you follow
patch submission rules (like SoB: line etc.).

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/rules.mk b/rules.mk
index c2860e5..385e5f5 100644
--- a/rules.mk
+++ b/rules.mk
@@ -29,11 +29,11 @@  $(obj).depend:      $(src)Makefile $(TOPDIR)/config.mk $(SRCS) $(HOSTSRCS)
                 @rm -f $@
                 @touch $@
                 @for f in $(SRCS); do \
-                       g=`basename $$f | sed -e 's/\(.*\)\.\w/\1.o/'`; \
+                       g=`basename $$f | sed -e 's/\(.*\)\..*/\1.o/'`; \
                         $(CC) -M $(CPPFLAGS) -MQ $(obj)$$g $$f>>  $@ ; \
                 done
                 @for f in $(HOSTSRCS); do \
-                       g=`basename $$f | sed -e 's/\(.*\)\.\w/\1.o/'`; \
+                       g=`basename $$f | sed -e 's/\(.*\)\..*/\1.o/'`; \
                         $(HOSTCC) -M $(HOSTCPPFLAGS) -MQ $(obj)$$g $$f>>  $@ ; \
                 done