From owner-freebsd-hackers Sun Mar 16 00:21:42 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id AAA15819 for hackers-outgoing; Sun, 16 Mar 1997 00:21:42 -0800 (PST) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id AAA15808 for ; Sun, 16 Mar 1997 00:21:36 -0800 (PST) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.3/8.6.9) id TAA31378; Sun, 16 Mar 1997 19:18:09 +1100 Date: Sun, 16 Mar 1997 19:18:09 +1100 From: Bruce Evans Message-Id: <199703160818.TAA31378@godzilla.zeta.org.au> To: chuckr@glue.umd.edu, imp@village.org Subject: Re: Make question Cc: hackers@freebsd.org Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >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