带有或不带有MSYS的MinGW Makefile(del vs rm) [英] MinGW makefile with or without MSYS (del vs rm)
问题描述
我正在使用MinGW在Windows上编译一些东西.我直接从cmd.exe
调用mingw32-make
,一切(我需要)都可以正常工作.但是我发现我将需要能够在MSYS环境中进行编译,并且我遇到了copy
和del
命令无法识别的问题.我知道只用cp
和rm
替换它们,但是我想在两种情况下都使用单个makefile.
I am using MinGW for compiling some stuff on Windows. I call mingw32-make
directly from cmd.exe
and everything (I need) works fine. However I found out I will need to be able to compile from the MSYS environment and I run in problems with copy
and del
commands not beeing recognized. I know it is only matter of replacing them with cp
and rm
, but I would like to use single makefile for both cases.
是否有一种方法可以强制msys环境调用系统del
和cp
命令?
Is there a way to force msys environment to call system del
and cp
commands?
或者更好的是,有没有办法区分是从cmd.exe
还是msys调用makefile?比我可以为命令设置适当的变量.这将非常有帮助,因为这样我就可以删除其他一些重复的makefile.
Or better yet, is there a way to distinguish whether the makefile is called from cmd.exe
or msys? Than I could set appropriate variables for the commands. This would be quite helpfull, because I could then remove some other duplicate makefiles.
感谢您的帮助.
谢谢
而且要使事情更困难:如果从cmd.exe
运行时在PATH中找到mingw32-make
,则似乎正在使用sh.exe
.这具有完全不同的环境变量集.
And to make things more difficult: mingw32-make
seems to be using sh.exe
if found in PATH when run from cmd.exe
. This has completely different set of environment variables.
编辑:好吧,如果仍然有人感兴趣,我最终得到了以下文件,该文件包含在我的其他Makefile中:
OK, if anyone is still interested, I ended up with the following file, which I include to my other Makefiles:
ifeq ($(OS),Windows_NT)
RM = del /Q /F
CP = copy /Y
ifdef ComSpec
SHELL := $(ComSpec)
endif
ifdef COMSPEC
SHELL := $(COMSPEC)
endif
else
RM = rm -rf
CP = cp -f
endif
如果不是,您仍然认为这是一个重复的问题,我当然可以删除此问题.
If not, and you still think this is a duplicate question I can of course delete this question.
出于我未知的原因,ComSpec
和COMPSPEC
有所作为.
For reasons unknown to me ComSpec
and COMPSPEC
make a difference.
推荐答案
我和您遇到了同样的情况.我将MSYS目录添加到virtual环境中,并且运行良好.
I met the same condition with you. I add MSYS directory to PATH environment virable, and it works well.
这篇关于带有或不带有MSYS的MinGW Makefile(del vs rm)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!