[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using the PWD environment variable.
From: |
Paul Smith |
Subject: |
Re: Using the PWD environment variable. |
Date: |
Wed, 05 Sep 2007 09:15:16 -0400 |
On Wed, 2007-09-05 at 12:16 +0530, Pratap Chakravarthy wrote:
> I am using a recursive make implementation, and am invoking a python
> script for a target that is two levels down.
> Makefile (parent makefile)
> subdir1/Makefile
> subdir1/subdir2/Makefile (target is invoked here)
> Inside the python script I am using the environment variable PWD and I
> am finding that it points to the location of parent makefile (the top
> level makefile) instead of pointing to .../subdir1/subdir2
>
> Is this an expected behavior ? I was under the impression that
> make -C
> would change the PWD too.
No. The PWD environment variable is set by the shell. If you run make
-C then make is doing the change directory operation, not the shell, and
so PWD is not reset. And, PWD is not even set by ALL shells. In
general, using PWD is fragile and non-portable and should be avoided in
robust environments.
> PS: CURDIR variable is not being exported from make and hence unable
> to access it from the python script.
Well, you can always export it. Or, you can say "PWD := $(CURDIR)" and
export that.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.mad-scientist.us
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist