[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to fully qualify entries in a "-I" list?
From: |
Robert P. J. Day |
Subject: |
Re: how to fully qualify entries in a "-I" list? |
Date: |
Tue, 20 Nov 2007 09:40:55 -0500 (EST) |
On Tue, 20 Nov 2007, Greg Chicares wrote:
> On 2007-11-20 11:02Z, Robert P. J. Day wrote:
> > wanted: a simple way to transform the string (and its entries):
> >
> > -Ia -I/b -Ic -I/d
> >
> > to
> >
> > -I/src/a -I/b -I/src/c -I/d
> >
> > in short, wherever an entry represents a location that is *not*
> > fully-qualified, i want to replace that entry with one that is now
> > fully-qualified (and for which i will supply the appropriate prefix).
>
> /tmp[0]$cat subst.make
> original := -Ia -I/b -Ic -I/d
> modified := $(shell echo $(original) | sed -e 's|-I\([^/]\)|-I/src/\1|g')
>
> .PHONY: all
> all:
> @echo original: $(original)
> @echo modified: $(modified)
>
> /tmp[0]$make -f subst.make
> original: -Ia -I/b -Ic -I/d
> modified: -I/src/a -I/b -I/src/c -I/d
>
> > is there a simple way to do with one "patsubst" operator?
>
> I don't see how to do it with just one.
actually, i came up with this, which is done in two parts, but needs
only one patsubst:
$(patsubst -I%,-I$(srctree)/%,$(filter-out -I/%,$(1))) \
$(filter -I/%,$(1))
obviously, the first line handles the cases where there is *no* slash
and applies the transformation i want, while the second simply scarfs
up the remainder unchanged.
> > i can see
> > a couple obvious ways with "foreach", but the tricky bit is that i'm
> > trying to invoke patsubst in places that *don't* match a given pattern
> > (that being "-I/").
>
> What transformation do you want for "-I/"?
none at all but, as you can see, i have something that appears to
work.
rday
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://crashcourse.ca
========================================================================