On 10/10/2013 06:32 AM, Thomas Jahns wrote: >> 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.
Almost. If AM_CONDITIONAL is defined, this expands to: AS_IF([test x"$var" != xfalse], [$test=1], AM_CONDITIONAL([TEST], [false])) which means the body of AM_CONDITIONAL is expanded before calling AS_IF, and that might not always work. > > 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. Yes, you would be safer with: AS_IF([test x"$var" != xfalse], [$test=1], m4_ifdef([AM_CONDITIONAL], [[AM_CONDITIONAL([TEST], [false])]])) which results in either: AS_IF([test x"$var" != xfalse], [$test=1], [AM_CONDITIONAL([TEST], [false])]) or AS_IF([test x"$var" != xfalse], [$test=1], ) (ie. you DO want to double quote the 2nd argument of m4_ifdef so that the net result is still a quoted 3rd argument to AS_IF). Another solution is to ensure that AM_CONDITIONAL is always defined (where its definition is a no-op if using an old automake that did not already define it): m4_define_default([AM_CONDITIONAL]) AS_IF([test x"$var" != xfalse], [$test=1], [AM_CONDITIONAL([TEST], [false])]) Finally, a question: what version of automake are you targetting? These days, RHEL 5 is about as old as I will personally go for a development target; but RHEL 5 includes automake 1.9.x, which defines AM_CONDITIONAL. Furthermore, unless you have taken efforts to patch your old automake, any stock upstream automake older than 1.12.2 will inject code into YOUR package that causes 'make distcheck' to have a CVE (ie. automake's CVE-2012-3386 and CVE-2009-4029 are viral - if your automake still suffers from one or both of those flaws, then every package built with that automake also suffers from the flaw). If you are worried about developing your code on a machine that has an automake older than 1.9, or even with automake 1.9 but where the vendor has not patched the CVEs yet, you are catering to museumware, and it may be simpler to just update your code to remove the cruft of trying to support something that ancient. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Autoconf mailing list Autoconf@gnu.org https://lists.gnu.org/mailman/listinfo/autoconf