bug-autoconf
[Top][All Lists]
Advanced

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

Re: dashes in Makefile macro names


From: Ralf Wildenhues
Subject: Re: dashes in Makefile macro names
Date: Fri, 28 Jan 2011 21:23:13 +0100
User-agent: Mutt/1.5.20 (2010-08-04)

* Eric Blake wrote on Fri, Jan 28, 2011 at 04:04:19PM CET:
> On 01/28/2011 04:38 AM, Bruno Haible wrote:
> > Can you use $(FOO-BAR) in Makefile? It's not portable in POSIX [1]
> 
> Then let's get that addressed in POSIX!

Thank you Eric for being thorough!

> We're already in the middle of
> getting POSIX to support ${var${v}} nested variable expansions, on the
> same arguments of multi-implementation portability and ease-of-use for
> automake:

Ugh, and I still need to provide some more feedback.  :-/

> http://austingroupbugs.net/view.php?id=336

> >     doc: Don't discourage dashes in Makefile macro names.
> >     * doc/autoconf.texi (Special Chars in Names): Mention that dashes in
> >     Makefile macro names are supported.
> 
> Looks reasonable to me.  But I'll wait for any additional feedback
> before pushing, in case anyone else has input on the matter.

Well, so far, automake -Wsyntax won't understand these variable names
and will complain and die if you use them in Makefile.am files.  The fix
is a couple of changes only, but also I would like to hear some feedback
from Posix people first, they might have some input about systems we do
not have test access to.

Thanks,
Ralf

    Accept dashes in make variable names.
    
    * lib/Automake/Variable.pm (Automake::Variable): Accept dashes
    in Variable names.
    * tests/minusvar.test: New test.
    * tests/Makefile.am: Update.
    * NEWS: Update.
    Suggestion from Bruno Haible.

diff --git a/NEWS b/NEWS
index dda6f8c..a02f609 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ New in 1.11a:
     syntax warnings.  For portable Makefiles, such code can be wrapped in
     the GNU_MAKE conditional.
 
+  - Dashes (minus signs) in make variable names are accepted now, since they
+    are seemingly portable.  The Unified naming scheme still flattens them to
+    underscores as before.
+
 * New targets:
 
   - New `cscope' target to build a cscope database for the source tree.
diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm
index 419a162..134de99 100644
--- a/lib/Automake/Variable.pm
+++ b/lib/Automake/Variable.pm
@@ -130,10 +130,10 @@ non-object).
 
 =cut
 
-my $_VARIABLE_CHARACTERS = 'address@hidden';
+my $_VARIABLE_CHARACTERS = 'address@hidden';
 my $_VARIABLE_PATTERN = '^' . $_VARIABLE_CHARACTERS . "\$";
 my $_VARIABLE_RECURSIVE_PATTERN =
-    '^(address@hidden|\$[({]' . $_VARIABLE_CHARACTERS . '[})]?)+' . "\$";
+    '^(address@hidden|\$[({]' . $_VARIABLE_CHARACTERS . '[})]?)+' . "\$";
 
 # The order in which variables should be output.  (May contain
 # duplicates -- only the first occurrence matters.)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 43c18b0..8f1087e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -625,6 +625,7 @@ mdate3.test \
 mdate4.test \
 mdate5.test \
 mdate6.test \
+minusvar.test \
 missing.test \
 missing2.test \
 missing3.test \
diff --git a/tests/minusvar.test b/tests/minusvar.test
new file mode 100755
index 0000000..3ba803f
--- /dev/null
+++ b/tests/minusvar.test
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Ensure automake allows and understand '-' in variable names.
+
+required=cc
+. ./defs || Exit 1
+
+cat >>configure.in <<\END
+AC_PROG_CC
+AC_OUTPUT
+END
+
+cat >Makefile.am <<\END
+var- = 1
+var2 = $(var-)
+var-3 = 3
+var4 = $(var-3)
+three = 3
+#var5 = $(var-$(three))
+prog-s = foo bar-s
+bar_s_SOURCES = bar.c
+bin_PROGRAMS = $(prog-s)
+
+test:
+       @echo $(var-)$(var2)$(var-3)$(var4)$(var5)
+END
+
+cat >foo.c <<\END
+int main (void) { return 0; }
+END
+cp foo.c bar.c
+
+$ACLOCAL
+$AUTOMAKE
+sed 's/^#//' Makefile.am > t
+mv -f t Makefile.am
+$AUTOMAKE -Wno-portability
+$AUTOCONF
+./configure
+$MAKE test >stdout || { cat stdout; Exit 1; }
+grep 11333 stdout
+$MAKE
+
+:



reply via email to

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