automake
[Top][All Lists]
Advanced

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

Re: dashes in Makefile macro names


From: Stefano Lattarini
Subject: Re: dashes in Makefile macro names
Date: Sun, 30 Jan 2011 14:41:56 +0100
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

On Sunday 30 January 2011, Ralf Wildenhues wrote:
> Hello Stefano,
>
Hi Ralf.  I still have a couple of nits; see in-line comments below.

> * Stefano Lattarini wrote on Fri, Jan 28, 2011 at 09:55:18PM CET:
> > But there's a minor mistake in your testsuite addition, and I also
> > have a couple small unrelated nits/suggestions ...
> 
> You're spot-on with your observations, thanks.  I've included all
> elided comments in the patch below.
> 
> > > +required=cc
> > >
> > Here's the mistake: we don't have a meaningful 'cc' requirement yet :-(
> 
> No, we do.  There is a default case in the required loop which isn't lax
> enough to allow any cc but good enough for any GCC installation to work.
> ;-)
> 
> I intend to push this patch and a followup one to remove the warnings
> about recursive variable expansion (the 'portability-recursive' channel
> stuff) once there is indication that it will be in the next Posix.
> 
> Thanks,
> Ralf
> 
>     Accept dashes in make variable names.
>     
>     * lib/Automake/Variable.pm (Automake::Variable): Accept dashes
>     in Variable names.
>     * tests/varname-dash.test: New test.
>     * tests/Makefile.am: Update.
>     * NEWS: Update.
>     Suggestion from Bruno Haible.
> 
> diff --git a/NEWS b/NEWS
> index a5dc93f..08d4955 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -7,6 +7,10 @@ New in 1.11a:
>    - The deprecated options `--output-dir', `--Werror' and `--Wno-error'
>      have been removed.
>  
> +  - 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 9b2c838..50caee1 100644
> --- a/lib/Automake/Variable.pm
> +++ b/lib/Automake/Variable.pm
> @@ -129,10 +129,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 f53a1f3..1c1e247 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -932,6 +932,7 @@ vala2.test \
>  vala3.test \
>  vala4.test \
>  vala5.test \
> +varname-dash.test \
>  vars.test \
>  vars3.test \
>  vartar.test \
> diff --git a/tests/Makefile.in b/tests/Makefile.in
> index b78e5a5..fc3cc5b 100644
> --- a/tests/Makefile.in
> +++ b/tests/Makefile.in
> @@ -1195,6 +1195,7 @@ vala2.test \
>  vala3.test \
>  vala4.test \
>  vala5.test \
> +varname-dash.test \
>  vars.test \
>  vars3.test \
>  vartar.test \
> diff --git a/tests/varname-dash.test b/tests/varname-dash.test
> new file mode 100755
> index 0000000..775c118
> --- /dev/null
> +++ b/tests/varname-dash.test
> @@ -0,0 +1,62 @@
> +#!/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
> +-var = 1
>
Hmm... whay don't give this another value, to unsure it's not confused
by make (or automake) with `var-'?  E.g.,
  -var = 0

> +var2 = $(var-)
> +var-3 = 3
> +var4 = $(var-3)
> +three = 3
> +#var5 = $(var-$(three))
> +#var6 = $(-var)
> +prog-s = foo bar-s
> +foo-bar = a-b
> +foo_SOURCES = $(foo-bar:a-b=foo.c)
> +bar_s_SOURCES = bar.c
> +bin_PROGRAMS = $(prog-s)
> +
> +test:
> +     test x'$(var-)$(var2)$(var-3)$(var4)$(var5)' = x11333
>
At this point, this should become IMO:
  test x'$(var-)$(-var)$(var2)$(var-3)$(var4)$(var5)$(var6)' = x1113331
or, if you decide to follow my advice above:
  test x'$(var-)$(-var)$(var2)$(var-3)$(var4)$(var5)$(var6)' = x1013330

> +.PHONY: test
> +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
> +$MAKE
> +
> +:
> 

Thanks,
  Stefano



reply via email to

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