wangtianhang
wangtianhang

Reputation: 1

mingw make fail by shell = cmd.exe

I compile phyx4.1 android build on win10 with mingw and failed.

After some hours research, I find this line SHELL = cmd.exe which make the behaviour stranger.

My makefile is like:

SHELL = cmd.exe
help:
echo hahaha
echo gagagaga
exit

I try to execute it by mingw command line

make help

but it enter cmd.exe and not return. anyone know why?

ps: finally, i found the solution, use mingw32-make.exe rather than make.exe ..thanks for your replays

Upvotes: 0

Views: 1067

Answers (2)

Philippe
Philippe

Reputation: 26422

GNU make passes -c to $(SHELL) to execute a command.

When you have a command like echo hahaha, make tries to run

cmd.exe -c echo hahaha

as cmd.exe does not recognize -c echo hahaha, it went into interactive session.

To make it work, you can do :

SHELL = cmd.exe
.SHELLFLAGS = /c
help:
    echo hahaha
    echo gagagaga
    exit

Upvotes: 1

John Bollinger
John Bollinger

Reputation: 180083

The SHELL variable designates the command interpreter with which make should execute rules' recipes. For most make implementations it defaults to one or another variation on the Bourne shell, such as Bash. This is important, because it has a deep and pervasive impact on the effects of running recipes.

Different shells are not interchangeable. Different Bourne-family shells are often similar enough that they will not exhibit different behavior for the recipes in a given makefile, but cmd.exe is an another beast altogether. Trying to use cmd.exe as the shell for a makefile written with a Bourne shell in mind (as most are) is a recipe for disaster.

i try to execute it by mingw command line

make help

but it enter cmd.exe and not return anyone know why?

It seems likely that the issue revolves around the use of the exit command in the recipe, which appears completely pointless. It is possible, however, that cmd.exe just doesn't work at all with your particular make. The details don't really matter because overall, this is a knob that you generally should not twiddle. You especially should not turn it to the cmd.exe setting unless you are the makefile author and you know exactly what you are doing.

Upvotes: 0

Related Questions