diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index 647948a985c4ed45a579b937aee6921e1da21cc8..cba68fa4c7e9869849de1adabb9503f2bb8763bf 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -42,6 +42,10 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [CF] Print SVN revision number instead of time in version info line.
+       Get SVN revision number from svn (if available) or guess from
+       Id strings. Rename generated file to svnversion.h.
+
   [CF] Makefile.am: Modify generation of cvsversion.h for SVN.
 
   [GP] Convert CVS repository to SVN.
diff --git a/sm5/INSTALL b/sm5/INSTALL
index 69d778da37805e9a234db083d1c080af9ceaae4f..5f3597d5d5f25d56beec34bc809873e803db0c01 100644
--- a/sm5/INSTALL
+++ b/sm5/INSTALL
@@ -1,7 +1,7 @@
 Smartmontools installation instructions
 =======================================
 
-$Id: INSTALL,v 1.83 2009/01/12 22:55:02 dlukes Exp $
+$Id$
 
 Please also see the smartmontools home page:
 http://smartmontools.sourceforge.net/
@@ -264,9 +264,9 @@ Table of contents:
     make CFLAGS='your options'
 
     The first output line of smartctl and smartd provides information
-    about release number, last CVS checkin date/time, platform, and
-    package. The latter defaults to "(local build)" and can be changed
-    by the variable BUILD_INFO, for example:
+    about release number, last SVN checkin date and revison, platform,
+    and package. The latter defaults to "(local build)" and can be
+    changed by the variable BUILD_INFO, for example:
     make BUILD_INFO='"(Debian 5.39-2)"'
 
 [4] Guidelines for different Linux distributions
@@ -495,8 +495,8 @@ To prepare os_win32 directory for MSVC8, use the following on Cygwin:
   The MSVC8 project files (os_win32/smartmontools_vc8.sln,
   os_win32/smart{ctl,d}_vc8.vcproj) are included in CVS (but not in
   source tarball). The target config-vc8 from a Makefile configured
-  for MinGW creates os_win32/{config,cvsversion}_vc8.h from
-  ./{config,cvsversion}.h. The configure skript must be run outside
+  for MinGW creates os_win32/{config,svnversion}_vc8.h from
+  ./{config,svnversion}.h. The configure skript must be run outside
   of the source directory to avoid inclusion of the original config.h.
 
   Unlike MinGW, MSVC can also be used to build the syslog message file
diff --git a/sm5/Makefile.am b/sm5/Makefile.am
index 7bdcb2f4bed318aaa3814a47b3b80e178eaec4b7..53218262dbd6d30fa37af481027aa3f53ecce013 100644
--- a/sm5/Makefile.am
+++ b/sm5/Makefile.am
@@ -241,8 +241,7 @@ EXTRA_DIST = smartd.initd.in                       \
              os_win32/installer.nsi                \
              $(docs_DATA)
 
-CLEANFILES = cvsversion.h       \
-             drivedb.h          \
+CLEANFILES = drivedb.h          \
              smartd.conf.5      \
              smartd.conf.4      \
              smartd.8           \
@@ -255,28 +254,35 @@ CLEANFILES = cvsversion.h       \
              smartctl.8.txt     \
              smartd.conf.5.html \
              smartd.conf.5.txt  \
-             smartd.initd 	\
+             smartd.initd       \
+             svnversion.h       \
              SMART
 
 if SMARTD_SUFFIX
 CLEANFILES += smartd.conf$(smartd_suffix)
 endif
 
-CVSVERSION_DEPS = CHANGELOG Makefile
-if IS_CVS_BUILD
-# Rebuild cvsversion.h after cvs update or commit
-CVSVERSION_DEPS += $(srcdir)/CVS/Entries
-endif
+utility.o: svnversion.h
 
-utility.o: cvsversion.h
+if IS_SVN_BUILD
+# Get version info from SVN
+svnversion.h: CHANGELOG Makefile $(srcdir)/.svn/entries
+	echo '/* svnversion.h.  Generated by Makefile from svn info.  */' > $@
+	chg="`(cd $(srcdir) && svn status -q 2>/dev/null | sed 's,^.*$$,+,;q')`" && \
+	(cd $(srcdir) && TZ= svn info 2>/dev/null ) \
+	| sed -n 'h;s,^.* Rev: *\([^ ]*\)$$,REV  "\1'"$$chg"'",p;s,^.* Date: *\([^ ]*\) .*$$,DATE "\1",p;g;s,^.* Date: *[^ ]* *\([^ ]*\) .*$$,TIME "\1",p' \
+	| sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
+else
 
