help-make
[Top][All Lists]
Advanced

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

Re: how to reference the directory where current Makefile resides ?


From: Pax Unix
Subject: Re: how to reference the directory where current Makefile resides ?
Date: Sat, 19 May 2007 12:46:30 -0400

On 5/19/07, Yakov Lerner <address@hidden> wrote:
How can I reference the directory where the currently executed Makefile
resides (like what $(dirname $0) is in bash ) ?

It sounds like you could use MAKEFILE_LIST inside Makefile:

makefileDir := $(dir $(firstword $(MAKEFILE_LIST)))

MAKEFILE_LIST contains the paths of all makefiles read (in order) during make's invocation.  The above won't quite work, though, if someone causes a different file to be included before the Makefile you specified:

    make -f otherdir/preMakefile  -f Makefile

In this case, the above would echo 'otherdir/', not './' like I expect you want.

--
Shawn Halpenny

reply via email to

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