This is either a bug in how the  patsubst  function works in GNU Make
3.79, or a bug in the documentation for same:

   % make --version
   GNU Make version 3.79, by Richard Stallman and Roland McGrath.
   Built for alphaev56-dec-osf4.0e
   Copyright (C) 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
           Free Software Foundation, Inc.
   This is free software; see the source for copying conditions.
   There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
   PARTICULAR PURPOSE.
   
   Report bugs to <[EMAIL PROTECTED]>.
   
   % cat patsubst.makefile
   dirs    := a b c
   files   := $(patsubst %, ../%/%.gfa, $(dirs))
   
   .PHONY  : gfa
   gfa     :
           @echo $(files)
   % make -f patsubst.makefile gfa
   ../a/%.gfa ../b/%.gfa ../c/%.gfa
   % 

I was expecting the output

   ../a/a.gfa ../b/b.gfa ../c/c.gfa


The GNU Make 3.79 info file says

> `$(patsubst PATTERN,REPLACEMENT,TEXT)'
>      Finds whitespace-separated words in TEXT that match PATTERN and
>      replaces them with REPLACEMENT.  Here PATTERN may contain a `%'
>      which acts as a wildcard, matching any number of any characters
>      within a word.  If REPLACEMENT also contains a `%', the `%' is
>      replaced by the text that matched the `%' in PATTERN.

but it doesn't say what happens if there are multiple `%' characters
in REPLACEMENT.  In my opinion the "right" behavior would be to substitute
all of them, but it appears Make only substitutes the first.

If the only-substitute-the-first behavior is indeed "correct", then
I'd suggest the info file have a note added to document this.

-- 
-- Jonathan Thornburg <[EMAIL PROTECTED]>
   http://www.thp.univie.ac.at/~jthorn/home.html
   Universitaet Wien (Vienna, Austria) / Institut fuer Theoretische Physik
   [visiting Albert Einstein Institute (Golm, Germany) until Sept 10]
   "I've come to believe that my mother was unexpectedly startled by the
    suggestion of a new keyword during her first pregnancy, and when a tempter
    in the early 1970s formulated schemes to avoid another one, the prenatal
    influence manifested itself." -- Dennis Ritchie in comp.std.c, explaining
    why C overloads keywords (eg "extern", "static") with multiple meanings

Reply via email to