设为首页 加入收藏

TOP

UBOOT编译--- UBOOT的$(version_h) $(timestamp_h)(七)(一)
2023-07-23 13:30:27 】 浏览:135
Tags:UBOOT 编译 --- version_h timestamp_h

1. 前言

 UBOOT版本:uboot2018.03,开发板myimx8mmek240。

2. 概述

在编译uboot的过程中,有两个特别的依赖version_h 和 timestamp_h,它们定义在顶层Makefile中(这里只讲解编译直接在源目录的情况,即srctree 为空),如下:

# 顶层Makefile

version_h := include/generated/version_autogenerated.h
timestamp_h := include/generated/timestamp_autogenerated.h

......

$(version_h): include/config/uboot.release FORCE
	$(call filechk,version.h)

$(timestamp_h): $(srctree)/Makefile FORCE
	$(call filechk,timestamp.h)

3. 目标$(version_h)

# 顶层Makefile
$(version_h): include/config/uboot.release FORCE
	$(call filechk,version.h)

3.1 $(version_h)依赖分析

3.1.1 依赖include/config/uboot.release

使用scripts/setlocalversion工具来生成include/config/uboot.release,只是一个版本号,不需要特别关注,参见LINUX 内核编译 LOCALVERSION 配置(分析内核版本号自动添加的"+"号)

# 顶层Makefile
# Store (new) UBOOTRELEASE string in include/config/uboot.release
include/config/uboot.release: include/config/auto.conf FORCE
	$(call filechk,uboot.release)

include/config/uboot.release定义在顶层Makefile中,该目标又依赖于include/config/auto.conf(参见UBOOT编译--- include/config/auto.conf、 include/config/auto.conf.cmd、 include/generated/autoconf.h (二)) 和 FORCE。

接下来我们看规则$(call filechk,uboot.release):

#note:scripts/Kbuild.include
###
# filechk is used to check if the content of a generated file is updated.
# Sample usage:
# define filechk_sample
#	echo $KERNELRELEASE
# endef
# version.h : Makefile
#	$(call filechk,sample)
# The rule defined shall write to stdout the content of the new file.
# The existing file will be compared with the new one.
# - If no file exist it is created
# - If the content differ the new file is used
# - If they are equal no change, and no timestamp update
# - stdin is piped in from the first prerequisite ($<) so one has
#   to specify a valid file as first prerequisite (often the kbuild file)
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

上述代码中:

  • ‘$@’ :目标include/config/uboot.release ;
  • ‘$(1)’ :第一个参数uboot.release;
  • ‘$ <’ :第一个依赖include/config/auto.conf ;
  • ‘filechk_$(1)’ :filechk_uboot.release;

filechk_uboot.release定义在顶层Makefile中:

#note:顶层Makefile
# Read UBOOTRELEASE from include/config/uboot.release (if it exists)
UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null)
UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)

......

define filechk_uboot.release
	echo "$(UBOOTVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
endef

全部展开,具体编译命令如下:

set -e; : '  CHK     include/config/uboot.release'; mkdir -p include/config/;   echo "2018.03$(/bin/sh ./scripts/setlocalversion .)" < include/config/auto.conf > include/config/uboot.release.tmp; if [ -r include/config/uboot.release ] && cmp -s include/config/uboot.release include/config/uboot.release.tmp; then rm -f include/config/uboot.release.tmp; else : '  UPD     include/config/uboot.release'; mv -f include/config/uboot.release.tmp include/config/uboot.release; fi

最终产生的include/config/uboot.release内容如下:
在这里插入图片描述

3.1.2 依赖FORCE

参见UBOOT编译--- make xxx_deconfig过程详解(一) 4.3小节 - 依赖 FORCE

3.2 $(ve

首页 上一页 1 2 3 4 下一页 尾页 1/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Cache的相关知识(二) 下一篇PHY驱动调试之 --- PHY控制器驱动..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目