'Makefile can't see sh or bash cygwin bins using enviroment variable
At my office we recently got a laptop replacement and now one of my colleagues and myself are having issues compiling our code.
One of our compilations tools requires Cygwin 32-bits version, I freshly installed one and my colleague copied and paste the one he had on its previous laptop. The computer we got are 64-bits but the previously ones we had were also 64-bits.
Both of us are having the issue that makefile returns this error:
make: "C:\cygwin\bin"/sh: No such file or directory
make: *** [Makefile:401: clean] Error 127
The way we're defining "C:\cygwin\bin" is using an environment variable CYGWIN_BINDIR and we call it like this in the makefile:
export CAT = "$(CYGWIN_BINDIR)"/cat
export TOUCH = "$(CYGWIN_BINDIR)"/touch
export SHELL = "$(CYGWIN_BINDIR)"/sh <----Complaining part
export COPY = "$(CYGWIN_BINDIR)"/cp
export PERL = "$(CYGWIN_BINDIR)"/perl
I can see that the binary for sh exists in the given path, I know we're mixing backslashes with normal slash but I read that cygwin takes care of fixing this and we've been compiling like this for years.
If we modify from:
export SHELL = "$(CYGWIN_BINDIR)"/sh
To:
export SHELL = sh
Now the makefile is able to use the binary, it seems like only sh is the one complaining since all the other binaries like cat/touch/cp/etc... are being used by the makefile properly.
Any ideas of what are we missing here?
As I mentioned we've been using this for years. I don't know what are we missing in our cygwin set up.
Solution 1:[1]
The issue here was that make (as it supposed to work) is handling double quotes as another character and is not expanding it as other interpreters do, like for example a shell interpreter.
Therefore make is trying to set the SHELL variable to the path "C:\cygwin\bin"/sh including double quotes and obviously that path doesn't exist.
Notice cygwin is capable of handle backslash and normal slash, even mixed.
This was fixed using a very old version of cygwin, where the double quotes are used to interpret backslashes, otherwise the path "$(CYGWIN_BINDIR)"/sh instead of being expanded to C:\cygwin\bin/sh is expanded to C:cygwinbin/sh.
I know we could have fixed our makefile to work with latest version of cygwin, but since this is a legacy project linked to other legacy tools we decided to use an older version of cygwin.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ElMaya |
