[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
trailing whitespace in make macros (was: bug#7868: splitting up test sui
From: |
Ralf Wildenhues |
Subject: |
trailing whitespace in make macros (was: bug#7868: splitting up test suites) |
Date: |
Sat, 22 Jan 2011 11:19:15 +0100 |
User-agent: |
Mutt/1.5.20 (2010-08-04) |
[ moving from automake bug#7868 ]
* Ralf Wildenhues wrote on Sat, Jan 22, 2011 at 11:06:48AM CET:
> * Stefano Lattarini wrote on Thu, Jan 20, 2011 at 10:19:24PM CET:
> > On Thursday 20 January 2011, Ralf Wildenhues wrote:
> > > That is the reason the check-TESTS rule is so ugly (and recursive) in
> > > the first place. I really would like to avoid more instances of this
> > > wart; so specifying files without extension is Not Good(TM).
> > >
> > OK, noted (and these considerations could IMHO end up somewhere in the
> > manual).
>
> Good suggestion. They should be mentioned in the portability section of
> autoconf.texi if they aren't already, and as ## comments in check.am.
Proposed patches for Automake maint and Autoconf below.
Thanks,
Ralf
Add comment to check-TESTS rule working around make 3.80 bug.
* lib/am/check.am (check-TESTS): Update comment.
Suggestion by Stefano Lattarini.
diff --git a/lib/am/check.am b/lib/am/check.am
index 5728081..d792372 100644
--- a/lib/am/check.am
+++ b/lib/am/check.am
@@ -235,6 +235,9 @@ check-TESTS:
## OTOH, this means that, in the rule for `$(TEST_SUITE_LOG)', we
## cannot use `$?' to compute the set of lazily rerun tests, lest
## we rely on .PHONY to work portably.
+##
+## Work around a GNU make 3.80 bug expanding trailing whitespace in
+## `TESTS = foo.test $(empty)' to `foo.log .log' in $(TESTS_LOGS).
@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
@list='$(TEST_LOGS)'; \
list=`for f in $$list; do \
docs: new sections about macros and comments, substitutions.
* doc/autoconf.texi (Top, Portable Make): Adjust menus.
(Comments in Make Macros, Trailing whitespace in Make Macros):
New sections.
Suggestion by Stefano Lattarini.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index eee4ba7..0e8c3cc 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -533,6 +533,8 @@ Portable Make Programming
* Parallel Make:: Parallel @command{make} quirks
* Comments in Make Rules:: Other problems with Make comments
* Newlines in Make Rules:: Using literal newlines in rules
+* Comments in Make Macros:: Other problems with Make comments in macros
+* Trailing whitespace in Make Macros:: Macro substitution problems
* obj/ and Make:: Don't name a subdirectory @file{obj}
* make -k Status:: Exit status of @samp{make -k}
* VPATH and Make:: @code{VPATH} woes
@@ -19135,6 +19137,8 @@ itself.
* Parallel Make:: Parallel @command{make} quirks
* Comments in Make Rules:: Other problems with Make comments
* Newlines in Make Rules:: Using literal newlines in rules
+* Comments in Make Macros:: Other problems with Make comments in macros
+* Trailing whitespace in Make Macros:: Macro substitution problems
* obj/ and Make:: Don't name a subdirectory @file{obj}
* make -k Status:: Exit status of @samp{make -k}
* VPATH and Make:: @code{VPATH} woes
@@ -19575,6 +19579,55 @@ nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \
sed -e "s/\$$/address@hidden@}/" < input > output
@end example
address@hidden Comments in Make Macros
address@hidden Comments in Make Macros
address@hidden Comments in @file{Makefile} macros
address@hidden @file{Makefile} macros and comments
+
+Avoid putting comments in macro values as far as possible. Posix
+specifies that the text starting from the @samp{#} sign until the end of
+the line is to be ignored, which has the unfortunate effect of
+disallowing them even quoted. Thus, the following might lead to a
+syntax error at compile time:
+
address@hidden
+CPPFLAGS = "-DCOMMENT_CHAR='#'"
address@hidden example
+
address@hidden
+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.
+
+Even without quoting involved, comments can have surprising effects,
+because the whitespace before them is part of the variable value:
+
address@hidden
+foo = bar # trailing comment
+print: ; @@echo "$(foo)."
address@hidden example
+
address@hidden
+prints @samp{bar .}, which is usually not intended, and can expose
address@hidden bugs as described below.
+
address@hidden Trailing whitespace in Make Macros
address@hidden Trailing whitespace in Make Macros
address@hidden whitespace in @file{Makefile} macros
address@hidden @file{Makefile} macros and whitespace
+
+GNU @command{make} 3.80 mistreats trailing whitespace in macro
+substitutions and appends another spurious suffix:
+
address@hidden
+empty =
+foo = bar $(empty)
+print: ; @@echo $(foo:=.test)
address@hidden example
+
address@hidden
+prints @samp{bar.test .test}.
+
@node obj/ and Make
@section The @file{obj/} Subdirectory and Make
@cindex @file{obj/}, subdirectory
- trailing whitespace in make macros (was: bug#7868: splitting up test suites),
Ralf Wildenhues <=