-cvsversion.h: $(CVSVERSION_DEPS)
-	echo '/* cvsversion.h.  Generated by Makefile.  */' > $@
+# SVN not available, guess version info from $Id$ strings
+svnversion.h: CHANGELOG Makefile
+	echo '/* svnversion.h.  Generated by Makefile from Id strings.  */' > $@
 	(cd $(srcdir) && cat Makefile.am configure.in smart*.in *.cpp *.h *.s) \
-	| sed -n 's,^.*\$$[I][d]: [^ ]* [^ ]* \(20[01][0-9][-/][01][0-9][-/][0-3][0-9] [0-9][0-9]:[0-9][0-9]\):[0-9][0-9][^$$]*\$$.*$$,\1,p' \
-	| sed 's,/,-,g' | sort -r \
-	| sed 's,^\(.*\)$$,#define SMARTMONTOOLS_CVS_DATE_TIME "\1",;1q' \
-	>> $@
+	| sed -n 's,^.*\$$[I][d]: [^ ]* \([0-9][0-9]* [0-9][-0-9]* [0-9][:0-9]*\)[^:0-9][^$$]*\$$.*$$,\1,p' \
+	| sort -n -r \
+	| sed -n 'h;s,^\([^ ]*\) .*$$,REV  "\1~",p;g;s,^[^ ]* \([^ ]*\) .*$$,DATE "\1",p;g;s,^[^ ]* [^ ]* \([^ ]*\)$$,TIME "\1",p;q' \
+	| sed 's,^,#define SMARTMONTOOLS_SVN_,' >> $@
+endif
 
 
 # Drive Database
@@ -399,10 +405,10 @@ endif
 
 if OS_FREEBSD
 .for file in $(man_MANS)
