The GNU Build System is basically composed of GNU Autoconf and GNU Automake. The latest versions of these tools are 2.59 and 1.9.1 respectively, at the moment of this writing. Compared to 2.13 and 1.4, these are far better, although not completely compatible with the previous ones. However, if you are maintaining a software project which uses these two tools, you should consider updating to the latest versions, as your program will be more portable and easier to manage.
Let’s discuss some of the changes you’ll need to do in the
configure.ac or configure.in file (note that the first name is
preferred):
- The
AC_INITmacro now takes four arguments (the last two are optional). The first one is the full name of the package in its full form; for example XML Catalog Manager; the second one is its version; the third one an email address where bugs should be reported; and the last one is the package name in its short form, like xmlcatmgr. Check out the GNU Autoconf manual for more details, because the last parameter can be automatically derived from the first if you follow some rules. - Be sure to set
AC_PREREQto2.59, so that GNU Autoconf knows if it should parse the file or not. - Since
AC_INITdoes not take a file name to verify if the script is being run from the appropiate directory, you have to use theAC_CONFIG_SRCDIRmacro to achieve the same thing. - Optionally set
AC_COPYRIGHTto a copyright string that should appear in the generated configure script, to take credit for your work. - The
AM_INIT_AUTOMAKEmacro now takes a whitespace separated list of options to pass to GNU Automake. My suggestion is that you add the following:1.9, which specifies the minimum version of the utility needed;-Wall, which turns on multiple warning messages;check-news, which verifies that yourNEWSfile describes the changes for the latest version; andno-define, which avoids defining thePACKAGEandVERSIONmacros in the configuration header (these two are deprecated anyway). - When formatting help strings, required by the
AC_ARG_ENABLEandAC_ARG_WITHmacros, use theAS_HELP_STRINGmacro. This ensures that the text appears properly aligned when calling./configure --help.
The Makefile.am files will also need some tweaks:
- Remove
AUTOMAKE_OPTIONSassignments, since we have specified them in theAM_INIT_AUTOMAKEmacro. - Rename the
INCLUDESvariable toAM_CPPFLAGS.
At last, since we are passing the no-define option to GNU Automake,
you’ll have to do some minor changes in your source files:
- Where you need to specify the full package name, use
PACKAGE_NAME. - Where you need to specify the package version, use
PACKAGE_VERSION. - Where you need to specify the full package name, together with its
version, use
PACKAGE_STRING. - Where you need to specify the short package name (usually, when
calling functions like
bindtextdomain), usePACKAGE_TARNAME. - As a rule of thumb, replacing
PACKAGEwithPACKAGE_TARNAMEandVERSIONwithPACKAGE_VERSIONshould produce the same results as before. However, the new macros allow more flexibility, so you can replace some hardcoded strings in your sources.
Well… and that’s all you need to get started. You may want to do other changes while you are at it, but you should now have a good idea of what needs to be done. Let’s code!
(Content also available at: gemini://capsule.jmmv.dev/post/2004/09/migrating-to-new-versions-of-gnu-build.gmi)