[Top][All Lists]

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

Re: Problems with conditional sources

From: Paul Smith
Subject: Re: Problems with conditional sources
Date: Mon, 25 Aug 2008 18:10:22 -0400

On Mon, 2008-08-25 at 15:55 -0600, John Calcote wrote:
> Andreas Schwab wrote:
> > John Calcote <address@hidden> writes:
> > 
> >> Make is a two-pass utility. The first pass completely assimilates
> all
> >> macro data specified in the Makefile. THEN, the second pass
> generates
> >> the rule dependency tree.
> > 
> > This is not true.  Variable refences in target and dependency lists
> are
> > expanded when they are read.  Any later redefinition will not change
> > them.
> > 
> > Andreas.
> > 
> This is only true if you use ':=' assignment. In this case (only),
> variable *assignments* are expanded immediately. But regular rule or
> command references are only expanded when the rule or command is
> evaluated (as opposed to read).

No.  Andreas is correct.  Make uses a two-pass model, but during the
first pass all rules (targets and prerequisites) are expanded and the
dependency graph is created.  On the second pass, make actually builds
out of date targets.

For example, if you write:

        FOO = foo

        $(FOO): bar

        FOO = baz

you will have defined a rule "foo : bar", NOT a rule "baz : bar", even
though you are using recursively expanded variables (try it!)

If you read the section of the GNU make manual "How make reads a
makefile" it describes which parts of a makefile are read with immediate
expansion and which are read with deferred expansion.  Target and
prerequisite lists are read with immediate expansion.

reply via email to

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