[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#7610: Stripping of comments with the `+=' operator
From: |
Stefano Lattarini |
Subject: |
bug#7610: Stripping of comments with the `+=' operator |
Date: |
Fri, 10 Dec 2010 19:06:43 +0100 |
User-agent: |
KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; ) |
Hello automakers.
The current automake implementation of variable-appending operator
`+=' tries to be smart w.r.t. comments in the values; for example:
$ cat configure.ac
AC_INIT(x,0)
AM_INIT_AUTOMAKE
AC_CONFIG_FILES(Makefile)
AC_OUTPUT
$ cat Makefile.am
foo1 = bar # comment 1
foo1 += baz # comment 2
foo2 = bar
foo2 += baz # comment 3
foo3 = bar baz # comment 4
results in:
$ aclocal && automake --foreign --add-missing
configure.ac:2: installing `./install-sh'
configure.ac:2: installing `./missing'
$ grep '^foo[0-9] *=' Makefile.in
foo1 = bar baz # comment 2
foo2 = bar baz # comment 3
foo3 = bar baz # comment 4
which is admittedly better than having something bogus like:
$ cat Makefile.am
foo = bar # comment
foo += baz
$ aclocal && automake ...
$ grep '^foo *=' Makefile.in
foo = bar # comment baz
However, the code in automake is apparently not smart enough to detect
that someone might be trying to put a *literal* `#' character in a
variable extended with `+=':
$ cat configure.ac
AC_INIT(x,0)
AM_INIT_AUTOMAKE
AC_CONFIG_FILES(Makefile)
AC_OUTPUT
$ cat Makefile.am
CDEFS = -D'FOO_STRING="\#\#foo\#\#"'
CDEFS += -DBAR
$ aclocal && automake --foreign --add-missing
configure.ac:2: installing `./install-sh'
configure.ac:2: installing `./missing'
$ grep '^CDEFS *=' Makefile.in
CDEFS = -D'FOO_STRING="\ -DBAR
Now, while the above use of -D'FOO_STRING="\#\#foo\#\#"' in a variable
definition is certainly bound to produce code unportable to some make
implementations, the right thing for automake to do is either to
assume the user knows what he's doing (maybe he's not interested into
portability to those make implementations), or to warn about the
unportable usage (if `-Wportability' is enabled, obviously).
Silently mangling the value of the resulting value of $(DEFS) is *not*
an acceptale behaviour IMHO, but unfortunately, that's exactly what
automake currently does (as seen above).
Tangentially, note that the definition:
CDEFS = -D'FOO_STRING="\#\#foo\#\#"'
actually works with at least GNU make, modern FreeBSD make,
and modern NetBSD make:
$ cat Makefile
CDEFS = -D'FOO_STRING="\#\#foo\#\#"'
all:; @echo $(CDEFS)
$ make # is either GNU, FreeBSD or NetBSD make
-DFOO_STRING="##foo##"
and "sorta" works with Solaris 10 make:
$ /usr/xpg4/bin/make
-DFOO_STRING="\#\#foo\#\#"
$ /usr/ccs/bin/make
-DFOO_STRING="\#\#foo\#\#"
Regards,
Stefano
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#7610: Stripping of comments with the `+=' operator,
Stefano Lattarini <=