automake: Conditional Programs
1
1 8.1.4 Conditional compilation of programs
1 -----------------------------------------
1
1 Sometimes it is useful to determine the programs that are to be built at
1 configure time. For instance, GNU ‘cpio’ only builds ‘mt’ and ‘rmt’
1 under special circumstances. The means to achieve conditional
1 compilation of programs are the same you can use to compile source files
1 conditionally: substitutions or conditionals.
1
1 Conditional Programs using ‘configure’ Substitutions
1 ....................................................
1
1 In this case, you must notify Automake of all the programs that can
1 possibly be built, but at the same time cause the generated
1 ‘Makefile.in’ to use the programs specified by ‘configure’. This is
1 done by having ‘configure’ substitute values into each ‘_PROGRAMS’
1 definition, while listing all optionally built programs in
1 ‘EXTRA_PROGRAMS’.
1
1 bin_PROGRAMS = cpio pax $(MT)
1 libexec_PROGRAMS = $(RMT)
1 EXTRA_PROGRAMS = mt rmt
1
1 As explained in ⇒EXEEXT, Automake will rewrite ‘bin_PROGRAMS’,
1 ‘libexec_PROGRAMS’, and ‘EXTRA_PROGRAMS’, appending ‘$(EXEEXT)’ to each
1 binary. Obviously it cannot rewrite values obtained at run-time through
1 ‘configure’ substitutions, therefore you should take care of appending
1 ‘$(EXEEXT)’ yourself, as in ‘AC_SUBST([MT], ['mt${EXEEXT}'])’.
1
1 Conditional Programs using Automake Conditionals
1 ................................................
1
1 You can also use Automake conditionals (⇒Conditionals) to select
1 programs to be built. In this case you don’t have to worry about
1 ‘$(EXEEXT)’ or ‘EXTRA_PROGRAMS’.
1
1 bin_PROGRAMS = cpio pax
1 if WANT_MT
1 bin_PROGRAMS += mt
1 endif
1 if WANT_RMT
1 libexec_PROGRAMS = rmt
1 endif
1