Back: A Minimal GNU Autotools Project
Forward: Generated Output Files
 
FastBack: A Minimal GNU Autotools Project
Up: A Minimal GNU Autotools Project
FastForward: Writing configure.in
Top: Autoconf, Automake, and Libtool
Contents: Table of Contents
Index: Index
About: About this document

5.1 User-Provided Input Files

The smallest project requires the user to provide only two files. The remainder of the files needed to build the package are generated by the GNU Autotools (see section 5.2 Generated Output Files).

  • `Makefile.am' is an input to automake.
  • `configure.in' is an input to autoconf.

I like to think of `Makefile.am' as a high-level, bare-bones specification of a project's build requirements: what needs to be built, and where does it go when it is installed? This is probably Automake's greatest strength--the description is about as simple as it could possibly be, yet the final product is a `Makefile' with an array of convenient make targets.

The `configure.in' is a template of macro invocations and shell code fragments that are used by autoconf to produce a `configure' script (see section C. Generated File Dependencies). autoconf copies the contents of `configure.in' to `configure', expanding macros as they occur in the input. Other text is copied verbatim.

Let's take a look at the contents of the user-provided input files that are relevant to this minimal project. Here is the `Makefile.am':

 
bin_PROGRAMS = foonly
foonly_SOURCES = main.c foo.c foo.h nly.c scanner.l parser.y
foonly_LDADD = @LEXLIB@

This `Makefile.am' specifies that we want a program called `foonly' to be built and installed in the `bin' directory when make install is run. The source files that are used to build `foonly' are the C source files `main.c', `foo.c', `nly.c' and `foo.h', the lex program in `scanner.l' and a yacc grammar in `parser.y'. This points out a particularly nice aspect about Automake: because lex and yacc both generate intermediate C programs from their input files, Automake knows how to build such intermediate files and link them into the final executable. Finally, we must remember to link a suitable lex library, if `configure' concludes that one is needed.

And here is the `configure.in':

 
dnl Process this file with autoconf to produce a configure script.
AC_INIT(main.c)
AM_INIT_AUTOMAKE(foonly, 1.0)
AC_PROG_CC
AM_PROG_LEX
AC_PROG_YACC
AC_OUTPUT(Makefile)

This `configure.in' invokes some mandatory Autoconf and Automake initialization macros, and then calls on some Autoconf macros from the AC_PROG family to find suitable C compiler, lex, and yacc programs. Finally, the AC_OUTPUT macro is used to cause the generated `configure' script to output a `Makefile'---but from what? It is processed from `Makefile.in', which Automake produces for you based on your `Makefile.am' (see section C. Generated File Dependencies).


This document was generated by Gary V. Vaughan on May, 24 2001 using texi2html