www.delorie.com/gnu/docs/automake/automake_11.html   search  
Buy GNU books!


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 A classic program

GNU hello is renowned for its classic simplicity and versatility. This section shows how Automake could be used with the GNU Hello package. The examples below are from the latest beta version of GNU Hello, but with all of the maintainer-only code stripped out, as well as all copyright comments.

Of course, GNU Hello is somewhat more featureful than your traditional two-liner. GNU Hello is internationalized, does option processing, and has a manual and a test suite.

Here is the `configure.in' from GNU Hello:

dnl Process this file with autoconf to produce a configure script.
AM_INIT_AUTOMAKE(hello, 1.3.11)

dnl Set of available languages.
ALL_LINGUAS="de fr es ko nl no pl pt sl sv"

dnl Checks for programs.

dnl Checks for libraries.

dnl Checks for header files.
AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h)

dnl Checks for library functions.

dnl Check for st_blksize in struct stat

dnl internationalization macros
AC_OUTPUT([Makefile doc/Makefile intl/Makefile po/Makefile.in \
           src/Makefile tests/Makefile tests/hello],
   [chmod +x tests/hello])

The `AM_' macros are provided by Automake (or the Gettext library); the rest are standard Autoconf macros.

The top-level `Makefile.am':

SUBDIRS = doc intl po src tests

As you can see, all the work here is really done in subdirectories.

The `po' and `intl' directories are automatically generated using gettextize; they will not be discussed here.

In `doc/Makefile.am' we see:

info_TEXINFOS = hello.texi
hello_TEXINFOS = gpl.texi

This is sufficient to build, install, and distribute the GNU Hello manual.

Here is `tests/Makefile.am':

TESTS = hello
EXTRA_DIST = hello.in testdata

The script `hello' is generated by configure, and is the only test case. make check will run this test.

Last we have `src/Makefile.am', where all the real work is done:

bin_PROGRAMS = hello
hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h
localedir = $(datadir)/locale
INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003