Index: trunk/psLib/src/sys/Makefile.am
===================================================================
--- trunk/psLib/src/sys/Makefile.am	(revision 22738)
+++ trunk/psLib/src/sys/Makefile.am	(revision 23115)
@@ -3,5 +3,14 @@
 noinst_LTLIBRARIES = libpslibsys.la
 
-libpslibsys_la_CPPFLAGS = $(SRCINC) $(PSLIB_CFLAGS) $(CFITSIO_CFLAGS)
+PSLIB_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+PSLIB_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`
+PSLIB_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+
+# Force recompilation of psConfigure.c, since it gets the version information
+psConfigure.c: FORCE
+	touch psConfigure.c
+FORCE: ;
+
+libpslibsys_la_CPPFLAGS = $(SRCINC) $(PSLIB_CFLAGS) $(CFITSIO_CFLAGS) -DPSLIB_VERSION=\"$(PSLIB_VERSION)\" -DPSLIB_BRANCH=\"$(PSLIB_BRANCH)\" -DPSLIB_SOURCE=\"$(PSLIB_SOURCE)\"
 libpslibsys_la_SOURCES = \
 	psAbort.c \
Index: trunk/psLib/src/sys/psConfigure.c
===================================================================
--- trunk/psLib/src/sys/psConfigure.c	(revision 22738)
+++ trunk/psLib/src/sys/psConfigure.c	(revision 23115)
@@ -12,9 +12,7 @@
  *  @author Ross Harman, MHPCC
  *  @author Robert DeSonia, MHPCC
+ *  @author Paul Price, IfA
  *
- *  @version $Revision: 1.28 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2008-08-08 18:05:08 $
- *
- *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
+ *  Copyright 2004-2009 Institute for Astronomy, University of Hawaii
  */
 
@@ -26,4 +24,12 @@
 #include <stdlib.h>
 #include <string.h>
+
+#include <fitsio.h>
+#include <longnam.h>
+#include <fftw3.h>
+#include <gsl/gsl_version.h>
+#ifdef HAVE_PSDB
+#include <mysql.h>
+#endif
 
 #include "psAbort.h"
@@ -41,26 +47,55 @@
 static FILE *memCheckFile = NULL;       // File to which to write results of mem check
 
-static const char *cvsTag = "$Name: not supported by cvs2svn $"; // CVS tag name
 
 psString psLibVersion(void)
 {
-    psString version = NULL;            // Version, to return
-    psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
-    return version;
+#ifndef PSLIB_VERSION
+#error "PSLIB_VERSION is not set"
+#endif
+#ifndef PSLIB_BRANCH
+#error "PSLIB_BRANCH is not set"
+#endif
+    return psStringCopy(PSLIB_BRANCH "@" PSLIB_VERSION);
+}
+
+psString psLibSource(void)
+{
+#ifndef PSLIB_SOURCE
+#error "PSLIB_SOURCE is not set"
+#endif
+    return psStringCopy(PSLIB_SOURCE);
 }
 
 psString psLibVersionLong(void)
 {
-    psString version = psLibVersion();    // Version, to return
-    psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
+    psString version = psLibVersion();  // Version, to return
+    psString source = psLibSource();    // Source
+
+    float cfitsioVersion;               // CFITSIO version number
+
+    psStringPrepend(&version, "psLib ");
+    psStringAppend(&version, " from %s, built %s, %s with cfitsio (%.3f), gsl (%s), fftw (%s)",
+                   source, __DATE__, __TIME__, fits_get_version(&cfitsioVersion), gsl_version,
+                   fftwf_version);
+    psFree(source);
 
 #ifdef HAVE_PSDB
-    psStringAppend(&version, " (cvs tag %s), %s, %s with psDB", tag, __DATE__, __TIME__);
+    psStringAppend(&version, ", mysql (%s)", mysql_get_client_info());
+#endif
+
+#ifdef __OPTIMIZE__
+    psStringAppend(&version, " optimised");
 #else
-    psStringAppend(&version, " (cvs tag %s), %s, %s without psDB", tag, __DATE__, __TIME__);
+    psStringAppend(&version, " unoptimised");
 #endif
-    psFree(tag);
+
+#ifdef PS_NO_TRACE
+    psStringAppend(&version, " without trace");
+#else
+    psStringAppend(&version, " with trace");
+#endif
+
     return version;
-}
+};
 
 // Check the memory; intended for use on exit, but might be used elsewhere
Index: trunk/psLib/src/sys/psConfigure.h
===================================================================
--- trunk/psLib/src/sys/psConfigure.h	(revision 22738)
+++ trunk/psLib/src/sys/psConfigure.h	(revision 23115)
@@ -29,8 +29,13 @@
  *  @return psString: String with version name.
  */
-psString psLibVersion(
-    void
-);
+psString psLibVersion(void);
 
+/** Get current psLib source
+ *
+ * Returns the current psLib source name as a string.
+ *
+ * @return psString: String with source name.
+ */
+psString psLibSource(void);
 
 /** Get current psLib version (full identification)
