0

I am using the following bash function in cygwin .bashrc (to return windows styed paths)

pwd() {
  cygpath -m "`command pwd`"
}
export pwd

So when I run pwd from bash, I get the result in windows style path. However, if I use pwd in Makefile, then I get cygwin style results

run:
    echo `pwd`

Can anyone please suggest me on how to make it work in the Makefile.

P.S: I can't use cygpath, this sample problem is just depicting one of the problem from my larger problem set.

sarbjit
  • 3,786
  • 9
  • 38
  • 60
  • Is the question how to get things from your `.bashrc` file to be available in make recipes? Or is the question something else? – Etan Reisner Jun 16 '15 at 17:00
  • Possible duplicate of [1](http://stackoverflow.com/questions/507641/functions-in-makefile) or [2](http://stackoverflow.com/questions/13109242/cannot-call-bash-function-inside-makefile) – Eugeniu Rosca Jun 16 '15 at 17:10
  • As an aside, `echo \`pwd\` ` is [Useless Use of `echo`](http://www.iki.fi/era/unix/award.html#echo) and better written simply `pwd`. – tripleee Jun 16 '15 at 19:22

1 Answers1

0

I think I understand your problem. My way to debug would be:

1) remove the custom pwd function from .bashrc

2) restart Cygwin

3) call type cygpath and keep the output.

4) call pwd and keep the output.

5) call and keep the output of:

cygpath -m `pwd`

6) Create and run this Makefile

all:
    @echo "type cygpath is: `type cygpath`"

7) Are the outputs of 3) and 6) are the same? if yes, go to next step.

8) Create and run this Makefile:

all:
    @echo "pwd is: `pwd`"

8) Are the outputs of 4) and 8) are the same? if yes, go to next step.

9) Create and run this Makefile:

all:
    @PWD=`pwd`; echo "Windows cygpath is: `cygpath -m $$PWD`"

10) Is this what you want?

Eugeniu Rosca
  • 5,177
  • 16
  • 45