NetBSD Problem Report #43669
From dholland@eecs.harvard.edu Mon Jul 26 07:47:11 2010
Return-Path: <dholland@eecs.harvard.edu>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by www.NetBSD.org (Postfix) with ESMTP id EC33663BAE5
for <gnats-bugs@gnats.NetBSD.org>; Mon, 26 Jul 2010 07:47:10 +0000 (UTC)
Message-Id: <20100726074152.384CAF8D4@tanaqui.eecs.harvard.edu>
Date: Mon, 26 Jul 2010 03:41:52 -0400 (EDT)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@gnats.NetBSD.org
Subject: another problem parsing conditionals in make
X-Send-Pr-Version: 3.95
>Number: 43669
>Category: bin
>Synopsis: another problem parsing conditionals in make
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jul 26 07:50:00 +0000 2010
>Closed-Date: Sun Jan 01 00:59:55 +0000 2017
>Last-Modified: Sun Jan 01 00:59:55 +0000 2017
>Originator: David A. Holland
>Release: NetBSD 5.99.29 (make from today though)
>Organization:
>Environment:
System: NetBSD valkyrie 5.99.29 NetBSD 5.99.29 (VALKYRIE) #1: Sat May 29 23:00:44 EDT 2010 dholland@valkyrie:/usr/src/sys/arch/amd64/compile/VALKYRIE amd64
Architecture: amd64
Machine: x86_64
>Description:
Make horks unexpectedly on some conditionals and not others that ought
to be entirely equivalent.
Consider the following two makefiles:
---- Makefile1 ----
moo:
.if defined(MOO) && !empty(MOO:Myes)
@echo moo
.else
@echo no moo
.endif
---- Makefile2 ----
moo:
.if defined(MOO) && !empty(MOO:Myes) && 1
@echo moo
.else
@echo no moo
.endif
---- (end) ----
and observe the following behavior:
valkyrie% make -f Makefile1 MOO=yes
moo
valkyrie% make -f Makefile1 MOO=no
no moo
valkyrie% make -f Makefile1 MOO=
no moo
valkyrie% make -f Makefile1
no moo
valkyrie% make -f Makefile2 MOO=yes
moo
valkyrie% make -f Makefile2 MOO=no
no moo
valkyrie% make -f Makefile2 MOO=
no moo
valkyrie% make -f Makefile2
make: "/tmp/test/Makefile2" line 2: Malformed conditional (defined(MOO) && !empty(MOO:Myes) && 1)
make: Fatal errors encountered -- cannot continue
make: stopped in /tmp/test
Exit 1
valkyrie%
I really can't think of any sane reason that make should accept the
conditional in Makefile1 when MOO isn't defined but not the form in
Makefile2.
For that matter, I can't think of any reason make should reject the
conditional in Makefile2; both defined(MOO) and !empty(MOO:Myes)
should yield false when MOO is undefined, not something like an empty
string that would legitimately upset make.
However, sanity isn't make's long suit. :-)
>How-To-Repeat:
as above
>Fix:
no idea.
(well, other than restructure the whole thing as I've proposed in the past)
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 01 Jan 2017 00:59:55 +0000
State-Changed-Why:
No longer happens.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.