changeset 28012:cc8f641d2fde

Add the MTN revision in the Pidgin About and finch --version dialogs. Main idea taken from monotone's own hook, but I left out the full revision stuff for now.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 25 Jul 2009 06:49:18 +0000
parents ed3184cc557d
children b55fb0a1b087
files Makefile.am finch/finch.c pidgin/gtkdialogs.c
diffstat 3 files changed, 42 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.am	Thu Jul 23 04:05:31 2009 +0000
+++ b/Makefile.am	Sat Jul 25 06:49:18 2009 +0000
@@ -16,13 +16,14 @@
 		intltool-extract.in \
 		intltool-merge.in \
 		intltool-update.in \
+		package_revision.h \
 		pidgin.apspec.in \
 		pidgin.spec.in \
 		pidgin.desktop.in \
 		po/Makefile.mingw \
 		valgrind-suppressions
 
-noinst_HEADERS = config.h
+noinst_HEADERS = config.h package_revision.h
 
 dist-hook: pidgin.spec
 	cp pidgin.spec $(distdir)
@@ -86,7 +87,42 @@
 PO_DIR=po
 endif
 
-SUBDIRS = libpurple doc $(GNT_DIR) $(GTK_DIR) m4macros $(PO_DIR) share/ca-certs share/sounds
+# This is phony, so that we always try to rebuild it.  If it succeeds
+# in calculating changes, it produces its target; otherwise, its
+# target does not exist.
+.PHONY: package_revision_raw.txt
+# if both attempts fail, then we need to remove the empty file that >
+# creates, and also make sure that the shell command exits
+# successfully; the rm -f ensures both
+package_revision_raw.txt:
+	REAL_BLDDIR=$$PWD/$(top_builddir); \
+	(cd $(srcdir) && $$REAL_BLDDIR/mtn --root=. automate get_base_revision_id) 2>/dev/null >$@ \
+	|| (cd $(srcdir) && mtn --root=. automate get_base_revision_id) 2>/dev/null >$@ \
+	|| rm -f $@
+package_revision.h: package_revision_raw.txt
+	if [ -f $< ]; then \
+	  sed 's/^\(.\+\)$$/#define REVISION "\1"/' $< > $@; \
+	fi
+	if [ ! -f $@ -a -f $(srcdir)/$@ ]; then \
+	  cp $(srcdir)/$@ $@; \
+	fi
+	[ -f $@ ] || echo "#define REVISION \"unknown\"" > $@
+
+# This is a magic directive copy-and-pasted, then modified, from the
+# automake 1.9 manual, section 13.4, "Checking the distribution".
+# Normally, 'distcheck' does a clean build, and then afterwards runs
+# 'distclean', and 'distclean' is supposed to remove everything that
+# the build created.  However, we have some targets (package_revision.txt)
+# that we distribute, but then always attempt to rebuild optimistically, and
+# then if that fails fall back on the distributed versions.  This
+# means that 'distclean' should _not_ remove those files, since they
+# are distributed, yet building the package will generate those files,
+# thus automake thinks that 'distclean' _should_ remove those files,
+# and 'distcheck' gets cranky if we don't.  So basically what this
+# line does is tell 'distcheck' to shut up and ignore those two files.
+distcleancheck_listfiles = find . -type f -a ! -name package_revision.h
+
+SUBDIRS = . libpurple doc $(GNT_DIR) $(GTK_DIR) m4macros $(PO_DIR) share/ca-certs share/sounds
 
 docs: Doxyfile
 if HAVE_DOXYGEN
--- a/finch/finch.c	Thu Jul 23 04:05:31 2009 +0000
+++ b/finch/finch.c	Sat Jul 25 06:49:18 2009 +0000
@@ -48,6 +48,7 @@
 #include <getopt.h>
 
 #include "config.h"
+#include "package_revision.h"
 
 static void
 debug_init(void)
@@ -314,7 +315,7 @@
 	if (opt_version) {
 		/* Translators may want to transliterate the name.
 		 It is not to be translated. */
-		printf("%s %s\n", _("Finch"), DISPLAY_VERSION);
+		printf("%s %s (%s)\n", _("Finch"), DISPLAY_VERSION, REVISION);
 		return 0;
 	}
 
--- a/pidgin/gtkdialogs.c	Thu Jul 23 04:05:31 2009 +0000
+++ b/pidgin/gtkdialogs.c	Sat Jul 25 06:49:18 2009 +0000
@@ -27,6 +27,7 @@
 
 #include "internal.h"
 #include "pidgin.h"
+#include "package_revision.h"
 
 #include "debug.h"
 #include "notify.h"
@@ -446,7 +447,7 @@
 	str = g_string_sized_new(4096);
 
 	g_string_append_printf(str,
-		"<CENTER><FONT SIZE=\"4\"><B>%s %s</B></FONT></CENTER><BR>(libpurple %s)<BR><BR>", PIDGIN_NAME, DISPLAY_VERSION, purple_core_get_version());
+		"<CENTER><FONT SIZE=\"4\"><B>%s %s</B></FONT></CENTER><BR>(libpurple %s)<BR>%s<BR><BR>", PIDGIN_NAME, DISPLAY_VERSION, purple_core_get_version(), REVISION);
 
 	g_string_append_printf(str,
 		_("%s is a graphical modular messaging client based on "