Makefile 中小知识点记录

$(VAR:XXX=YYY)

如果变量VAR中出现 XXX 则用 YYY替换

例如在U-boot的Makefile中遇到的 $(@:_config=) 如果 $@ 的值中出现 _config 则用 空 替换。


normal prerequisites && order-only prerequisites

GUN Makefile Manual Chapter4.3参考博客

targets : normal-prerequisites | order-only-prerequisites

简单的讲就是:如果目标的依赖中有 order-only prerequisites ,只有在目标第一次生成时,会去检查并生成这些 order-only prerequisites 。如果目标已经存在,在判断是否需要更新目标时,则忽略 order-only prerequisites ,即:即使这些 order-only prerequisites 有更新,也忽略这些更新,当然,如果 normal prerequisites 有更新,则目标就会更新。


include & -include & sinclude

The include directive tells make to suspend reading the current makefile and read one or more other makefiles before continuing.

The -include directive to include makefiles with no error for a nonexistent file comes from SunOS 4 make. (But note that SunOS 4 make does not allow multiple makefiles to be specified in one -include directive.) The same feature appears with the name sinclude in SGI make and perhaps others.


@ + -

all:
	@command
	-command
	+command
  • @ 不显示命令本身
  • - 忽略错误
  • + 忽略 -n , -t , -q 三个参数的影响。(命令前使用 + 和 使用$(MAKE)${MAKE} 是相同的作用。) As a special feature, using the variable MAKE in the recipe of a rule alters the effects of the ‘-t’ (‘–touch’), ‘-n’ (‘–just-print’), or ‘-q’ (‘–question’) option. Using the MAKE variable has the same effect as using a ‘+’ character at the beginning of the recipe line. GUN Makefile Manual Chapter5.7.1

.SUFFIXES:

# eliminate default suffix rules
.SUFFIXES: .c .S .h

.DELETE_ON_ERROR:

# delete target files if there is an error (or make is interrupted)
.DELETE_ON_ERROR:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值