[Top][All Lists]

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

Re: AM_COND_IF with m4_foreach+m4_include

From: Ralf Wildenhues
Subject: Re: AM_COND_IF with m4_foreach+m4_include
Date: Thu, 10 Feb 2011 22:27:19 +0100
User-agent: Mutt/1.5.20 (2010-08-04)

Hello Dave,

* Dave Goodell wrote on Thu, Feb 10, 2011 at 10:02:12PM CET:
> I'm extremely confused about some behavior I recently encountered
> while adding AM_CONDITIONAL and AM_COND_IF to my project.  For some
> reason m4/autoconf don't want to expand AM_COND_IF when I use it in a
> particular fashion.  Here's my
> ----8<----
> AC_INIT([foo],[1.0])
> AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.11 subdir-objects])
> LT_INIT([])
> #begin
> var="yes"
> AM_CONDITIONAL([COND],[test "$var" = "yes"])
> dnl this makes m4 bail, claiming that AM_COND_IF is undefined
> m4_foreach([subsys_i],[[subconfigure]],[m4_include(subsys_i[.m4])])
> #end
> AC_OUTPUT([Makefile])
> ----8<----
> and here's subconfigure.m4:
> ----8<----
> # begin subconfigure.m4
> # this AM_COND_IF doesn't get expanded for some reason...
> AM_COND_IF([COND],[echo COND is true],[echo COND is false])
> # end subconfigure.m4
> ----8<----

leading to:

> autoreconf: running: /Users/goodell/prefix/bin/autoconf --force
> error: possibly undefined macro: AM_COND_IF
>       If this token and others are legitimate, please use m4_pattern_allow.
>       See the Autoconf documentation.
> autoreconf: /Users/goodell/prefix/bin/autoconf failed with exit status: 1

Yep.  This is a limitation in aclocal.  You know, aclocal is a bit dumb
sometimes.  It doesn't understand that subconfigure.m4 is included by
your, thus doesn't see that AM_COND_IF might be needed,
thus doesn't copy the definition of that macro into aclocal.m4.  Then
later, autoconf will protest about the unknown macro as you saw.

aclocal currently uses a regex to match m4_include lines against lines.  That of course fails when the argument to
m4_include contains a macro itself (subsys_i in your case).

The Right Fix[tm] would probably be to let aclocal use m4 tracing (or
ditch aclocal).  Not sure if that could be done safely, when macro
definitions are missing however.

A workaround is to add a dummy use of AM_COND_IF somewhere in your, so that it is pulled in by aclocal.

Hope that helps.


reply via email to

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