automake
[Top][All Lists]
Advanced

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

Re: Canonical way to conditionally add (a large amount of) sources to P


From: Guido Draheim
Subject: Re: Canonical way to conditionally add (a large amount of) sources to PROG_SOURCES?
Date: Tue, 12 Jun 2001 02:06:40 +0200

Hi Tim,

you do confuse me a bit - it seems as if you just missed the
target by micrometer, especially the middle one of your
examples looks very good....

> if MYCONDITIONAL
> OPTIONAL = lotsasource.c lotsayacc.y
> else
> OPTIONAL=
> endif
> 
> foo_SOURCES = $(REGULAR) $(OPTIONAL)

The only thing that I can see is that you did not yet make
a call to AM_CONDITIONAL (??) - that is the one that sets the
two _SUBST-vars called MYCONDITIONAL_FALSE and its sister
MYCONDITIONAL_TRUE, and these are probably the names that
will be later warned about. Just a guess anyway....

So, indeed use the if'..endif mark, and go along with a call 
to AM_CONDITIONAL in the configure.in. I think it should be
documented in the automake-docs, look for a section like
`Conditionals` - to quote from there:

|   Automake supports a simple type of conditionals.
|
|   Before using a conditional, you must define it by using
|`AM_CONDITIONAL' in the `configure.in' file (*note Macros::.).  The
|`AM_CONDITIONAL' macro takes two arguments.
|
|   The first argument to `AM_CONDITIONAL' is the name of the
|conditional.  This should be a simple string starting with a letter and
|containing only letters, digits, and underscores.
|
|   The second argument to `AM_CONDITIONAL' is a shell condition,
|suitable for use in a shell `if' statement.  The condition is evaluated
|when `configure' is run.

and therefore, if you used AM_CONDITIONAL(USE_OPTIONAL,xxx), then use

if USE_CONDITIONAL
OPTIONAL = lotsasource.c lotsayacc.y
endif

foo_SOURCES = $(REGULAR) $(OPTIONAL)

apart from that fact that this *should* work (unless you do other
tricky things), I don't like this scheme, and such is the same
for lots of others IMO - it isn't used very often. Sadly, other 
tricks  are simply not possible with stock automake since automake 
will see the list of source-files and generate a list of object-files 
- and it won't do that at make-time/configure-time, it will be 
done at autotools-time. I call this a misfeature, but for your
problem, the current am_conditional-scheme should be working.
HTH, cheers, Guido


Tim Van Holder wrote:
> 
> Hi,
> 
> I need to conditionally (based on a --with configure option)
> add a fairly large number (~50) of sources to foo_SOURCES.
> 
> First I tried
> 
> OPTIONAL=
> if MYCONDITIONAL
> OPTIONAL = lotsasource.c lotsayacc.y
> endif
> 
> foo_SOURCES = $(REGULAR) $(OPTIONAL)
> 
> but that didn't work; automake complains that OPTIONAL is already
> set in TRUE, which implies MYCONDITIONAL_TRUE.
> 
> Moving it to
> 
> if MYCONDITIONAL
> OPTIONAL = lotsasource.c lotsayacc.y
> else
> OPTIONAL=
> endif
> 
> foo_SOURCES = $(REGULAR) $(OPTIONAL)
> 
> didn't help; now I get three separate errors about am_foo_OBJECTS
> already being defined in a condition implied by another one.
> 
> So I tried
> 
> OPTIONAL = lotsasource.c lotsayacc.y
> 
> if MYCONDITIONAL
> foo_SOURCES = $(REGULAR) $(OPTIONAL)
> else
> foo_SOURCES = $(REGULAR)
> endif
> 
> which didn't give any warnings, but am_foo_OBJECTS is empty :-(
> 
> What is the proper way of handling such a situation?
> (If it's in the manual, please point me to the correct
> chapter; a cursory examination revealed nothing much).



reply via email to

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