winewrapper 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/sh
  2. #
  3. # Wrapper script to run Wine and Winelib apps from inside the source tree
  4. #
  5. # Copyright (C) 2002 Alexandre Julliard
  6. #
  7. # This library is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public
  9. # License as published by the Free Software Foundation; either
  10. # version 2.1 of the License, or (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public
  18. # License along with this library; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  20. #
  21. # first determine the directory that contains the app itself
  22. appdir=""
  23. name=$0
  24. case "$0" in
  25. */*)
  26. # $0 contains a path, use it
  27. appdir=`dirname "$0"`
  28. name=`basename "$0"`
  29. ;;
  30. *)
  31. # no directory in $0, search in PATH
  32. saved_ifs=$IFS
  33. IFS=:
  34. for d in $PATH
  35. do
  36. IFS=$saved_ifs
  37. if [ -x "$d/$name" ]
  38. then
  39. appdir="$d"
  40. break
  41. fi
  42. done
  43. ;;
  44. esac
  45. # now find the top-level directory of the build tree
  46. if [ -x "$appdir/server/wineserver" ]
  47. then topdir="$appdir"
  48. elif [ -x "$appdir/../server/wineserver" ]
  49. then topdir="$appdir/.."
  50. elif [ -x "$appdir/../../server/wineserver" ]
  51. then topdir="$appdir/../.."
  52. elif [ -x "$appdir/../../../server/wineserver" ]
  53. then topdir="$appdir/../../.."
  54. else
  55. echo "$name: could not locate the Wine build tree"
  56. exit 1
  57. fi
  58. # setup the environment
  59. topdir=`cd "$topdir" && pwd`
  60. if [ "`uname -s`" = "Darwin" ]
  61. then
  62. if [ -n "$DYLD_LIBRARY_PATH" ]
  63. then
  64. DYLD_LIBRARY_PATH="$topdir/libs/wine:$topdir/dlls/ntdll:$DYLD_LIBRARY_PATH"
  65. else
  66. DYLD_LIBRARY_PATH="$topdir/libs/wine:$topdir/dlls/ntdll"
  67. fi
  68. export DYLD_LIBRARY_PATH
  69. else
  70. if [ -n "$LD_LIBRARY_PATH" ]
  71. then
  72. LD_LIBRARY_PATH="$topdir/libs/wine:$LD_LIBRARY_PATH"
  73. else
  74. LD_LIBRARY_PATH="$topdir/libs/wine"
  75. fi
  76. export LD_LIBRARY_PATH
  77. fi
  78. if [ -x "$topdir/loader/$name" ]
  79. then WINELOADER="$topdir/loader/$name"
  80. elif [ -x "$topdir/loader/wine" ]
  81. then WINELOADER="$topdir/loader/wine"
  82. elif [ -x "$topdir/loader/wine64" ]
  83. then WINELOADER="$topdir/loader/wine64"
  84. else
  85. echo "$name: could not find the Wine loader in $topdir"
  86. exit 1
  87. fi
  88. export WINELOADER
  89. # any local settings ?
  90. if [ -f "$topdir/.winewrapper" ]
  91. then
  92. . $topdir/.winewrapper
  93. fi
  94. # and run the application
  95. exec "$WINELOADER" "$@"