[Top][All Lists]

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


From: Eric Blake
Subject: Re: AC_INIT mangling of PACKAGE_TARNAME
Date: Mon, 15 Jun 2009 06:00:10 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20090302 Thunderbird/ Mnenhy/

Hash: SHA1

According to Roger Leigh on 6/13/2009 9:13 AM:
> dnl Quoting the first argument results in a bizarrely corrupted package 
> tarname
> AC_INIT(sbuild_m4_esyscmd_s([sed -ne 
> '/^Package:/{s/Package:[[:space:]][[:space:]]*//p;q}' VERSION]),
>         [sbuild_m4_esyscmd_s([sed -ne 
> '/^Version:/{s/Version:[[:space:]][[:space:]]*//p;q}' VERSION])],
>         [sbuild_m4_esyscmd_s([sed -ne 
> '/^Maintained-By:/{s/Maintained-By:[[:space:]][[:space:]]*//p;q}' VERSION])])

And that is to be expected.  There are some macros (mostly in the m4_
namespace provided by m4sugar) that exist to massage text that will be
passed as an argument to other macros, rather than to be called after the
outer macro has been expanded.  AC_INIT treats its first argument as a
literal (rather than as a macro that might be later expanded), therefore
this is one of those cases where you WANT to call m4_esyscmd_s without
extra quotes.

> However, if I was to correctly quote the first argument to AC_INIT:
> AC_INIT([sbuild_m4_esyscmd_s([sed -ne 
> '/^Package:/{s/Package:[[:space:]][[:space:]]*//p;q}' VERSION])],
>         [sbuild_m4_esyscmd_s([sed -ne 
> '/^Version:/{s/Version:[[:space:]][[:space:]]*//p;q}' VERSION])],
>         [sbuild_m4_esyscmd_s([sed -ne 
> '/^Maintained-By:/{s/Maintained-By:[[:space:]][[:space:]]*//p;q}' VERSION])])

This is one case where it is NOT correct to quote the first argument to
AC_INIT, because you are using the esyscmd to generate a literal string
that will not be later expanded.

> I can't understand why PACKAGE_TARNAME is being handled in some special
> manner which results in this mess rather than just using the expanded
> form as for PACKAGE_NAME.  What is the reason for this, and if it's
> buggy please could it be fixed?

It's not buggy.  The manual states "It is preferable that the arguments of
AC_INIT be static, i.e., there should not be any shell computation, but
they can be computed by M4."  The reason for this special handling is that
the literal text passed to AC_INIT is then reused to build other macros
which can then be expanded elsewhere within configure.ac, and thus do not
undergo further macro expansion.

By the way, your use of [[:space:]] in those sed calls is not portable.
Not all sed implementations understand character classes.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


reply via email to

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