autoconf
[Top][All Lists]
Advanced

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

AM_COND_IF with m4_foreach+m4_include


From: Dave Goodell
Subject: AM_COND_IF with m4_foreach+m4_include
Date: Thu, 10 Feb 2011 15:02:12 -0600

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 
configure.in:

----8<----
AC_INIT([foo],[1.0])
AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.11 subdir-objects])
LT_INIT([])
AC_PROG_CC
#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<----

here's the resulting snippet of configure between "#begin" and "#end":

----8<----
#begin
var="yes"
 if test "$var" = "yes"; then
  COND_TRUE=
  COND_FALSE='#'
else
  COND_TRUE='#'
  COND_FALSE=
fi

# 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

#end
----8<----

And here's the error message from autoconf (invoked via "autoreconf -vif"):

----8<----
autoreconf: running: /Users/goodell/prefix/bin/autoconf --force
configure.in:8: 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
----8<----

Many variations of this script work as expected, including non-looped 
"m4_include" and looped "m4_include" but explicitly naming "subconfigure.m4" 
instead of attempting to compute it from the loop variable.  Have I botched the 
m4 quoting somehow?  Is there a gotcha w.r.t. using m4_include that I missed 
somewhere?  Other "AC_" macros (such as "AC_PROG_GREP") seem to work just fine 
in the included file, so I don't think it's a general issue.  Also, the include 
file name seems to be computed correctly and used by m4_include, since the 
contents of subconfigure.m4 do end up in the output stream...

I believe I have several possible workarounds, so I'm not too worried about the 
fact that I can't get this to work.  However it sure is baffling, and 
conditional AC_CONFIG_FILES support would be nice.  Any insight that a more 
m4/autotools-proficient reader can offer would be appreciated.

Thanks,
-Dave

P.S. If it's relevant, I'm using m4-1.4.14, autoconf-2.67, automake-1.11.1, and 
libtool-2.2.6b.


reply via email to

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