Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!uwm.edu!cs.utexas.edu!tut.cis.ohio-state.edu!CS.BROWN.EDU!wsd
From: wsd@CS.BROWN.EDU
Newsgroups: gnu.utils.bug
Subject: new vpsearch fn
Message-ID: <8909300149.AA09530@cslab3b.cs.brown.edu>
Date: 30 Sep 89 01:49:42 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 49


We in the Graphics Group at Brown have adopted GNUmake as part of our
software standards.  In doing so, we made a few changes that others
might find useful:

1) . allowed in vpath (why was this explicitly excluded?)
just remove the lines

      if (len == 1 && *v == '.')
	continue;

from construct_vpath_list() in vpath.c.  This is useful in conjunction
with vpsearch.

2) vpsearch function

   This takes a bunch of filenames, finds them in the vpath, then
attaches the directory where each was found to each file.  So, if
VPATH is ../include:. and ../include contains foo and . contains bar,
then $(vpsearch foo bar) returns "../include/foo ./bar".  An example
of its use is:

wc:
	wc $(vpsearch $(src))

here's the code (for expand_function() in function.c):

    case function_vpsearch:
      text = expand_argument(text, end);
      i    = strlen(text);

      p3 = text;
      while (p = find_next_token(&p3, NULL)) {
	  p2 = p;
	  if (vpath_search(&p2)) {
	     o = variable_buffer_output(o, p2, strlen(p2));
	     o = variable_buffer_output(o, " ", 1);
	     doneany = 1;
	  }
	  else error("vpsearch couldn't find file %s", p);
      }
      if (doneany) --o;

      free(p2);
      free(text);
      break;

These contributions are from Paul Strauss, Mike Natkin, and Scott
Draves.