delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/29/04:05:30

Date: Mon, 29 Sep 1997 10:02:44 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
cc: djgpp AT delorie DOT com
Subject: Re: Make v3.76.1 bug?
In-Reply-To: <nkhK9HAe2RL0Ewn3@talula.demon.co.uk>
Message-ID: <Pine.SUN.3.91.970929100221.1917C-100000@is>
MIME-Version: 1.0

On Sat, 27 Sep 1997, Shawn Hargreaves wrote:

> The latest version of make seems to be doing some quite strange things
> when conditional expressions are used to change the default target!

This seems to be a subtle bug in Make that is not DOS-specific.  The
part that deals with reading the Makefile and figuring out what each
line means is notoriously intertwined, and a change was done there in
the last version.  But I didn't have enough time to see what exactly
triggers this bug.

Anyway, it only takes a change as simple as removing the extra blank
between "target1" and the colon, and your Makefile works:

	ifeq ($(VAL),1)

	target1:
		@echo this is target #1
	endif

This works for me (please see that it does for you also).

(Personally, I'd advise against extra white space before the colon,
since this part of Makefile syntax is extremely tricky.  It is
possible that I never saw this bug because I *NEVER* leave excess
blanks before the colon.)

And btw, why did you have to use this weird way of choosing between
two targets?  I think the following is much better:

	ifeq ($(VAL),1)
	target = target1
	endif

	ifeq ($(VAL),2)
	target = target2
	endif

	default: $(target)
		 @echo Done.

	target1:
		@echo this is target 1

	target2:
		@echo this is target 2

IMHO, conditionals in the middle of rules, or conditionals that make
targets disappear, are dangerous.  I'm not even sure whether non-GNU
Make's support such a feature.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019