From d5416dad666d2d4e44a96cb165363300fa30d461 Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Wed, 20 Apr 2005 14:26:33 +0000
Subject: [PATCH] Properly support out-of-tree builds (based on patch by Paul
 Millar).

---
 tools/wineprefixcreate.in | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/tools/wineprefixcreate.in b/tools/wineprefixcreate.in
index 9fa206f9f75..145e4654b64 100644
--- a/tools/wineprefixcreate.in
+++ b/tools/wineprefixcreate.in
@@ -29,7 +29,7 @@ usage()
     echo "  -h, --help                 Display this message"
     echo "      --prefix <dir>         Directory to create (default: \$WINEPREFIX or ~/.wine)"
     echo "  -q, --quiet                Don't print status messages"
-    echo "      --use-wine-tree <dir>  Run from the Wine source tree <dir>"
+    echo "      --use-wine-tree <dir>  Run from the Wine build tree <dir>"
     echo "  -w, --wait                 Wait for the wineserver to exit before returning"
     echo ""
 }
@@ -74,10 +74,24 @@ do
                     LD_LIBRARY_PATH="$topdir/libs"
                 fi
                 export LD_LIBRARY_PATH
+
+                # find the source directory
+                link=`readlink "$WINELOADER"`
+                if [ -z "$link" ]
+                then
+                    topsrcdir="$topdir"
+                else
+                    link=`dirname "$link"`
+                    case "$link" in
+                        /*) topsrcdir=`cd "$link/.." && pwd` ;;
+                         *) topsrcdir=`cd "$topdir/$link/.." && pwd` ;;
+                    esac
+                fi
+
                 dlldir="$topdir/programs"
-                datadir="$topdir/tools"
+                datadir="$topsrcdir/tools"
             else
-                echo "$2 is not a valid Wine source tree"
+                echo "$2 is not a valid Wine build tree"
                 exit 1
             fi
             shift 2
-- 
GitLab