[Top][All Lists]

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

Re: How to get the absolute path of a makefile?

From: Philip Guenther
Subject: Re: How to get the absolute path of a makefile?
Date: Sun, 3 May 2009 18:40:14 -0700

On Sun, May 3, 2009 at 6:03 PM, Peng Yu <address@hidden> wrote:
> Thank you for your reply. But what you pointed to me is not exactly
> what I am looking for.
> I want the path of the directory where the Makefile is in.
> make -f some_makefile_in_another_directory
> If I use the above command, $CURDIR will not be the directory where
> `some_makefile_in_another_directory' is in.

Ah, I see.

First of all, section 3.5 we see a description of the MAKEFILE_LIST
variable and how, at the start of a makefile, $(lastword
$(MAKEFILE_LIST)) is the name of the makefile.

Next, as search for 'absolute' turns up section 8.3, where we find this:

`$(realpath NAMES...)'
     For each file name in NAMES return the canonical absolute name.  A
     canonical name does not contain any `.' or `..' components, nor
     any repeated path separators (`/') or symlinks.  In case of a
     failure the empty string is returned.  Consult the `realpath(3)'
     documentation for a list of possible failure causes.

So: $(realpath $(lastword $(MAKEFILE_LIST)))

Make sense?

Philip Guenther

reply via email to

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