All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeroen Hofstee <dasuboot@myspectrum.nl>
To: u-boot@lists.denx.de
Subject: [U-Boot] GNU specific sed argument in rules.mk
Date: Wed, 29 Jun 2011 20:48:02 +0000	[thread overview]
Message-ID: <4E0B8F82.4000600@myspectrum.nl> (raw)

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

             reply	other threads:[~2011-06-29 20:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-29 20:48 Jeroen Hofstee [this message]
2011-06-29 19:38 ` [U-Boot] GNU specific sed argument in rules.mk 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E0B8F82.4000600@myspectrum.nl \
    --to=dasuboot@myspectrum.nl \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.