0

Thanks a lot for the comments. In this case actually VPATH is not used.

I write some makefiles to recursively build my project.

Part of the makefile in the root directory looks like this,

VPATH += $(shell find -type d)
export VPATH

#Codes to generate $(ARXIVS), i.e. the list of all local archives,
#is omitted here to save spaces
all : main.o $(ARXIVS)

$(ARXIVS) :
           $(MAKE) --directory $(@D)

.PHONY : $(ARXIVS) all

As you can see, I pass the variable VPATH to sub-makes, in order to save some computational cost. And the whole system works.

But the searching paths in a sub-directory is different from the ones in the root directory.

I have print the values of VAPTH in sub-makes, the paths are indeed the ones with respect to the root directory. So VPATH in the sub-makes should be wrong.

But the whole system works. How did this happen?Any one give the suggestion to me. Thanks in advance

ZF Du
  • 1
  • 2
  • Maybe it works because VPATH isn't even needed? The command `find -type d` doesn't work because there is no directory specified. If it works on your system, does it output *absolute* pathnames? – Jens Apr 17 '17 at 08:07
  • Ah, I made a mistake. You are right. VPATH is not used. Secondly, the command `find -type d` does work. And the result is not absolute pathnames. In my case, the `find` command searches in the current directory. – ZF Du Apr 17 '17 at 14:54
  • `find -type d` works if you're using GNU find; in GNU find if there's no value given as the first argument then `.` is assumed. In BSD find (for example, if you're using MacOS) then you have to explicitly type the `.` (I find this very annoying). – MadScientist Apr 17 '17 at 19:47

0 Answers0