如何强制 make 在 Windows/MSYS2 上使用 bash 作为 shell
How to force make to use bash as a shell on Windows/MSYS2
我正在尝试重新编译一个已经有 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
运行s 它的命令行使用 windows native shell(这对于大多数简单命令来说不是问题,但当它依赖于 bash-like 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:\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
根据 make 文档,make
采用 SHELL
环境。考虑变量。
SHELL
设置为 unix 风格的路径,但我试图用 $ export SHELL="C:/msys64/usr/bin/bash.exe"
更改它以反映原生 windows 路径(make
可能不会了解 MSYS2)但无济于事)
那么如何告诉 make
使用 bash
shell 而不是 Windows shell 呢?
Built for i686-pc-mingw32
该行表示您使用的 GNU Make 版本错误。您使用的是为 MinGW 运行time 构建的,而不是为 MSYS2 运行time(Cygwin 的一个分支)构建的。
确保 运行 pacman -S make
安装正确版本的 GNU Make,然后 运行 which make
returns /usr/bin/make
。新 make 应该将自己标识为 "Built for x86_64-pc-msys".
我正在尝试重新编译一个已经有 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
运行s 它的命令行使用 windows native shell(这对于大多数简单命令来说不是问题,但当它依赖于 bash-like 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:\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
根据 make 文档,make
采用 SHELL
环境。考虑变量。
SHELL
设置为 unix 风格的路径,但我试图用 $ export SHELL="C:/msys64/usr/bin/bash.exe"
更改它以反映原生 windows 路径(make
可能不会了解 MSYS2)但无济于事)
那么如何告诉 make
使用 bash
shell 而不是 Windows shell 呢?
Built for i686-pc-mingw32
该行表示您使用的 GNU Make 版本错误。您使用的是为 MinGW 运行time 构建的,而不是为 MSYS2 运行time(Cygwin 的一个分支)构建的。
确保 运行 pacman -S make
安装正确版本的 GNU Make,然后 运行 which make
returns /usr/bin/make
。新 make 应该将自己标识为 "Built for x86_64-pc-msys".