List Info

Thread: Re: how to fully qualify entries in a "-I" list?




Re: how to fully qualify entries in a "-I" list?
user name
2007-11-20 10:11:57
On Nov 20, 2007 3:02 AM, Robert P. J. Day <rpjdaycrashcourse.ca> 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

Here is a solution but I'm not sure if you will consider it
short and sweet.

paths := a /b c /d
abspaths := $(filter /%,$(paths))
relpaths := $(filter-out /%,$(paths))
qual-paths := $(addprefix /src/,$(relpaths)) $(abspaths)
include-paths := $(addprefix -I,$(qual-paths))

$(info paths="$(paths)")
$(info abspaths="$(abspaths)")
$(info relpaths="$(relpaths)")
$(info qual-paths="$(qual-paths)")
$(info include-paths="$(include-paths)")

If your paths already come with -I attached, $(patsubst) can
easily
generate $(paths) for you.

   Ken Smith


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

Re: how to fully qualify entries in a "-I" list?
user name
2007-11-20 13:53:44
On Nov 20, 2007 9:11 AM, Ken Smith <kgsmithgmail.com> wrote:
> On Nov 20, 2007 3:02 AM, Robert P. J. Day
<rpjdaycrashcourse.ca> 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
>
> Here is a solution but I'm not sure if you will
consider it short and sweet.
>
> paths := a /b c /d
> abspaths := $(filter /%,$(paths))
> relpaths := $(filter-out /%,$(paths))
> qual-paths := $(addprefix /src/,$(relpaths))
$(abspaths)

That reorders the paths, putting all the previously-relative
paths
before all the previously-absolute paths.  That may not be
acceptable.
 To preserve the order, perform the transformation inside a
$(foreach):

# A function that adds $1 as a prefix to any non-absolute
paths in $2
make-absolute = $(foreach dir,$2,$(if $(filter-out
/%,$),$1)$)

absprefix = /src/
paths = a /b c /d
abs-paths = $(call make-absolute,$,$)

Chaining that with $(patsubst) to strip and re-add the -I
should be
straightforward.


Philip Guenther


_______________________________________________
Help-make mailing list
Help-makegnu.org
http:
//lists.gnu.org/mailman/listinfo/help-make

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )