linux makefile filechk

本文介绍了一个用于自动生成U-Boot版本信息文件的Makefile脚本实现过程。该脚本通过读取配置文件uboot.release来获取版本信息,并将其写入到version_autogenerated.h中,同时记录编译器和链接器的版本信息。
version_h := include/generated/version_autogenerated.h

$(version_h): include/config/uboot.release FORCE

$(call filechk,version.h)


define filechk_version.h
(echo \#define PLAIN_VERSION \"$(UBOOTRELEASE)\"; \
echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; \
echo \#define CC_VERSION_STRING \"$$(LC_ALL=C $(CC) --version | head -n 1)\"; \
echo \#define LD_VERSION_STRING \"$$(LC_ALL=C $(LD) --version | head -n 1)\"; )
endef

define filechk
$(Q)set -e; \
$(kecho) '  CHK     $@'; \
mkdir -p $(dir $@); \
$(filechk_$(1)) < $< > $@.tmp; \
if [ -r $@ ] && cmp -s $@ $@.tmp; then \
rm -f $@.tmp; \
else \
$(kecho) '  UPD     $@'; \
mv -f $@.tmp $@; \
fi

endef


define filechk
$(Q)set -e; \
$(kecho) '  CHK     $@'; \
mkdir -p include/generated/; \
$(filechk_version.h) < include/config/uboot.release > include/generated/version_autogenerated.h.tmp; \
if [ -r $@ ] && cmp -s $@ $@.tmp; then \
rm -f $@.tmp; \
else \
$(kecho) '  UPD     $@'; \
mv -f $@.tmp $@; \
fi
endef


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值