Fix running autogen.sh out-of-tree
As done in GNOME's jhbuild building tool.

https://bugzilla.libsdl.org/show_bug.cgi?id=3374
diff --git a/autogen.sh b/autogen.sh
index 649d7b3..3e958e1 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -3,6 +3,10 @@
 echo "Generating build information using autoconf"
 echo "This may take a while ..."
 
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+pushd $srcdir
+
 # Regenerate configuration files
 cat acinclude/* >aclocal.m4
 found=false
@@ -15,5 +19,7 @@
 fi
 (cd test; sh autogen.sh)
 
+popd
+
 # Run configure for this platform
 echo "Now you are ready to run ./configure"