help-make
[Top][All Lists]
Advanced

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

Re: variable modifier within a for loop - How?


From: Paul D. Smith
Subject: Re: variable modifier within a for loop - How?
Date: Fri, 28 Jan 2005 00:26:41 -0500

%% Shawn Honess <address@hidden> writes:

  sh> I'd like to do something like this...

  sh>      SRC = ./one/foo.c ./two/bar.c
  sh>      target:
  sh>   for file in $(SRC) ; do \
  sh>           $(HACK) < $$file > ./log/$$(basename file).log

You can't use make functions to operate on shell variables, of course!

Make will expand the shell script, including all make variables and
functions, _before_ invoking the shell and passing the script to the
shell to run.  There's no way the shell can send those things back to
make to have it do some more processing on the script, right in the
middle.


You have to use shell operations with shell variables; try something
like this:

     SRC = ./one/foo.c ./two/bar.c
     target:
        for file in $(SRC) ; do \
          $(HACK) < $$file > ./log/`basename $$file`.log; \
        done

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          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]