| Projects Home | Tools | Style | CVS | Doxygen |
![]() |
Autobuilding Projects |
From the autoconf manual:
Autoconf is a tool for producing shell scripts that automatically
configure software source code packages to adapt to many kinds of
UNIX-like systems.
Autoconf works by producing system-specific variants of files - the input files are named filename. and contain @varname@ symbols. Compilation is controlled by a script named configure which takes all of the filename.in sources and substitutes @varname@ with values determined by the configure script.
The companion of autoconf is automake which attempts to provide standard mechanisms for producing the input files to autoconf. The most important function of automake is to generate Makefile.in files for use by autoconf. It generates these files from Makefile.am files written by the programmer.
Setup
Each project has a unique home directory (usually the name of
the project). This directory contains configuration and
top-level documentation files used by autoconf and automake.
Since the directory is rather cluttered, source code is kept in
a subdirectory (by convention named src).
Source code can be placed directly in src or in subdirectories of src. If the project involves libraries and test programs it is wise to use at least two subdirectories: one for the library sources and another for the test programs. If you are using a subdirectory structure, the Makefile.am in src should contain a single single line "SUBDIRS = xxx yyy zzz" listing the subdirectory names. Compilation will proceed in the order specified, so in this case xxx will be compiled before yyy.
To add a directory containing code, you need to create a
Makefile.am, add the subdirectory to the parent directory's
Makefile.am and list the Makefile to be generated in
configure.in in the toplevel directory. If, for example, I was
to add a new subdirectory daemons to a project named Statmon in
/home/kkaugars/Statmon, I would:
mkdir /home/kkaugars/Statmon/src/daemons
create /home/kkaugars/Statmon/src/daemons/Makefile.am
edit /home/kkaugars/Statmon/src/Makefile.am to include daemons on the
SUBDIRS = line
edit /home/kkaugars/Statmon/configure.in and add src/daemons/Makefile
to the AC_OUTPUT section.
Makefile.am
The input to automake is Makefile.am. This is a highly
simplified form of a makefile which automake uses to generate
the complex Makefile.in files used by autoconf. The automatic
building system takes care of dependency checks, installation
paths, project packaging, etc...
To write a Makefile.am for a binary program, you need at least
two lines in the file:
bin_PROGRAMS = progname
progname_SOURCES = file1.C file2.C ...
The first line tells automake to build the program named
progname, the second tells automake that this program
consists of the source code files file1.C file2.C and so on.
aclocal Takes the macros in acinclude.m4 along with
any other local macros defined on the system and places them
into aclocal.m4 which will be picked up by the configure
script.
automake -a Translates the Makefile.am files into
Makefile.in files. The -a flag stands for "add any missing
files" and will add a series of support files into the project
home directory.
autoconf Generates the configure script.
The standard configure script accepts a number of standard parameters,
type ./configure --help in the project home
directory to see a complete list. The one flag most commonly
used is --prefix to set the prefix of the home directory, but
you do not need to specify even this flag for development. Just
run ./configure to generate the Makefiles needed
for your project.
Making
make the project will be compiled in place.
make clean will delete all of the object and other
temporary files.
make dist will build a .tar.gz file suitable for
distribution.
make install will install the project onto the system
make uninstall will remove the project from the system
More information
The manuals are also available for on-line browsing through www.gnu.org at:
http://www.gnu.org/manual/autoconf-2.52/autoconf.html
http://www.gnu.org/manual/autoconf-2.52/autoconf.html
I also have them installed locally:
autoconf
automake
And you can download a tar.gz file with the html documentation for use at home:
autoconf
automake
| Projects Home | Tools | Style | CVS | Doxygen |