[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Empty else part in AS_IF
From: |
Thomas Jahns |
Subject: |
Re: Empty else part in AS_IF |
Date: |
Thu, 10 Oct 2013 14:32:04 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130922 Icedove/17.0.9 |
On 10/09/13 21:31, Eric Blake wrote:
> On 10/09/2013 01:18 PM, Julien LIE wrote:
>> The following piece of code:
>>
>> AS_IF([test x"$var" != xfalse], [$test=1], [m4_ifdef([AM_CONDITIONAL],
>> [AM_CONDITIONAL([TEST], [false])])])
>>
>> gives the following configure code with autoconf 2.69:
>>
>> if test x"$var" != xfalse; then : $test=1
>
> That's unusual shell syntax (it does NOT do a variable assignment; did you
> mean 'test=1' instead of trying to execute the program whose name is the
> expansion of $test concatenated with '=1'?)
>
>> else
>>
>> fi
>>
>> which is not a valid syntax.
>
> Indeed. The problem is that autoconf cannot tell if a non-empty literal
> will expand to empty text (m4_ifdef results in no output). You'll have to
> workaround it yourself:
>
> AS_IF([test x"$var" != xfalse], [$test=1], [: m4_ifdef(...)])
>
>
>>
>> Is it the expected behaviour of AS_IF when the else part is empty?
>
> Yes, it's expected that autoconf can't predict which macros expand to
> nothing. It's a dark corner case, where it costs far more m4 time to try
> and work around it (and probably get things wrong in the process) than it
> does to just say "don't do that".
The better(TM) approach is to let m4 figure out that the else part is empty by
not quoting the m4_ifdef, thereby deferring its evaluation.
AS_IF([test x"$var" != xfalse],
[$test=1],
m4_ifdef([AM_CONDITIONAL],
[AM_CONDITIONAL([TEST], [false])]))
Should give the expected result.
I haven't investigated if an additional level of quoting around
[AM_CONDITIONAL([TEST], [false])], i.e. using [[AM_CONDITIONAL([TEST],
[false])]] instead would improve matters in case of more complicated content.
Regards, Thomas
--
Thomas Jahns
DKRZ GmbH, Department: Application software
Deutsches Klimarechenzentrum
Bundesstrae 45a
D-20146 Hamburg
Phone: +49-40-460094-151
Fax: +49-40-460094-270
Email: Thomas Jahns <address@hidden>
smime.p7s
Description: S/MIME Cryptographic Signature
- Empty else part in AS_IF, Julien ÉLIE, 2013/10/09
- Re: Empty else part in AS_IF, Eric Blake, 2013/10/09
- Re: Empty else part in AS_IF, Julien ÉLIE, 2013/10/09
- Re: Empty else part in AS_IF,
Thomas Jahns <=
- Re: Empty else part in AS_IF, Eric Blake, 2013/10/10
- Re: Empty else part in AS_IF, Julien ÉLIE, 2013/10/10
- Re: Empty else part in AS_IF, Russ Allbery, 2013/10/10
- Re: Empty else part in AS_IF, Eric Blake, 2013/10/10
- Re: Empty else part in AS_IF, Russ Allbery, 2013/10/10
Re: Empty else part in AS_IF, Russ Allbery, 2013/10/10