On Wed, 15 Sep 2010, Eric Blake wrote:
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.
Well, i already tried to do that, with always the same message:
configure.ac:3: error: m4_defn: undefined macro: _m4_divert_diversion
configure.ac:3: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: autom4te failed with exit status: 1
So I was wondering if it was possible. Line 3 is where MY_INIT() is
called.
I tried to include the m4 file before with m4_include([m4/my_init.m4]).
Same error message
Vincent Torri
_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf