Date: Fri, 18 Jan 2002 09:56:43 -0500 (EST) From: Alan Eldridge <ports@geeksrus.net> To: FreeBSD-gnats-submit@freebsd.org Cc: sobomax@freebsd.org Subject: bin/34032: make fails to evaluate some reasonable conditional expressions Message-ID: <200201181456.g0IEuhC39935@wwweasel.geeksrus.net>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200201181456.g0IEuhC39935>