[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.1.3.1 Conditional compilation using _LDADD substitutions

Automake must know all the source files that could possibly go into a program, even if not all the files are built in every circumstance. Any files which are only conditionally built should be listed in the appropriate `EXTRA_' variable. For instance, if `hello-linux.c' or `hello-generic.c' were conditionally included in hello, the `Makefile.am' would contain:

 
bin_PROGRAMS = hello
hello_SOURCES = hello-common.c
EXTRA_hello_SOURCES = hello-linux.c hello-generic.c
hello_LDADD = @HELLO_SYSTEM@
hello_DEPENDENCIES = @HELLO_SYSTEM@

You can then setup the @HELLO_SYSTEM@ substitution from `configure.in':

 
...
case $host in
  *linux*) HELLO_SYSTEM='hello-linux.$(OBJEXT)' ;;
  *)       HELLO_SYSTEM='hello-generic.$(OBJEXT)' ;;
esac
AC_SUBST([HELLO_SYSTEM])
...

In this case, HELLO_SYSTEM should be replaced by `hello-linux.o' or `hello-bsd.o', and added to hello_DEPENDENCIES and hello_LDADD in order to be built and linked in.



This document was generated by Jeff Bailey on December, 24 2002 using texi2html