SUBDIRS
vs. DIST_SUBDIRS
Automake considers two sets of directories, defined by the variables
SUBDIRS
and DIST_SUBDIRS
.
SUBDIRS
contains the subdirectories of the current directory
that must be built (see Recursing subdirectories). It must be defined
manually; Automake will never guess a directory is to be built. As we
will see in the next two sections, it is possible to define it
conditionally so that some directory will be omitted from the build.
DIST_SUBDIRS
is used in rules that need to recurse in all
directories, even those that have been conditionally left out of the
build. Recall our example where we may not want to build subdirectory
opt/, but yet we want to distribute it? This is where
DIST_SUBDIRS
comes into play: ‘opt’ may not appear in
SUBDIRS
, but it must appear in DIST_SUBDIRS
.
Precisely, DIST_SUBDIRS
is used by ‘make
maintainer-clean’, ‘make distclean’ and ‘make dist’. All
other recursive rules use SUBDIRS
.
If SUBDIRS
is defined conditionally using Automake
conditionals, Automake will define DIST_SUBDIRS
automatically
from the possible values of SUBDIRS
in all conditions.
If SUBDIRS
contains AC_SUBST
variables,
DIST_SUBDIRS
will not be defined correctly because Automake
does not know the possible values of these variables. In this case
DIST_SUBDIRS
needs to be defined manually.