bug-automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"conditional +=" doesn't work as suggested by documentation


From: Richard Brooksby
Subject: "conditional +=" doesn't work as suggested by documentation
Date: Fri, 12 May 2006 17:00:47 +0100

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".

Attachment: configure.ac
Description: Binary data

Attachment: Makefile.am
Description: Binary data


I get output like this:

address@hidden 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)
  }
address@hidden


reply via email to

[Prev in Thread] Current Thread [Next in Thread]