How does make determine which shells to invoke when executing external commands?

Warren Young
Wed Jun 5 16:42:00 GMT 2013

On 6/5/2013 09:32, Hua Ai wrote:
> I have gone through FAQ and mailing lists but couldn't find an answer
> to this.

The answer is in the GNU make docs, or in the O'Reilly book if you prefer.

> Especially, this line:
>     @mkdir -p $(dir $@)
> It seems that, for the computers where it didn't work, the makefile
> always invokes the mkdir from windows (Windows 7 64bit).

That means those computers have a native Windows version of GNU make on 
them, most likely the one from MinGW.  MinGW GNU make is built to use 
cmd.exe to interpret shell commands, not /bin/sh as Cygwin's GNU make 
does by default.

The docs will further enlighten you about how the SHELL variable can 
override this default behavior.  I suspect "SHELL=/bin/sh" still won't 
do the right thing, though, since MinGW GNU make doesn't understand 
POSIX paths.  Something like SHELL=c:\cygwin\bin\sh.exe *might* work.

A superior solution is to get everyone to use Cygwin make.

If you can't do that, because you don't have any influence over the 
software installed on the other computers, you might have to switch to 
one of the portable Makefile builders, so you can ship both POSIX and 
MinGW makefiles.  Bakefile ( can do this for sure. 
  CMake and Scons probably can, too.

Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list