makefile学习7:echo的使用

类似于shell的echo的语句,echo可以在make执行时打印出自己预设的内容。

这个是内核源码根目录的makefile内容,>&2这个是将错误输出到文件描述为2的文件,其实是标准错误。

makefile学习7:echo的使用

 例子:

[email protected]:~/mc$ cat Makefile 
obj=test.o printarr.o
test:$(obj)
	gcc -o test $(obj)
$(obj):std.h

.PHONY:clean
clean:
	@echo "start rm"
	@echo "--------------"
	echo "start rm"
	-rm test $(obj)

结果:

[email protected]:~/mc$ make clean
start rm
--------------
echo "start rm"
start rm
rm test test.o printarr.o

可以看到有@之后,echo是不出现的,只出现之后的语句,没有echo的话,会打印echo那一行,还要再打印一次双引号里的内容。

参考:http://www.cnblogs.com/liangxiaxu/archive/2012/07/31/2617384.html