Date: Sun, 16 Mar 1997 19:18:09 +1100 From: Bruce Evans <bde@zeta.org.au> To: chuckr@glue.umd.edu, imp@village.org Cc: hackers@freebsd.org Subject: Re: Make question Message-ID: <199703160818.TAA31378@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>I think the problem is that /usr/src is a symlink to >/jaz/FreeBSD/current/src and when I recurse it uses the real path, >while when I don't it uses $PWD. When I cd to >/jaz/FreeBSD/current/src/usr.bin/file rather than >/usr/src/usr.bin/file, then it picks up the right thing :-(. > >Sounds like a bug to me. Yes, the existence of $PWD support in `make' and shells is probably a bug. If $PWD is set and has the same device and inode as the real path, then `make' uses it instead of the path returned by getcwd() for ${.CURDIR}. It also sets $PWD in the environment to ${.CURDIR} in an attempt to show a consistent tree to sub-makes. However, this can't work unless all shells set $PWD in the same way as `make'. They don't: First, the setting of $PWD seen by the top-level make depends on whether the shell that invoked this make sets and/or exports $PWD. E.g., /bin/sh neither sets nor exports $PWD, but if $PWD is already set and exported then it will be re-exported (with the wrong value after a cd). Fix: use only real shells (that don't export $PWD). Second, sub-makes use /bin/sh, so the behaviour is deterministic, but it is normal for $PWD to be stale after a cd. `make' notices that the device or inode for $PWD is wrong, so it doesn't use the wrong $PWD; it uses the canonical one instead of the one you want. This is a non-problem except for its interaction with the first problem. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703160818.TAA31378>