Index: trunk/ppStats/src/Makefile.am
===================================================================
--- trunk/ppStats/src/Makefile.am	(revision 23118)
+++ trunk/ppStats/src/Makefile.am	(revision 23119)
@@ -1,4 +1,14 @@
 lib_LTLIBRARIES = libppStats.la
-libppStats_la_CFLAGS = $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
+
+PPSTATS_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+PPSTATS_BRANCH=`if [ -e ../../BRANCH ]; then cat ../../BRANCH; else svn info | sed -n -e '/URL:/ h' -e '/Repository Root:/ { x; H; x; s|Repository Root: \(.*\)\nURL: \1\(.*\)|\2| ; s|^/|| ; s|/[a-zA-Z]*/src.*|| ; p }'; fi`
+PPSTATS_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+
+# Force recompilation of ppStatsVersion.c, since it gets the version information
+ppStatsVersion.c: FORCE
+	touch ppStatsVersion.c
+FORCE: ;
+
+libppStats_la_CFLAGS = $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPPSTATS_VERSION=\"$(PPSTATS_VERSION)\" -DPPSTATS_BRANCH=\"$(PPSTATS_BRANCH)\" -DPPSTATS_SOURCE=\"$(PPSTATS_SOURCE)\"
 libppStats_la_LDFLAGS = $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
 
Index: trunk/ppStats/src/ppStats.h
===================================================================
--- trunk/ppStats/src/ppStats.h	(revision 23118)
+++ trunk/ppStats/src/ppStats.h	(revision 23119)
@@ -22,7 +22,7 @@
     psList *summary;                    // Summary statistics to calculate
     // Options for input data
-    bool doFirstReadout3D;		// for 3D data, use the first readout?
+    bool doFirstReadout3D;              // for 3D data, use the first readout?
     float sample;                       // Fraction of cell to sample for statistics
-    psImageMaskType maskVal;		// Mask value for images
+    psImageMaskType maskVal;            // Mask value for images
     psList *chips;                      // Chips to look at
     psList *cells;                      // Cells to look at
@@ -108,4 +108,7 @@
 psString ppStatsVersion(void);
 
+/// Return source information
+psString ppStatsSource(void);
+
 /// Return long version information
 psString ppStatsVersionLong(void);
Index: trunk/ppStats/src/ppStatsVersion.c
===================================================================
--- trunk/ppStats/src/ppStatsVersion.c	(revision 23118)
+++ trunk/ppStats/src/ppStatsVersion.c	(revision 23119)
@@ -1,19 +1,38 @@
 #include "ppStatsInternal.h"
-
-static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
 
 psString ppStatsVersion(void)
 {
-    psString version = NULL;            // Version, to return
-    psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
-    return version;
+#ifndef PPSTATS_VERSION
+#error "PPSTATS_VERSION is not set"
+#endif
+#ifndef PPSTATS_BRANCH
+#error "PPSTATS_BRANCH is not set"
+#endif
+    return psStringCopy(PPSTATS_BRANCH "@" PPSTATS_VERSION);
+}
+
+psString ppStatsSource(void)
+{
+#ifndef PPSTATS_SOURCE
+#error "PPSTATS_SOURCE is not set"
+#endif
+    return psStringCopy(PPSTATS_SOURCE);
 }
 
 psString ppStatsVersionLong(void)
 {
-    psString version = ppStatsVersion(); // Version, to return
-    psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
-    psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
-    psFree(tag);
+    psString version = ppStatsVersion();  // Version, to return
+    psString source = ppStatsSource();    // Source
+
+    psStringPrepend(&version, "ppStats ");
+    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
+    psFree(source);
+
+#ifdef __OPTIMIZE__
+    psStringAppend(&version, " optimised");
+#else
+    psStringAppend(&version, " unoptimised");
+#endif
+
     return version;
-}
+};
