help-make
[Top][All Lists]
Advanced

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

Re: problem with rule chaining


From: gk
Subject: Re: problem with rule chaining
Date: Sat, 08 Feb 2003 19:02:00 -0800

From the manual:
>   Ordinarily, a file cannot be intermediate if it is mentioned in the
makefile as a target or prerequisite.  However, you can explicitly mark
a file as intermediate by listing it as a prerequisite of the special
target `.INTERMEDIATE'.  This takes effect even if the file is mentioned
explicitly in some other way.

I found a solution in using:
.INTERMEDIATE: foo.a

But this is confusing since 'foo.a' is not mentioned in my makefile as a target or prerequisite.

Here's the modified makefile that works. Is this the recommended solution?

#makefile
%: %.a
        touch $@

%.a: %.b
        touch $@

foo.b:
        touch $@

%:
        $(error No rule for target: $@))

.INTERMEDIATE: foo.a
#eof

address@hidden src]$ make foo
touch foo.b
touch foo.a
touch foo
rm foo.a

At 04:15 PM 2/8/2003 -0800, gk wrote:
It appears that rule chaining only works one level deep.
Can anyone explain what I'm doing wrong here?

I was under the impression that the way make works in deciding if a pattern rule applies is:
* if all prerequisites exist or can be made, then the rule applies
* if several rules 'can' apply, the one used is the first appearing in the makefile order

If the above is a correct understanding, then I expect make to use my explicit rule for 'foo.b' instead of the match-anything rule which comes later.

I am unable to build target 'foo' in the makefile below.

#makefile
%: %.a
        touch $@

%.a: %.b
        touch $@

foo.b:
        touch $@

%:
        $(error No rule for target: $@))
#eof

address@hidden src]$ make foo
Makefile:12: *** No rule for target: foo.  Stop.

- Greg Keraunen
http://www.xmake.org
http://www.xmlmake.com





reply via email to

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