Next: Building etags and ctags, Previous: A simple example, start to finish, Up: Some example packages [Contents][Index]
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. GNU Hello is a deep package.
Here is the configure.in from GNU Hello:
dnl Process this file with autoconf to produce a configure script. AC_INIT(src/hello.c) AM_INIT_AUTOMAKE(hello, 1.3.11) AM_CONFIG_HEADER(config.h) dnl Set of available languages. ALL_LINGUAS="de fr es ko nl no pl pt sl sv" dnl Checks for programs. AC_PROG_CC AC_ISC_POSIX dnl Checks for libraries. dnl Checks for header files. AC_STDC_HEADERS AC_HAVE_HEADERS(string.h fcntl.h sys/file.h sys/param.h) dnl Checks for library functions. AC_FUNC_ALLOCA dnl Check for st_blksize in struct stat AC_ST_BLKSIZE dnl internationalization macros AM_GNU_GETTEXT 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:
EXTRA_DIST = BUGS ChangeLog.O 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 hello_LDADD = @INTLLIBS@ @ALLOCA@ localedir = $(datadir)/locale INCLUDES = -I../intl -DLOCALEDIR=\"$(localedir)\"
Next: Building etags and ctags, Previous: A simple example, start to finish, Up: Some example packages [Contents][Index]