Out-of-tree compilation and running

Paul Millar paul at astro.gla.ac.uk
Wed Mar 30 16:04:32 CST 2005


OK, some people like to make life difficult for themselves and compile outside
the source tree.  Thus, they have a source-tree (just a simple cvs check-out)
and a binary-tree (the cwd whilst doing "configure && make depend && make")

This, of course, works.

However, *running* wine out of such a situation currently doesn't if one hasn't
got a ~/.wine directory.  The problem is that wineprefixcreate tacitly assumes
that the binary tree and the source tree are the same.  For the most part, that
doesn't matter.  However, the wine.inf file is found in the source-tree, not the
binary-tree.  Of course, one could simply copy the wine.inf file from one to 'tuther
but I couldn't bring myself to such skull-duggary.

So, the following patch relaxes the assumption that the two trees are the same.

As a Brucy Bonus, it also fixes a problem where having a directory with a space
isn't quite handled right (although people with spaces in their directory names
probably deserve everything they get).

I've tested this with an in-tree and out-of-tree compilation.  Seems to work OK
for me in both cases.

Cheers,

Paul.

ChangeLog:
   Relax the assumption that the source-tree is coincident with the binary tree.
   Fix a missing quotation so directories with spaces are handled correctly


Index: tools/wineprefixcreate.in
===================================================================
RCS file: /home/wine/wine/tools/wineprefixcreate.in,v
retrieving revision 1.7
diff -u -r1.7 wineprefixcreate.in
--- tools/wineprefixcreate.in 16 Dec 2004 14:22:37 -0000 1.7
+++ tools/wineprefixcreate.in 30 Mar 2005 21:29:24 -0000
@@ -26,11 +26,12 @@
     echo "Usage: $0 [options]"
     echo ""
     echo "Options:"
-    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 "  -u, --update               Update the prefix directory if it already exists"
-    echo "      --use-wine-tree <dir>  Run from the Wine source tree <dir>"
+    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 "  -u, --update                 Update the prefix directory if it already exists"
+    echo "      --use-wine-tree <dir>    Run from the Wine binary tree <dir>"
+    echo "      --use-source-tree <dir>  Take data from the Wine source tree <dir>"
     echo ""
 }
 
@@ -77,11 +78,20 @@
                 dlldir="$topdir/programs"
                 datadir="$topdir/tools"
             else
-                echo "$2 is not a valid Wine source tree"
+                echo "$2 is not a valid Wine binary tree"
                 exit 1
             fi
             shift 2
             ;;
+       --use-source-tree)
+           srcdatadir=`cd "$2/tools" && pwd`
+           if [ ! -e "$srcdatadir/wine.inf" ]
+           then
+               echo "$2 is not a valid Wine source tree"
+               exit 1
+           fi
+           shift 2
+           ;;
         *)
             echo "Unknown option $1"
             usage
@@ -162,10 +172,20 @@
 link_app winebrowser  "$CROOT/windows/winebrowser.exe"
 
 # Copy the .inf script and run it
+for dir in "$datadir" "$srcdatadir"; do
+  if [ -n "$dir" -a -e "$dir/wine.inf" ]; then
+    cp "$dir/wine.inf" "$CROOT/windows/inf/wine.inf"
+    break
+  fi
+done
+
+if [ ! -e "$CROOT/windows/inf/wine.inf" ]; then
+  echo "Cannot find the wine.inf file.  This is either a bug within wine or its packaging."
+  exit 1
+fi
 
-cp "$datadir/wine.inf" "$CROOT/windows/inf/wine.inf"
 export WINEPREFIX
-${WINELOADER:-wine} rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 128 wine.inf
+"${WINELOADER:-wine}" rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 128 wine.inf
 
 # Wait for the wineserver to finish
 
Index: tools/winewrapper
===================================================================
RCS file: /home/wine/wine/tools/winewrapper,v
retrieving revision 1.10
diff -u -r1.10 winewrapper
--- tools/winewrapper 16 Jul 2004 02:45:25 -0000 1.10
+++ tools/winewrapper 30 Mar 2005 21:29:25 -0000
@@ -22,6 +22,7 @@
 # first determine the directory that contains the app itself
 
 appdir=""
+srcdir=""
 case "$0" in
   */*)
     # $0 contains a path, use it
@@ -43,25 +44,42 @@
     ;;
 esac
 
-# now find the top-level directory of the source tree
 
-if [ -x "$appdir/server/wineserver" ]
-then topdir="$appdir"
-elif [ -x "$appdir/../server/wineserver" ]
-then topdir="$appdir/.."
-elif [ -x "$appdir/../../server/wineserver" ]
-then topdir="$appdir/../.."
-elif [ -x "$appdir/../../../server/wineserver" ]
-then topdir="$appdir/../../.."
-else
-  echo "$0: could not locate Wine source tree"
-  exit 1
-fi
+  # find the top-level directory of a Wine tree
+function findBase() {
 
-# setup the environment
+  if [ -e "$2/$3" ]
+  then dir="."
+  elif [ -e "$2/../$3" ]
+  then dir=".."
+  elif [ -e "$2/../../$3" ]
+  then dir="../.."
+  elif [ -e "$2/../../../$3" ]
+  then dir="../../.."
+  else
+    echo "$0: could not locate the Wine tree"
+    exit 1
+  fi
+
+  # Convert to absolute dir
+  adir=`cd "$2/$dir" && pwd`
+
+  # Store in the right variable
+  cmd=$1=\"$adir\"
+  eval "$cmd"
+}
+
+# now find the top-level directory of the (binary) Wine tree
+findBase topdir "$appdir" "server/wineserver" 
+
+# if we're operating out of a different directory, search that tree for data
+if [ -h "$0" ]; then
+  ptr=$(dirname $(readlink "$0"))
+  findBase srcdir "$ptr" "tools/wine.inf"
+fi
 
-topdir=`cd "$topdir" && pwd`
 
+# setup the environment
 if [ -n "$LD_LIBRARY_PATH" ]
 then
   LD_LIBRARY_PATH="$topdir/libs:$LD_LIBRARY_PATH"
@@ -88,7 +106,11 @@
 
 if [ -z "$WINEPREFIX" -a ! -d "$HOME/.wine" ]
 then
-    "$topdir/tools/wineprefixcreate" --update --use-wine-tree "$topdir"
+    if [ ! -z "$srcdir" ]; then
+        "$topdir/tools/wineprefixcreate" --update --use-wine-tree "$topdir" --use-source-tree "$srcdir"
+    else
+        "$topdir/tools/wineprefixcreate" --update --use-wine-tree "$topdir"
+    fi
 fi
 
 # and run the application


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20050330/0d8c51f9/attachment.pgp


More information about the wine-patches mailing list