This script gets called from make to determine the SVN revision (on Windows):

rene@thunder:~/src/qmc2> cat arch/Windows/svnversion.bat
@echo off
subwcrev . scripts\subwcrev.template scripts\subwcrev.out > NUL
type scripts\subwcrev.out
del /f scripts\subwcrev.out

On Linux / UNIX / Mac OS X I use this:

svnversion 2>&1 | sed -e "s/[MS]//g" -e "s/^[[:digit:]]*://" | grep "^[0-9]*$$"

A mind is like a parachute. It doesn't work unless it's open. [Frank Zappa]