target-specific variable behavior

[email protected]
Newsgroups gmane.comp.gnu.utils
Organization http://groups.google.com
Message-ID <[email protected]>
could someone please explain as to why this is the behavior of
target-specific variable?
the output that I'm expecting is

[expected output]
target1, bar1 bar2
target2, bar1

but this is what i got instead

[real output]
target1, bar1 bar2
target2,


[makefile]
foo := bar1

all : target1 target2

target1 : foo += bar2
target1 :
	@echo target1, $(foo)

target2 : foo += 
target2 :
	@echo target2, $(foo)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.