%% Edd <[EMAIL PROTECTED]> writes:

  e> I'm having a little trouble with the patsubst function of gnu
  e> make. Please consider:

  e> BASE_NAMES = a b c
  e> EXPANDED_NAMES = $(patsubst,%,%/%.txt,$(BASE_NAMES))

You don't want the first comma there.  It should just be:

  EXPANDED_NAMES = $(patsubst %,%/%.txt,$(BASE_NAMES))

However...

  e> I was hoping EXPANDED_NAMES would expand to:
  e> a/a.txt b/b.txt c/c.txt

No.  The documentation of the "patsubst" function is clear:

    Only the first `%' in the PATTERN and REPLACEMENT is treated this
    way; any subsequent `%' is unchanged.

  e> but instead it expands to:
  e> a/%.txt b/%.txt c/%.txt

  e> Is there a way to achieve the behavior I want?

In this particular case you could use:

    EXPANDED_NAMES = $(foreach N,$(BASE_NAMES),$(N)/$(N).txt)

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[EMAIL PROTECTED]>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
_______________________________________________
help-gnu-utils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gnu-utils

Reply via email to