The version numbers that are reported by modules reflect the version of
the upstream driver around the time we last pulled it directly into this
project. Because these numbers are basically static, it isn't terribly
useful when diagnosing problems that depend on knowing the exact driver
that is currently loaded. To work around this, this patch appends a
version number which is automatically regenerated (either from git, or
a distributed "version" file) whenever the driver is recompiled.

Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>
---
 2.6.30/Makefile.in |  2 ++
 2.6.30/wacom.h     |  5 ++++-
 2.6.36/Makefile.in |  2 ++
 2.6.36/wacom.h     |  5 ++++-
 2.6.38/Makefile.in |  2 ++
 2.6.38/wacom.h     |  5 ++++-
 3.17/Makefile.in   |  2 ++
 3.17/wacom.h       |  5 ++++-
 3.7/Makefile.in    |  2 ++
 3.7/wacom.h        |  5 ++++-
 Makefile.am        | 10 +++++++++-
 git-version-gen    | 32 ++++++++++++++++++++++++++++++++
 12 files changed, 71 insertions(+), 6 deletions(-)
 create mode 100755 git-version-gen

diff --git a/2.6.30/Makefile.in b/2.6.30/Makefile.in
index 6ed762c..e0c696f 100644
--- a/2.6.30/Makefile.in
+++ b/2.6.30/Makefile.in
@@ -5,6 +5,8 @@ ifneq ($(KERNELRELEASE),)
 # $(error ... ) stuff work
 
 ifneq ($(CONFIG_USB_WACOM),y)
+WCM_VERSION := $(shell cd $(KBUILD_EXTMOD)/.. && ./git-version-gen)
+ccflags-y := -DWACOM_VERSION_SUFFIX=\"-$(WCM_VERSION)\"
 wacom-objs := wacom_wac.o wacom_sys.o
 obj-m += wacom.o
 obj-m += wacom_w8001.o
diff --git a/2.6.30/wacom.h b/2.6.30/wacom.h
index f1fe1a4..c87cc16 100755
--- a/2.6.30/wacom.h
+++ b/2.6.30/wacom.h
@@ -93,7 +93,10 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v1.52-input-wacom-0.4"
+#ifndef WACOM_VERSION_SUFFIX
+#define WACOM_VERSION_SUFFIX ""
+#endif
+#define DRIVER_VERSION "v1.52"WACOM_VERSION_SUFFIX
 #define DRIVER_AUTHOR "Vojtech Pavlik <vojt...@ucw.cz>"
 #define DRIVER_DESC "USB Wacom tablet driver"
 #define DRIVER_LICENSE "GPL"
diff --git a/2.6.36/Makefile.in b/2.6.36/Makefile.in
index 6ed762c..e0c696f 100644
--- a/2.6.36/Makefile.in
+++ b/2.6.36/Makefile.in
@@ -5,6 +5,8 @@ ifneq ($(KERNELRELEASE),)
 # $(error ... ) stuff work
 
 ifneq ($(CONFIG_USB_WACOM),y)
+WCM_VERSION := $(shell cd $(KBUILD_EXTMOD)/.. && ./git-version-gen)
+ccflags-y := -DWACOM_VERSION_SUFFIX=\"-$(WCM_VERSION)\"
 wacom-objs := wacom_wac.o wacom_sys.o
 obj-m += wacom.o
 obj-m += wacom_w8001.o
