> The variable assigned in the parent makefile will be carried on to the
> child makefile.
This is only true if the variable is exported (export XXX:=abc) or, as
in your example, if it is passed as a command line parameter.

> I'm wondering if there is a way to localize this
> effect only to the parent.
Yes, there is a way, in case of the command line parameter you need
the override directive:
override(XX=whatever else) 

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of 
Peng Yu
Sent: Mittwoch, 13. Juli 2011 18:07
To: make-help mailing list
Subject: How to limit the assignment of variable from command line only to the 
current makefile?

Hi,

The variable assigned in the parent makefile will be carried on to the
child makefile. I'm wondering if there is a way to localize this
effect only to the parent.

$ cat Makefile
.PHONY: all

XX:=abc

$(info $(XX))

all:
        $(MAKE) -C dir

$ cat dir/Makefile
.PHONY: all

XX:=abc

$(info $(XX))

all:

$ make XX=100
100
make -C dir
100
make[1]: Entering directory `/tmp/cmdl_arg/dir'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/tmp/cmdl_arg/dir'


-- 
Regards,
Peng

_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to