Index: trunk/psastro/src/Makefile.am
===================================================================
--- trunk/psastro/src/Makefile.am	(revision 23790)
+++ trunk/psastro/src/Makefile.am	(revision 23804)
@@ -1,11 +1,27 @@
 lib_LTLIBRARIES = libpsastro.la
 
-libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS) -DPSASTRO_VERSION=$(PSASTRO_VERSION) -DPSASTRO_BRANCH=$(PSASTRO_BRANCH) -DPSASTRO_SOURCE=$(PSASTRO_SOURCE)
-libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
+if HAVE_SVNVERSION
+PSASTRO_VERSION=`$(SVNVERSION) ../..`
+else
+PSASTRO_VERSION="UNKNOWN"
+endif
+
+if HAVE_SVN
+PSASTRO_BRANCH=`$(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 }'`
+PSASTRO_SOURCE=`$(SVN) info | $(SED) -n -e 's/Repository UUID: // p'`
+else
+PSASTRO_BRANCH="UNKNOWN"
+PSASTRO_SOURCE="UNKNOWN"
+endif
 
 # Force recompilation of psastroVersion.c, since it gets the version information
-psastroVersion.c: FORCE
-	touch psastroVersion.c
+psastroVersion.c: psastroVersionDefinitions.h
+psastroVersionDefinitions.h: psastroVersionDefinitions.h.in FORCE
+	-$(RM) psastroVersionDefinitions.h
+	$(SED) -e "s|@PSASTRO_VERSION@|\"$(PSASTRO_VERSION)\"|" -e "s|@PSASTRO_BRANCH@|\"$(PSASTRO_BRANCH)\"|" -e "s|@PSASTRO_SOURCE@|\"$(PSASTRO_SOURCE)\"|" psastroVersionDefinitions.h.in > psastroVersionDefinitions.h
 FORCE: ;
+
+libpsastro_la_CFLAGS = $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(PSMODULE_CFLAGS) $(PSLIB_CFLAGS)
+libpsastro_la_LDFLAGS = $(PSASTRO_LIBS) $(PPSTATS_LIBS) $(PSMODULE_LIBS) $(PSLIB_LIBS)
 
 bin_PROGRAMS = psastro psastroExtract psastroModel psastroModelFit gpcModel
@@ -121,5 +137,5 @@
 
 ### Error codes.
-BUILT_SOURCES = psastroErrorCodes.h psastroErrorCodes.c
+BUILT_SOURCES = psastroErrorCodes.h psastroErrorCodes.c psastroVersionDefinitions.h
 CLEANFILES = psastroErrorCodes.h psastroErrorCodes.c
 EXTRA_DIST = psastroErrorCodes.dat psastroErrorCodes.h.in psastroErrorCodes.c.in
Index: trunk/psastro/src/psastroVersion.c
===================================================================
--- trunk/psastro/src/psastroVersion.c	(revision 23790)
+++ trunk/psastro/src/psastroVersion.c	(revision 23804)
@@ -9,4 +9,5 @@
 
 #include "psastroInternal.h"
+#include "psastroVersionDefinitions.h"
 
 #ifndef PSASTRO_VERSION
@@ -20,11 +21,8 @@
 #endif
 
-#define xstr(s) str(s)
-#define str(s) #s
-
 psString psastroVersion(void)
 {
     char *value = NULL;
-    psStringAppend(&value, "%s@%s", xstr(PSASTRO_BRANCH), xstr(PSASTRO_VERSION));
+    psStringAppend(&value, "%s@%s", PSASTRO_BRANCH, PSASTRO_VERSION);
     return value;
 }
@@ -32,5 +30,5 @@
 psString psastroSource(void)
 {
-  return psStringCopy(xstr(PSASTRO_SOURCE));
+  return psStringCopy(PSASTRO_SOURCE);
 }
 
Index: trunk/psastro/src/psastroVersionDefinitions.h.in
===================================================================
--- trunk/psastro/src/psastroVersionDefinitions.h.in	(revision 23804)
+++ trunk/psastro/src/psastroVersionDefinitions.h.in	(revision 23804)
@@ -0,0 +1,8 @@
+#ifndef PSASTRO_VERSION_DEFINITIONS_H
+#define PSASTRO_VERSION_DEFINITIONS_H
+
+#define PSASTRO_VERSION @PSASTRO_VERSION@ // SVN version
+#define PSASTRO_BRANCH  @PSASTRO_BRANCH@  // SVN branch
+#define PSASTRO_SOURCE  @PSASTRO_SOURCE@  // SVN source
+
+#endif
