Go to the previous, next section.

Upgrading From Version 1

Autoconf version 2 is mostly backward compatible with version 1. However, it introduces better ways to do some things, and doesn't support some of the ugly things in version 1. So, depending on how sophisticated your `configure.in' files are, you might have to do some manual work in order to upgrade to version 2. This chapter points out some problems to watch for when upgrading. Also, perhaps your configure scripts could benefit from some of the new features in version 2; the changes are summarized in the file `NEWS' in the Autoconf distribution.

First, make sure you have GNU m4 version 1.1 or higher installed, preferably 1.3 or higher. Versions before 1.1 have bugs that prevent them from working with Autoconf version 2. Versions 1.3 and later are much faster than earlier versions, because as of version 1.3, GNU m4 has a more efficient implementation of diversions and can freeze its internal state in a file that it can read back quickly.

Changed File Names

If you have an `aclocal.m4' installed with Autoconf (as opposed to in a particular package's source directory), you must rename it to `acsite.m4'. See section Using autoconf to Create configure.

If you distribute `install.sh' with your package, rename it to `install-sh' so make builtin rules won't inadvertantly create a file called `install' from it. AC_PROG_INSTALL looks for the script under both names, but it is best to use the new name.

If you were using `config.h.top' or `config.h.bot', you still can, but you will have less clutter if you merge them into `acconfig.h'. See section Using autoheader to Create `config.h.in'.

Changed Makefiles

Add `@CFLAGS@', `@CPPFLAGS@', and `@LDFLAGS@' in your `Makefile.in' files, so they can take advantage of the values of those variables in the environment when configure is run. Doing this isn't necessary, but it's a convenience for users.

Also add `@configure_input@' in a comment to each input file for AC_OUTPUT, so that the output files will contain a comment saying they were produced by configure. Automatically selecting the right comment syntax for all the kinds of files that people call AC_OUTPUT on became too much work.

Add `config.log' and `config.cache' to the list of files you remove in distclean targets.

If you have the following in `Makefile.in':

prefix = /usr/local
exec_prefix = ${prefix}

you must change it to:

prefix = @prefix@
exec_prefix = @exec_prefix@

The old feature of replacing those variables without `@' characters around them has been removed.

Changed Macros

Many of the macros were renamed in Autoconf version 2. You can still use the old names, but the new ones are clearer, and it's easier to find the documentation for them. See section Old Macro Names, for a table showing the new names for the old macros. Use the autoupdate program to convert your `configure.in' to using the new macro names. See section Using autoupdate to Modernize configure.

Some macros have been superseded by similar ones that do the job better, but are not call-compatible. If you get warnings about calling obsolete macros while running autoconf, you may safely ignore them, but your configure script will generally work better if you follow the advice it prints about what to replace the obsolete macros with. In particular, the mechanism for reporting the results of tests has changed. If you were using echo or AC_VERBOSE (perhaps via AC_COMPILE_CHECK), your configure script's output will look better if you switch to AC_MSG_CHECKING and AC_MSG_RESULT. See section Printing Messages. Those macros work best in conjunction with cache variables. See section Caching Results.

Using autoupdate to Modernize configure

The autoupdate program updates a `configure.in' file that calls Autoconf macros by their old names to use the current macro names. In version 2 of Autoconf, most of the macros were renamed to use a more uniform and descriptive naming scheme. See section Macro Names, for a description of the new scheme. Although the old names still work (see section Old Macro Names, for a list of the old macro names and the corresponding new names), you can make your `configure.in' files more readable and make it easier to use the current Autoconf documentation if you update them to use the new macro names.

@evindex SIMPLE_BACKUP_SUFFIX If given no arguments, autoupdate updates `configure.in', backing up the original version with the suffix `~' (or the value of the environment variable SIMPLE_BACKUP_SUFFIX, if that is set). If you give autoupdate an argument, it reads that file instead of `configure.in' and writes the updated file to the standard output.

autoupdate accepts the following options:

--help
-h
Print a summary of the command line options and exit.

--macrodir=dir
-m dir
@evindex AC_MACRODIR Look for the Autoconf macro files in directory dir instead of the default installation directory. You can also set the AC_MACRODIR environment variable to a directory; this option overrides the environment variable.

--version
Print the version number of autoupdate and exit.

Changed Results

If you were checking the results of previous tests by examining the shell variable DEFS, you need to switch to checking the values of the cache variables for those tests. DEFS no longer exists while configure is running; it is only created when generating output files. This difference from version 1 is because properly quoting the contents of that variable turned out to be too cumbersome and inefficient to do every time AC_DEFINE is called. See section Cache Variable Names.

For example, here is a `configure.in' fragment written for Autoconf version 1:

AC_HAVE_FUNCS(syslog)
case "$DEFS" in
*-DHAVE_SYSLOG*) ;;
*) # syslog is not in the default libraries.  See if it's in some other.
  saved_LIBS="$LIBS"
  for lib in bsd socket inet; do
    AC_CHECKING(for syslog in -l$lib)
    LIBS="$saved_LIBS -l$lib"
    AC_HAVE_FUNCS(syslog)
    case "$DEFS" in
    *-DHAVE_SYSLOG*) break ;;
    *) ;;
    esac
    LIBS="$saved_LIBS"
  done ;;
esac

Here is a way to write it for version 2:

AC_CHECK_FUNCS(syslog)
if test $ac_cv_func_syslog = no; then
  # syslog is not in the default libraries.  See if it's in some other.
  for lib in bsd socket inet; do
    AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG)
      LIBS="$LIBS $lib"; break])
  done
fi

If you were working around bugs in AC_DEFINE_UNQUOTED by adding backslashes before quotes, you need to remove them. It now works predictably, and does not treat quotes (except backquotes) specially. See section Setting Output Variables.

All of the boolean shell variables set by Autoconf macros now use `yes' for the true value. Most of them use `no' for false, though for backward compatibility some use the empty string instead. If you were relying on a shell variable being set to something like 1 or `t' for true, you need to change your tests.

Changed Macro Writing

When defining your own macros, you should now use AC_DEFUN instead of define. AC_DEFUN automatically calls AC_PROVIDE and ensures that macros called via AC_REQUIRE do not interrupt other macros, to prevent nested `checking...' messages on the screen. There's no actual harm in continuing to use the older way, but it's less convenient and attractive. See section Macro Definitions.

You probably looked at the macros that came with Autoconf as a guide for how to do things. It would be a good idea to take a look at the new versions of them, as the style is somewhat improved and they take advantage of some new features.

If you were doing tricky things with undocumented Autoconf internals (macros, variables, diversions), check whether you need to change anything to account for changes that have been made. Perhaps you can even use an officially supported technique in version 2 instead of kludging. Or perhaps not.

To speed up your locally written feature tests, add caching to them. See whether any of your tests are of general enough usefulness to encapsulate into macros that you can share.

Go to the previous, next section.