Previous: , Up: Some example packages   [Index]


17.4 A deep hierarchy

The GNU textutils are a collection of programs for manipulating text files. They are distributed as a deep package. The textutils have only recently been modified to use Automake; the examples come from a prerelease.

Here is the top-level Makefile.am:

SUBDIRS = lib src doc man

In the lib directory, a library is built which is used by each textutil. Here is lib/Makefile.am:

noinst_LIBRARIES = tu

EXTRA_DIST = rx.c regex.c

tu_SOURCES = error.h getline.h getopt.h linebuffer.h \
long-options.h md5.h regex.h rx.h xstrtod.h xstrtol.h xstrtoul.h \
error.c full-write.c getline.c getopt.c getopt1.c \
linebuffer.c long-options.c md5.c memchr.c safe-read.c \
xmalloc.c xstrtod.c xstrtol.c xstrtoul.c

tu_LIBADD = @REGEXOBJ@ @LIBOBJS@ @ALLOCA@

The src directory contains the source for all the textutils – 23 programs in all. The Makefile.am for this directory also includes some simple checking code, and constructs a version.c file on the fly:

bin_PROGRAMS = cat cksum comm csplit cut expand fmt fold head join md5sum \
nl od paste pr sort split sum tac tail tr unexpand uniq wc

noinst_HEADERS = system.h version.h
DISTCLEANFILES = stamp-v version.c

INCLUDES = -I$(top_srcdir)/lib

LDADD = version.o ../lib/libtu.a

$(PROGRAMS): version.o ../lib/libtu.a

AUTOMAKE_OPTIONS = ansi2knr

version.c: stamp-v
stamp-v: Makefile
	rm -f t-version.c
	echo '#include <config.h>' > t-version.c
	echo '#include "version.h"' >> t-version.c
	echo 'const char *version_string = "'GNU @PACKAGE@ @VERSION@'";' \
		>> t-version.c
	if cmp -s version.c t-version.c; then	\
	  rm t-version.c;			\
	else					\
	  mv t-version.c version.c;		\
	fi
	echo timestamp > $@

check: md5sum
	./md5sum \
	 --string="" \
	 --string="a" \
	 --string="abc" \
	 --string="message digest" \
	 --string="abcdefghijklmnopqrstuvwxyz" \
	 --string="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" \
	 --string="12345678901234567890123456789012345678901234567890123456789012345678901234567890" \
       | diff -c $(srcdir)/md5-test.rfc -

The doc directory builds the info documentation for the textutils:

info_TEXINFOS = textutils.texi

And, last, the man directory installs the man pages for all the textutils:

man_MANS = cat.1 cksum.1 comm.1 csplit.1 cut.1 expand.1 fmt.1 fold.1 head.1 \
join.1 md5sum.1 nl.1 od.1 paste.1 pr.1 sort.1 split.1 sum.1 tac.1 tail.1 \
tr.1 unexpand.1 uniq.1 wc.1

You can now see how easy it is to handle even a largish project using Automake.


Previous: Automake uses itself, Up: Some example packages   [Index]