Next: , Up: Format of   [Contents][Index]

5.2.1 The Autoconf Language

The Autoconf language is shell script augmented with the M4 preprocessor. See Syntax in The GNU M4 Manual for more information about the format of M4 input files. may contain references to macros, whose names are sequences of letters, digits and underscores (‘_’). Any macro names appearing in that are not to be expanded, or any strings looking like a macro, need to be quoted to prevent them being expanded. See Macro name quoting.

Arguments given to macros should be surrounded in parentheses and separated by commas. Any blanks or newlines immediately following either the open parenthesis, or a comma separating arguments, are ignored.

No white space may appear between the macro name and the opening parenthesis:

AC_INIT([hello], [1.0]) # good
AC_INIT ([oops], [1.0]) # incorrect

It is usually advisable to enclose the arguments with the quote characters ‘[’ and ‘]’. See Quoting macro arguments.

Whitespace is not ignored before commas or the closing parenthesis, whether it is enclosed in quotes or not, so the following includes a newline at the end of the second argument:

AC_INIT([oops], [1.0]
) # incorrect

Some macros take optional arguments, which this documentation represents as [arg] (not to be confused with the quote characters ‘[’ and ‘]’). You may just leave them empty, omit the trailing commas, or use ‘[]’ to make the emptiness of the argument explicit. The three lines below are equivalent:

AC_CHECK_HEADERS([stdio.h], [], [], [])

It is best to put each macro call on its own line in Most of the macros don’t add extra newlines: they rely on the newline after the macro call to terminate the commands. This approach makes the generated configure script a little easier to read by not inserting lots of blank lines. It is generally safe to set shell variables on the same line as a macro call, because the shell allows assignments without intervening newlines.

You can include comments in files by starting them with ‘#’. For example, it is helpful to begin files with a line like this:

# Process this file with autoconf to produce a configure script.

There are special sequences called quadrigraphs that the writer of may use to place characters in the produced configure script that are special in Autoconf’s syntax. For example, ‘@<:@’ is transformed into ‘[’, and ‘@:>@’ into ‘]’. See Quadrigraphs.

Next: , Up: Format of   [Contents][Index]