diff --git a/2.6.36/wacom.h b/2.6.36/wacom.h
index 04251a3..2fd031c 100644
--- a/2.6.36/wacom.h
+++ b/2.6.36/wacom.h
@@ -106,7 +106,10 @@ static inline int input_mt_get_value(const struct 
input_mt_slot *slot,
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v1.52-input-wacom-0.2"
+#ifndef WACOM_VERSION_SUFFIX
+#define WACOM_VERSION_SUFFIX ""
+#endif
+#define DRIVER_VERSION "v1.52"WACOM_VERSION_SUFFIX
 #define DRIVER_AUTHOR "Vojtech Pavlik <vojt...@ucw.cz>"
 #define DRIVER_DESC "USB Wacom tablet driver"
 #define DRIVER_LICENSE "GPL"
diff --git a/2.6.38/Makefile.in b/2.6.38/Makefile.in
index 6ed762c..e0c696f 100644
--- a/2.6.38/Makefile.in
+++ b/2.6.38/Makefile.in
@@ -5,6 +5,8 @@ ifneq ($(KERNELRELEASE),)
 # $(error ... ) stuff work
 
 ifneq ($(CONFIG_USB_WACOM),y)
+WCM_VERSION := $(shell cd $(KBUILD_EXTMOD)/.. && ./git-version-gen)
+ccflags-y := -DWACOM_VERSION_SUFFIX=\"-$(WCM_VERSION)\"
 wacom-objs := wacom_wac.o wacom_sys.o
 obj-m += wacom.o
 obj-m += wacom_w8001.o
diff --git a/2.6.38/wacom.h b/2.6.38/wacom.h
index ad11e69..3908dad 100644
--- a/2.6.38/wacom.h
+++ b/2.6.38/wacom.h
@@ -97,7 +97,10 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v1.53"
+#ifndef WACOM_VERSION_SUFFIX
+#define WACOM_VERSION_SUFFIX ""
+#endif
+#define DRIVER_VERSION "v1.53"WACOM_VERSION_SUFFIX
 #define DRIVER_AUTHOR "Vojtech Pavlik <vojt...@ucw.cz>"
 #define DRIVER_DESC "USB Wacom tablet driver"
 #define DRIVER_LICENSE "GPL"
diff --git a/3.17/Makefile.in b/3.17/Makefile.in
index 58d2af7..e96e628 100644
--- a/3.17/Makefile.in
+++ b/3.17/Makefile.in
@@ -5,6 +5,8 @@ ifneq ($(KERNELRELEASE),)
 # $(error ... ) stuff work
 
 ifneq ($(CONFIG_HID_WACOM),y)
+WCM_VERSION := $(shell cd $(KBUILD_EXTMOD)/.. && ./git-version-gen)
+ccflags-y := -DWACOM_VERSION_SUFFIX=\"-$(WCM_VERSION)\"
 wacom-objs := wacom_wac.o wacom_sys.o
 obj-m += wacom.o
 obj-m += wacom_w8001.o
diff --git a/3.17/wacom.h b/3.17/wacom.h
index 1b782f3..c01898c 100644
--- a/3.17/wacom.h
+++ b/3.17/wacom.h
@@ -98,7 +98,10 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v2.00"
+#ifndef WACOM_VERSION_SUFFIX
+#define WACOM_VERSION_SUFFIX ""
+#endif
+#define DRIVER_VERSION "v2.00"WACOM_VERSION_SUFFIX
 #define DRIVER_AUTHOR "Vojtech Pavlik <vojt...@ucw.cz>"
 #define DRIVER_DESC "USB Wacom tablet driver"
 #define DRIVER_LICENSE "GPL"
diff --git a/3.7/Makefile.in b/3.7/Makefile.in
index 6ed762c..e0c696f 100644
--- a/3.7/Makefile.in
+++ b/3.7/Makefile.in
@@ -5,6 +5,8 @@ ifneq ($(KERNELRELEASE),)
 # $(error ... ) stuff work
 
 ifneq ($(CONFIG_USB_WACOM),y)
+WCM_VERSION := $(shell cd $(KBUILD_EXTMOD)/.. && ./git-version-gen)
+ccflags-y := -DWACOM_VERSION_SUFFIX=\"-$(WCM_VERSION)\"
 wacom-objs := wacom_wac.o wacom_sys.o
 obj-m += wacom.o
 obj-m += wacom_w8001.o
diff --git a/3.7/wacom.h b/3.7/wacom.h
index b53fb2d..8e0149e 100644
--- a/3.7/wacom.h
+++ b/3.7/wacom.h
@@ -93,7 +93,10 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v1.53"
+#ifndef WACOM_VERSION_SUFFIX
+#define WACOM_VERSION_SUFFIX ""
+#endif
+#define DRIVER_VERSION "v1.53"WACOM_VERSION_SUFFIX
 #define DRIVER_AUTHOR "Vojtech Pavlik <vojt...@ucw.cz>"
 #define DRIVER_DESC "USB Wacom tablet driver"
 #define DRIVER_LICENSE "GPL"
diff --git a/Makefile.am b/Makefile.am
index 25f8be1..fb1d956 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,13 @@
 SUBDIRS = @WCM_KERNEL_VER@
 
 DIST_SUBDIRS = 2.6.30 2.6.36 2.6.38 3.7 3.17
-EXTRA_DIST = inputattach/inputattach.c inputattach/README \
+EXTRA_DIST = git-version-gen version \
+             inputattach/inputattach.c inputattach/README \
             inputattach/serio-ids.h
+
+.PHONY: generate-version
+
+version: generate-version
+
+generate-version:
+       ./git-version-gen > version
diff --git a/git-version-gen b/git-version-gen
new file mode 100755
index 0000000..d7eed0a
--- /dev/null
+++ b/git-version-gen
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+DEF_VER=UNKNOWN
+TAG_PREFIX="input-wacom-"
+LF='
+'
+
+# First see if we're in a git directory and try git-describe, then
+# try the 'version' file if present (included in release tarballs),
+# and finally the default.
+if test -d ${GIT_DIR:-.git} -o -f .git &&
+       VN=$(git describe --match "${TAG_PREFIX}*" --abbrev=7 HEAD 2>/dev/null) 
&&
+       case "$VN" in
+       *$LF*) (exit 1) ;;
+       ${TAG_PREFIX}*)
+               git update-index -q --refresh
+               test -z "$(git diff-index --name-only HEAD --)" ||
+               VN="$VN-dirty" ;;
+       esac
+then
+       VN=$(echo "$VN" | sed -e "s/${TAG_PREFIX}//");
+       VN=$(echo "$VN" | sed -e 's/-/./g');
+elif test -f version
+then
+       VN=$(cat version) || VN="$DEF_VER"
+else
+       VN="$DEF_VER"
+fi
+
+VN=$(expr "$VN" : v*'\(.*\)')
+
+echo $VN
-- 
2.4.6


------------------------------------------------------------------------------
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to