Automatically determine appropriate source path + better support for in-tree builds


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4019 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/unix/build-xorg b/unix/build-xorg
index a158476..166fad7 100755
--- a/unix/build-xorg
+++ b/unix/build-xorg
@@ -6,15 +6,11 @@
 
 set -e
 
-if [ "$PREFIX" = "" ]; then
-    PREFIX=`pwd`/xorg.build
-fi
-export ACLOCAL="aclocal -I ${PREFIX}/share/aclocal"
-export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
+PREFIX=
 MAKE="make"
 STATIC=0
 XORG_VERSION=
-SRCDIR=..
+SRCDIR=`dirname $0`/..
 
 modules="dri2proto \
     libpthread-stubs \
@@ -210,22 +206,17 @@
 usage ()
 {
     echo "Usage: $0  init -version <7.4 | 7.5>"
-    echo "       [-srcdir <source dir>]"
     echo
     echo "       $0  build -version <7.4 | 7.5>"
-    echo "       [-srcdir <source dir>] [-static] [additional configure flags]"
+    echo "       [-static] [additional configure flags]"
     echo
     echo "       $0  rebuild -version <7.4 | 7.5> "
     echo "       [additional make options]"
     echo
     echo "       $0  update -version <7.4 | 7.5>"
-    echo "       [-srcdir <source dir>]"
     echo
     echo "-static = build a stand-alone version of Xvnc which does not depend on"
     echo "          the shared X11 libraries"
-    echo
-    echo "-srcdir = specify the top directory of the TigerVNC source tree"
-    echo "          (default = ..)"
     exit 1
 }
 
@@ -252,8 +243,20 @@
 
 pushd $SRCDIR
 SRCDIR=`pwd`
+echo "*** Using TigerVNC source tree at $SRCDIR ***"
 popd
 
+if [ "`pwd`" = "$SRCDIR/unix" ]; then
+    cd $SRCDIR
+fi
+
+if [ "$PREFIX" = "" ]; then
+    PREFIX=`pwd`/xorg.build
+fi
+
+export ACLOCAL="aclocal -I ${PREFIX}/share/aclocal"
+export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
+
 case "$MODE" in
     init)       init                 ;;
     build)      build ${1+"$@"}      ;;