首页 / 操作系统 / Linux / u-boot中的version命令
[u-boot: v2013.04][Author: Bo Shen voice.shen@gmail.com]1. Source Code<common/cmd_version.c>2. UsageU-Boot > help versionversion - print monitor versionU-boot > versionU-Boot 2013.04-00085-g5ed6f443. Source code go throughconst char __weak version_string[] = U_BOOT_VERSION_STRING;static int do_version(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
printf("
%s
", version_string);
#ifdef CC_VERSION_STRING
puts(CC_VERSION_STRING "
");
#endif
#ifdef LD_VERSION_STRING
puts(LD_VERSION_STRING "
");
#endif
#ifdef CONFIG_SYS_COREBOOT
printf("coreboot-%s (%s)
", lib_sysinfo.version, lib_sysinfo.build);
#endif
return 0;
}其中,U_BOOT_VERSION_STRING在<include/version.h>定义:#define U_BOOT_VERSION_STRING U_BOOT_VERSION " (" U_BOOT_DATE " - "
U_BOOT_TIME ")" CONFIG_IDENT_STRINGU_BOOT_VERSION, CC_VERSION_STRING, LD_VERSION_STRING: 定义在<include/generated/version_autogenerated.h>此文件通过名字可以看出是自动生成的。其具体生成代码在顶层目录中的Makefile里面。代码如下:$(VERSION_FILE):
@mkdir -p $(dir $(VERSION_FILE))
@( localvers="$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))" ;
printf "#define PLAIN_VERSION "%s%s"
"
"$(U_BOOT_VERSION)" "$${localvers}" ;
printf "#define U_BOOT_VERSION "U-Boot %s%s"
"
"$(U_BOOT_VERSION)" "$${localvers}" ;
) > $@.tmp
@( printf "#define CC_VERSION_STRING "%s"
"
"$(shell $(CC) --version | head -n 1)" )>> $@.tmp
@( printf "#define LD_VERSION_STRING "%s"
"
"$(shell $(LD) -v | head -n 1)" )>> $@.tmp
@cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@