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

Jeroen Hofstee dasuboot at myspectrum.nl
Wed Jun 29 22:48:02 CEST 2011


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 at blue ~]$ echo some/example/test.c | sed -e 's/\(.*\)\.\w/\1.o/';
some/example/test.c
[jeroen at blue ~]$ echo some/example/test.c | gsed -e 's/\(.*\)\.\w/\1.o/';
some/example/test.o
[jeroen at blue ~]$ echo some/example/test.w | sed -e 's/\(.*\)\.\w/\1.o/';
some/example/test.o
[jeroen at 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 at blue ~]$ echo some/example/test.c | sed -e 
's/\(.*\)\.[[:alnum:]_]/\1.o/';
some/example/test.o
[jeroen at blue ~]$ echo some/example/test.c | gsed -e 
's/\(.*\)\.[[:alnum:]_]/\1.o/';
some/example/test.o

or shorter (regex are greedy):
[jeroen at blue ~]$ echo some/example/test.c | sed -e 's/\(.*\)\..*/\1.o/';
some/example/test.o
[jeroen at 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 ...

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

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


More information about the U-Boot mailing list