[gnu.utils.bug] make: target: .vs. vpath suggestion

pat@EDDIE.MIT.EDU (Pat Lashley) (10/10/89)

I have been using GNU make for some time now and have become totally spoiled by
some of the features. (Let's hear it for 'obj: ${subst .c,.o,${wildcard *.c}}`.)

One difficulty has been nagging at me though.  We have several programmers working
on the same project and sharing modules.  There is a central archive area for the
latest checkpointed copies of the sources, working copies are checked out into
private directories.  The goal: prevent the programmer from the need to update
their makefile every time they check something in or out, but allow them to link
archived versions of object files for modules that they do not have private copies
of.  The answer: `vpath %.o /archive-dir' right?

Well, let's try it.  Let's call the program foo, and one of it's object modules
bar.o.  Ok, I want to change bar so I check out bar.c, edit it, `make depend' and
`make foo'.  I don't have a local bar.o yet, so it links in /archive-dir/bar.o.
Luckily, I notice what happened. Ok, try `make bar.o' first. "make: /archive-dir/bar.o
is up to date."  This is getting nowhere; `touch bar.o ; touch bar.c ; make foo'.
Ok, I have a local bar.o now; everything is cool.

Now, there may be some subtle way to prevent that interaction, or some simple way
that I'm being too subtle to see.  I was looking for some way to coerce make into
applying default rules in the current directory before checking the vpath.  Today
I realized that all I really wanted was for make to completely ignore the vpath
for any targets which appear as explicit targets in the makefile.  Since we do a
`make depend' every time we check files in or out, there is guaranteed to be a
.o target for every local .c file.  And this would actually reduce the work that
make needs to do....  

So I went looking in the make source, and found what appears to be a trivial
change which implements the new behaviour.  It works for our usage, but I'm
not sure that it is complete for all cases (i.e. archives).


diff -c make-3.55/remake.c make-3.55K/remake.c
*** make-3.55/remake.c  Tue Aug 22 02:21:12 1989
--- make-3.55K/remake.c Sat Sep 30 18:23:35 1989
***************
*** 725,731 ****
      {
        /* If name_mtime failed, search VPATH.  */
        char *name = file->name;
!       if (vpath_search (&name))
        {
          rename_file (file, name);
          mtime = name_mtime (name);
--- 725,731 ----
      {
        /* If name_mtime failed, search VPATH.  */
        char *name = file->name;
!       if ((!file->is_target) && vpath_search (&name))
        {
          rename_file (file, name);
          mtime = name_mtime (name);

-Pat