[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Substitution references
From: |
Phil Endecott |
Subject: |
Substitution references |
Date: |
Tue, 30 Oct 2001 09:09:09 -0500 (EST) |
Hi Make experts,
When I did this:
X=$(words Y)
test:
echo $(X)
echo $(X:Y=a b c)
I expected to get "1" and "3", but actually I got "1" and "1".
Is this the expected behaviour? (GNU Make version 3.73).
What I was really trying to do was to use substitution references to
give a common interface to multiple programs that have the same
purpose but with different command-line formats. My first idea
was (vaguely) like this:
if some-condition
DO_FOO=fooprog IN > OUT
else
DO_FOO=otherfoo -in IN -out OUT
endif
y: x
$(DO_FOO:IN=x:OUT=y)
But of couse I can't do two substitututions in one go like this. I could
go for this:
$(subst IN,x,$(subst OUT,y,$(DO_FOO)))
but that's a bit long, so I tried this:
DO_FOO=fooprog $(word 1,IN_OUT) > $(word 2,IN_OUT)
or DO_FOO=otherfoo -in $(word 1,IN_OUT) -out $(word 2,IN_OUT)
and then
$(DOO_FOO:IN_OUT=x y)
but this fails because the $(word...) functions seem to be applied before
IN_OUT is substituted. It ends up doing "fooprog x y >" or
"otherfoo -in x y -out".
So, experts!, how would you do this? Do you have a better solution
than the nested $(subst....) calls? (In my real problem I have more than
just the two parameters). My aim is to keep the rules where the pattern
is used simple, but I don't care how complex the definitions are.
Thanks in advance for your help.
--Phil.
- Substitution references,
Phil Endecott <=