autoconf
[Top][All Lists]
Advanced

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

Re: m4 macro that would call AAC_INIT


From: Eric Blake
Subject: Re: m4 macro that would call AAC_INIT
Date: Wed, 15 Sep 2010 09:39:27 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.3

On 09/15/2010 09:21 AM, Vincent Torri wrote:

Hey,

except AC_PREREQ() (and m4 calls), no macro should be called before
AC_INIT(). Does this include the call of an m4 macro which itself would
call AC_INIT. that is, smething like that:

*** my_init.m4 ***

AC_DEFUN([EFL_INIT],
[

m4_define([v_maj], [$2])
m4_define([v_min], [$3])
m4_define([v_mic], [$4])
m4_define([v_ver], [v_maj.v_min.v_mic])

AC_INIT([$1], [v_ver])

])

*** configure.ac ***

MY_INIT(foo, 1, 2, 3)

I see no reason why that would not work from the m4 perspective, *as long as* my_init.m4 is somehow sourced prior to the MY_INIT line in configure.ac. Generally, when using the autom4te --language=Autoconf language, this means that my_init.m4 is included from aclocal.m4 (either because aclocal from the Automake package noticed it was a used AC_DEFUN macro, or because you did it by hand). If MY_INIT is defined in time, then it will be expanded at m4 time, which in turn calls four instances of m4_define (all safe, by your above quote), and finally the call to AC_INIT will properly occur as the first autoconf-specific macro.

However, there may be other tools outside of autoconf that grep configure.ac (rather than properly relying on autom4te tracing), and might get confused by what you've done. Likewise, I'm not sure whether aclocal will succeed at generating aclocal.m4 correctly, since it uses autom4te --language=Autoconf-without-aclocal-m4 under the hood, and with that particular invocation of autom4te, I don't see how you are going to have my_init.m4 included in time to have EFL_INIT defined before it is used; AC_INIT _has_ to be expanded even during aclocal for the rest of aclocal's magic to work.

If you are having problems getting the definition of MY_INIT seen with that cross-file approach, maybe adding m4_include([my_init.m4]) at the start of configure.ac will help?

At any rate, rather than just asking about the theory, how about trying it out first. Either it will work, and you are done; or things will fail to do what you were hoping, but then you are armed with explicit error messages and actual output so that your query to the list can contain more details about what you tried vs. what you were hoping.

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

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