help-make
[Top][All Lists]
Advanced

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

Re: how to work around the "long command line" in djgpp make


From: John Graham-Cumming
Subject: Re: how to work around the "long command line" in djgpp make
Date: Thu, 26 May 2005 15:02:53 -0400

On Thu, 2005-05-26 at 11:23 +0800, Jiqing Tang wrote:
> if I have a relative path like a/b/c/../../d, how can I expand it to
> an absolute path like: /home/user/a/d ?

Here's a GNU Make function that will do the right thing for .. and .
(doesn't understand DOS style paths and there mustn't be a space in the
path).

include gmsl

normalize-path = $(strip $(eval __junk := $(foreach p,                 \
                         $(call split,/,$1),                           \
                             $(if $(call seq,$p,..),$(call pop,path),  \
                             $(if $(call seq,$p,.),,                   \
                                 $(call push,path,$p)))))              \
                 $(call merge,/,$(call reverse,$(__gmsl_stack_path))))

P = a/b/././c/../../d

all:
        @echo $(call normalize-path,$(P))

It relies on having my "GNU Make Standard Library" of functions (see
below).

John.
-- 
John Graham-Cumming

Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/
GNU Make Standard Library: http://gmsl.sf.net/






reply via email to

[Prev in Thread] Current Thread [Next in Thread]