Subject: Re: make: Dir_FindFile still broken
To: None <tech-toolchain@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-toolchain
Date: 11/13/2002 22:23:42
In article <200211132034.MAA13216@zen.crufty.net>,
Simon J. Gerraty <sjg@crufty.net> wrote:
>>>On Tue, 12 Nov 2002 10:27:41 -0800 (PST), Simon Gerraty writes:
>>>>I'm still looking at the diffs for rev 1.32 and 1.27 to spot what to
>>>>do about it.
>>>
>>>Is the following fix too ugly?
>
>>I'd rather examine why the lookup does not stop when the first
>>one is found.
>
>Do you mean when say cat.c was first found as ../../src/bin/cat/cat.c ?
>It does, but then ../../src/bin/cat/cat.c ends up in .depend (a side effect
>of using gcc's -MD to automatically update dependencies), so on
>the next build make looks for ../../src/bin/cat/cat.c instead of cat.c
>and absent this change or some other fix, will find 
>../../src/bin/cat/../../src/bin/cat/cat.c and so on and so forth.
>
>I guess the real root cause of this is the fact that when you
>.PATH:
>to clear .PATH, the original 'dot' which has an absolute path is left
>which requires a releative path to .CURDIR to be added as well as .DOTLAST
>to get the desired behaviour.

But this is what it is supposed to do... I don't really want to do
the extra stat() because then we cheat and we look at `.' when we
are supposed to only look at it last; also we need to make sure
that the two paths resolve to the same file, and that will require
2 stats(). One way is to use size_t len = strlen(path); strncmp(path,
file, len) && file[len] == '/' but that does not feel right. Another
way is to parse the /../ and collapse them. Again this is ucky and
does not work in all cases.

christos