I need pointing what I'm missing about makefiles. For given makefile:
VPATH=
targ1: VPATH=src
targ1: targ2
targ2: targ2
echo $(VPATH)
and empty src direcotry, every time calling "make targ1" I get as expected:
echo src
src
since there is not file targ2 in makefile directory and in src direcotry targ2 needs to be updated.
But the problem is that even when I create targ2 file in src directory targ2 is updated every time of calling 'make targ1'. In that case VPATH is not working as expected.
The value of the make variable VPATH specifies a list of directories that make should search. Most often, the directories are expected to contain prerequisite files that are not in the current directory; however, make uses VPATH as a search list for both prerequisites and targets of rules.
Howewer problem does not occure when I set VPATH in global scope:
VPATH=src
targ1: VPATH=src
targ1: targ2
targ2: targ2
echo $(VPATH)
Result is: make: Nothing to be done for 'targ1'.
Why there is such difference?