Subject: bin/5116: Odd conditional/escaping behavior in make
To: None <gnats-bugs@gnats.netbsd.org>
From: David Holland <dholland@eecs.harvard.edu>
List: netbsd-bugs
Date: 03/04/1998 16:00:05
>Number:         5116
>Category:       bin
>Synopsis:       Odd conditional/escaping behavior in make
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar  4 13:20:01 1998
>Last-Modified:
>Originator:     David A. Holland <dholland@eecs.harvard.edu>
>Organization:
   - David A. Holland             |    VINO project home page:
     dholland@eecs.harvard.edu    | http://www.eecs.harvard.edu/vino
>Release:        1.2.1
>Environment:
	
System: NetBSD chianti.eecs.harvard.edu 1.2.1 NetBSD 1.2.1 (CHIANTI) #1: Tue Sep 9 16:52:39 EDT 1997 root@chianti.eecs.harvard.edu:/usr/src/sys/arch/i386/compile/CHIANTI i386

This also occurs in a -current I have from last April 10 (I know, that's
not much help.)

>Description:
	The parsing of makefiles seems to depend in this particular 
	case on the truth of an earlier enclosing conditional. 
	Specifically, an .endif seems to evaporate under the given
	circumstances when embedded in the non-evaluating branch of
	another conditional, thus leading to a mistaken claim of an
	unclosed conditional.
>How-To-Repeat:
	Take the following makefile and run it both with and without
	a file CONFIG present in the current directory. It fails with
	a parse error only if CONFIG is not present.


SWITCH=1

.if !exists(CONFIG)
all:
	@echo no config

.else


.if ($(SWITCH)==0)
SOMEVAR= bbb \
	bbb
.else
SOMEVAR= aaa \
	aaa \

.endif


all: 
	@echo $(SOMEVAR)

.endif
>Fix:
	The problem may be worked around by omitting the trailing slash
	on the second "aaa \". Inserting an additional blank line before
	the first .endif also seems to make it go away.

	I don't have a real fix.

>Audit-Trail:
>Unformatted: