Subject: bin/4778: make .if empty() breaks with .for formal
To: None <gnats-bugs@gnats.netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: netbsd-bugs
Date: 01/05/1998 08:01:04
>Number: 4778
>Category: bin
>Synopsis: make .if empty() breaks with .for formal
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jan 5 05:05:02 1998
>Last-Modified:
>Originator: der Mouse
>Organization:
Dis-
>Release: 1.3
>Environment:
NetBSD/sparc on a SS1+
>Description:
make(1)'s .if empty() directive breaks when used to test a
(modified form of a) loop formal of a .for loop; make reacts as
though the loop formal were undefined. (The "Malformed
conditional" error below is the same error I get when I apply
.if empty() to an undefined variable.)
>How-To-Repeat:
% cat z
FOO != echo x; echo FLARP is $(FLARP) 1>&2
.for x in $(FLARP)
.if empty(x:E:Na)
FOO != echo x; echo the .if is true 1>&2
.else
FOO != echo x; echo the .if is false 1>&2
.endif
.endfor
% make -f z FLARP='foo.a bar.so'
FLARP is foo.a bar.so
"z", line 1: Malformed conditional (empty(x:E:Na))
"z", line 1: Missing dependency operator
the .if is true
"z", line 3: if-less else
"z", line 3: Need an operator
the .if is false
"z", line 5: if-less endif
"z", line 5: Need an operator
"z", line 1: Malformed conditional (empty(x:E:Na))
"z", line 1: Missing dependency operator
the .if is true
"z", line 3: if-less else
"z", line 3: Need an operator
the .if is false
"z", line 5: if-less endif
"z", line 5: Need an operator
Fatal errors encountered -- cannot continue
% diff z z2
3c3,4
< .if empty(x:E:Na)
---
> BAR := $(x:E:Na)
> .if empty(BAR)
% make -f z2 FLARP='foo.a bar.so'
FLARP is foo.a bar.so
the .if is true
the .if is false
make: no target to make.
%
>Fix:
I suspect that .for loops are implemented by constructing
transient makefile segments consisting of the body with the
iteration variable substituted out, which would explain several
oddities I've seen, including this bug. If so, about the only
hope is a reimplementation of .for, though in the interim it
would probably be a workable substitute to splatter warnings
all over the man page that .for loop formals do not work as
empty() arguments (and other such situations, if any).
der Mouse
mouse@rodents.montreal.qc.ca
7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
>Audit-Trail:
>Unformatted: