0

This is a GNU Make dependency resolution issue.

My problem is that I copy the source files from a remote file server to a scratch disk (which speeds up the build process by 50%). If the file copy fails, I want to use the source files from the file server, else I want to read them from the scratch disk.

I have tried to use the vpath mechanism, but the problem is that, as far as I understand, make will by default start looking for the source files in the current directory and only if it fails to find the files there, look in the directories listed with vpath.

Is it possible to have make first look in the vpath directories before looking in the current directory? Or perhaps only look in the vpath directories (and explicitly and dynamically add the current directory to vpath)?

Only way I can think of is to temporary change directory so that make always will fail to find the source files.

dala
  • 1,975
  • 3
  • 14
  • 15
  • Is there a particular reason you must allow untrusted versions of source files to reside in the current directory? – Beta Apr 27 '11 at 16:29
  • The source files will be identical in the two directories, but I want to use the copy on the scratch disk due to better performance (the build takes several hours). – dala Apr 27 '11 at 16:40
  • I understand that, but I don't see what it has to do with my question. Are there any source files in the current directory? – Beta Apr 27 '11 at 16:52

1 Answers1

0

Look at the path to the source directory on the server. Suppose it's "/server/someplace/src/". And suppose you don't have a "src" directory in the current directory (if you do, we just have to tweak this method). Just make sure that the path to the source directory on the scratch disk ends in "/src/", such as "/scratch/wednesday/src/". Then you can do this:

SCRATCH_PATH = /scratch/wednesday/
SERVER_PATH = /server/someplace/

VPATH = $(SCRATCH_PATH) $(SERVER_PATH)

%.o: src/%.cc
    $(CC) blah blah blah
Beta
  • 96,650
  • 16
  • 149
  • 150