Another possibility is to define
(see Setting Output Variables).
… if test "$want_opt" = yes; then MAYBE_OPT=opt else MAYBE_OPT= fi AC_SUBST([MAYBE_OPT]) AC_CONFIG_FILES([Makefile src/Makefile opt/Makefile]) …
In this case the top-level Makefile.am should look as follows.
SUBDIRS = src $(MAYBE_OPT) DIST_SUBDIRS = src opt
The drawback of this method is that since Automake cannot guess what the
possible values of
MAYBE_OPT are, it is necessary to define