%% "Albert L. Ting" <[EMAIL PROTECTED]> writes:

  >> RCS
  >> Any file `N' is extracted if necessary from an RCS file named
  >> either `N,v' or `RCS/N,v'.  `N' will not be extracted from RCS if it
  >> already exists, even if the RCS file is newer.  

  alt> The above rule, where the RCS file is newer, does not seem to
  alt> work if the location of the RCS'd file is in a directory defined
  alt> by VPATH.  Enclosed is a tar file but I'll explain the test case.
  alt> The directory structure is:

  alt>     drwxrwx--- alt      0 2000-03-17 17:01 make-bug2/
  alt>     -rw-rw---- alt     79 2000-03-17 17:01 make-bug2/Makefile
  alt>     drwxrwx--- alt      0 2000-03-17 17:00 make-bug2/foo/
  alt>     drwxrwx--- alt      0 2000-03-17 17:00 make-bug2/foo/RCS/
  alt>     -r--r----- alt    184 2000-03-17 16:40 make-bug2/foo/RCS/bar.old,v
  alt>     -r--r----- alt      8 1999-06-07 14:29 make-bug2/foo/bar.old

  alt> The makefile is:

  alt>     VPATH := foo
  alt>     foo: bar.new
  alt>     %.new:       %.old
  alt>          cp $^ $@ 

  alt> Typing "make" will "co" a copy of bar.old into the directory,
  alt> which it shouldn't.

Hmm.  I disagree that this is a bug.

The rule you cite isn't implemented in make per se; that is, there's
nothing in the target/prerequisite setup that makes it true.

What makes it true is that the shell script for the checkout tests to
see if the file exists and if so, it doesn't actually _do_ the checkout.

When VPATH enters the mix, consider this statement from the VPATH
documentation "How Directory Searches Are Performed":

  4. After processing the prerequisites, the target may or may not need
     to be rebuilt:

        [...]

       b. If the target *does* need to be rebuilt (is out-of-date), the
          pathname found during directory search is *thrown away*, and
          the target is rebuilt using the file name specified in the
          makefile.  In short, if `make' must rebuild, then the target
          is rebuilt locally, not in the directory found via directory
          search.

So, what happens?  Well, make wants to build bar.new.  So it looks for
a bar.old, and sees it in directory foo via VPATH.  Then it wants to
build foo/bar.old, and finds an RCS file that's newer in foo/RCS.

Since the prerequisite is newer, the target needs to be rebuilt, so by
rule (4b) above the VPATH pathname is thrown out and make runs the rule
to build just "bar.old".  The rule you quote for RCS says that files
that exist won't be updated, but "bar.old" _doesn't_ exist (foo/bar.old
does, but that's not what we're building), so it _is_ updated.

This seems to me to be correct and documented behavior.

I _think_ what you want to do is add a "GPATH := foo" to your makefile.
That will tell make that "foo" is a "global directory" and that make
shouldn't throw out pathnames when targets are found in that directory.
See the make manual docs for GPATH.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.

Reply via email to