public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] GNU specific sed argument in rules.mk
@ 2011-06-29 20:48 Jeroen Hofstee
  2011-06-29 19:38 ` Wolfgang Denk
  0 siblings, 1 reply; 5+ messages in thread
From: Jeroen Hofstee @ 2011-06-29 20:48 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-06-30 21:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-29 20:48 [U-Boot] GNU specific sed argument in rules.mk Jeroen Hofstee
2011-06-29 19:38 ` Wolfgang Denk
2011-06-30 16:38   ` Jeroen Hofstee
2011-06-30 21:42     ` [U-Boot] arm - versatilepb Jeroen Hofstee
2011-06-30 21:11       ` stefano babic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox