I am using make version 4.2.1 on windows. I have a very simple make file:
some_target:
if EXIST C:\ echo hi
However, when I run the following command:
"..\env\build_tools\make\make.exe" -f "make.mk" -j16 some_target
I get the following error:
/usr/bin/sh: -c: line 3: syntax error: unexpected end of file
make: *** [make.mk: some_target] Error 2
When I run the same recipe line in a regular command prompt it executes perfectly fine and doesn't throw any errors. What is happening here? It's also weird because if I put the source code and makefile in an eclipse project and configure the build correctly, it runs perfectly fine.
This is not that mysterious; the answer is in the output you posted here:
/usr/bin/sh: -c: line 3: syntax error: unexpected end of file
This means that the command you told make to run was given to /usr/bin/sh
, which is a POSIX shell. But the command you wanted to run:
if EXIST C:\ echo hi
is a Windows cmd.exe
shell command. That cannot work. Try starting a Git Bash shell for example and typing the above command into it: you'll get the same error. If you want your makefile to always use cmd.exe
as its shell you have to add that to your makefile:
SHELL := cmd.exe
should do it I think (I don't really do Windows). The make program was created back in the 1970's on UNIX systems and so it's fundamentally a POSIX program and it prefers to run using POSIX tools; if you don't specify which shell to use then the Windows port will first look for a POSIX shell and if one is found it will use that; if it's not found it will fall back to cmd.exe
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments