Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does make.exe try to run /usr/bin/sh on Windows?

I have recently moved from Window 7 to Windows 10 and I cannot get my makefiles to work anymore.

I have been using the GNU Make for Windows

The first thing that I noticed was that it had started treating Windows folder dividers (backslash characters '\') as line continuation characters, so I modified the 'clean' section as shown below to use forward slash '/' characters instead:

clean:
    del $(ObjDir)/*.o

When I call make -ftest.mak clean I get the following error which suggests it is now trying to run in a MinGw/Cygwin environment:

c:\Test\Source>make -ftest.mak clean
del obj/*.o
/usr/bin/sh: del: command not found
make: *** [clean] Error 127

I do have MinGw folder on my PC (which I have renamed to stop make looking for it) and I can't see any 'MingGw' related environment variables in my Cmd.exe environment or PATH

How can I get make working so it doesn't try executing sh under Windows?

Is there some configuration parameter somewhere that makes it call sh instead of cmd.exe?

Update: Just tried running make -d which logs debug output. It looks as though it is using my Git folder as some sort of root folder:

Must remake target `clean'.
del obj/*.o
CreateProcess(NULL,C:/Program Files/Git/usr/bin/sh.exe -c "del obj/*.o",...)
Putting child 0x006e7fc0 (clean) PID 7234712 on the chain.
like image 300
SparkyNZ Avatar asked Dec 18 '17 19:12

SparkyNZ


2 Answers

The cleanest way is to specify SHELL on command line.

make -ftest.mak clean SHELL=cmd

will do the job. ndk-build will do that for you, see your ndk-build.cmd. Don't try to run ndk-build bash script on Windows. The scripts in NDK may go amoc when you run them on Windows in bash.

like image 51
Alex Cohn Avatar answered Nov 17 '22 05:11

Alex Cohn


Nasty conclusion to this problem.

make looks through the PATH environment variable for anything containing usr/bin. It just so happens that since I also installed Git on my Windows 10 PC, Git added the following folder to PATH:

C:\Program Files\Git\usr\bin

Adding any path with the substring "usr\bin" will cause make to try running sh instead of cmd.exe on Windows.

My solution: Remove the C:\Program Files\Git\usr\bin from my PATH.

Update: I changed the name from usr\bin to user\bin but make still finds sh.exe within that folder. In the end I renamed sh.exe to _sh.exe within the Git\usr\bin folder.

like image 30
SparkyNZ Avatar answered Nov 17 '22 06:11

SparkyNZ