Index: trunk/psphot/src/Makefile.am
===================================================================
--- trunk/psphot/src/Makefile.am	(revision 22718)
+++ trunk/psphot/src/Makefile.am	(revision 23118)
@@ -1,4 +1,14 @@
 lib_LTLIBRARIES = libpsphot.la
-libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
+
+PSPHOT_VERSION=`if [ -e ../../VERSION ]; then cat ../../VERSION; else svnversion; fi`
+PSPHOT_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`
+PSPHOT_SOURCE=`if [ -e ../../SOURCE ]; then cat ../../SOURCE; else svn info | sed -n -e 's/Repository UUID: // p'; fi`
+
+# Force recompilation of psphotVersion.c, since it gets the version information
+psphotVersion.c: FORCE
+	touch psphotVersion.c
+FORCE: ;
+
+libpsphot_la_CFLAGS = $(PSPHOT_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSPHOT_VERSION=\"$(PSPHOT_VERSION)\" -DPSPHOT_BRANCH=\"$(PSPHOT_BRANCH)\" -DPSPHOT_SOURCE=\"$(PSPHOT_SOURCE)\"
 libpsphot_la_LDFLAGS = $(PSPHOT_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
 
Index: trunk/psphot/src/psphot.h
===================================================================
--- trunk/psphot/src/psphot.h	(revision 22718)
+++ trunk/psphot/src/psphot.h	(revision 23118)
@@ -16,4 +16,5 @@
 const char     *psphotCVSName(void);
 psString        psphotVersion(void);
+psString        psphotSource(void);
 psString        psphotVersionLong(void);
 
Index: trunk/psphot/src/psphotVersion.c
===================================================================
--- trunk/psphot/src/psphotVersion.c	(revision 22718)
+++ trunk/psphot/src/psphotVersion.c	(revision 23118)
@@ -1,40 +1,58 @@
-# include "psphotInternal.h"
+#include "psphotInternal.h"
 
-# if (HAVE_KAPA)
-# include <kapa.h>
-# endif
-
-static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
+#ifdef HAVE_KAPA
+#include <kapa.h>
+#endif
 
 psString psphotVersion(void)
 {
-    psString version = NULL;            // Version, to return
-    psStringAppend(&version, "%s-%s",PACKAGE_NAME,PACKAGE_VERSION);
-    return version;
+#ifndef PSPHOT_VERSION
+#error "PSPHOT_VERSION is not set"
+#endif
+#ifndef PSPHOT_BRANCH
+#error "PSPHOT_BRANCH is not set"
+#endif
+    return psStringCopy(PSPHOT_BRANCH "@" PSPHOT_VERSION);
+}
+
+psString psphotSource(void)
+{
+#ifndef PSPHOT_SOURCE
+#error "PSPHOT_SOURCE is not set"
+#endif
+    return psStringCopy(PSPHOT_SOURCE);
 }
 
 psString psphotVersionLong(void)
 {
-    psString version = psphotVersion(); // Version, to return
-    psString tag = psStringStripCVS(cvsTag, "Name"); // CVS tag
-    psStringAppend(&version, " (cvs tag %s) %s, %s", tag, __DATE__, __TIME__);
+    psString version = psLibVersion();  // Version, to return
+    psString source = psLibSource();    // Source
 
-# if (HAVE_KAPA)
-    psString ohanaVersion = psStringStripCVS (ohana_version(), "Name");
-    psString libdvoVersion = psStringStripCVS (libdvo_version(), "Name");
+    psStringPrepend(&version, "psphot ");
+    psStringAppend(&version, " from %s, built %s, %s", source, __DATE__, __TIME__);
+    psFree(source);
 
-    psStringAppend (&version, " with libkapa (ohana %s, libdvo: %s)", ohanaVersion, libdvoVersion);
-    psFree (ohanaVersion);
-    psFree (libdvoVersion);
-# else
-    psStringAppend (&version, " WITHOUT libkapa");
-# endif
+#ifdef __OPTIMIZE__
+    psStringAppend(&version, " optimised");
+#else
+    psStringAppend(&version, " unoptimised");
+#endif
 
-    psFree(tag);
+#ifdef HAVE_KAPA
+#if 0
+    // XXX Need to get ohana and libdvo versions
+    psString ohanaVersion = psStringStripCVS(ohana_version(), "Name");
+    psString libdvoVersion = psStringStripCVS(libdvo_version(), "Name");
+    psStringAppend(&version, " with libkapa (ohana %s, libdvo: %s)", ohanaVersion, libdvoVersion);
+    psFree(ohanaVersion);
+    psFree(libdvoVersion);
+#else
+    psStringAppend(&version, " with libkapa");
+#endif
+
+#else
+    psStringAppend (&version, " without libkapa");
+#endif
+
     return version;
 }
-
-// Defined by RHL; leaving for backwards compatibility.
-const char *psphotCVSName(void) {
-   return cvsTag;
-}
