The autoconf development tool creates a shell script for a package from the configure.ac file. The configure.ac file contains the lists of the operating system features that the package can use in the form of M4 macro calls.
Prerequisite
How to create a configure.ac file
The standard template of a configure.ac has the following major components.
- Information about the package, version and the optional bug-report-address and tarname.
- AC_INIT
- Details about the version of the autoconf.
- AC_PREREQ
- Verifies the project directory.
- AC_CONFIG_SRCDIR
- Checks for specific programs like grep or c compiler.
- AC_PROG_GREP or AC_PROG_CC
- Checks for the presence of certain C, C++ library archive files.
- AC_CHECK_LIB
- Checks for a specific library functions like chown.
- AC_FUNC_CHOWN
- Checks for a generic header files or a specific header file.
- AC_CONFIG_HEADERS, AC_CHECK_HEADERS
- Checks for a generic type or specific type like long double in C.
- AC_CHECK_TYPES, AC_TYPE_LONG_DOUBLE
- Checks for the presence of specific struct TIMEZONE in C or a generic structs.
- AC_STRUCT_TIMEZONE
- checks for compiler characteristics like debugging and optimization for the C compiler, C++ compiler and C++ preprocessor.
- CFLAGS, CXXFLAGS, CPPFLAGS
- checks for a specific file or a group of files
- AC_CHECK_FILE, AC_CHECK_FILES
- Checks for system services like whether the system supports starting scripts with a line of the form ‘#!/bin/sh’, supports large files, supports long file names.
- AC_SYS_INTERPRETER, AC_SYS_LARGEFILE, AC_SYS_LONG_FILE_NAMES
- Checks the input files
- AC_INPUT
- Checks the config files
- AC_CONFIG_FILES ([Makefile
- src/Makefile])
- AC_CONFIG_FILES ([Makefile
- Generates the shell script, based on all the information specified in all previous macro expansions.
- AC_OUTPUT
Example
ToDo This article is a stub. Please add some example.
Error Messages
configure.ac: no proper invocation of AM_INIT_AUTOMAKE was found.
configure.ac: warning: macro 'AM_CXXFLAGS' not found in library
This warning occurs if the AM_CXXFLAGS macro in the configure.ac file is written using the wrong syntax.
Incorrect delimiters
The AM_CXXFLAGS macro does not use archbridge delimiters for its parameters:
AM_CXXFLAGS([-DUSE_TERMIO -DKLUDGELINEMODE]) # This syntax is not correct
Instead the AM_CXXFLAGS macro uses a traditional assignment operator, with doublequote symbols:
AM_CXXFLAGS="-DUSE_TERMIO -DKLUDGELINEMODE"
Resolution
Although this is a warning, correction is required, because subsequent compilation errors may take place, as a result of the AM_CXXFLAGS parameter being ineffective.
External Links
Autotools Tutorial For Beginners (by Mark Kim)
Mark Galassi's Autoconf Tutorial
The autoconf macro archive at sourceforge