Fake directx 9c instead of 9b.
[wine] / tools / wineprefixcreate.in
1 #!/bin/sh
2 #
3 # Script to create the initial WINEPREFIX directory
4 #
5 # Copyright 1999 Ove Kåven
6 # Copyright 2004 Chris Morgan
7 # Copyright 2004 Alexandre Julliard
8 #
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
13 #
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # Lesser General Public License for more details.
18 #
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22 #
23
24 usage()
25 {
26     echo "Usage: $0 [options]"
27     echo ""
28     echo "Options:"
29     echo "  -h, --help                 Display this message"
30     echo "      --prefix <dir>         Directory to create (default: \$WINEPREFIX or ~/.wine)"
31     echo "  -q, --quiet                Don't print status messages"
32     echo "      --use-wine-tree <dir>  Run from the Wine build tree <dir>"
33     echo "  -w, --wait                 Wait for the wineserver to exit before returning"
34     echo ""
35 }
36
37 set -e
38
39 dlldir="@dlldir@"
40 datadir="@datadir@/wine"
41
42 do_wait=0
43 quiet=0
44
45 while [ $# -gt 0 ]
46 do
47     case "$1" in
48         -h|--help)
49             usage
50             exit 0
51             ;;
52         --prefix)
53             WINEPREFIX="$2"
54             shift 2
55             ;;
56         -q|--quiet)
57             quiet=1
58             shift
59             ;;
60         -w|--wait)
61             do_wait=1
62             shift
63             ;;
64         --use-wine-tree)
65             topdir=`cd "$2" && pwd`
66             if [ -x "$topdir/server/wineserver" ]
67             then
68                 WINELOADER="$topdir/wine"
69                 WINESERVER="$topdir/server/wineserver"
70                 if [ -n "$LD_LIBRARY_PATH" ]
71                 then
72                     LD_LIBRARY_PATH="$topdir/libs:$LD_LIBRARY_PATH"
73                 else
74                     LD_LIBRARY_PATH="$topdir/libs"
75                 fi
76                 export LD_LIBRARY_PATH
77
78                 # find the source directory
79                 link=`readlink "$WINELOADER"`
80                 if [ -z "$link" ]
81                 then
82                     topsrcdir="$topdir"
83                 else
84                     link=`dirname "$link"`
85                     case "$link" in
86                         /*) topsrcdir=`cd "$link/.." && pwd` ;;
87                          *) topsrcdir=`cd "$topdir/$link/.." && pwd` ;;
88                     esac
89                 fi
90
91                 dlldir="$topdir/programs"
92                 datadir="$topsrcdir/tools"
93             else
94                 echo "$2 is not a valid Wine build tree"
95                 exit 1
96             fi
97             shift 2
98             ;;
99         *)
100             echo "Unknown option $1"
101             usage
102             exit 1
103             ;;
104   esac
105 done
106
107 WINEPREFIX="${WINEPREFIX:-$HOME/.wine}"
108
109 if [ -d "$WINEPREFIX" ] || mkdir "$WINEPREFIX"; then :
110 else
111     echo "Could not create $WINEPREFIX, aborting"
112     exit 1
113 fi
114
115 WINEPREFIX=`cd "$WINEPREFIX" && pwd`
116
117 # Create the drive symlinks
118
119 if [ ! -d "$WINEPREFIX/dosdevices" ]
120 then
121     mkdir "$WINEPREFIX/dosdevices"
122     [ -d "$WINEPREFIX/drive_c" ] || mkdir "$WINEPREFIX/drive_c"
123     ln -s "../drive_c" "$WINEPREFIX/dosdevices/c:"
124     ln -s "/" "$WINEPREFIX/dosdevices/z:"
125 fi
126
127 CROOT="$WINEPREFIX/dosdevices/c:"
128
129 # Create the directory tree
130
131 for i in \
132     "$CROOT/My Documents" \
133     "$CROOT/My Documents/My Music" \
134     "$CROOT/My Documents/My Pictures" \
135     "$CROOT/My Documents/My Video" \
136     "$CROOT/Program Files" \
137     "$CROOT/Program Files/Common Files" \
138     "$CROOT/windows" \
139     "$CROOT/windows/command" \
140     "$CROOT/windows/fonts" \
141     "$CROOT/windows/inf" \
142     "$CROOT/windows/profiles" \
143     "$CROOT/windows/profiles/Administrator" \
144     "$CROOT/windows/Start Menu" \
145     "$CROOT/windows/Application Data" \
146     "$CROOT/windows/Start Menu/Programs" \
147     "$CROOT/windows/Start Menu/Programs/Startup" \
148     "$CROOT/windows/system" \
149     "$CROOT/windows/system32" \
150     "$CROOT/windows/system32/drivers" \
151     "$CROOT/windows/temp"
152 do
153     [ -d "$i" ] || mkdir "$i"
154 done
155
156 # Create the application symlinks
157
158 link_app()
159 {
160    rm -f "$2" && ln -s "$dlldir/$1.exe.so" "$2" || echo "Warning: failed to create $2"
161 }
162
163 link_app start        "$CROOT/windows/command/start.exe"
164 link_app notepad      "$CROOT/windows/notepad.exe"
165 link_app regedit      "$CROOT/windows/regedit.exe"
166 link_app rundll32     "$CROOT/windows/rundll32.exe"
167 link_app wcmd         "$CROOT/windows/system32/wcmd.exe"
168 link_app control      "$CROOT/windows/system32/control.exe"
169 link_app winhelp      "$CROOT/windows/system32/help.exe"
170 link_app msiexec      "$CROOT/windows/system32/msiexec.exe"
171 link_app notepad      "$CROOT/windows/system32/notepad.exe"
172 link_app progman      "$CROOT/windows/system32/progman.exe"
173 link_app regsvr32     "$CROOT/windows/system32/regsvr32.exe"
174 link_app winemine     "$CROOT/windows/system32/winmine.exe"
175 link_app winver       "$CROOT/windows/system32/winver.exe"
176 link_app uninstaller  "$CROOT/windows/uninstall.exe"
177 link_app winhelp      "$CROOT/windows/winhelp.exe"
178 link_app winhelp      "$CROOT/windows/winhlp32.exe"
179 link_app winebrowser  "$CROOT/windows/winebrowser.exe"
180
181 # Copy the .inf script and run it
182
183 cp "$datadir/wine.inf" "$CROOT/windows/inf/wine.inf"
184 export WINEPREFIX
185 "${WINELOADER:-wine}" rundll32.exe setupapi.dll,InstallHinfSection DefaultInstall 128 wine.inf
186
187 # Wait for the wineserver to finish
188
189 if [ $do_wait = 1 ]
190 then
191     "${WINESERVER:-wineserver}" -w
192 fi
193
194 if [ $quiet = 0 ]
195 then
196     echo "$WINEPREFIX updated successfully."
197 fi