[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to reference the directory where current Makefile resides ?
From: |
Yakov Lerner |
Subject: |
Re: how to reference the directory where current Makefile resides ? |
Date: |
Sat, 19 May 2007 18:48:29 +0300 |
On 5/19/07, Eli Zaretskii <address@hidden> wrote:
> Date: Sat, 19 May 2007 10:34:08 +0300
> From: "Yakov Lerner" <address@hidden>
>
> How can I reference the directory where the currently executed Makefile
> resides (like what $(dirname $0) is in bash ) ?
Does ${CURDIR} do what you want?
No. Both $(CURDIR) and $(shell pwd) do not do what I want.
Because my CURDIR is not where Makefile resides.
Here is small demo example:
cd /tmp # /tmp is my cwd, and /var/tmp will be dir of Makefiles
echo 'all: ; echo this is sub.make' >/var/tmp/sub.make
echo 'include sub.make' >/var/tmp/Makefile
make -f /var/tmp/Makefile
/var/tmp/Makefile:1: /tmp/sub.make: No such file or directory
I need to fix the line 'include sub.make' to something like
'include $(dirname $0)/sub.make' where $(dirname $0) would
be directory of toplevel makefile.
The difference between what i need and $(CURDIR) is same as
difference between `pwd` and $(dirname $0) when my cwd *IS NOT* same
as directory where Makefile/script resides.
Both bourne shell and perl have clear idiom for "directory where
toplevel script resides", which is `dirname $0` in bourne shell, and
dirname($0) in perl.
I can't believe gmake doesn't have expression for
"directory where toplevel Makefile resides" ?
Thanks
Yakov