automake
[Top][All Lists]
Advanced

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

Re: Appending to builtin Automake variables from an included file


From: Ralf Wildenhues
Subject: Re: Appending to builtin Automake variables from an included file
Date: Sat, 28 Feb 2009 11:16:18 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hello,

* Allan Caffee wrote on Thu, Feb 26, 2009 at 02:49:16PM CET:
> That is certainly one possibility.  Unfortunately though that means that
> in the Makefile.am files you _must_ use += since Automake will error out
> if you assign more than one value to a variable (within the same
> Automake conditional block).

Which is a good thing: two assignments are a potential error, and will
often result in something undesirable.

> But I was hoping for away that wouldn't
> require the author of Makefile.am to change their syntax.  I want to
> "sneak" some additional files onto the clean list.

This attitude can be fixed by changing the default approach: always
write your Makefile.am files or snippets so they only append to
variables.  :-)
That way, the only person needing to adjust is the one supplying the
outer file (or you first include a snippet that initializes all needed
variables to empty).

> Modern Automake does support appending.  But only appending to a
> variable that has already been set.

Yes.  This is done primarily to be able to diagnose typos, e.g.,
  foolish =
  foo1ish += bar

(no pun intended, BTW), but also to provide more deterministic semantics
in the presence of conditionals (I don't remember the details).

Is it worth the hassle?  It's certainly a trade-off:
- more work due to required initializations of all variables,
- OTOH typos in variables can have rather subtle implications,
  esp. if those variables are of the "magic automake" kind.

I suppose a more sophisticated implementation would allow to let
automake work in a mode that wouldn't error out on += for uninitialized
variables (e.g., with a command line switch -Wno-var-append or so).

>  My understanding is that Automake
> handles appending in a way very similar to that shown above, using temp
> variables which depending on the Automake conditionals defined, may or
> may not be empty.

Yes, possibly.

> This allows it to sidestep implementations of Make
> which don't allow +=.  Perhaps we could just drop the error about
> appending to an undefined variable and treat it as setting the variable
> if not already set.  I don't know how this would effect the reporting of
> "multiply defined" variables though.

See above.

> The real reason I think it would be nice to have this flexibility is for
> macro authors to be able to add files to be cleaned up/distributed
> without requiring the users to manually add anything to their setup.  So
> assuming anything I just said was actually correct, how difficult would
> it be to safely allow this?

I think thinking through the special cases that can come up with
conditionals would be most of the work.  If you want to contribute a
patch, please read the HACKING file in the git tree.

Cheers,
Ralf




reply via email to

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