[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: autoconf's -I flag in simple configure.ac cases
From: |
Zack Weinberg |
Subject: |
Re: autoconf's -I flag in simple configure.ac cases |
Date: |
Sun, 27 Sep 2020 11:25:07 -0400 |
On Sun, Sep 27, 2020 at 10:53 AM Jannick <thirdedition@gmx.net> wrote:
>
> it appears that autoconf's -I flag does not show any effect in simple cases
> (namely simple test cases without AC_CONFIG_MACRO_DIRS which implies other
> dependencies like AM_INIT_AUTOMAKE).
>
> The simple example below shows that autoconf passes the -I flag on to
> autom4te, but the m4-macro defined in m4/help.m4 is not expanded in
> configure. Or is it that hell.m4 is to be explicitly m4_include'd in
> configure.ac (which does certainly help here)? If this was correct, what
> exactly should one expect autoconf's -I flag to do - in such a simple case
> and in general?
The effect of `-I m4` on autoconf itself is to let you write
`m4_include([hello.m4])` instead of `m4_include([m4/hello.m4])`. If I
change your sample configure.ac to read
AC_INIT
m4_include([hello.m4])
SAY_HELLO
AC_OUTPUT
then
$ autoconf; echo $?
/usr/bin/m4:configure.ac:2: cannot open `hello.m4': No such file or directory
autom4te: /usr/bin/m4 failed with exit status: 1
1
but
$ autoconf -I m4; echo $?
0
$ grep -i hello configure
$as_echo Hello!
If you want to not have to write the m4_include yourself, you need
`aclocal`, which is distributed along with automake, but can be used
without automake proper. For instance (same m4/hello.m4)
$ cat > configure.ac <<EOF
AC_INIT
SAY_HELLO
AC_OUTPUT
EOF
$ aclocal -I m4
$ autoconf # -I m4 no longer needed here
$ grep -i hello configure
$as_echo Hello!
$ grep m4_include aclocal.m4
m4_include([m4/hello.m4])
Hope this helps.
zw