[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
7.2 Conditional Subdirectories
It is possible to define the SUBDIRS
variable conditionally if,
like in the case of GNU Inetutils, you want to only build a subset of
the entire package.
To illustrate how this works, let's assume we have two directories
‘src/’ and ‘opt/’. ‘src/’ should always be built, but we
want to decide in configure
whether ‘opt/’ will be built
or not. (For this example we will assume that ‘opt/’ should be
built when the variable ‘$want_opt’ was set to ‘yes’.)
Running make
should thus recurse into ‘src/’ always, and
then maybe in ‘opt/’.
However ‘make dist’ should always recurse into both ‘src/’ and ‘opt/’. Because ‘opt/’ should be distributed even if it is not needed in the current configuration. This means ‘opt/Makefile’ should be created unconditionally.
There are two ways to setup a project like this. You can use Automake
conditionals (see section Conditionals) or use Autoconf AC_SUBST
variables (see (autoconf)Setting Output Variables section `Setting Output Variables' in The Autoconf Manual). Using Automake
conditionals is the preferred solution. Before we illustrate these
two possibilities, let's introduce DIST_SUBDIRS
.
7.2.1 SUBDIRS vs. DIST_SUBDIRS | Two sets of directories | |
7.2.2 Subdirectories with AM_CONDITIONAL | Specifying conditional subdirectories | |
7.2.3 Subdirectories with AC_SUBST | Another way for conditional recursion | |
7.2.4 Unconfigured Subdirectories | Not even creating a ‘Makefile’ |