如何在Windows/MSYS2上强制make使用bash作为外壳 [英] How to force make to use bash as a shell on Windows/MSYS2

查看:117
本文介绍了如何在Windows/MSYS2上强制make使用bash作为外壳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

当然,您仍然需要运行 ./configure ,因此您需要MSYS或MSYS2.

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

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

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

!出乎意料的是法语消息的近似翻译(因此可能略有不同),但让我想起了很多神秘的Windows批处理文件消息.因此,我假设 make 使用Windows本机外壳程序运行其命令行(对于大多数简单命令而言,这不是问题,但当它依赖于类似bash的外壳程序时则不存在此问题),这一假设已得到确认使用make调试模式:

! 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

从make文档中, make 接受 SHELL env.变量.

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

SHELL 设置为unix样式的路径,但是我尝试使用 $ export SHELL ="C:/msys64/usr/bin/bash.exe"进行更改.反映本机Windows路径( make 可能不支持MSYS2),但无济于事

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)

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

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

推荐答案

适用于i686-pc-mingw32

Built for i686-pc-mingw32

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

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).

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

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".

这篇关于如何在Windows/MSYS2上强制make使用bash作为外壳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