At http://sources.redhat.com/automake/automake.html it says:
7.1.3.2 Conditional compilation using Automake conditionals
An often simpler way to compile source files conditionally is to
use Automake conditionals. For instance, you could use this
Makefile.am construct to build the same hello example:
bin_PROGRAMS = hello
if LINUX
hello_SOURCES = hello-linux.c hello-common.c
else
hello_SOURCES = hello-generic.c hello-common.c
endif
In this case, configure.ac should setup the LINUX conditional using
AM_CONDITIONAL (see Conditionals).
When using conditionals like this you don't need to use the EXTRA_
variable, because Automake will examine the contents of each
variable to construct the complete list of source files.
If your program uses a lot of files, you will probably prefer a
conditional +=.
bin_PROGRAMS = hello
hello_SOURCES = hello-common.c
if LINUX
hello_SOURCES += hello-linux.c
else
hello_SOURCES += hello-generic.c
endif
The former works, the latter does not. I'm running automake 1.6.3 on
Mac OS X 10.4. Try putting the attached minimal files in a directory
and running aclocal followed by automake.
configure.ac
Description: Binary data
Makefile.am
Description: Binary data
I get output like this:
[EMAIL PROTECTED] automake
Makefile.am:4: hello_SOURCES was already defined in condition TRUE,
which implies condition LINUX_TRUE
hello_SOURCES (User, where = Makefile.am:4) +=
{
TRUE = hello-common.c
}
Makefile.am:4: hello_SOURCES was already defined in condition TRUE,
which implies condition LINUX_FALSE
hello_SOURCES (User, where = Makefile.am:4) +=
{
TRUE = hello-common.c
LINUX_TRUE = hello-linux.c
}
Makefile.am:4: warning: automake does not support conditional
definition of hello_SOURCES in hello_SOURCES
Makefile.am:4: warning: automake does not support conditional
definition of hello_SOURCES in hello_SOURCES
Use of uninitialized value in concatenation (.) or string at /usr/bin/
automake line 8449.
: am_hello_OBJECTS was already defined in condition LINUX_TRUE, which
is implied by condition TRUE
am_hello_OBJECTS (Automake, where = undefined) =
{
LINUX_TRUE = hello-common.$(OBJEXT) hello-linux.$(OBJEXT)
}
Use of uninitialized value in concatenation (.) or string at /usr/bin/
automake line 8449.
: am_hello_OBJECTS was already defined in condition TRUE, which
implies condition LINUX_FALSE
am_hello_OBJECTS (Automake, where = undefined) =
{
TRUE = hello-common.$(OBJEXT)
LINUX_TRUE = hello-common.$(OBJEXT) hello-linux.$(OBJEXT)
}
[EMAIL PROTECTED]