configure.info: Getting Started Example 3
Go forward to Generate Files in Example
Go backward to Getting Started Example 2
Go up to Getting Started Example
Go to the top op configure
Third Try
For our third try at this program, we will write a `configure.in'
script to discover the configuration features on the host system, rather
than requiring the user to edit the `Makefile'. We will also write a
`Makefile.am' rather than a `Makefile'.
The only change to `poke.c' is to add a line at the start of the
file:
#include "config.h"
The new `configure.in' file is as follows.
AC_INIT(poke.c)
AM_INIT_AUTOMAKE(poke, 1.0)
AM_CONFIG_HEADER(config.h:config.in)
AC_PROG_CC
AC_HEADER_STDC
AC_CHECK_HEADERS(utime.h)
AC_EGREP_HEADER(utimbuf, utime.h, AC_DEFINE(HAVE_STRUCT_UTIMBUF))
AC_FUNC_UTIME_NULL
AC_OUTPUT(Makefile)
The first four macros in this file, and the last one, were described
above; see *Note Write configure.in::. If we omit these macros, then
when we run `automake' we will get a reminder that we need them.
The other macros are standard autoconf macros.
`AC_HEADER_STDC'
Check for standard C headers.
`AC_CHECK_HEADERS'
Check whether a particular header file exists.
`AC_EGREP_HEADER'
Check for a particular string in a particular header file, in this
case checking for `utimbuf' in `utime.h'.
`AC_FUNC_UTIME_NULL'
Check whether `utime' accepts a NULL second argument to set the
file change time to the current time.
See the autoconf manual for a more complete description.
The new `Makefile.am' file is as follows. Note how simple this is
compared to our earlier `Makefile'.
bin_PROGRAMS = poke
poke_SOURCES = poke.c
This means that we should build a single program name `poke'. It
should be installed in the binary directory, which we called `bindir'
earlier. The program `poke' is built from the source file `poke.c'.
We must also write a `acconfig.h' file. Besides `PACKAGE' and
`VERSION', which must be mentioned for all packages which use automake,
we must include `HAVE_STRUCT_UTIMBUF', since we mentioned it in an
`AC_DEFINE'.
/* Name of package. */
#undef PACKAGE
/* Version of package. */
#undef VERSION
/* Whether utime.h defines struct utimbuf. */
#undef HAVE_STRUCT_UTIMBUF
Created Wed Sep 1 16:41:59 2004 on bee with info_to_html version 0.9.6.