Run git describe on build and push the output into xorg-git-version.h. Then print that out in the logfile.
Signed-off-by: Peter Hutterer <[email protected]> --- Do we want something like this? Suggestions for less dodgy implementations are welcome, but the current one passes distcheck. GIT-GENERATE-VERSION | 24 ++++++++++++++++++++++++ Makefile.am | 2 +- hw/xfree86/common/xf86Init.c | 5 +++++ include/Makefile.am | 7 +++++++ 4 files changed, 37 insertions(+), 1 deletions(-) create mode 100755 GIT-GENERATE-VERSION diff --git a/GIT-GENERATE-VERSION b/GIT-GENERATE-VERSION new file mode 100755 index 0000000..6872a76 --- /dev/null +++ b/GIT-GENERATE-VERSION @@ -0,0 +1,24 @@ +#!/bin/sh +# Get the git version if possible and store it in $GITFILE if it differs to +# the one contained already. + +GITFILE="xorg-git-version.h" + +if ! which git > /dev/null; then + VER="Git not available." +else + VER=`git describe HEAD 2>/dev/null` + + if test $? -ne 0; then + VER="Unknown version or not build from git." + fi +fi + +if test -e "$GITFILE"; then + FILE_VER=$(sed -e "s/^#define XORG_GIT_VERSION //" < $GITFILE) + if test "$FILE_VER" == "$VER"; then + exit 0 + fi +fi + +echo "#define XORG_GIT_VERSION \"$VER\"" > $GITFILE diff --git a/Makefile.am b/Makefile.am index 8b7a2c8..cce5f23 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,7 +49,7 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = xorg-server.pc endif -EXTRA_DIST = xorg-server.pc.in xorg-server.m4 autogen.sh +EXTRA_DIST = xorg-server.pc.in xorg-server.m4 autogen.sh GIT-GENERATE-VERSION DISTCHECK_CONFIGURE_FLAGS=\ --with-xkb-path=$(XKB_BASE_DIRECTORY) \ diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 71ac9a9..d37a292 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -34,6 +34,8 @@ #include <xorg-config.h> #endif +#include <xorg-git-version.h> + #include <stdlib.h> #include <errno.h> @@ -242,6 +244,9 @@ xf86PrintBanner(void) xf86ErrorFVerb(0, "\tBefore reporting problems, check " ""__VENDORDWEBSUPPORT__"\n" "\tto make sure that you have the latest version.\n"); +#ifdef XORG_GIT_VERSION + xf86ErrorFVerb(0, "git version: " XORG_GIT_VERSION "\n"); +#endif } static void diff --git a/include/Makefile.am b/include/Makefile.am index eddc86c..e052b8b 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -62,6 +62,11 @@ sdk_HEADERS = \ nodist_sdk_HEADERS = xorg-server.h endif +BUILT_SOURCES = xorg-git-version.h + +xorg-git-version.h: + sh $(top_srcdir)/GIT-GENERATE-VERSION + AM_CFLAGS = $(DIX_CFLAGS) EXTRA_DIST = \ @@ -69,3 +74,5 @@ EXTRA_DIST = \ eventconvert.h eventstr.h \ protocol-versions.h \ xsha1.h + +DISTCLEANFILES = xorg-git-version.h -- 1.6.6.1 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
