From owner-freebsd-bugs Fri Jan 18 7: 0:15 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 09EA337B41C for ; Fri, 18 Jan 2002 07:00:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g0IF01P31076; Fri, 18 Jan 2002 07:00:01 -0800 (PST) (envelope-from gnats) Received: from wwweasel.geeksrus.net (wwweasel.geeksrus.net [64.67.200.82]) by hub.freebsd.org (Postfix) with ESMTP id 239E837B419; Fri, 18 Jan 2002 06:57:12 -0800 (PST) Received: (from alane@localhost) by wwweasel.geeksrus.net (8.11.6/8.11.6) id g0IEuhC39935; Fri, 18 Jan 2002 09:56:43 -0500 (EST) (envelope-from alane) Message-Id: <200201181456.g0IEuhC39935@wwweasel.geeksrus.net> Date: Fri, 18 Jan 2002 09:56:43 -0500 (EST) From: Alan Eldridge Reply-To: Alan Eldridge To: FreeBSD-gnats-submit@freebsd.org Cc: sobomax@freebsd.org X-Send-Pr-Version: 3.113 Subject: bin/34032: make fails to evaluate some reasonable conditional expressions Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 34032 >Category: bin >Synopsis: make fails to evaluate some reasonable conditional expressions >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jan 18 07:00:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Alan Eldridge >Release: FreeBSD 4.4-STABLE i386 >Organization: Geeksrus.NET >Environment: System: FreeBSD wwweasel.geeksrus.net 4.4-STABLE FreeBSD 4.4-STABLE #0: Sun Dec 2 19:14:12 EST 2001 root@wwweasel.geeksrus.net:/usr/obj/usr/src/sys/WWWEASEL i386 >Description: A conditional such as: .if defined(WITH_FOO) && ${WITH_FOO:L} == yes does not evaluate correctly if WITH_FOO is undefined. This is exactly the sort of test we should be doing in ports makefiles to check for settings of knobs which control the build. Make shouldn't choke on this. Note: .if defined(WITH_FOO) && ${WITH_FOO} == yes works ok. It's the :L operator that is not behaving in the case of the variable being undefined. >How-To-Repeat: [alane ~]$ cat Makefile .if defined(WITH_FOO) && ${WITH_FOO:L} == yes all: echo foo .else all: echo bar .endif [alane ~]$ make all "Makefile", line 1: Malformed conditional (defined(WITH_FOO) && ${WITH_FOO:L} == yes) "Makefile", line 1: Need an operator "Makefile", line 4: if-less else "Makefile", line 4: Need an operator "Makefile", line 7: if-less endif "Makefile", line 7: Need an operator make: fatal errors encountered -- cannot continue [alane ~]$ make WITH_FOO=XX all echo bar bar [alane ~]$ make WITH_FOO=YES all echo foo foo [alane ~]$ >Fix: First, we have to decide what is broken. 1. The evaluation should be short-circuited once the value is known. OR 2. The :L and :U (and generally, all the :X suffix) operators should apply to an undefined variable as if it was defined to "". Which one is right? I think (1) is right; (2) introduces "silent failure" cases where error diagnostics should be produced. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message