help-make
[Top][All Lists]
Advanced

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

Re: How to replace string conditionally?


From: Paul Smith
Subject: Re: How to replace string conditionally?
Date: Tue, 24 Nov 2009 00:00:03 -0500

On Mon, 2009-11-23 at 22:21 -0600, Peng Yu wrote:
> $(wildcard *.py)
> 
> Suppose that I have the above list of file names. I want to replace
> any .py file by the coresponding .sh file if it exists.
> 
> That is,
> 
> If I have the following files,
> 
> a.py a.sh b.py
> 
> I want to get the following files
> 
> a.sh b.py
> 
> Could somebody show me how to do it? 

PY_FILES := $(patsubst %.py,%,$(wildcard *.py))
SH_FILES := $(foreach F,$(PYFILES),$(if $(wildcard $F.sh),$F.sh,$F.py))

something like that should work.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "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]