The previous example showed an example of a hand-crafted layout template for configure.ac.
The layout template can be created automatically by another autotool, autoscan.
Just type the following in an empty directory:
autoscan
You should now have 2 files in the current directory:
$ ls
autoscan.log configure.scan
As we see, the contents of the generated configure.scan is similar to our hand-crafted template:
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.56)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
# Checks for programs.
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.56)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([sleep.c])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS([unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT
As we see, autoscan detected our source file sleep.c and added the following macros:
AC_CONFIG_SRCDIR:
some file that is in the package's source directory.
AC_CONFIG_HEADER:
containing C preprocessor #define statements.
AC_PROG_CC:
determine a C compiler to use.
AC_CHECK_HEADERS:
check for existing header file(s) (in our case only one, unistd.h).
To get a very basic, but working input file to autoconf, rename configure.scan to configure.ac...
mv configure.scan configure.ac
... and update the AC_INIT macro, and add the AC_COPYRIGHT macro:
configure.ac
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.56)
AC_INIT(sleep, 0.0.1, [email protected])
AC_CONFIG_SRCDIR([sleep.c])
AC_CONFIG_HEADER([config.h])
AC_COPYRIGHT([Copyright 2007, Johan Kuuse])
# Checks for programs.
AC_PROG_CC# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS([unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT
Run autoconf to create configure:
autoconf
Run the configure script, just to test the AC_INIT and AC_COPYRIGHT macros:
./configure --version
You should see something similar to:
sleep configure 0.0.1
generated by GNU Autoconf 2.56
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
Copyright 2007, Johan Kuuse