【发布时间】: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