I'm currently over-hauling OpenBSD make.
During my investigations, I've stumbled upon an oddity of the way
VPATH works.
There are currently two hooks in make that handle VPATH.
- in dir.c, file name lookups resort to handling along the VPATH
when a file is not found in the current directory.
- the suffix handling rules know how to handle VPATH.
One part is left in the cold: explicit target rules. They're always
looked up with Targ_FindNode, and don't take VPATH into account.
Consider the following Makefile:
VPATH=some_dir
a: b
cp $> a
some_dir/b:
echo "toto" >$@
If you say `make', it will answer "don't know how to make b".
If you first say `make some_dir/b', then it will know how to make a,
looking up b in the right place.
You can get even weirder results if the some_dir/b: rule includes some
dependencies, because such dependencies won't be checked, even though
they apply to the same file.
This is completely inconsistent, and very error-prone.
Besides, I've had a hard time explaining this twice or thrice to gnu-make
advocates... as that program does the right thing in such a case.
The fix is probably not too hard. All revolves around Job_CheckCommands(),
which checks that a node is a `real' node first. Strategy is as follows:
- let the make parser generate false nodes as usual.
- around Job_CheckCommands, if the node is not real, try to see if there
is a more `real' node (e.g., one with dependencies and recreation rules)
along the path, and substitute it instead. (a bit icky, as the vpath
lookup rules in dir.c are not too fun, but I know how to do it).
Currently, what I'm interested in is collaboration: this changes the semantics
of make slightly, in a non-obvious way. If OpenBSD performs the change in a
dark corner, we'll be able to accept Makefiles that other BSD* may complain
about. Spewing a `warning, non standard feature used' is always possible,
but it would be better if we could agree on a common plan...
--
Marc Espie
|anime, sf, juggling, unicycle, acrobatics, comics...
|AmigaOS, OpenBSD, C++, perl, Icon, PostScript...
| `real programmers don't die, they just get out of beta'
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message