【问题标题】:How to force make to use bash as a shell on Windows/MSYS2如何强制 make 在 Windows/MSYS2 上使用 bash 作为 shell
【发布时间】:2018-02-04 00:12:48
【问题描述】:

我正在尝试重新编译一个已经有 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 调试模式得到确认:

$ 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?

【问题讨论】:

  • 如果导出的变量不起作用,请尝试make SHELL=bash - 如果可以在$PATH 上找到完整路径,则不需要完整路径。
  • @o11c 已经尝试过了。大卫回答钉了它。我使用的是 MinGW(本机)版本的 make,而我应该使用 MSYS make、MSYS & bash。

标签: windows bash makefile gnu-make msys2


【解决方案1】:

为 i686-pc-mingw32 构建

该行表示您使用了错误的 GNU Make 版本。您使用的是为 MinGW 运行时构建的,而不是为 MSYS2 运行时构建的(Cygwin 的一个分支)。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-14
    • 2016-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-04
    相关资源
    最近更新 更多