autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trailing whitespace in make macros


From: Ralf Wildenhues
Subject: Re: trailing whitespace in make macros
Date: Sat, 22 Jan 2011 19:41:12 +0100
User-agent: Mutt/1.5.20 (2010-08-04)

* Eric Blake wrote on Sat, Jan 22, 2011 at 03:03:02PM CET:
> Should we also mention the converse issue of non-comments?  That is,
> Posix requires that # embedded in the middle of a rule (and not a macro)
> is okay.  Which is why gnulib's include-next module works [...]

Yes, sure.  There already exists a node "Comments in Make Rules",
so it would fit there, with appropriate cross-references.  OK?

Eventually, the chapter might benefit from a bit of reordering,
but this too, can be done later in a separate patch I think.

Thanks,
Ralf

    docs: document how to use comment characters in rules.
    
    * doc/autoconf.texi (Comments in Make Rules): Explain how to
    produce a `#' in a rule.
    (Comments in Make Macros): Add cross reference.
    Suggestion from Eric Blake.

diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 110f5f5..8a92ffd 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -19553,6 +19553,21 @@ Comments in Make Rules
         : "foo"
 @end example
 
+Conversely, if you want to use the @samp{#} character in some command,
+you can only do so by expanding it inside a rule (@pxref{Comments in
+Make Macros}).  So for example, if @samp{COMMENT_CHAR} is substituted by
address@hidden as @samp{#}, then the following substitutes
address@hidden@@COMMENT_CHAR@@} in a generated header:
+
address@hidden
+foo.h: foo.h.in
+        sed -e 's|@@''COMMENT_CHAR''@@|@@COMMENT_CHAR@@|g' \
+            $(srcdir)/foo.h.in > $@@
address@hidden example
+
+The funny shell quoting avoids a substitution at @command{config.status}
+run time of the left-hand side of the @command{sed} @samp{s} command.
+
 @node Newlines in Make Rules
 @section Newlines in Make Rules
 @cindex Newlines in @file{Makefile} rules
@@ -19599,7 +19614,8 @@ Comments in Make Macros
 @noindent
 as @samp{CPPFLAGS} may be expanded to @samp{"-DCOMMENT_CHAR='}.
 Luckily, most @command{make} implementations disregard this and treat
-single and double quotes specially here.
+single and double quotes specially here; @pxref{Comments in Make Rules},
+for a more portable alternative.
 
 Even without quoting involved, comments can have surprising effects,
 because the whitespace before them is part of the variable value:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]