automake: Subdirectories with AM_CONDITIONAL
1
1 7.2.2 Subdirectories with ‘AM_CONDITIONAL’
1 ------------------------------------------
1
1 ‘configure’ should output the ‘Makefile’ for each directory and define a
1 condition into which ‘opt/’ should be built.
1
1 ...
1 AM_CONDITIONAL([COND_OPT], [test "$want_opt" = yes])
1 AC_CONFIG_FILES([Makefile src/Makefile opt/Makefile])
1 ...
1
1 Then ‘SUBDIRS’ can be defined in the top-level ‘Makefile.am’ as
1 follows.
1
1 if COND_OPT
1 MAYBE_OPT = opt
1 endif
1 SUBDIRS = src $(MAYBE_OPT)
1
1 As you can see, running ‘make’ will rightly recurse into ‘src/’ and
1 maybe ‘opt/’.
1
1 As you can’t see, running ‘make dist’ will recurse into both ‘src/’
1 and ‘opt/’ directories because ‘make dist’, unlike ‘make all’, doesn’t
1 use the ‘SUBDIRS’ variable. It uses the ‘DIST_SUBDIRS’ variable.
1
1 In this case Automake will define ‘DIST_SUBDIRS = src opt’
1 automatically because it knows that ‘MAYBE_OPT’ can contain ‘opt’ in
1 some condition.
1