I'm trying to make a bare-bones autotools project. I'm adapting from this tutorial:
https://crypto.bi/autotools/
I have all the required files (I think) and run aclocal --verbose
and I get a lot of output, most of which is probably not too helpful, save one line I think which is relevant:
...
aclocal: found macro AM_INIT_AUTOMAKE in /usr/share/aclocal-1.13/init.m4: 23
...
After this program finishes, there isn't any aclocal.m4
created, and from what I understand, there should be.
After running aclocal
, if I run automake --add-missing
, I get the following error:
configure.ac: error: no proper invocation of AM_INIT_AUTOMAKE was found.
configure.ac: You should verify that configure.ac invokes AM_INIT_AUTOMAKE,
configure.ac: that aclocal.m4 is present in the top-level directory,
configure.ac: and that aclocal.m4 was recently regenerated (using aclocal)
automake: error: no 'Makefile.am' found for any configure output
automake: Did you forget AC_CONFIG_FILES([Makefile]) in configure.ac?
I have the following configure.ac
AC_INIT([YOURPROJECT], [1.0])
AC_CONFIG_SRCDIR([.])
AC_INIT_AUTOMAKE
AC_CONFIG_MACRO_DIRS([m4])
AC_PREREQ([2.69])
AC_CONFIG_HEADERS([config.h])
AC_PROG_CC
AC_CHECK_HEADERS([stdlib.h])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
and the following Makefile.am
:
AM_LDFLAGS=
AM_CPPFLAGS=
ACLOCAL_AMFLAGS=-I m4
bin_PROGRAMS=main
main_SOURCES=main.c
main_LDADD=
How can I generate that aclocal.m4
file?
Rewriting your configure.ac
to something which has a chance of working:
AC_PREREQ([2.69])
AC_INIT([YOURPROJECT], [1.0])
AC_CONFIG_SRCDIR([my-main.c])
AC_CONFIG_MACRO_DIRS([m4])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([])
AC_PROG_CC
AC_CHECK_HEADERS([stdlib.h])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
The main change:
AM_INIT_AUTOMAKE
does not start with AC_
. Not finding AM_INIT_AUTOMAKE
is exactly what your automake
error message is complaining about. So this should make it possible to generate an aclocal.m4
file.Additional changes:
AC_PREREQ
should be in the first line.AC_CONFIG_SRCDIR
.Also, just call autoreconf
once and let it take care of which tools to call in which sequence (aclocal, automake, autoconf, autoheader, and whatever else).