How to force make to use bash as a shell on Windows/MSYS2

萝らか妹 提交于 2019-12-11 05:22:54

问题


I'm trying to recompile an application already having a windows port (so it's supposed to work)

Of course, you still need to run ./configure so you need MSYS or MSYS2.

The configure part worked well. Now when I run make -n (so it shows which rules are executed) I get:

$ make -n
if test ! -f config.h; then \
  rm -f stamp-h1; \
  make stamp-h1; \
else :; fi
! was unexpected
make: *** [config.h] Error 255

! was unexpected is the approximate translation of a french message (so it may be slightly different) but reminded me very much of the cryptic Windows batch file messages. So I suppose that make runs its command lines using windows native shell (which isn't an issue for most simple commands, but not when it relies on a bash-like shell), assumption which was confirmed by using make debug mode:

$ make -d
GNU Make 3.82
Built for i686-pc-mingw32
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
<I'll spare you that boring part then:>
Invoking recipe from Makefile:164 to update target `config.h'.
Creating temporary batch file C:\msys64\tmp\make11752-1.bat
Batch file contents:
        @echo off
        if test ! -f config.h; then   rm -f stamp-h1;   make stamp-h1; else :; fi

From the make documentation, make takes the SHELL env. variable into account.

SHELL is set to a unix-style path, but I've tried to change it with $ export SHELL="C:/msys64/usr/bin/bash.exe" to reflect native windows path (make may not be MSYS2 aware) but to no avail)

So how to tell make to use bash shell instead of the Windows shell ?


回答1:


Built for i686-pc-mingw32

That line means you are using the wrong version of GNU Make. You are using one that is built for the MinGW runtime instead of one built for the MSYS2 runtime (a fork of Cygwin).

Make sure you run pacman -S make to install the proper version of GNU Make, and then run which make and make sure it returns /usr/bin/make. The new make should identify itself as something like "Built for x86_64-pc-msys".



来源:https://stackoverflow.com/questions/45889953/how-to-force-make-to-use-bash-as-a-shell-on-windows-msys2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!