--- /dev/null
+#!/bin/sh
+
+Sources="."
+Target=".."
+
+Version=$(cat "$Sources/CMakeLists.txt" | sed -n -e 's/^SET(sarg_VERSION \([0-9]\))/\1/p')
+if [ -z "$Version" ] ; then
+ echo "No version found"
+ exit 1
+fi
+Revision=$(cat "$Sources/CMakeLists.txt" | sed -n -e 's/^SET(sarg_REVISION "\([0-9][0-9]*.*\)")/\1/p')
+if [ -z "$Revision" ] ; then
+ echo "No revision found"
+ exit 1
+fi
+Version="$Version.$Revision"
+
+VersionCheck=$(cat "$Sources/configure.in" | sed -n -e 's/^AC_INIT(\[sarg\],\[\([0-9][0-9]*\.[0-9][0-9]*.*\)\])/\1/p')
+if [ "x$Version" != "x$VersionCheck" ] ; then
+ echo "CMakeLists and configure doesn't refer to the same version"
+ exit 1
+fi
+
+SargList="$Target/sarglist.txt.unsort"
+SortList="$Target/sarglist.txt"
+ExcludeList="$Target/sargexclude.txt"
+CompressFile="$Target/sarg-$Version.tar.gz"
+
+SedSources=$(echo "$Sources" | sed -e 's/\./\\./')
+ls $Sources/*.c | sed -e "s/^$SedSources\///" > $SargList
+ls $Sources/include/*.h | sed -e "s/^$SedSources\///" >> $SargList
+ls $Sources/po/*.{po,gmo,pot} | sed -e "s/^$SedSources\///" >> $SargList
+
+echo "
+config.h
+aclocal.m4
+BETA-TESTERS
+ChangeLog
+CMakeLists.txt
+configure
+configure.in
+CONTRIBUTORS
+COPYING
+css.tpl
+DONATIONS
+Doxyfile
+exclude_codes
+htaccess
+LICENSE
+Makefile.in
+README
+README_cmake
+sarg.1
+sarg.conf
+user_limit_block
+cfgaux
+documentation
+fonts
+images
+include/config.h.in
+sarg-php
+po/remove-potcdate.sin
+po/Makefile.in.in
+po/POTFILES.in
+po/quot.sed
+po/Rules-quot
+po/insert-header.sin
+po/ChangeLog
+po/LINGUAS
+po/en@quot.header
+po/en@boldquot.header
+po/boldquot.sed
+po/Makevars
+sorttable/sorttable.js
+" >> $SargList
+
+sort $SargList > $SortList
+rm $SargList
+
+echo "
+*/.svn
+*/.git
+*~
+*.o
+.gitignore
+" > "$ExcludeList"
+
+tar zcf "$CompressFile" -C "$Sources" --files-from="$SortList" --exclude-from="$ExcludeList" --transform="s,^,sarg-$Version/," --owner root --group root --mode 644
+
+md5sum $CompressFile > "$Target/sarg-$Version.md5sum"
+echo "md5sum:"
+cat "$Target/sarg-$Version.md5sum"
+
+sha1sum $CompressFile > "$Target/sarg-$Version.sha1sum"
+echo "sha1sum:"
+cat "$Target/sarg-$Version.sha1sum"
+
+sha256sum $CompressFile > "$Target/sarg-$Version.sha256sum"
+echo "sha256sum:"
+cat "$Target/sarg-$Version.sha256sum"