This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: What does PWD = $${PWDCMD-pwd} do in make?

On Wed, Jul 02, 2003 at 06:13:03PM -0700, Roland McGrath wrote:
> > Hi Roland,
> > 
> > I have a strange make related problem. In gcc, there is
> > 
> > PWD = $${PWDCMD-pwd}
> This is surely ill-advised, but what it means is clear enough.
> $$ means a literal $, and make has nothing more to do with this.
> If this string is used in a sh command, then ${PWDCMD-pwd} is
> sh syntax meaning $PWDCMD if that's defined and pwd otherwise.
> Modern shells define an environment variable PWD with the name of the
> current directory.  Anything that expects to use such a value will surely
> not be expecting a string like '${PWDCMD-pwd}' in its environment.  If
> make's environment includes PWD, then it will be default export PWD to its
> children, and give them whatever literal value the make variable PWD has.
> > It doesn't happen with pmake. Any ideas?
> I can't imagine pmake processing this string any differently than GNU make
> does unless it's in wild violation of the POSIX.2 spec for make.  Perhaps
> in your pmake scenario, either something overrides PWD with the name of the
> current directory and so clobbers the problematic value with what other
> programs are expecting, or else whatever piece of shell or whatnot it is
> that is depending on the PWD environment variable is not called in the same
> way.

Here are what I found so far:

1. GNU make will set PWD in its children's environment.
2. Pmake won't set PWD in its children's environment.
3. getpwd in libiberty and glibc use shell's PWD.
4. -g will call getpwd in libiberty.
5. When PWD is set to value like "${PWDCMD-pwd}", different, but
correct result will be generated by gcc.
6. If -g is not used, getpwd in libiberty won't be called and the
output is the same no matter what value PWD is set to.

Can gcc use something else instead of a common shell environment


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]