On Sun, Feb 05, 2006 at 11:14:47PM +0100, August Karlstrom wrote:
> 
> OK I see. So what should I add to the makefile to tell make to create a 
> .suffix2 file for each .suffix1 file? I have tried the following but it 
> doesn't seem to work:
> 
> .PHONY: main
> 
> main: $(wildcard *.suffix2)
> 

I guess it is obvious why it doesn't work. The wildcard function
expands to a list of all the files ending in ".suffix2" present in the
current directory. Since no such files are present, it expands to an
empty string. In effect the lines above is as if you were writing:

  .PHONY: main
  main:

What you described in your text, though, is correct: You need to make
a ".suffix2" file for every corresponding ".suffix1" file present in
the current directory. A possible solution is this:

  .PHONY: main
  main: $(patsubst %.suffix1,%.suffix2,$(wildcard *.suffix1))

Or, written in a more readable, though essentially identical, manner:

  s1list := $(wildcard *.suffix1)
  s2list := $(s1list:.suffix1=.suffix2)

  .PHONY: main
  main: $(s2list)

/npat

-- 
I have a hobby...I have the world's largest collection of sea shells.
I keep it scattered on beaches all over the world.  Maybe you've seen
some of it... 
  -- Stephen Wright


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to