make - reassign variable using if-then ?

Anton Shterenlikht mexas at bristol.ac.uk
Wed May 6 08:32:03 UTC 2009


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?

% make
/usr/home/mexas
one
VAR=two
one

And gmake gives an error:

% gmake
makefile:7: *** missing separator.  Stop.
% 

please help
many thanks
anton

-- 
Anton Shterenlikht
Room 2.6, Queen's Building
Mech Eng Dept
Bristol University
University Walk, Bristol BS8 1TR, UK
Tel: +44 (0)117 928 8233 
Fax: +44 (0)117 929 4423


More information about the freebsd-questions mailing list