Subject: Re: make seems to find the wrong source file
To: David Laight <david@l8s.co.uk>
From: Greywolf <greywolf@starwolf.com>
List: tech-toolchain
Date: 01/11/2004 11:58:03
Thus spake David Laight ("DL> ") sometime Today...

DL> With the following makefile:
DL>
DL> .SUFFIXES:
DL> .SUFFIXES: .a .b
DL>
DL> all: .PHONY x.b
DL>
DL> .a.b:
DL>         echo $<
DL>
DL> x.b: dir/x.a
DL>
DL> make tries to generate x.b using the commands from the .a.b suffix rule,
DL> but using the source file dir/x.a, rather that the source
DL> file implied by the suffix rule.
DL>
DL> I'm not sure this is (ever) desirable.
DL> Note that it requies the filename to match - so it will only ever
DL> build x.a, never y.a using the commands from the suffix rule.

It doesn't appear that it will ever build x.a at all unless you have
an explicit rule for generating it; your ".a.b" rule says "This is how
I translate .a files into .b files".  Did you, perhaps, mean that it
would build x.b, not y.b, using the commands from the suffix rule?
If so, I beg to differ:

#Contents of makefile:
.SUFFIXES:
.SUFFIXES: .a .b

.a.b:
	echo default rule $< $> $? $* $@

x.b:	./x.a

y.b:	./y.a
	echo specific rule $< $> $? $* $@

$ make x.b
make: don't know how to make ./x.a(continuing)
`x.b' not remade because of errors.
$ make y.b
make: don't know how to make ./y.a(continuing)
`y.b' not remade because of errors.
$ make z.b
make: don't know how to make z.b(continuing)


Stop.
make: stopped in /tmp
$ touch x.a y.a z.a
$ make x.b
echo default rule ./x.a ./x.a ./x.a x x.b
default rule ./x.a ./x.a ./x.a x x.b
$ make y.b
echo specific rule ./y.a ./y.a ./y.a y y.b
specific rule ./y.a ./y.a ./y.a y y.b
$ make z.b
echo default rule z.a z.a z.a z z.b
default rule z.a z.a z.a z z.b
$

Or did I miss completely what you were trying to say?

DL> It causes particular problems when the 'x.b: dir/x.a' line comes
DL> from the .depend file which also contains '.OPTIONAL: dir/x.a' and
DL> the source files have all been moved to a different directory.

I think that's a different problem altogether...

				--*greywolf;
--
22 Ways to Get Yourself Killed While Watching 'The Lord Of The Rings':

#6: Finish off every one of Elrond's lines with "...Mr. Anderson."