]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Add GIT version information (commid ID) to untagged U-Boot versions
authorWolfgang Denk <wd@pollux.(none)>
Tue, 21 Feb 2006 16:33:04 +0000 (17:33 +0100)
committerWolfgang Denk <wd@pollux.(none)>
Tue, 21 Feb 2006 16:33:04 +0000 (17:33 +0100)
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

CHANGELOG
Makefile
include/version.h
tools/setlocalversion [new file with mode: 0755]

index 394cb14faaeeb784b7b6d7a7e78ae66c8316da58..44989b849de6b6f3fef1156563da8519fa328ddd 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,21 @@
 Changes since U-Boot 1.1.4:
 ======================================================================
 
+* 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
+
 * Update default environment for INKA4x00 board.
 
 * Convert CPCI750 to use common CFI flash driver
index 9305cab38bb4257e58b9da2d8de3ba1d93182fc2..08a8e4670867af31a5c4c26686861a2c730399f7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2005
+# (C) Copyright 2000-2006
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
 # MA 02111-1307 USA
 #
 
+VERSION = 1
+PATCHLEVEL = 1
+SUBLEVEL = 4
+EXTRAVERSION =
+U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
+VERSION_FILE = include/version_autogenerated.h
+
 HOSTARCH := $(shell uname -m | \
        sed -e s/i.86/i386/ \
            -e s/sun4u/sparc64/ \
@@ -154,14 +161,14 @@ u-boot.bin:       u-boot
 u-boot.img:    u-boot.bin
                ./tools/mkimage -A $(ARCH) -T firmware -C none \
                -a $(TEXT_BASE) -e 0 \
-               -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' include/version.h | \
+               -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \
                        sed -e 's/"[     ]*$$/ for $(BOARD) board"/') \
                -d $< $@
 
 u-boot.dis:    u-boot
                $(OBJDUMP) -d $< > $@
 
-u-boot:                depend $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
+u-boot:                depend version $(SUBDIRS) $(OBJS) $(LIBS) $(LDSCRIPT)
                UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) |sed  -n -e 's/.*\(__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
                $(LD) $(LDFLAGS) $$UNDEF_SYM $(OBJS) \
                        --start-group $(LIBS) --end-group $(PLATFORM_LIBS) \
@@ -173,6 +180,13 @@ $(LIBS):
 $(SUBDIRS):
                $(MAKE) -C $@ all
 
+version:
+               @echo -n "#define U_BOOT_VERSION \"U-Boot " > $(VERSION_FILE); \
+               echo -n "$(U_BOOT_VERSION)" >> $(VERSION_FILE); \
+               echo -n $(shell $(CONFIG_SHELL) $(TOPDIR)/tools/setlocalversion \
+                        $(TOPDIR)) >> $(VERSION_FILE); \
+               echo "\"" >> $(VERSION_FILE)
+
 gdbtools:
                $(MAKE) -C tools/gdb || exit 1
 
@@ -1838,7 +1852,7 @@ clobber:  clean
                -o -name '*.srec' -o -name '*.bin' -o -name u-boot.img \) \
                -print0 \
                | xargs -0 rm -f
-       rm -f $(OBJS) *.bak tags TAGS
+       rm -f $(OBJS) *.bak tags TAGS include/version_autogenerated.h
        rm -fr *.*~
        rm -f u-boot u-boot.map u-boot.hex $(ALL)
        rm -f tools/crc32.c tools/environment.c tools/env/crc32.c
index 4f8b498cf37bf0b59f91c2e06e84d4570e85661e..b56d2e9900b8309c66d3f265ab73b03ebd46137e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000-2003
+ * (C) Copyright 2000-2006
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * See file CREDITS for list of people who contributed to this
@@ -24,6 +24,6 @@
 #ifndef        __VERSION_H__
 #define        __VERSION_H__
 
-#define        U_BOOT_VERSION  "U-Boot 1.1.4"
+#include "version_autogenerated.h"
 
 #endif /* __VERSION_H__ */
diff --git a/tools/setlocalversion b/tools/setlocalversion
new file mode 100755 (executable)
index 0000000..9a23825
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Print additional version information for non-release trees.
+
+usage() {
+       echo "Usage: $0 [srctree]" >&2
+       exit 1
+}
+
+cd "${1:-.}" || usage
+
+# Check for git and a git repo.
+if head=`git rev-parse --verify HEAD 2>/dev/null`; then
+       # Do we have an untagged version?
+       if  [ "`git name-rev --tags HEAD`" = "HEAD undefined" ]; then
+               printf '%s%s' -g `echo "$head" | cut -c1-8`
+       fi
+
+       # Are there uncommitted changes?
+       if git diff-files | read dummy; then
+               printf '%s' -dirty
+       fi
+fi