+# Build a Unix source distribution from the Puzzles SVN area.
+#
+# Pass a numeric argument to have the archive tagged as that SVN
+# revision. Otherwise, the script will work it out itself by
+# calling `svnversion', or failing that it will not version-tag the
+# archive at all.
+
+case "$#" in
+ 0)
+ # Ignore errors; if we can't get a version, we'll have a blank
+ # string.
+ rev=`svnversion . 2>/dev/null`
+ if test "x$rev" = "xexported"; then rev=; fi
+ ;;
+ *)
+ case "$1" in *[!0-9M]*) echo "Malformed revision number '$1'">&2;exit 1;;esac
+ rev="$1"
+ ;;
+esac
+
+if test "x$rev" != "x"; then
+ arcsuffix="-r$rev"
+ ver="-DREVISION=$rev"
+else
+ arcsuffix=
+ ver=
+fi
+