-${file}: $(srcdir)/${file}.in Makefile cvsversion.h
+${file}: $(srcdir)/${file}.in Makefile svnversion.h
 	sed "s|CURRENT_CVS_VERSION|$(releaseversion)|g; \
-	     s|CURRENT_CVS_DATE|`sed -n 's,^[^"]*"\([^ ]*\) [^"]*".*$$,\1,p' cvsversion.h`|g; \
-	     s|CURRENT_CVS_TIME|`sed -n 's,^[^"]*"[^ ]* \([^"]*\)".*$$,\1,p' cvsversion.h`|g; \
+	     s|CURRENT_CVS_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
+	     s|CURRENT_CVS_TIME|`sed -n 's,^.*TIME[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g; \
 	     s|/usr/local/share/man/|$(mandir)/|g; \
 	     s|/usr/local/sbin/|$(sbindir)/|g; \
 	     s|/usr/local/etc/rc\\.d/init.d/|$(initddir)/|g; \
@@ -413,10 +419,10 @@ ${file}: $(srcdir)/${file}.in Makefile cvsversion.h
 	$(MAN_SAVESTATES) > $@
 .endfor
 else
-smart%: $(srcdir)/smart%.in Makefile cvsversion.h
+smart%: $(srcdir)/smart%.in Makefile svnversion.h
 	sed "s|CURRENT_CVS_VERSION|$(releaseversion)|g" $< | \
-	sed "s|CURRENT_CVS_DATE|`sed -n 's,^[^"]*"\([^ ]*\) [^"]*".*$$,\1,p' cvsversion.h`|g" | \
-	sed "s|CURRENT_CVS_TIME|`sed -n 's,^[^"]*"[^ ]* \([^"]*\)".*$$,\1,p' cvsversion.h`|g" | \
+	sed "s|CURRENT_CVS_DATE|`sed -n 's,^.*DATE[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g" | \
+	sed "s|CURRENT_CVS_TIME|`sed -n 's,^.*TIME[^"]*"\([^"]*\)".*$$,\1,p' svnversion.h`|g" | \
 	sed "s|/usr/local/share/man/|$(mandir)/|g" | \
 	sed "s|/usr/local/sbin/|$(sbindir)/|g" | \
 	sed "s|/usr/local/etc/rc\\.d/init.d/|$(initddir)/|g" | \
@@ -589,17 +595,17 @@ smartctl-nc.exe: smartctl.exe
 	mv -f $@.tmp $@
 
 
-# Build {config,cvsversion}_vc8.h for MSVC8 from MinGW {config,cvsversion}.h
+# Build {config,svnversion}_vc8.h for MSVC8 from MinGW {config,svnversion}.h
 
-config-vc8: $(srcdir)/os_win32/config_vc8.h  $(srcdir)/os_win32/cvsversion_vc8.h
+config-vc8: $(srcdir)/os_win32/config_vc8.h  $(srcdir)/os_win32/svnversion_vc8.h
 
 $(srcdir)/os_win32/config_vc8.h: config.h
 	sed '1i/* config_vc8.h.  Generated from config.h by Makefile.  */' $< | \
 	sed 's,^#define HAVE_\(ATTR_PACKED\|INTTYPES_H\|STDINT_H\|STRINGS_H\|STRTOULL\|U*INT64_T\|UNISTD_H\|WORKING_SNPRINTF\) 1$$,/* #undef HAVE_\1 */,' | \
 	sed 's,i.86-pc-mingw32,i686-pc-win32vc8,' > $@
 
-$(srcdir)/os_win32/cvsversion_vc8.h: cvsversion.h
-	cp cvsversion.h $@
+$(srcdir)/os_win32/svnversion_vc8.h: svnversion.h
+	cp svnversion.h $@
 
 endif
 
diff --git a/sm5/configure.in b/sm5/configure.in
index 9c9c84bcb426d3879a5935d0280dc1b41adbe0cd..51cc1a61c0b9126a47ff7710f15d4c270ae3a7d8 100644
--- a/sm5/configure.in
+++ b/sm5/configure.in
@@ -1,5 +1,5 @@
 #
-# $Id: configure.in,v 1.148 2009/03/19 18:00:35 chrfranke Exp $
+# $Id$
 #
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.50)
@@ -7,7 +7,7 @@ AC_INIT(smartmontools, 5.39, smartmontools-support@lists.sourceforge.net)
 AC_CONFIG_SRCDIR(smartctl.cpp)
 
 smartmontools_configure_date=`date -u +"%Y/%m/%d %T %Z"`
-smartmontools_cvs_tag=`echo '$Id: configure.in,v 1.148 2009/03/19 18:00:35 chrfranke Exp $'`
+smartmontools_cvs_tag=`echo '$Id$'`
 smartmontools_release_date=2008/03/10
 smartmontools_release_time="10:44:07 GMT"
 
@@ -43,12 +43,17 @@ case "${host}" in
 		;;
 esac
 
-# Check for CVS.
-AC_MSG_CHECKING([whether this is a build from CVS])
-is_cvs_build=no
-test -f "$srcdir/CVS/Entries" && is_cvs_build=yes
-AM_CONDITIONAL(IS_CVS_BUILD, [test "$is_cvs_build" = "yes"])
-AC_MSG_RESULT([$is_cvs_build])
+# Check for SVN.
+AC_MSG_CHECKING([whether this is a build from SVN])
+is_svn_build=no
+if test -f "$srcdir/.svn/entries"; then
+  is_svn_build=unknown
+  if (cd "$srcdir" && svn --version && svn info && svn status -q) >/dev/null 2>&1; then
+    is_svn_build=yes
+  fi
+fi
+AM_CONDITIONAL(IS_SVN_BUILD, [test "$is_svn_build" = "yes"])
+AC_MSG_RESULT([$is_svn_build])
 
 dnl Checks for libraries needed for name services (Solaris needs
 dnl libnsl, might in the future also need libsocket)
diff --git a/sm5/os_win32/smartctl_vc8.vcproj b/sm5/os_win32/smartctl_vc8.vcproj
index b89d754700046f72e15e584983133fdbe38a4959..9ea7924b0a134e60ceb3c081fe297e3bcebcf175 100644
--- a/sm5/os_win32/smartctl_vc8.vcproj
+++ b/sm5/os_win32/smartctl_vc8.vcproj
@@ -497,30 +497,6 @@
 			RelativePath="..\configure.in"
 			>
 		</File>
-		<File
-			RelativePath=".\cvsversion_vc8.h"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCustomBuildTool"
-					Description="Copy $(InputPath) cvsversion.h"
-					CommandLine="copy $(InputPath) cvsversion.h&#x0D;&#x0A;"
-					Outputs="cvsversion.h"
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCustomBuildTool"
-					Description="Copy $(InputPath) cvsversion.h"
-					CommandLine="copy $(InputPath) cvsversion.h&#x0D;&#x0A;"
-					Outputs="cvsversion.h"
-				/>
-			</FileConfiguration>
-		</File>
 		<File
 			RelativePath="..\dev_ata_cmd_set.cpp"
 			>
@@ -1033,6 +1009,30 @@
 			RelativePath="..\smartd.initd.in"
 			>
 		</File>
+		<File
+			RelativePath=".\svnversion_vc8.h"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCCustomBuildTool"
+					Description="Copy $(InputPath) svnversion.h"
+					CommandLine="copy $(InputPath) svnversion.h&#x0D;&#x0A;"
+					Outputs="svnversion.h"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCCustomBuildTool"
+					Description="Copy $(InputPath) svnversion.h"
+					CommandLine="copy $(InputPath) svnversion.h&#x0D;&#x0A;"
+					Outputs="svnversion.h"
+				/>
+			</FileConfiguration>
+		</File>
 		<File
 			RelativePath="..\TODO"
 			>
diff --git a/sm5/os_win32/smartd_vc8.vcproj b/sm5/os_win32/smartd_vc8.vcproj
index 6c2ea5ff57a67b7eef29c33054f2ce2721e6d5ab..d9330b150df614051f4cbc35915e8931c9fe306b 100644
--- a/sm5/os_win32/smartd_vc8.vcproj
+++ b/sm5/os_win32/smartd_vc8.vcproj
@@ -417,30 +417,6 @@
 			RelativePath="..\configure.in"
 			>
 		</File>
-		<File
-			RelativePath=".\cvsversion_vc8.h"
-			>
-			<FileConfiguration
-				Name="Debug|Win32"
-				>
-				<Tool
-					Name="VCCustomBuildTool"
-					Description="Copy $(InputPath) cvsversion.h"
-					CommandLine="copy $(InputPath) cvsversion.h&#x0D;&#x0A;"
-					Outputs="cvsversion.h"
-				/>
-			</FileConfiguration>
-			<FileConfiguration
-				Name="Release|Win32"
-				>
-				<Tool
-					Name="VCCustomBuildTool"
-					Description="Copy $(InputPath) cvsversion.h"
-					CommandLine="copy $(InputPath) cvsversion.h&#x0D;&#x0A;"
-					Outputs="cvsversion.h"
-				/>
-			</FileConfiguration>
-		</File>
 		<File
 			RelativePath="..\dev_ata_cmd_set.cpp"
 			>
@@ -985,6 +961,30 @@
 			RelativePath="..\smartd.initd.in"
 			>
 		</File>
+		<File
+			RelativePath=".\svnversion_vc8.h"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCCustomBuildTool"
+					Description="Copy $(InputPath) svnversion.h"
+					CommandLine="copy $(InputPath) svnversion.h&#x0D;&#x0A;"
+					Outputs="svnversion.h"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCCustomBuildTool"
+					Description="Copy $(InputPath) svnversion.h"
+					CommandLine="copy $(InputPath) svnversion.h&#x0D;&#x0A;"
+					Outputs="svnversion.h"
+				/>
+			</FileConfiguration>
+		</File>
 		<File
 			RelativePath="..\TODO"
 			>
diff --git a/sm5/utility.cpp b/sm5/utility.cpp
index 401dee42f798fa37a99119d153a556e3d4029c9b..2b2d04f7d8b67383452367d5afb18451284ecd7f 100644
--- a/sm5/utility.cpp
+++ b/sm5/utility.cpp
@@ -42,7 +42,7 @@
 #include <stdexcept>
 
 #include "config.h"
-#include "cvsversion.h"
+#include "svnversion.h"
 #include "int64.h"
 #include "utility.h"
 
@@ -50,7 +50,7 @@
 #include "dev_interface.h"
 
 // Any local header files should be represented by a CVSIDX just below.
-const char* utility_c_cvsid="$Id: utility.cpp,v 1.75 2009/02/09 21:57:37 chrfranke Exp $"
+const char* utility_c_cvsid="$Id$"
 CONFIG_H_CVSID INT64_H_CVSID UTILITY_H_CVSID;
 
 const char * packet_types[] = {
@@ -89,9 +89,10 @@ const char *format_version_info(const char *progname)
 {
   static char info[200];
   snprintf(info, sizeof(info),
-    "%s %s %s [%s] %s\n"
+    "%s %s %s r%s [%s] %s\n"
     "Copyright (C) 2002-9 by Bruce Allen, http://smartmontools.sourceforge.net\n",
-    progname, PACKAGE_VERSION, SMARTMONTOOLS_CVS_DATE_TIME, smi()->get_os_version_str(), BUILD_INFO
+    progname, PACKAGE_VERSION, SMARTMONTOOLS_SVN_DATE, SMARTMONTOOLS_SVN_REV,
+    smi()->get_os_version_str(), BUILD_INFO
   );
   return info;
 }