Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 May 2009 11:15:07 +0200
From:      Mel Flynn <mel.flynn+fbsd.questions@mailing.thruhere.net>
To:        freebsd-questions@freebsd.org
Cc:        Anton Shterenlikht <mexas@bristol.ac.uk>
Subject:   Re: make - reassign variable using if-then ?
Message-ID:  <200905061115.07888.mel.flynn%2Bfbsd.questions@mailing.thruhere.net>
In-Reply-To: <20090506083152.GA48658@mech-cluster238.men.bris.ac.uk>
References:  <20090506083152.GA48658@mech-cluster238.men.bris.ac.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 06 May 2009 10:31:53 Anton Shterenlikht wrote:
> I've this simple makefile:
>
> VAR=one
>
> all	:	main
>
> main	:
> 	@echo ${.CURDIR}
> .if ${.CURDIR}
> 	@echo ${VAR}
> 	VAR=two
> 	@echo ${VAR}
> .endif
>
> When I output VAR second time, the value is still "one", and not the
> new value "two". Why?

Because it is expanded before being passed to the shell. Sh sees:
echo one
VAR=two
echo one

What are you really trying to accomplish?
-- 
Mel



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905061115.07888.mel.flynn%2Bfbsd.questions>