Search code examples
linuxautotoolsconfigureautoconfautomake

automake error message in autotools


I am trying to use Autotools for the first time. I have managed to compile my code with Hand written Makefile.in. and using autoconf (The ./configure make).

However Now, i decided to use Automake to generate a Makefile.in using Makefile.am

My Makefile.am:

bin_PROGRAMS=hello_portable
hello_portable_SOURCES=hello_portable.c

My configure.ac auto-generated by autoscan:

AC_PREREQ([2.69])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AM_INIT_AUTOMAKE(summary, 1.0.0)
AC_CONFIG_SRCDIR([hello_portable.c])
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS([sys/time.h])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
AC_CHECK_FUNCS([gettimeofday])

AC_OUTPUT

When I do automake in order to generate Makefile.in

# automake --add-missing

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)
Makefile.am: error: required file './NEWS' not found
Makefile.am: error: required file './README' not found
Makefile.am: error: required file './AUTHORS' not found
Makefile.am: error: required file './ChangeLog' not found
/usr/share/automake-1.14/am/depend2.am: error: am__fastdepCC does not appear in AM_CONDITIONAL
/usr/share/automake-1.14/am/depend2.am:   The usual way to define 'am__fastdepCC' is to add 'AC_PROG_CC'
/usr/share/automake-1.14/am/depend2.am:   to 'configure.ac' and run 'aclocal' and 'autoconf' again
/usr/share/automake-1.14/am/depend2.am: error: AMDEP does not appear in AM_CONDITIONAL
/usr/share/automake-1.14/am/depend2.am:   The usual way to define 'AMDEP' is to add one of the compiler tests
/usr/share/automake-1.14/am/depend2.am:     AC_PROG_CC, AC_PROG_CXX, AC_PROG_OBJC, AC_PROG_OBJCXX,
/usr/share/automake-1.14/am/depend2.am:     AM_PROG_AS, AM_PROG_GCJ, AM_PROG_UPC
/usr/share/automake-1.14/am/depend2.am:   to 'configure.ac' and run 'aclocal' and 'autoconf' again

What did I do wrong.


Solution

  • You need add couple of lines to your configure.ac:

    AC_PREREQ([2.69])
    AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
    AM_INIT_AUTOMAKE(summary, 1.0.0)
    AC_CONFIG_SRCDIR([hello_portable.c])
    AC_CONFIG_HEADERS([config.h])
    #LINE1!!!!!!!!!!
    AM_INIT_AUTOMAKE([1.9])
    
    # Checks for programs.
    AC_PROG_CC
    
    # Checks for libraries.
    
    # Checks for header files.
    AC_CHECK_HEADERS([sys/time.h])
    
    # Checks for typedefs, structures, and compiler characteristics.
    
    # Checks for library functions.
    AC_CHECK_FUNCS([gettimeofday])
    #LINE2!!!!!!!!!!!
    AC_CONFIG_FILES([Makefile])
    
    AC_OUTPUT
    

    after such modification you can run:

    touch NEWS README AUTHORS ChangeLog && autoreconfig -i && ./configure
    

    By the way there GNU hello world, you can use it as example: https://www.gnu.org/software/hello/