configure: Remove no longer needed check for -fshort-wchar.
[wine] / tools / wineinstall
1 #!/bin/sh
2 # WINE Installation script
3 # Can do almost everything from compiling to configuring...
4 #
5 # Copyright 1999 Ove Kåven
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
22 #--- defaults (change these if you are a packager)
23 CONFARGS=""                   # configure args, e.g. --prefix=/usr
24
25 std_sleep() {
26   sleep 1
27 }
28
29 conf_yesno_answer() {
30   unset ANSWER
31   while [ "$ANSWER" != 'yes' ] && [ "$ANSWER" != 'no' ]
32   do {
33     echo -n "$1"
34     read ANSWER
35   }
36   done
37 }
38
39 # startup...
40
41 echo "Wine Installer v1.0"
42 echo
43
44 if [ ! -f configure ]
45 then
46     if [ -f ../configure ]
47     then {
48       cd ..
49     }
50     else {
51       echo "You're running this from the wrong directory."
52       echo "Change to the Wine source's main directory and try again."
53       exit 1
54     }
55     fi
56 fi
57
58 if [ -w / ]
59 then
60     echo "You are running wineinstall as root, this is not advisable. Please rerun as a user."
61     echo "Aborting."
62     exit 1
63 fi
64
65 if [ ! -w . ]
66 then
67     echo "The source directory is not writable. You probably extracted the sources as root."
68     echo "You should remove the source tree and extract it again as a normal user."
69     exit 1
70 fi
71
72 # check whether RPM installed, and if it is, remove any old wine rpm.
73 if [ -x `which rpm 2>/dev/null` ]; then
74     if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then
75       echo "Warning: Old Wine RPM install detected. Do you want to remove it first?"
76       conf_yesno_answer "(yes/no) "
77       if [ "$ANSWER" = 'yes' ]; then
78         echo "We need to remove the rpm as root, please enter your root password"
79         echo
80         echo Starting wine rpm removal...
81         su -c "rpm -e wine; RET=$?"
82         if [ $RET -eq 0 ]; then
83           echo Done.
84         else
85           echo "FAILED. Probably you aren't installing as root."
86           echo "Expect problems (library conflicts with existing install etc.)."
87         fi
88       else
89         echo "Sorry, I won't install Wine when an rpm version is still installed."
90         echo "(Wine support suffered from way too many conflicts between RPM"
91         echo "and source installs)"
92         echo "Have a nice day !"
93         exit 1
94       fi
95     fi
96 fi
97
98 # check whether wine binary still available
99 if [ -x `which wine 2>/dev/null` ] && [ -n "`wine --version 2>/dev/null`" ]
100 then
101     echo "Warning !! wine binary (still) found, which may indicate"
102     echo "a (conflicting) previous installation."
103     echo "You might want to abort and uninstall Wine first."
104     echo "(If you previously tried to install from source manually, "
105     echo "run 'make uninstall' from the wine root directory)"
106     std_sleep
107 fi
108
109 # run the configure script, if necessary
110
111 if [ -f Makefile ]
112 then
113     echo "I see that Wine has already been configured, so I'll skip that."
114     std_sleep
115 else
116     echo "Running configure..."
117     echo
118     if ! ./configure $CONFARGS
119     then {
120       echo
121       echo "Configure failed, aborting install."
122       exit 1
123     }
124     fi
125 fi
126
127 # now do the compilation and install, we need to always do this because we
128 # don't want the 'make install' command we might run to run 'make' as root
129
130 # ask the user if they want to build and install wine
131 echo
132 echo "We need to install wine as root user, do you want us to build wine,"
133 echo "'su root' and install Wine?  Enter 'no' to continue without installing"
134 conf_yesno_answer "(yes/no) "
135 ROOTINSTALL="$ANSWER"
136
137 if [ "$ROOTINSTALL" = "yes" ]
138 then sucommand="make install"
139 fi
140
141 echo
142 echo "Compiling Wine. Grab a lunch or two, rent a video, or whatever,"
143 echo "in the meantime..."
144 echo
145 std_sleep
146
147 # try to just make wine, if this fails 'make depend' and try to remake
148 if ! { make; }
149 then
150     if ! { make depend && make; }
151     then
152       echo
153       echo "Compilation failed, aborting install."
154       exit 1
155     fi
156 fi
157
158 if [ "$ROOTINSTALL" = "no" ]
159 then
160     exit 0
161 fi
162
163 echo
164 echo "Performing 'make install' as root to install binaries, enter root password"
165
166 if ! su root -c "$sucommand"
167 then
168     echo
169     echo "Incorrect root password. If you are running Ubuntu or a similar distribution,"
170     echo "'make install' needs to be run via the sudo wrapper, so trying that one now"
171     if ! sudo su root -c "$sucommand"
172     then
173          echo
174          echo "Either you entered an incorrect password or we failed to"
175          echo "run '$sucommand' correctly."
176          echo "If you didn't enter an incorrect password then please"
177          echo "report this error and any steps to possibly reproduce it to"
178          echo "http://bugs.winehq.org/"
179          echo
180          echo "Installation failed, aborting."
181          exit 1
182     fi
183 fi
184
185 # it's a wrap
186 echo
187 echo "Installation complete."
188 echo "If you have problems with Wine, please read the documentation first,"
189 echo "as many kinds of potential problems are explained there."
190
191 exit 0