help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setting variable value


From: Aditya Kher
Subject: Re: setting variable value
Date: Wed, 23 Aug 2006 18:27:02 +0530

Use target specific variables:

$ cat Makefile
FOO := whatever
.PHONY : all
all : target_1 target_2 target_3
target_1 : FOO := foo # override FOO for this target
target_2 : FOO := bar # override FOO for this target
target_% : ; @echo "cd ${FOO} && ls"

$ make
cd foo && ls
cd bar && ls
cd whatever && ls

Note that you have to put cd and ls on the same line, because each rule line is
executed by another invocation of shell, so the effect of cd in the previous
line is lost.


cool . this works but playing devils advocate...
why cant Make allow me something like this (gives error) ?

target_1 : FOO := foo # override FOO for this target
 ; @echo "cd ${FOO} && ls"

-aditya




reply via email to

[Prev in Thread] Current Thread [Next in Thread]