[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a small question about subst
From: |
Ken Smith |
Subject: |
Re: a small question about subst |
Date: |
Thu, 12 May 2005 16:54:24 -0400 |
User-agent: |
Mutt/1.5.9i |
Cool. Thanks for the corrections.
Ken
On Thu, May 12, 2005 at 04:34:35PM -0400, Paul D. Smith wrote:
> %% Ken Smith <address@hidden> writes:
>
> ks> Without seeing your code, I can only assume that you are trying to
> ks> do this in the command section of a rule. If that is the case,
> ks> you'll need to use sed or something similar.
>
> Not true.
>
> ks> The GNU make functions will be processed when the files are read
> ks> and not when the targets are run.
>
> No. Only parts of the makefile which are processed "immediately" are
> processed when the files are read in. It has nothing to do with what
> KIND of thing it is (variables, functions, etc.) and everything to do
> with WHERE in the makefile it appears.
>
> The section "How make Reads a Makefile" in the manual explains which
> parts of the makefile are expanded immediately, and which are deferred.
>
> The contents of the command scripts are always deferred.
>
> ks> my_root=root
>
> ks> file1.out: $(my_root)/folder1/file1
> ks> @echo "modified prerequisite=\"`echo $< | sed -e
> 's/folder1\///'`\""
>
> This is way overkill; a simple:
>
> file1.out: $(my_root)/folder1/file1
> @echo 'modified prerequisite="$(subst folder1/,,$<)"'
>
> will work fine.
>
> --
> -------------------------------------------------------------------------------
> 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