Make child processes inherit command-line options through the
[wine.git] / tools / wineinstall
blob8f4e11f5d0bdd035abd2bba605f43404b89e8c33
1 #!/bin/bash
2 # WINE Installation script
4 # Mar 31 1999 - Ove Kåven
5 # First version
6 # Dec 9 1999 - Ove Kåven
7 # require Xpm
8 # Feb 25 2000 - Ove Kåven
9 # auto-add /usr/local/lib to /etc/ld.so.conf
10 # Mar 2 2000 - Ove Kåven
11 # source rather than grep config.cache
12 # use sourced config.cache to start ldconfig
13 # reconfigure if config.cache doesn't exist
14 # Mar 30 2000 - Ove Kåven
15 # autoconfigure no-windows installs
16 # do not install registry on real-windows installs
17 # some support for binary package installs
18 # set and tell user about LD_LIBRARY_PATH if necessary
19 # set EXTRA_LD_LIBRARY_PATH in wine.conf
20 # Apr 9 2000 - Ove Kåven
21 # make root's registry global (system-default)
22 # May 9 2000 - Ove Kåven
23 # use ttydrv when running regapi, so we don't have to run from X
24 # change debugger path in registry
26 #--- defaults (change these if you are a packager)
27 CONFARGS= # configure args, e.g. --prefix=/usr --sysconfdir=/etc
28 prefix=/usr/local # installation prefix
29 sysconfdir=$prefix/etc # where wine.conf and global registry is supposed to be
30 bindir=$prefix/bin # where winelib apps will be (or is) installed
31 libdir=$prefix/lib # where libwine.so will be (or is) installed
32 exdir=documentation/samples # where the example system.ini resides
33 CONF=$sysconfdir/wine.conf # default path of the wine.conf
34 BINDIST=no # whether called from a binary package config script
35 DOCONF=auto # whether to autogenerate wine.conf
36 DOWCHK=auto # whether to autoconfigure existing-windows installation
37 DOWINE=auto # whether to autoconfigure no-windows installation
38 DOREG=auto # whether to install default registry
39 SYSREG=yes # whether to make root's registry global (system-default)
41 # "make install" still installs the dlls into $libdir, but this may change in the future
42 # (DLLPATH should point to them if/when they are not in standard ld.so paths)
43 DLLPATH=$libdir/wine # default path of the dll .so files (except libwine.so)
45 # having the Wine debugger launched automatically will be a plus for us
46 DEBUGGER=$bindir/winedbg # the (installed) path of winedbg
47 HDEBUGGER=debugger/winedbg # the (non-installed) path of winedbg
49 # this is only for existing-windows installs
50 WINECONF=tools/wineconf # the path of wineconf perl script
52 # this is only for no-windows installs
53 WINEINI=wine.ini # the path of default wine.ini (also used by wineconf)
54 WININI=/dev/null # the path of default win.ini
55 SYSTEMINI=$exdir/system.ini # the path of default system.ini
56 REGAPI=programs/regapi/regapi # the path of regapi winelib application
57 DEFREG=winedefault.reg # the path of the registry file to be fed to regapi
58 # CROOT=/var/wine # the path of the fake Drive C (asks user if not set)
59 #--- end of defaults
61 # temporary files used by the installer
62 TMPCONF=/tmp/wineinstall.conf
63 TMPREG=/tmp/wineinstall.reg
65 # startup...
67 echo "WINE Installer v0.4"
68 echo
70 if [ "$BINDIST" = 'no' ]
71 then {
73 if ! [ -f configure ]
74 then {
75 echo "You're running this from the wrong directory."
76 echo "Change to the Wine directory and try again."
77 exit 1
81 # run the configure script, if necessary
83 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
84 then {
85 echo "I see that WINE has already been configured, so I'll skip that."
86 # load configure results
87 . ./config.cache
89 else {
90 echo "Running configure..."
91 echo
92 if ! ./configure $CONFARGS
93 then {
94 echo
95 echo "Configure failed, aborting install."
96 rm -f config.cache
97 exit 1
100 # load configure results
101 . ./config.cache
102 # make sure X was found
103 eval "$ac_cv_have_x"
104 if [ "$have_x" != "yes" ]
105 then {
106 echo "Install the X development headers and try again."
107 rm -f config.cache
108 exit 1
110 elif [ "$ac_cv_header_X11_xpm_h" != "yes" ]
111 then {
112 echo "Install the Xpm development headers and try again."
113 rm -f config.cache
114 exit 1
120 # now do the compilation
122 if [ -f wine ] && [ wine -nt Makefile ]
123 then {
124 echo "Hmm, looks like WINE is already compiled. I'll skip that too, I guess."
126 else {
127 echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever, in the meantime..."
128 echo
129 if ! { make depend && make; }
130 then {
131 echo
132 echo "Compilation failed, aborting install."
133 exit 1
136 echo
140 # and installation, if root
142 if [ `whoami` != 'root' ]
143 then {
144 echo "You aren't root, so I'll skip the make install."
145 # setup to run from current directory
146 DLLPATH="$PWD/dlls"
147 if [ -z "$LD_LIBRARY_PATH" ]
148 then LD_LIBRARY_PATH="$PWD:$DLLPATH"
149 else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
151 export LD_LIBRARY_PATH
152 DEBUGGER=$PWD/$HDEBUGGER
153 echo
154 echo "NOTE! To run Wine without installing, you must set the environment variable"
155 echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
156 echo "in your logon scripts."
158 else {
159 echo "Now installing binaries onto the system..."
160 echo
161 if ! make install
162 then {
163 echo
164 echo "Installation failed, aborting."
165 exit 1
168 if [ -f /etc/ld.so.conf ] && ! grep -qs "$libdir" /etc/ld.so.conf
169 then {
170 echo
171 echo "$libdir didn't exist in your /etc/ld.so.conf, adding it now..."
172 echo "$libdir" >>/etc/ld.so.conf
173 echo "Re-running ldconfig..."
174 eval "$ac_cv_path_LDCONFIG"
179 echo
182 fi # BINDIST
184 # now check whether we should generate wine.conf
185 if [ -z "$DOCONF" ]
186 then DOCONF=auto
189 if [ "$DOCONF" = 'auto' ]
190 then {
191 # see if we already have a system wine.conf
192 if [ -f $CONF ]
193 then DOCONF=no
198 if [ "$DOCONF" != 'no' ]
199 then {
200 if [ `whoami` != 'root' ]
201 then {
202 CONF=~/.winerc
203 if ! [ -f $CONF ]
204 then {
205 if [ "$DOCONF" != 'yes' ]
206 then {
207 echo "Since you aren't root, and there's no system wine.conf, I assume"
208 echo "you want a user-specific .winerc. Am I correct? (yes/no)"
209 while [ "$DOCONF" != 'yes' ] && [ "$DOCONF" != 'no' ]
210 do read DOCONF
211 done
214 if [ "$DOCONF" = 'no' ]
215 then {
216 echo "Aborting install. Try again as root to generate a system wine.conf."
217 exit 1
220 echo
224 else {
225 mkdir -p $sysconfdir
226 DOCONF=yes
232 # generate wine.conf from existing windows install, if any
233 if [ "$DOCONF" = 'yes' ]
234 then {
235 if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
236 then {
237 echo "Searching for an existing Windows installation..."
238 if ! $WINECONF > $CONF 2>/dev/null
239 then {
240 rm -f $CONF
241 echo
242 echo "Windows was not found on your system, so I assume you want a Wine-only installation."
243 echo "Am I correct? (yes/no)"
244 while [ "$DOWINE" != 'yes' ] && [ "$DOWINE" != 'no' ]
245 do read DOWINE
246 done
247 if [ "$DOWINE" = 'no' ]
248 then {
249 echo "Aborting install. Make sure your Windows partition is mounted and try again,"
250 echo "or create $CONF manually by copying from $WINEINI and adapting the drive paths."
251 exit 1
255 else {
256 echo
257 echo "Created $CONF using your existing Windows installation."
258 echo "You probably want to review the file, though."
259 DOWINE=no
262 echo
264 elif [ "$DOWINE" = 'auto' ]
265 then DOWINE=yes
268 elif [ "$DOWINE" = 'auto' ]
269 then DOWINE=no
272 # setup a no-windows installation, if necessary
273 if [ "$DOWINE" = 'yes' ]
274 then {
275 if [ `whoami` != 'root' ]
276 then DCROOT=~/c
277 else DCROOT=/c
279 echo "Configuring Wine without Windows. Some fake Windows directories must be created, to"
280 echo "hold any .ini files, DLLs, and start menu entries your applications may need to install."
281 while [ -z "$CROOT" ]
282 do {
283 echo "Where would you like your fake C drive to be placed? (default is $DCROOT)"
284 read CROOT
285 if [ -z "$CROOT" ]
286 then CROOT="$DCROOT"
288 if ! [ -d "$CROOT" ]
289 then {
290 if ! mkdir -p "$CROOT"
291 then unset CROOT
296 done
297 echo "Configuring Wine for a no-windows install in $CROOT..."
298 for tdir in "$CROOT/windows" "$CROOT/windows/system" "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs"
299 do [ -d "$tdir" ] || mkdir "$tdir"
300 done
301 [ -f "$CROOT/windows/win.ini" ] || cp "$WININI" "$CROOT/windows/win.ini"
302 [ -f "$CROOT/windows/system.ini" ] || cp "$SYSTEMINI" "$CROOT/windows/system.ini"
303 if [ "$DOCONF" = 'yes' ]
304 then {
305 sed "s/Path=\/c$/Path=${CROOT//\//\\/}/" $WINEINI > $CONF
306 echo "Created $CONF using default Wine configuration."
307 echo "You probably want to review the file, though."
310 # now we really need to install the registry
311 DOREG=yes
313 elif [ -z "$CROOT" ]
314 then {
315 echo "Reading current Wine configuration from $CONF..."
316 CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^Path=\(.*\)/\1/p' $CONF`
317 echo "Drive C is configured at $CROOT."
320 echo
322 # fixup EXTRA_LD_LIBRARY_PATH
323 if [ "$DOCONF" = 'yes' ]
324 then {
325 echo "Setting EXTRA_LD_LIBRARY_PATH in .winerc to $DLLPATH..."
326 sed "s/EXTRA_LD_LIBRARY_PATH=.*/EXTRA_LD_LIBRARY_PATH=${DLLPATH//\//\\/}/" $CONF > $CONF.new
327 mv -f $CONF.new $CONF
328 echo
332 # check whether we need to install default registry
333 # (not to be done if windows registry exists)
334 if [ "$DOREG" = 'auto' ]
335 then {
336 echo "Checking for real Windows registry..."
337 if [ -f "$CROOT/windows/system.dat" ]
338 then DOREG=no
339 elif [ -f "$CROOT/windows/system32/config/system" ]
340 then DOREG=no
341 else DOREG=yes
343 if [ "$DOREG" = 'yes' ]
344 then echo "Not found, default Wine registry will be installed."
345 else echo "Windows registry found, will not install default Wine registry."
347 echo
351 # install default registry entries
352 if [ "$DOREG" = 'yes' ]
353 then {
354 if [ "$BINDIST" = 'no' ]
355 then {
356 echo "Compiling regapi..."
357 echo
358 (cd programs/regapi; make)
359 echo
362 echo "Preparing to install default Wine registry entries..."
364 # create a temporary wineinstall.conf file using ttydrv,
365 # so that we don't have to run regapi under X
366 sed "s/GraphicsDriver=.*/GraphicsDriver=ttydrv/" $CONF > $TMPCONF
368 # create a temporary wineinstall.reg with fixed debugger path
369 sed "s/debugger\/winedbg/${DEBUGGER//\//\\/}/" $DEFREG > $TMPREG
371 echo "Installing default Wine registry entries..."
372 echo
373 if ! $REGAPI --config $TMPCONF setValue < $TMPREG > /dev/null
374 then {
375 rm -f $TMPCONF $TMPREG
376 echo
377 echo "Registry install failed."
378 exit 1
380 else echo "Registry entries successfully installed."
382 rm -f $TMPCONF $TMPREG
383 if [ "$SYSREG" = 'auto' ]
384 then SYSREG=yes
389 # make root's registry global, if desired
390 if [ `whoami` = 'root' ] && [ "$SYSREG" = 'yes' ]
391 then {
392 if ! [ -f $sysconfdir/wine.userreg ]
393 then {
394 echo "Linking root's user registry hive to the global registry..."
395 cp ~/.wine/wine.userreg $sysconfdir/wine.userreg
396 ln -sf $sysconfdir/wine.userreg ~/.wine/wine.userreg
399 if ! [ -f $sysconfdir/wine.systemreg ]
400 then {
401 echo "Linking root's system registry hive to the global registry..."
402 cp ~/.wine/system.reg $sysconfdir/wine.systemreg
403 ln -sf $sysconfdir/wine.systemreg ~/.wine/system.reg
409 # it's a wrap
410 echo
411 echo "Installation complete for now. Good luck (this is still alpha software)."
412 echo "If you have problems with WINE, please read the documentation first,"
413 echo "as many kinds of potential problems are explained there."