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
diff --git a/tools/setlocalversion b/tools/setlocalversion
new file mode 100755
index 0000000..9a23825
--- /dev/null
+++ b/tools/setlocalversion
@@ -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