I wrote very simple Makefile
to show problem which I got. Please take a look:
我编写了非常简单的Makefile来显示我得到的问题。请看看:
Makefile:
Makefile:
.PHONY: clean
clean:
-rmdir /S /Q not_existing_directory >nul 2>&1
Running this Makefile
with command make clean
doesn't redirects errors from rmdir
to the NULL
device. The interesting thing is that running the same command from cmd.exe
works as expected, namely it hides errors. My question is why is it happening ?
使用make clean命令运行这个Makefile不会将错误从rmdir重定向到空设备。有趣的是,从cmd运行相同的命令。exe按预期工作,即隐藏错误。我的问题是为什么会这样?
This error manifested on Windows 7 32-bit version as make
I'm using mingw
from http://www.mingw.org/ in following version:
这个错误出现在Windows 7的32位版本中,我使用的是http://www.mingw.org/的mingw:
GNU Make 3.82.90
Built for i686-pc-mingw32
Here are also my enviromental variables which I'm setting through batch file:
下面是我通过批处理文件设置的环境变量:
setenv.bat:
setenv.bat:
set PATH=C:\Windows\system32;C:\Program Files\COSMIC\CXSTM8;C:\MinGW\bin;C:\Program Files\Vim
%comspec% /k PATH
I would really appreciate your help.
非常感谢你的帮助。
1 个解决方案
#1
1
I can't explain any more why this is working, but I had the same problem and I'm using the following to really quiet commands in Makefiles with cmd
:
我不能再解释为什么它会工作,但是我有同样的问题,我正在用下面的方法在makefile中使用cmd来实现真正的安静命令:
>nul 2>nul & verify >nul
To keep the Makefile compatible with sh
, too, it might be a good idea to define variables, I use for example this in an include for cmd
:
为了使Makefile与sh兼容,定义变量可能是一个好主意,我在cmd的include中使用了这个例子:
CMDSEP := &
PSEP := \\
CPF := copy /y
RMF := del /f /q
RMFR := -rd /s /q
MDP := -md
CMDQUIET := >nul 2>nul & verify >nul
while the following section is for bash
and other sh
-compatible shells:
下一节介绍bash和其他与sh兼容的shell:
CMDSEP := ;
PSEP := /
CPF := cp -f
RMF := rm -f
RMFR := rm -fr
MDP := mkdir -p
CMDQUIET := >/dev/null 2>&1
example usage:
使用示例:
distclean: clean
$(RMF) conf.mk
$(RMFR) $(SDKDIR) $(CMDQUIET)
$(RMFR) $(OUTDIR) $(CMDQUIET)
#1
1
I can't explain any more why this is working, but I had the same problem and I'm using the following to really quiet commands in Makefiles with cmd
:
我不能再解释为什么它会工作,但是我有同样的问题,我正在用下面的方法在makefile中使用cmd来实现真正的安静命令:
>nul 2>nul & verify >nul
To keep the Makefile compatible with sh
, too, it might be a good idea to define variables, I use for example this in an include for cmd
:
为了使Makefile与sh兼容,定义变量可能是一个好主意,我在cmd的include中使用了这个例子:
CMDSEP := &
PSEP := \\
CPF := copy /y
RMF := del /f /q
RMFR := -rd /s /q
MDP := -md
CMDQUIET := >nul 2>nul & verify >nul
while the following section is for bash
and other sh
-compatible shells:
下一节介绍bash和其他与sh兼容的shell:
CMDSEP := ;
PSEP := /
CPF := cp -f
RMF := rm -f
RMFR := rm -fr
MDP := mkdir -p
CMDQUIET := >/dev/null 2>&1
example usage:
使用示例:
distclean: clean
$(RMF) conf.mk
$(RMFR) $(SDKDIR) $(CMDQUIET)
$(RMFR) $(OUTDIR) $(CMDQUIET)