为什么可以';我的makefile是否调用Windows 10 cmd shell?

为什么可以';我的makefile是否调用Windows 10 cmd shell?,cmd,makefile,Cmd,Makefile,由于某种原因,make无法调用cmd,因此我无法使用新的Windows 10工作站构建任何项目。该命令通常用于检查目录等中的版本号,并导致生成过程的取消 请参见此处有关makefile的一些片段: # windows cmd shell SHELL=$(SYSTEMROOT)/System32/cmd CC=c:/path/to/compiler # ... COMPILER_VALID=FALSE ifeq ($(DESIRED_VERSION),$(shell "$(CC)")) C

由于某种原因,
make
无法调用
cmd
,因此我无法使用新的Windows 10工作站构建任何项目。该命令通常用于检查目录等中的版本号,并导致生成过程的取消

请参见此处有关makefile的一些片段:

# windows cmd shell
SHELL=$(SYSTEMROOT)/System32/cmd
CC=c:/path/to/compiler
# ...
COMPILER_VALID=FALSE
ifeq ($(DESIRED_VERSION),$(shell "$(CC)"))
    COMPILER_VALID=TRUE
endif
ifneq ($(COMPILER_VALID),TRUE)
    $(error incorrect compiler version)
endif
# ...
这曾经在我的旧电脑上工作;它仍然像我所有同事所期望的那样工作。但是,当我在当前机器上运行
make
时,它会产生以下输出:

PS C:\Users\Buerger\Project> make release
make: C:Windows/System32/cmd: Command not found
build\makefile.mak:123: *** incorrect compiler version.  Stop.
cmd.exe
位于C:\Windows\System32\,C:\path\to\compiler是我机器上的有效目录。据我所知,所有必需的开发工具都已安装。我在这里遗漏了什么,为什么我不能建立其他人都能做到的东西


编辑寻址注释:更改makefile不是一个选项。
make--version
的输出和
SYSTEMROOT
的值为

> make --version 
GNU Make 3.81                                                                                                          Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This program built for i686-pc-cygwin         

> echo %SYSTEMROOT%
C:\Windows

这是此Cygwin版本make的一个问题

带有Cygwin的版本3.81似乎错误地扩展了这个SHELL变量中的反斜杠。这会产生类似于
C:Windows/system32/cmd
的路径

例如:

PS C:\Users\WDAGUtilityAccount\Downloads> Get-Content .\Makefile
$(info $(SYSTEMROOT))

SHELL=$(SYSTEMROOT)/system32/cmd

$(info $(shell ver))

PS C:\Users\WDAGUtilityAccount\Downloads> C:\cygwin\bin\make.exe
C:\Windows
make: C:Windows/system32/cmd: Command not found

make: *** No targets.  Stop.
这是一个有效的路径,它是驱动器C:中当前工作目录的相对路径,这意味着要使其工作,需要将驱动器C:的当前工作目录设置为根驱动器,并使用完整路径(或从其他驱动器)调用
Makefile
。或者,您可以将
SHELL
设置更改为只读取
cmd.exe
(无路径),以便通过
path
自动定位

但即使在这些情况下,在现代Windows上,您也会遇到另一个问题-挂起的
cmd.exe
会话,例如:

PS C:\> C:\cygwin\bin\make.exe -f C:\Users\WDAGUtilityAccount\Downloads\Makefile -dr
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i686-pc-cygwin
Reading makefiles...
Reading makefile `C:\Users\WDAGUtilityAccount\Downloads\Makefile'...
C:\Windows
<< hanging indefinitely >>
如果您尝试从PowerShell自己运行它,您将看到它将在
cmd
中结束,而不会返回到PS:

PS C:\Users\WDAGUtilityAccount> cmd -c ver
Microsoft Windows [Version 10.0.18362.836]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\WDAGUtilityAccount>exit    <--- Note command prompt change
PS C:\Users\WDAGUtilityAccount>
您可以使用
.SHELLFLAGS
-c
替换为
/c
,但这是在make 3.82中引入的


一句话:我认为您应该使用更新版本的
make
。我的第一个选择是使用基于
cmd
的语法,它是makeforwindows的本地版本(不是Cygwin,不是MinGW)。如果您坚持使用Cygwin,则应安装最新版本(当前Cygwin
make
为4.3,并且没有这些问题)。请注意,您尝试使用的版本是在2006年发布的,从那时起,已经实施了许多改进(包括基于Windows的行为)。

我将放弃此
SHELL
设置,因为它是默认设置。还请共享
make--version
的输出,因为make for Windows有许多不同的变体。嗨,raspy,我添加了这些信息。但是无法删除SHELL。我在make:C:Windows/System32/cmd:Command-not-foundAgreed中看到“C:”后面缺少“/”:缺少的
/
肯定是个问题。可能您的
SYSTEMROOT
变量设置不正确:您没有向我们显示该变量的值来自何处。如果它来自环境,请检查您的环境变量是否设置正确。SYSTEMROOT未在makefile中定义,它来自环境
echo%SYSTEMROOT%
生成了
C:\Windows
,这似乎与我同事的机器一致。谢谢,这确实是问题的原因!关于make构建,我的选择是有限的,但改用MinGW成功了。
PS C:\Users\WDAGUtilityAccount> cmd -c ver
Microsoft Windows [Version 10.0.18362.836]
(c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\WDAGUtilityAccount>exit    <--- Note command prompt change
PS C:\Users\WDAGUtilityAccount>
PS C:\Users\WDAGUtilityAccount> cmd /c ver

Microsoft Windows [Version 10.0.18362.836]
PS C:\Users\WDAGUtilityAccount>