make - reassign variable using if-then ?

Mel Flynn mel.flynn+fbsd.questions at mailing.thruhere.net
Wed May 6 09:15:13 UTC 2009


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


More information about the freebsd-questions mailing list