Added sample config file in the new format.
[wine/multimedia.git] / tools / wineinstall
blobb43ac33b8462f021e7ffeab4d0caadc9c5aa5136
1 #!/bin/bash
2 # WINE Installation script
3 # Can do almost everything from compiling to configuring...
5 # Mar 31 1999 - Ove Kåven
6 # First version
7 # Dec 9 1999 - Ove Kåven
8 # require Xpm
9 # Feb 25 2000 - Ove Kåven
10 # auto-add /usr/local/lib to /etc/ld.so.conf
11 # Mar 2 2000 - Ove Kåven
12 # source rather than grep config.cache
13 # use sourced config.cache to start ldconfig
14 # reconfigure if config.cache doesn't exist
15 # Mar 30 2000 - Ove Kåven
16 # autoconfigure no-windows installs
17 # do not install registry on real-windows installs
18 # some support for binary package installs
19 # set and tell user about LD_LIBRARY_PATH if necessary
20 # set EXTRA_LD_LIBRARY_PATH in wine.conf
21 # Apr 9 2000 - Ove Kåven
22 # make root's registry global (system-default)
23 # May 9 2000 - Ove Kåven
24 # use ttydrv when running regapi, so we don't have to run from X
25 # change debugger path in registry
26 # Oct 29 2000 - Ove Kåven
27 # added --enable-opengl to default confargs
28 # added conf_question, conf_yesno_answer, and conf_string_answer functions
29 # added DEFCAT variable
30 # (later that day...)
31 # added conf_reset_question function
32 # added file existence checks to the registry copying
33 # fixed problem with no-windows directory creation
34 # some text reformatting from Eric Maryniak
36 #--- defaults (change these if you are a packager)
37 CONFARGS=--enable-opengl # configure args, e.g. --prefix=/usr --sysconfdir=/etc
38 prefix=/usr/local # installation prefix
39 sysconfdir=$prefix/etc # where wine.conf and global registry is supposed to be
40 bindir=$prefix/bin # where winelib apps will be (or is) installed
41 libdir=$prefix/lib # where libwine.so will be (or is) installed
42 exdir=documentation/samples # where the example system.ini resides
43 CONF=$sysconfdir/wine.conf # default path of the wine.conf
44 BINDIST=no # whether called from a binary package config script
45 DOCONF=auto # whether to autogenerate wine.conf
46 DOWCHK=auto # whether to autoconfigure existing-windows installation
47 DOWINE=auto # whether to autoconfigure no-windows installation
48 DOREG=auto # whether to install default registry
49 SYSREG=yes # whether to make root's registry global (system-default)
51 # "make install" still installs the dlls into $libdir, but this may change in the future
52 # (DLLPATH should point to them if/when they are not in standard ld.so paths)
53 DLLPATH=$libdir/wine # default path of the dll .so files (except libwine.so)
55 # having the Wine debugger launched automatically will be a plus for us
56 DEBUGGER=$bindir/winedbg # the (installed) path of winedbg
57 HDEBUGGER=debugger/winedbg # the (non-installed) path of winedbg
59 # this is only for existing-windows installs
60 WINECONF=tools/wineconf # the path of wineconf perl script
62 # this is only for no-windows installs
63 WINEINI=wine.ini # the path of default wine.ini (also used by wineconf)
64 WININI=/dev/null # the path of default win.ini
65 SYSTEMINI=$exdir/system.ini # the path of default system.ini
66 REGAPI=programs/regapi/regapi # the path of regapi winelib application
67 DEFREG=winedefault.reg # the path of the registry file to be fed to regapi
68 # CROOT=/var/wine # the path of the fake Drive C (asks user if not set)
69 DEFCAT=cat # program to cat $DEFREG with (some packages need zcat)
70 #--- end of defaults
72 # temporary files used by the installer
73 TMPCONF=/tmp/wineinstall.conf
74 TMPREG=/tmp/wineinstall.reg
76 # functions
78 function std_sleep {
79 sleep 1
82 function conf_question {
83 # parameters: $1 = importance, $2 = question-id, $3+ = message lines
84 # the first two parameters can be used by e.g. debconf in debian packages
85 # but here we just print the message
86 shift 2
87 echo
88 local LINE="$1"
89 while shift
90 do {
91 echo "$LINE"
92 LINE="$1"
94 done
97 function conf_reset_question {
98 # parameters: $1 = question-id
99 # this is used to flush any cached answers and "already-displayed" flags
100 shift # dummy command
103 function conf_yesno_answer {
104 unset ANSWER
105 while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
106 do {
107 echo -n "$1"
108 read ANSWER
110 done
113 function conf_string_answer {
114 echo -n "$1"
115 read ANSWER
118 # startup...
120 echo "WINE Installer v0.5"
121 echo
123 if [ "$BINDIST" = 'no' ]
124 then {
126 if ! [ -f configure ]
127 then {
128 echo "You're running this from the wrong directory."
129 echo "Change to the Wine source's main directory and try again."
130 exit 1
134 # check whether RPM installed, and if it is, remove any old wine rpm.
135 hash rpm &>/dev/null
136 RET=$?
137 if [ $RET -eq 0 ]; then
138 if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
139 echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
140 conf_yesno_answer "(yes/no) "
141 if [ "$ANSWER" = 'yes' ]; then
142 echo Starting wine rpm removal...
143 rpm -e wine; RET=$?
144 if [ $RET -eq 0 ]; then
145 echo Done.
146 else
147 echo "FAILED. Probably you aren't installing as root."
148 echo "Expect problems (library conflicts with existing install etc.)."
150 else
151 echo "Sorry, I won't install Wine when an rpm version is still installed."
152 echo "(Wine support suffered from way too many conflicts)"
153 echo "Have a nice day !"
154 exit 1
159 # run the configure script, if necessary
161 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
162 then {
163 echo "I see that WINE has already been configured, so I'll skip that."
164 std_sleep
165 # load configure results
166 . ./config.cache
168 else {
169 echo "Running configure..."
170 echo
171 if ! ./configure $CONFARGS
172 then {
173 echo
174 echo "Configure failed, aborting install."
175 rm -f config.cache
176 exit 1
179 # load configure results
180 . ./config.cache
181 # make sure X was found
182 eval "$ac_cv_have_x"
183 if [ "$have_x" != "yes" ]
184 then {
185 echo "Install the X development headers and try again."
186 rm -f config.cache
187 exit 1
189 elif [ "$ac_cv_header_X11_xpm_h" != "yes" ]
190 then {
191 echo "Install the Xpm development headers and try again."
192 rm -f config.cache
193 exit 1
199 # now do the compilation
201 if [ -f wine ] && [ wine -nt Makefile ]
202 then {
203 echo "Hmm, looks like WINE is already compiled. I'll skip that too, I guess."
204 std_sleep
206 else {
207 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever,"
208 echo "in the meantime..."
209 echo
210 std_sleep
211 if ! { make depend && make; }
212 then {
213 echo
214 echo "Compilation failed, aborting install."
215 exit 1
218 echo
222 # and installation, if root
224 if [ `whoami` != 'root' ]
225 then {
226 echo "You aren't root, so I'll skip the make install."
227 # setup to run from current directory
228 DLLPATH="$PWD/dlls"
229 if [ -z "$LD_LIBRARY_PATH" ]
230 then LD_LIBRARY_PATH="$PWD:$DLLPATH"
231 else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
233 export LD_LIBRARY_PATH
234 DEBUGGER="$PWD/$HDEBUGGER"
235 echo
236 echo "NOTE! To run Wine without installing, you must set the environment variable"
237 echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
238 echo "in your logon scripts."
240 else {
241 echo "Now installing binaries onto the system..."
242 echo
243 std_sleep
244 if ! make install
245 then {
246 echo
247 echo "Installation failed, aborting."
248 exit 1
251 if [ -f /etc/ld.so.conf ] && ! grep -qs "$libdir" /etc/ld.so.conf
252 then {
253 echo
254 echo "$libdir didn't exist in your /etc/ld.so.conf, adding it now..."
255 echo "$libdir" >>/etc/ld.so.conf
256 echo "Re-running ldconfig..."
257 eval "$ac_cv_path_LDCONFIG"
264 fi # BINDIST
266 # now check whether we should generate wine.conf
267 if [ -z "$DOCONF" ]
268 then DOCONF=auto
271 if [ "$DOCONF" = 'auto' ]
272 then {
273 # see if we already have a system wine.conf
274 if [ -f $CONF ]
275 then DOCONF=no
280 if [ "$DOCONF" != 'no' ]
281 then {
282 if [ `whoami` != 'root' ]
283 then {
284 CONF=~/.winerc
285 if ! [ -f $CONF ]
286 then {
287 if [ "$DOCONF" != 'yes' ]
288 then {
289 conf_question medium make_user_winerc \
290 "Since you aren't root, and there's no system wine.conf, I assume" \
291 "you want a user-specific .winerc. Am I correct?"
292 conf_yesno_answer "(yes/no) "
293 DOCONF="$ANSWER"
296 if [ "$DOCONF" = 'no' ]
297 then {
298 conf_question high need_root \
299 "Aborting install. Try again as root to generate a system wine.conf."
300 exit 1
303 echo
307 else {
308 mkdir -p $sysconfdir
309 DOCONF=yes
315 # generate wine.conf from existing windows install, if any
316 if [ "$DOCONF" = 'yes' ]
317 then {
318 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
319 then {
320 echo
321 echo -n "Searching for an existing Windows installation..."
322 if ! $WINECONF -inifile "$WINEINI" > $CONF 2>/dev/null
323 then {
324 rm -f $CONF
325 echo " not found."
326 conf_question low do_without_windows \
327 "Windows was not found on your system, so I assume you want" \
328 "a Wine-only installation. Am I correct?"
329 conf_yesno_answer "(yes/no) "
330 if [ "$ANSWER" = 'no' ]
331 then {
332 conf_question high windows_not_found \
333 "Aborting install. Make sure your Windows partition is mounted and try again," \
334 "or create $CONF manually by copying from $WINEINI and adapting the drive paths."
335 exit 1
338 DOWINE=yes
340 else {
341 echo " found."
342 conf_reset_question windows_found
343 conf_question low windows_found \
344 "Created $CONF using your existing Windows installation." \
345 "You probably want to review the file, though."
346 DOWINE=no
350 elif [ "$DOWINE" = 'auto' ]
351 then DOWINE=yes
354 elif [ "$DOWINE" = 'auto' ]
355 then DOWINE=no
358 # setup a no-windows installation, if necessary
359 if [ "$DOWINE" = 'yes' ]
360 then {
361 if [ `whoami` != 'root' ]
362 then DCROOT=~/c
363 else DCROOT=/c
365 conf_question low drivec_path \
366 "Configuring Wine without Windows." \
367 "Some fake Windows directories must be created, to hold any .ini files, DLLs," \
368 "start menu entries, and other things your applications may need to install." \
369 "Where would you like your fake C drive to be placed?"
370 while [ -z "$CROOT" ]
371 do {
372 conf_string_answer "(default is $DCROOT) "
373 [ -z "$ANSWER" ] && ANSWER="$DCROOT"
374 if ! [ -d "$ANSWER" ]
375 then {
376 if mkdir -p "$ANSWER"
377 then CROOT="$ANSWER"
378 else
379 echo "Directory $ANSWER can't be created !"
380 conf_reset_question drivec_path
383 else CROOT="$ANSWER"
386 done
387 echo "Configuring Wine for a no-windows install in $CROOT..."
388 for tdir in "$CROOT/windows" "$CROOT/windows/system" \
389 "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs" \
390 "$CROOT/Common Files" "$CROOT/Program Files" \
391 "$CROOT/windows/Profiles" "$CROOT/windows/Profiles/Administrator"
392 do [ -d "$tdir" ] || mkdir "$tdir"
393 done
394 [ -f "$CROOT/windows/win.ini" ] || cp "$WININI" "$CROOT/windows/win.ini"
395 [ -f "$CROOT/windows/system.ini" ] || cp "$SYSTEMINI" "$CROOT/windows/system.ini"
396 if [ "$DOCONF" = 'yes' ]
397 then {
398 sed "s|Path=/c\$|Path=${CROOT}|" $WINEINI > $CONF
399 conf_reset_question default_config
400 conf_question low default_config \
401 "Created $CONF using default Wine configuration." \
402 "You probably want to review the file, though."
405 # now we really should install the registry
406 if [ "$DOREG" = 'auto' ]
407 then DOREG=yes
410 elif [ -z "$CROOT" ]
411 then {
412 echo
413 echo "Reading current Wine configuration from $CONF..."
414 CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^Path=\(.*\)/\1/p' $CONF`
415 echo "Drive C is configured at $CROOT."
418 echo
420 # fixup EXTRA_LD_LIBRARY_PATH
421 if [ "$DOCONF" = 'yes' ]
422 then {
423 echo "Setting EXTRA_LD_LIBRARY_PATH in .winerc to $DLLPATH..."
424 sed "s|EXTRA_LD_LIBRARY_PATH=.*|EXTRA_LD_LIBRARY_PATH=${DLLPATH}|" $CONF > $CONF.new
425 mv -f $CONF.new $CONF
426 echo
430 # check whether we need to install default registry
431 # (not to be done if windows registry exists)
432 if [ "$DOREG" = 'auto' ]
433 then {
434 echo "Checking for real Windows registry..."
435 if [ -f "$CROOT/windows/system.dat" ]
436 then DOREG=no
437 elif [ -f "$CROOT/windows/system32/config/system" ]
438 then DOREG=no
439 else DOREG=yes
441 if [ "$DOREG" = 'yes' ]
442 then echo "Not found, default Wine registry will be installed."
443 else echo "Windows registry found, will not install default Wine registry."
445 echo
449 # install default registry entries
450 if [ "$DOREG" = 'yes' ]
451 then {
452 if [ "$BINDIST" = 'no' ]
453 then {
454 echo "Compiling regapi..."
455 echo
456 (cd programs/regapi; make)
457 echo
460 echo "Preparing to install default Wine registry entries..."
462 # create a temporary wineinstall.conf file using ttydrv,
463 # so that we don't have to run regapi under X
464 sed "s/GraphicsDriver=.*/GraphicsDriver=ttydrv/" $CONF > $TMPCONF
466 # create a temporary wineinstall.reg with fixed debugger path
467 $DEFCAT $DEFREG | sed "s|debugger/winedbg|${DEBUGGER}|" > $TMPREG
469 echo "Installing default Wine registry entries..."
470 echo
471 if ! $REGAPI --config $TMPCONF setValue < $TMPREG > /dev/null
472 then {
473 rm -f $TMPCONF $TMPREG
474 echo "Registry install failed."
475 conf_reset_question regapi_error
476 conf_question high regapi_error
477 exit 1
479 else echo "Registry entries successfully installed."
481 rm -f $TMPCONF $TMPREG
482 if [ "$SYSREG" = 'auto' ]
483 then SYSREG=yes
488 # make root's registry global, if desired
489 if [ `whoami` = 'root' ] && [ "$SYSREG" = 'yes' ]
490 then {
491 [ -d ~/.wine ] || mkdir ~/.wine
492 if ! [ -f $sysconfdir/wine.userreg ]
493 then {
494 echo "Linking root's user registry hive to the global registry..."
495 [ -f ~/.wine/wine.userreg ] && cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
496 ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
499 if ! [ -f $sysconfdir/wine.systemreg ]
500 then {
501 echo "Linking root's system registry hive to the global registry..."
502 [ -f ~/.wine/system.reg ] && cp ~/.wine/system.reg $sysconfdir/wine.systemreg
503 ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
509 # it's a wrap
510 echo
511 echo "Installation complete for now. Good luck (this is still alpha software)."
512 echo "If you have problems with WINE, please read the documentation first,"
513 echo "as many kinds of potential problems are explained there."
515 exit 0