manpagez: man pages & more
info autoconf
Home | html | info | man

File: autoconf.info,  Node: Comments in Make Rules,  Next: Newlines in Make Rules,  Prev: Parallel Make,  Up: Portable Make

12.11 Comments in Make Rules
============================

Do not try to put comments (lines beginning with ‘#’) in a rule, as they
end the rule.  It is OK for a rule line to start with a tab followed by
‘#’, as a comment passed to a shell that does nothing.

   To use the ‘#’ character in a command, put it in a rule not a macro,
as the character cannot portably appear in macros (*note Comments in
Make Macros::).  So for example, assuming the output variable
‘COMMENT_CHAR’ stands for ‘#’, the following replaces ‘@COMMENT_CHAR@’
by ‘#’ in a generated header:

     foo.h: foo.h.in
             sed -e 's|@''COMMENT_CHAR''@|@COMMENT_CHAR@|g' \
               '$(srcdir)/foo.h.in' > $@

   The funny shell quoting avoids a substitution at ‘config.status’ run
time of the left-hand side of the ‘sed’ ‘s’ command.

© manpagez.com 2000-2026
Individual documents may contain additional copyright information.