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
