最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】makfile执行任意命令时输出一些信息

makefile crifan 2534浏览 0评论

折腾:

【已解决】Mac中写Makefile或脚步实现自动化执行命令

期间,希望每次运行makefile,不论执行任何target

比如此处的:

<code>make dir_info
</code>

都可以输出一些信息

比如当前makefile脚本的version版本

试了:

<code>$(shell $(echo "20171207"))
</code>

没用。

make 打印版本信息

makefile print version

Go,Makefile与自动程序版本号的实现 | iTimothy

Linux 中,如何显示 (gcc)make时实际执行命令 – klchang – 博客园

How can I print message in Makefile? – Stack Overflow

【总结】

最后用:

<code>Author=crifan.com
Version=20171207
Function=Auto use gitbook to generated files: website/pdf/epub/mobi. Run 'make help' to see usage
$(info ####################################################################################################)
$(info Author: $(Author))
$(info Version: $(Version))
$(info Function: $(Function))
$(info ####################################################################################################)

</code>

效果:

<code>➜  http_summary git:(master) ✗ make dir_info
####################################################################################################
Author: crifan.com
Version: 20171207
Function: Auto use gitbook to generated files: website/pdf/epub/mobi. Run 'make help' to see usage
####################################################################################################
</code>

【后记】

除了info,还有warning和error:

  • warning:打印出警告信息,但不停止运行

  • error:报错,且停止运行

比如:

<code>$(info ####################################################################################################)
$(warning Author: $(Author))
$(error Version: $(Version))
</code>

效果:

<code>➜  http_summary git:(master) ✗ make dir_info
####################################################################################################
Makefile:5: Author: crifan.com
Makefile:6: *** Version: 20171207.  Stop.
</code>

转载请注明:在路上 » 【已解决】makfile执行任意命令时输出一些信息

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.170 seconds, using 22.10MB memory