Commit 881a87ecbab328656eb3e9d25c3ed6868587b197

Authored by Wolfgang Denk
1 parent 654c2d2836

Add GIT version information (commid ID) to untagged U-Boot versions

As done in the linux kernel, the U-Boot version (U_BOOT_VERSION)
of all unreleased (untagged) U-Boot images will be automatically
extended upon compiletime with a part of the GIT commit ID and
possibly with "dirty" if uncommited changes are detected.

Here an example for the resulting version:
"U-Boot 1.1.4-g3457ac18-dirty"

The version is now maintained in the toplevel Makefile and the
version headers are autogenerated.

Patch by Stefan Roese, 9 Feb 2006

Showing 4 changed files with 57 additions and 6 deletions Side-by-side Diff

... ... @@ -2,6 +2,21 @@
2 2 Changes since U-Boot 1.1.4:
3 3 ======================================================================
4 4  
  5 +* Add GIT version information (commid ID) to untagged U-Boot versions
  6 +
  7 + As done in the linux kernel, the U-Boot version (U_BOOT_VERSION)
  8 + of all unreleased (untagged) U-Boot images will be automatically
  9 + extended upon compiletime with a part of the GIT commit ID and
  10 + possibly with "dirty" if uncommited changes are detected.
  11 +
  12 + Here an example for the resulting version:
  13 + "U-Boot 1.1.4-g3457ac18-dirty"
  14 +
  15 + The version is now maintained in the toplevel Makefile and the
  16 + version headers are autogenerated.
  17 +
  18 + Patch by Stefan Roese, 9 Feb 2006
  19 +
5 20 * Update default environment for INKA4x00 board.
6 21  
7 22 * Convert CPCI750 to use common CFI flash driver
1 1 #
2   -# (C) Copyright 2000-2005
  2 +# (C) Copyright 2000-2006
3 3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 4 #
5 5 # See file CREDITS for list of people who contributed to this
... ... @@ -21,6 +21,13 @@
21 21 # MA 02111-1307 USA
22 22 #
23 23  
  24 +VERSION = 1
  25 +PATCHLEVEL = 1
  26 +SUBLEVEL = 4
  27 +EXTRAVERSION =
  28 +U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
  29 +VERSION_FILE = include/version_autogenerated.h
  30 +
24 31 HOSTARCH := $(shell uname -m | \
25 32 sed -e s/i.86/i386/ \
26 33 -e s/sun4u/sparc64/ \
27 34  
... ... @@ -154,14 +161,14 @@
154 161 u-boot.img: u-boot.bin
155 162 ./tools/mkimage -A $(ARCH) -T firmware -C none \
156 163 -a $(TEXT_BASE) -e 0 \
157   - -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' include/version.h | \
  164 + -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
158 165 sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \
159 166 -d $< $@
160 167  
161 168 u-boot.dis: u-boot
162 169 $(OBJDUMP) -d $< > $@
163 170  
164   -u-boot: depend $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
  171 +u-boot: depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
165 172 UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
166 173 $(LD) $(LDFLAGS) $$UNDEF_SYM $(OBJS) \
167 174 --start-group $(LIBS) --end-group $(PLATFORM_LIBS) \
... ... @@ -173,6 +180,13 @@
173 180 $(SUBDIRS):
174 181 $(MAKE) -C $@ all
175 182  
  183 +version:
  184 + @echo -n "#define U_BOOT_VERSION \"U-Boot " > $(VERSION_FILE); \
  185 + echo -n "$(U_BOOT_VERSION)" >> $(VERSION_FILE); \
  186 + echo -n $(shell $(CONFIG_SHELL) $(TOPDIR)/tools/setlocalversion \
  187 + $(TOPDIR)) >> $(VERSION_FILE); \
  188 + echo "\"" >> $(VERSION_FILE)
  189 +
176 190 gdbtools:
177 191 $(MAKE) -C tools/gdb || exit 1
178 192  
... ... @@ -1838,7 +1852,7 @@
1838 1852 -o -name '*.srec' -o -name '*.bin' -o -name u-boot.img \) \
1839 1853 -print0 \
1840 1854 | xargs -0 rm -f
1841   - rm -f $(OBJS) *.bak tags TAGS
  1855 + rm -f $(OBJS) *.bak tags TAGS include/version_autogenerated.h
1842 1856 rm -fr *.*~
1843 1857 rm -f u-boot u-boot.map u-boot.hex $(ALL)
1844 1858 rm -f tools/crc32.c tools/environment.c tools/env/crc32.c
1 1 /*
2   - * (C) Copyright 2000-2003
  2 + * (C) Copyright 2000-2006
3 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 4 *
5 5 * See file CREDITS for list of people who contributed to this
... ... @@ -24,7 +24,7 @@
24 24 #ifndef __VERSION_H__
25 25 #define __VERSION_H__
26 26  
27   -#define U_BOOT_VERSION "U-Boot 1.1.4"
  27 +#include "version_autogenerated.h"
28 28  
29 29 #endif /* __VERSION_H__ */
tools/setlocalversion
  1 +#!/bin/sh
  2 +# Print additional version information for non-release trees.
  3 +
  4 +usage() {
  5 + echo "Usage: $0 [srctree]" >&2
  6 + exit 1
  7 +}
  8 +
  9 +cd "${1:-.}" || usage
  10 +
  11 +# Check for git and a git repo.
  12 +if head=`git rev-parse --verify HEAD 2>/dev/null`; then
  13 + # Do we have an untagged version?
  14 + if [ "`git name-rev --tags HEAD`" = "HEAD undefined" ]; then
  15 + printf '%s%s' -g `echo "$head" | cut -c1-8`
  16 + fi
  17 +
  18 + # Are there uncommitted changes?
  19 + if git diff-files | read dummy; then
  20 + printf '%s' -dirty
  21 + fi
  22 +fi