help-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: make: $(patsubst,%,%/%.txt,$(BASE_NAMES)) not quite right


From: Paul D. Smith
Subject: Re: make: $(patsubst,%,%/%.txt,$(BASE_NAMES)) not quite right
Date: 02 Jan 2006 20:53:02 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

%% Edd <edd@crapnunswithguns.net> 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 <psmith@gnu.org>          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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]