Index: /trunk/psastro/src/Makefile.am
===================================================================
--- /trunk/psastro/src/Makefile.am	(revision 23119)
+++ /trunk/psastro/src/Makefile.am	(revision 23120)
@@ -1,5 +1,14 @@
+lib_LTLIBRARIES = libpsastro.la
 
-lib_LTLIBRARIES = libpsastro.la
-libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
+PSASTRO_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+PSASTRO_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`
+PSASTRO_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+
+# Force recompilation of psastroVersion.c, since it gets the version information
+psastroVersion.c: FORCE
+	touch psastroVersion.c
+FORCE: ;
+
+libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSASTRO_VERSION=\"$(PSASTRO_VERSION)\" -DPSASTRO_BRANCH=\"$(PSASTRO_BRANCH)\" -DPSASTRO_SOURCE=\"$(PSASTRO_SOURCE)\"
 libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
 
Index: /trunk/psastro/src/psastro.h
===================================================================
--- /trunk/psastro/src/psastro.h	(revision 23119)
+++ /trunk/psastro/src/psastro.h	(revision 23120)
@@ -95,4 +95,5 @@
 // Return version strings.
 psString          psastroVersion(void);
+psString          psastroSource(void);
 psString          psastroVersionLong(void);
 
Index: /trunk/psastro/src/psastroVersion.c
===================================================================
--- /trunk/psastro/src/psastroVersion.c	(revision 23119)
+++ /trunk/psastro/src/psastroVersion.c	(revision 23120)
@@ -5,7 +5,4 @@
  *  @ingroup libpsastro
  *
- *  @author IfA
- *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-07 02:03:34 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
@@ -13,20 +10,38 @@
 #include "psastroInternal.h"
 
-static const char *cvsTag = "$Name: not supported by cvs2svn $";///< CVS tag name
-
 psString psastroVersion(void)
 {
-    psString version = NULL;            // Version, to return
-    psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
-    return version;
+#ifndef PSASTRO_VERSION
+#error "PSASTRO_VERSION is not set"
+#endif
+#ifndef PSASTRO_BRANCH
+#error "PSASTRO_BRANCH is not set"
+#endif
+    return psStringCopy(PSASTRO_BRANCH "@" PSASTRO_VERSION);
+}
+
+psString psastroSource(void)
+{
+#ifndef PSASTRO_SOURCE
+#error "PSASTRO_SOURCE is not set"
+#endif
+    return psStringCopy(PSASTRO_SOURCE);
 }
 
 psString psastroVersionLong(void)
 {
-    psString version = psastroVersion(); // Version, to return
-    psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
-    psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
-    psFree(tag);
+    psString version = psastroVersion();  // Version, to return
+    psString source = psastroSource();    // Source
+
+    psStringPrepend(&version, "psastro ");
+    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
+    psFree(source);
+
+#ifdef __OPTIMIZE__
+    psStringAppend(&version, " optimised");
+#else
+    psStringAppend(&version, " unoptimised");
+#endif
+
     return version;
-}
-
+};
