wineinstall now properly configures no-windows installs, and should now
[wine] / tools / wineinstall
1 #!/bin/bash
2 # WINE Installation script
3
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
21 # defaults (change these if you are a packager)
22 CONFARGS=                     # configure args, e.g. --prefix=/usr --sysconfdir=/etc
23 prefix=/usr/local             # installation prefix
24 sysconfdir=$prefix/etc        # where wine.conf is supposed to be
25 libdir=$prefix/lib            # where libwine.so will be installed
26 CONF=$sysconfdir/wine.conf    # default path of the wine.conf
27 BINDIST=no                    # whether called from a binary package config script
28 DOCONF=auto                   # whether to autogenerate wine.conf
29 DOWCHK=auto                   # whether to autoconfigure existing-windows installation
30 DOWINE=auto                   # whether to autoconfigure no-windows installation
31 DOREG=auto                    # whether to install default registry
32 # elfdlls are not implemented yet, so this has no effect yet
33 DLLPATH=$libdir/wine          # default path of the elfdll .so files
34 # only for existing-windows installs
35 WINECONF=tools/wineconf       # the path of wineconf perl script (for existing-windows)
36 # only for no-windows installs
37 WINEINI=wine.ini              # the path of default wine.ini (also used by wineconf)
38 WININI=/dev/null              # the path of default win.ini
39 SYSTEMINI=documentation/samples/system.ini          # the path of default system.ini
40 REGAPI=programs/regapi/regapi # the path of regapi winelib application
41 DEFREG=winedefault.reg        # the path of the registry file to be fed to regapi
42 # CROOT=/var/wine             # the path of the fake Drive C (for no-windows)
43
44 # startup...
45
46 echo "WINE Installer v0.3"
47 echo
48
49 if [ "$BINDIST" = 'no' ]
50 then {
51
52 if ! [ -f configure ]
53 then {
54   echo "You're running this from the wrong directory."
55   echo "Change to the Wine directory and try again."
56   exit 1
57 }
58 fi
59
60 # run the configure script, if necessary
61
62 if [ -f config.cache ] && [ -f Makefile ] && [ Makefile -nt configure ]
63 then {
64   echo "I see that WINE has already been configured, so I'll skip that."
65   # load configure results
66   . ./config.cache
67 }
68 else {
69   echo "Running configure..."
70   echo
71   if ! ./configure $CONFARGS
72   then {
73     echo
74     echo "Configure failed, aborting install."
75     rm -f config.cache
76     exit 1
77   }
78   fi
79   # load configure results
80   . ./config.cache
81   # make sure X was found
82   eval "$ac_cv_have_x"
83   if [ "$have_x" != "yes" ]
84   then {
85     echo "Install the X development headers and try again."
86     rm -f config.cache
87     exit 1
88   }
89   elif [ "$ac_cv_header_X11_xpm_h" != "yes" ]
90   then {
91     echo "Install the Xpm development headers and try again."
92     rm -f config.cache
93     exit 1
94   }
95   fi
96 }
97 fi
98
99 # now do the compilation
100
101 if [ -f wine ] && [ wine -nt Makefile ]
102 then {
103   echo "Hmm, looks like WINE is already compiled. I'll skip that too, I guess."
104 }
105 else {
106   echo "Compiling WINE. Grab a lunch or two, rent a video, or whatever, in the meantime..."
107   echo
108   if ! { make depend && make; }
109   then {
110     echo
111     echo "Compilation failed, aborting install."
112     exit 1
113   }
114   fi
115   echo
116 }
117 fi
118
119 # and installation, if root
120
121 if [ `whoami` != 'root' ]
122 then {
123   echo "You aren't root, so I'll skip the make install."
124   # setup to run from current directory
125   DLLPATH="$PWD/dlls"
126   if [ -z "$LD_LIBRARY_PATH" ]
127   then LD_LIBRARY_PATH="$PWD:$DLLPATH"
128   else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD:$DLLPATH"
129   fi
130   export LD_LIBRARY_PATH
131   echo
132   echo "NOTE! To run Wine without installing, you must set the environment variable"
133   echo "LD_LIBRARY_PATH to $PWD:$DLLPATH"
134   echo "in your logon scripts."
135 }
136 else {
137   echo "Now installing binaries onto the system..."
138   echo
139   if ! make install
140   then {
141     echo
142     echo "Installation failed, aborting."
143     exit 1
144   }
145   fi
146   if [ -f /etc/ld.so.conf ] && ! grep -qs "$libdir" /etc/ld.so.conf
147   then {
148     echo
149     echo "$libdir didn't exist in your /etc/ld.so.conf, adding it now..."
150     echo "$libdir" >>/etc/ld.so.conf
151     echo "Re-running ldconfig..."
152     eval "$ac_cv_path_LDCONFIG"
153   }
154   fi
155 }
156 fi
157 echo
158
159 }
160 fi # BINDIST
161
162 # now check whether we should generate wine.conf
163 if [ -z "$DOCONF" ]
164 then DOCONF=auto
165 fi
166
167 if [ "$DOCONF" = 'auto' ]
168 then {
169   # see if we already have a system wine.conf
170   if [ -f $CONF ]
171   then DOCONF=no
172   fi
173 }
174 fi
175
176 if [ "$DOCONF" != 'no' ]
177 then {
178   if [ `whoami` != 'root' ]
179   then {
180     CONF=~/.winerc
181     if ! [ -f $CONF ]
182     then {
183       if [ "$DOCONF" != 'yes' ]
184       then {
185         echo "Since you aren't root, and there's no system wine.conf, I assume"
186         echo "you want a user-specific .winerc. Am I correct? (yes/no)"
187         while [ "$DOCONF" != 'yes' ] && [ "$DOCONF" != 'no' ]
188         do read DOCONF
189         done
190       }
191       fi
192       if [ "$DOCONF" = 'no' ]
193       then {
194         echo "Aborting install. Try again as root to generate a system wine.conf."
195         exit 1
196       }
197       fi
198       echo
199     }
200     fi
201   }
202   else {
203     mkdir -p $sysconfdir
204     DOCONF=yes
205   }
206   fi
207 }
208 fi
209
210 # generate wine.conf from existing windows install, if any
211 if [ "$DOCONF" = 'yes' ]
212 then {
213   if [ "$DOWCHK" = 'yes' ] || [ "$DOWCHK" = 'auto' ]
214   then {
215     echo "Searching for an existing Windows installation..."
216     if ! $WINECONF > $CONF 2>/dev/null
217     then {
218       rm -f $CONF
219       echo
220       echo "Windows was not found on your system, so I assume you want a Wine-only installation."
221       echo "Am I correct? (yes/no)"
222       while [ "$DOWINE" != 'yes' ] && [ "$DOWINE" != 'no' ]
223       do read DOWINE
224       done
225       if [ "$DOWINE" = 'no' ]
226       then {
227         echo "Aborting install. Make sure your Windows partition is mounted and try again,"
228         echo "or create $CONF manually by copying from $WINEINI and adapting the drive paths."
229         exit 1
230       }
231       fi
232     }
233     else {
234       echo
235       echo "Created $CONF using your existing Windows installation."
236       echo "You probably want to review the file, though."
237       DOWINE=no
238     }
239     fi
240     echo
241   }
242   elif [ "$DOWINE" = 'auto' ]
243   then DOWINE=yes
244   fi
245 }
246 elif [ "$DOWINE" = 'auto' ]
247 then DOWINE=no
248 fi
249
250 # generate wine.conf for no-windows install, if necessary
251 if [ "$DOWINE" = 'yes' ]
252 then {
253   if [ `whoami` != 'root' ]
254   then DCROOT=~/c
255   else DCROOT=/c
256   fi
257   echo "Configuring Wine without Windows. Some fake Windows directories must be created, to"
258   echo "hold any .ini files, DLLs, and start menu entries your applications may need to install."
259   while [ -z "$CROOT" ]
260   do {
261     echo "Where would you like your fake C drive to be placed? (default is $DCROOT)"
262     read CROOT
263     if [ -z "$CROOT" ]
264     then CROOT="$DCROOT"
265     fi
266     if ! [ -d "$CROOT" ]
267     then {
268       if ! mkdir -p "$CROOT"
269       then unset CROOT
270       fi
271     }
272     fi
273   }
274   done
275   echo "Configuring Wine for a no-windows install in $CROOT..."
276   for tdir in "$CROOT/windows" "$CROOT/windows/system" "$CROOT/windows/Start Menu" "$CROOT/windows/Start Menu/Programs"
277   do [ -d "$tdir" ] || mkdir "$tdir"
278   done
279   [ -f "$CROOT/windows/win.ini" ]    || cp "$WININI"    "$CROOT/windows/win.ini"
280   [ -f "$CROOT/windows/system.ini" ] || cp "$SYSTEMINI" "$CROOT/windows/system.ini"
281   if [ "$DOCONF" = 'yes' ]
282   then {
283     sed "s/Path=\/c$/Path=${CROOT//\//\\/}/" $WINEINI > $CONF
284     echo "Created $CONF using default Wine configuration."
285     echo "You probably want to review the file, though."
286   }
287   fi
288   # now we really need to install the registry
289   DOREG=yes
290 }
291 elif [ -z "$CROOT" ]
292 then {
293   echo "Reading current Wine configuration from $CONF..."
294   CROOT=`sed -n '/^\[Drive C\]$/,/^\[.*\]$/ s/^Path=\(.*\)/\1/p' $CONF`
295   echo "Drive C is configured at $CROOT."
296 }
297 fi
298 echo
299
300 # fixup EXTRA_LD_LIBRARY_PATH
301 if [ "$DOCONF" = 'yes' ]
302 then {
303   echo "Setting EXTRA_LD_LIBRARY_PATH in .winerc to $DLLPATH..."
304   sed "s/EXTRA_LD_LIBRARY_PATH=.*/EXTRA_LD_LIBRARY_PATH=${DLLPATH//\//\\/}/" $CONF > $CONF.new
305   mv -f $CONF.new $CONF
306   echo
307 }
308 fi
309
310 # check whether we need to install default registry
311 # (not to be done if windows registry exists)
312 if [ "$DOREG" = 'auto' ]
313 then {
314   echo "Checking for real Windows registry..."
315   if [ -f "$CROOT/windows/system.dat" ]
316   then DOREG=no
317   elif [ -f "$CROOT/windows/system32/config/system" ]
318   then DOREG=no
319   else DOREG=yes
320   fi
321   if [ "$DOREG" = 'yes' ]
322   then echo "Not found, default Wine registry will be installed."
323   else echo "Windows registry found, will not install default Wine registry."
324   fi
325   echo
326 }
327 fi
328
329 # install default registry entries
330 if [ "$DOREG" = 'yes' ]
331 then {
332   if [ "$BINDIST" = 'no' ]
333   then {
334     echo "Compiling regapi..."
335     echo
336     (cd programs/regapi; make)
337     echo
338   }
339   fi
340   echo "Installing default Wine registry entries..."
341   echo
342   if ! $REGAPI setValue < $DEFREG > /dev/null
343   then {
344     echo
345     echo "Registry install failed. Perhaps you weren't running X."
346     exit 1
347   }
348   else echo "Registry successfully installed."
349   fi
350   # FIXME: perhaps install registry to $sysconfdir/winesystem.reg and $sysconfdir/wineuser.reg?
351 }
352 fi
353 echo
354 echo "Installation complete for now. Good luck (this is still alpha software)."
355 echo "If you have problems with WINE, please read the documentation first,"
356 echo "as many kinds of potential problems are explained there."