manpagez: man pages & more
info automake
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.1 Recursing subdirectories

In packages with subdirectories, the top level ‘Makefile.am’ must tell Automake which subdirectories are to be built. This is done via the SUBDIRS variable.

The SUBDIRS variable holds a list of subdirectories in which building of various sorts can occur. The rules for many targets (e.g., all) in the generated ‘Makefile’ will run commands both locally and in all specified subdirectories. Note that the directories listed in SUBDIRS are not required to contain ‘Makefile.am’s; only ‘Makefile’s (after configuration). This allows inclusion of libraries from packages that do not use Automake (such as gettext; see also Third-Party ‘Makefile’s).

In packages that use subdirectories, the top-level ‘Makefile.am’ is often very short. For instance, here is the ‘Makefile.am’ from the GNU Hello distribution:

EXTRA_DIST = BUGS ChangeLog.O README-alpha
SUBDIRS = doc intl po src tests

When Automake invokes make in a subdirectory, it uses the value of the MAKE variable. It passes the value of the variable AM_MAKEFLAGS to the make invocation; this can be set in ‘Makefile.am’ if there are flags you must always pass to make.

The directories mentioned in SUBDIRS are usually direct children of the current directory, each subdirectory containing its own ‘Makefile.am’ with a SUBDIRS pointing to deeper subdirectories. Automake can be used to construct packages of arbitrary depth this way.

By default, Automake generates ‘Makefiles’ that work depth-first in postfix order: the subdirectories are built before the current directory. However, it is possible to change this ordering. You can do this by putting ‘.’ into SUBDIRS. For instance, putting ‘.’ first will cause a prefix ordering of directories.

Using

SUBDIRS = lib src . test

will cause ‘lib/’ to be built before ‘src/’, then the current directory will be built, finally the ‘test/’ directory will be built. It is customary to arrange test directories to be built after everything else since they are meant to test what has been constructed.

All clean rules are run in reverse order of build rules.


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

This document was generated on February 3, 2012 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.