dmake中的shell命令添加'/ S'

时间:2012-09-04 20:36:00

标签: windows bash makefile mingw porting

我正在使用MinGW系统编译Xindy。 dmake总是因为错误而死亡,我已经将它缩小到Makefile中的几行。尝试运行dmake:

SHELL = /bin/sh
some-target:
    target=`echo info-recursive | sed s/-recursive//`;

如果您使用常规Windows CMD而不是MinGW shell,则必须将SHELL变量的位置更改为指向“C:/MinGW/msys/1.0/sh.exe”之类的内容。无论如何,以上都失败了:

CreateProcess failed (2).
dmake: Error executing 'bin/sh /S /c "target=`echo info-recursive | sed s/-recursive//`;"': No such file or directory
dmake: Error code -1, while making 'some-target'

安装了Sed和sh,它们工作正常。当我尝试通过错误消息单独运行给定命令作为输出时,我得到了这个:

$ /bin/sh /S /c "target=`echo info-recursive | sed s/-recursive//`;"
/bin/sh: /S: No such file or directory

所以似乎dmake(或其他东西)将'/ S / c'添加到shell参数中,而bash认为它是一个文件名,然后在找不到它时失败。

有没有人有这方面的经验或知道如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

dmake 源代码的简要检查表明问题是$(SHELL)设置太晚并且在启动时仍为空(macros.mk,第37行) :

11  .IF $(SHELL) == $(NULL)
...
15     SHELL *:= $(COMSPEC)
...
...
35  .IF $(SHELL) == $(COMSPEC)
36  .IF $(COMSPEC:lf) == cmd.exe
37     SHELLFLAGS       *:= $(SWITCHAR)S $(SWITCHAR)c

您可以通过将SHELL="C:/MinGW/msys/1.0/sh.exe"添加到dmake命令行调用来解决此问题。

(我多年没有使用过dmake,所以可能会在这里弄错,但是如果你能得到一个看起来像autoconfiscated makefile的dmake,我会留下深刻的印象,IIRC有一些不同的味道。更容易找到GNU make 或类似的。)