8.12 Functions That Control Make / makefile debug

本文介绍了Makefile中用于控制Make行为的几个关键函数:error、warning和info。这些函数主要用于向用户提供信息或在检测到环境错误时使Make停止运行。error函数会生成一个致命错误并退出;warning函数显示消息但继续处理;info函数仅打印消息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

8.12 Functions That Control Make

These functions control the way make runs. Generally, they are used to provide information to the user of the makefile or to cause make to stop if some sort of environmental error is detected.
$(error text...)
Generates a fatal error where the message is text. Note that the error is generated whenever this function is evaluated. So, if you put it inside a recipe or on the right side of a recursive variable assignment, it won't be evaluated until later. The text will be expanded before the error is generated.

For example,
ifdef ERROR1
$(error error is $(ERROR1))
endif

will generate a fatal error during the read of the makefile if the make variable ERROR1 is defined. Or,
ERR = $(error found an error!)

.PHONY: err
err: ; $(ERR)

will generate a fatal error while make is running, if the err target is invoked.
$(warning text...)
This function works similarly to the error function, above, except that make doesn't exit. Instead, text is expanded and the resulting message is displayed, but processing of the makefile continues.

The result of the expansion of this function is the empty string.
$(info text...)

This function does nothing more than print its (expanded) argument(s) to standard output. No makefile name or line number is added. The result of the expansion of this function is the empty string.


see 

http://gnu.april.org/software/make/manual/html_node/Make-Control-Functions.html#Make-Control-Functions 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值