Subject: bin/23821: [dM] make's chdir("obj") undocumented
To: None <gnats-bugs@gnats.netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: netbsd-bugs
Date: 12/21/2003 07:28:28
>Number: 23821
>Category: bin
>Synopsis: make's chdir to ./obj is undocumented
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: doc-bug
>Submitter-Id: net
>Arrival-Date: Sun Dec 21 12:29:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: der Mouse
>Release: 1.4T, 1.6.1, probably -current
>Organization:
Dis-
>Environment:
Any
>Description:
Under some circumstances, if ./obj exists, make(1) will
silently chdir to it. This is known to break ghostscript's
build under at least two versions. This is bad enough (there
really is no reason "obj"'s mere existence should be magic when
make is given no special options), but for the manpage to fail
to mention it is inexcusable - especially when it is almost
aggressively omitted; the manpage talks about MAKEOBJDIRPREFIX
and MAKEOBJDIR, but fails to mention that if neither is set,
./obj is used if it exists. (If I hadn't seen the obj/
semantics mentioned on-list, I would have been very
hard-pressed to figure out why the build was so inexplicably
breaking. I probably would have had to throw a debugger at it;
even as it was, I had to use the ktrace sledgehammer before I
twigged to it.)
I noticed this under 1.4T. I confirmed its presence under
1.6.1. I read the code and it looks to me as though it will
also be present in -current, though I haven't tried it there.
>How-To-Repeat:
(This transcript from a 1.6.1 system.)
$ cat Makefile
foo: bar
mkdir -p obj
cp bar foo
$ touch bar
$ ls -ld foo bar obj
ls: foo: No such file or directory
ls: obj: No such file or directory
-rw-r--r-- 1 root wheel 0 Dec 21 07:09 bar
$ make foo
mkdir -p obj
cp bar foo
$ rm foo
$ make foo
mkdir -p obj
cp bar foo
cp: bar: No such file or directory
*** Error code 1
Stop.
make: stopped in /home/mouse
$
Then change the Makefile so the directory name is something
else (and remove the obj/ that was created), and....
$ cat Makefile
foo: bar
mkdir -p objx
cp bar foo
$ touch bar
$ ls -ld foo bar obj objx
ls: foo: No such file or directory
ls: obj: No such file or directory
ls: objx: No such file or directory
-rw-r--r-- 1 root wheel 0 Dec 21 07:09 bar
$ make foo
mkdir -p objx
cp bar foo
$ rm foo
$ make foo
mkdir -p objx
cp bar foo
$
>Fix:
Personally, I feel that for make to use ./obj in the absence of
any explicit instruction to do so (such as an environment
variable or a command-line flag) is a bug. (It most certainly
violates least surprise.) Because I do not expect NetBSD to
agree with this position, I have classed this as a doc-bug
rather than a sw-bug, because the problem then becomes that
this use of ./obj is not documented, with the fix being to
describe the actual behaviour in the manpage.
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML mouse@rodents.montreal.qc.ca
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
>Release-Note:
>Audit-Trail:
>Unformatted: