help-make
[Top][All Lists]
Advanced

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

RE: A question about Makefile


From: Warlich, Christof
Subject: RE: A question about Makefile
Date: Wed, 8 Dec 2010 11:03:16 +0100

Jed Jia wrote:
> Take a look at the following Makefile:
> 
> > x: obj/./t
> >     touch x
> >
> > obj/t: a
> >     touch obj/t
> 
> but make outputs:
> > make: *** No rule to make target `obj/./t', needed by `x'.  Stop.

While I'm not able to answer your final question, this function may help
(taken from https://github.com/dmoulding/boilermake):

> # CANONICAL_PATH - Given one or more paths, converts the paths to the 
> canonical
> #   form. The canonical form is the path, relative to the project's top-level
> #   directory (the directory from which "make" is run), and without
> #   any "./" or "../" sequences. For paths that are not  located below the
> #   top-level directory, the canonical form is the absolute path (i.e. from
> #   the root of the filesystem) also without "./" or "../" sequences.
> define CANONICAL_PATH
> $(patsubst ${CURDIR}/%,%,$(abspath ${1}))
> endef

With this function, you could then write:

> define CANONICAL_PATH
> $(patsubst ${CURDIR}/%,%,$(abspath ${1}))
> endef
> x: $(call CANONICAL_PATH,obj/./t)
>       touch x
> 
> $(call CANONICAL_PATH,obj/t):
>       touch $(call CANONICAL_PATH,obj/t)

This make your makefile independent from how a path is specified.

Cheers,

Christof



reply via email to

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