如何强制制作在 Windows/MSYS2 上使用 bash 作为 shell



我正在尝试重新编译已经具有Windows端口的应用程序(所以它应该可以工作(

当然,你仍然需要运行./configure所以你需要MSYS或MSYS2。

配置部分运行良好。现在,当我运行make -n(因此它显示执行了哪些规则(时,我得到:

$ 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是法语消息的近似翻译(因此可能略有不同(,但让我想起了神秘的Windows批处理文件消息。所以我想make使用 Windows 本机 shell 运行其命令行(这对于大多数简单的命令来说不是问题,但当它依赖于类似 bash 的 shell 时就不是了(,通过使用 make debug 模式确认的假设:

$ 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:msys64tmpmake11752-1.bat
Batch file contents:
@echo off
if test ! -f config.h; then   rm -f stamp-h1;   make stamp-h1; else :; fi

从 make 文档中,make考虑了SHELLenv. 变量。

SHELL设置为Unix风格的路径,但我试图用$ export SHELL="C:/msys64/usr/bin/bash.exe"更改它以反映本机Windows路径(make可能不是MSYS2感知的(,但无济于事(

那么如何告诉make使用bash外壳而不是Windows shell呢?

专为 i686-pc-mingw32 构建

这一行意味着你使用了错误版本的GNU Make。 您正在使用为MinGW运行时构建的,而不是为MSYS2运行时(Cygwin的一个分支(构建的。

确保运行pacman -S make以安装正确版本的 GNU Make,然后运行which make并确保它返回/usr/bin/make。 新品牌应该将自己标识为"为x86_64-pc-msys构建"。

最新更新