1 | #! /bin/sh |
---|
2 | # |
---|
3 | # $Id: configure 265 2006-05-31 12:54:53Z livings124 $ |
---|
4 | |
---|
5 | # |
---|
6 | # Default settings |
---|
7 | # |
---|
8 | SYSTEM= |
---|
9 | BEOS_NETSERVER=no |
---|
10 | MATH=no |
---|
11 | PTHREAD=no |
---|
12 | OPENSSL= |
---|
13 | GTK= |
---|
14 | PREFIX=/usr/local |
---|
15 | CC="${CC-cc}" |
---|
16 | CFLAGS="${CFLAGS}" |
---|
17 | CXX="${CXX-c++}" |
---|
18 | CXXFLAGS="${CXXFLAGS}" |
---|
19 | LDFLAGS="${LDFLAGS}" |
---|
20 | |
---|
21 | # |
---|
22 | # Functions |
---|
23 | # |
---|
24 | usage() |
---|
25 | { |
---|
26 | cat << EOF |
---|
27 | |
---|
28 | Options: |
---|
29 | --disable-openssl Disable OpenSSL, use built-in SHA1 implementation |
---|
30 | --disable-gtk Don't build the GTK+ GUI |
---|
31 | --prefix=PATH Installation path |
---|
32 | |
---|
33 | Some influential environment variables: |
---|
34 | CC C compiler command |
---|
35 | CFLAGS C compiler flags |
---|
36 | CXX C++ compiler command |
---|
37 | CXXFLAGS C++ compiler flags |
---|
38 | LDFLAGS linker flags |
---|
39 | |
---|
40 | EOF |
---|
41 | } |
---|
42 | |
---|
43 | cc_test() |
---|
44 | { |
---|
45 | cat > testconf.c <<EOF |
---|
46 | int main() |
---|
47 | { |
---|
48 | return 0; |
---|
49 | } |
---|
50 | EOF |
---|
51 | if ! $CC -o testconf testconf.c > /dev/null 2>&1; then |
---|
52 | rm -f testconf.c testconf |
---|
53 | echo "Could not find a working compiler" |
---|
54 | exit 1 |
---|
55 | fi |
---|
56 | rm -f testconf.c testconf |
---|
57 | } |
---|
58 | |
---|
59 | openssl_test() |
---|
60 | { |
---|
61 | cat > testconf.c << EOF |
---|
62 | #include <stdio.h> |
---|
63 | #include <openssl/sha.h> |
---|
64 | int main() |
---|
65 | { |
---|
66 | SHA1( 0, 0, 0 ); |
---|
67 | } |
---|
68 | EOF |
---|
69 | if $CC $CFLAGS $LDFLAGS -o testconf testconf.c -lcrypto > /dev/null 2>&1 |
---|
70 | then |
---|
71 | echo "yes" |
---|
72 | OPENSSL=yes |
---|
73 | else |
---|
74 | echo "missing, using built-in SHA1 implementation" |
---|
75 | OPENSSL=no |
---|
76 | fi |
---|
77 | rm -f testconf.c testconf |
---|
78 | } |
---|
79 | |
---|
80 | lm_test() |
---|
81 | { |
---|
82 | cat > testconf.c << EOF |
---|
83 | int main() |
---|
84 | { |
---|
85 | return cos( 42 ); |
---|
86 | } |
---|
87 | EOF |
---|
88 | if ! $CC -o testconf testconf.c > /dev/null 2>&1 |
---|
89 | then |
---|
90 | if $CC -o testconf testconf.c -lm > /dev/null 2>&1 |
---|
91 | then |
---|
92 | LDFLAGS="$LDFLAGS -lm" |
---|
93 | fi |
---|
94 | fi |
---|
95 | rm -f testconf.c testconf |
---|
96 | } |
---|
97 | |
---|
98 | lrintf_test() |
---|
99 | { |
---|
100 | cat > testconf.c << EOF |
---|
101 | int main() |
---|
102 | { |
---|
103 | return ( lrintf( 3.14 ) != 3 ); |
---|
104 | } |
---|
105 | EOF |
---|
106 | if ( $CC -o testconf testconf.c $LDFLAGS && ./testconf ) > /dev/null 2>&1 |
---|
107 | then |
---|
108 | CFLAGS="$CFLAGS -DHAVE_LRINTF" |
---|
109 | fi |
---|
110 | rm -f testconf.c testconf |
---|
111 | } |
---|
112 | |
---|
113 | gettext_test() |
---|
114 | { |
---|
115 | cat > testconf.c <<EOF |
---|
116 | #include <libintl.h> |
---|
117 | int main() |
---|
118 | { |
---|
119 | gettext(""); |
---|
120 | } |
---|
121 | EOF |
---|
122 | |
---|
123 | if $CC $CFLAGS_GTK $LDFLAGS_GTK -o testconf testconf.c > /dev/null 2>&1 |
---|
124 | then |
---|
125 | rm -f testconf.c testconf |
---|
126 | return 0 |
---|
127 | fi |
---|
128 | |
---|
129 | for intl_testdir in $PREFIX/include \ |
---|
130 | /usr/local/include /usr/X11R6/include /usr/pkg/include |
---|
131 | do |
---|
132 | if $CC $CFLAGS_GTK -I$intl_testdir $LDFLAGS_GTK -o testconf testconf.c > /dev/null 2>&1 |
---|
133 | then |
---|
134 | CFLAGS_GTK="CFLAGS_GTK -I$intl_testdir" |
---|
135 | rm -f testconf.c testconf |
---|
136 | return 0 |
---|
137 | fi |
---|
138 | done |
---|
139 | rm -f testconf.c testconf |
---|
140 | return 1 |
---|
141 | } |
---|
142 | |
---|
143 | gtk_test() |
---|
144 | { |
---|
145 | if pkg-config gtk+-2.0 > /dev/null 2>&1 |
---|
146 | then |
---|
147 | if expr `pkg-config --modversion gtk+-2.0` '>=' 2.6.0 > /dev/null 2>&1 |
---|
148 | then |
---|
149 | cat > testconf.c << EOF |
---|
150 | #include <gtk/gtk.h> |
---|
151 | int main() |
---|
152 | { |
---|
153 | gtk_main(); |
---|
154 | } |
---|
155 | EOF |
---|
156 | if $CC `pkg-config gtk+-2.0 --cflags --libs` -o testconf testconf.c > /dev/null 2>&1 |
---|
157 | then |
---|
158 | CFLAGS_GTK=`pkg-config gtk+-2.0 --cflags` |
---|
159 | LDFLAGS_GTK=`pkg-config gtk+-2.0 --libs` |
---|
160 | if gettext_test |
---|
161 | then |
---|
162 | echo "yes" |
---|
163 | GTK=yes |
---|
164 | LOCALEDIR="$PREFIX/share/locale" |
---|
165 | CFLAGS_GTK="$CFLAGS_GTK -DLOCALEDIR=\\"\""$LOCALEDIR\\"\" |
---|
166 | else |
---|
167 | echo "no (could not find gettext libintl.h)" |
---|
168 | GTK=no |
---|
169 | fi |
---|
170 | else |
---|
171 | echo "no" |
---|
172 | GTK=no |
---|
173 | fi |
---|
174 | rm -f testconf.c testconf |
---|
175 | else |
---|
176 | echo "no (2.6.0 or later is required)" |
---|
177 | GTK=no |
---|
178 | fi |
---|
179 | else |
---|
180 | echo "no" |
---|
181 | GTK=no |
---|
182 | fi |
---|
183 | } |
---|
184 | |
---|
185 | # |
---|
186 | # Parse options |
---|
187 | # |
---|
188 | while [ $# -ne 0 ]; do |
---|
189 | param=`expr "opt$1" : 'opt[^=]*=\(.*\)'` |
---|
190 | |
---|
191 | case "x$1" in |
---|
192 | x--disable-openssl) |
---|
193 | OPENSSL=no |
---|
194 | ;; |
---|
195 | x--disable-gtk) |
---|
196 | GTK=no |
---|
197 | ;; |
---|
198 | x--prefix=*) |
---|
199 | PREFIX="$param" |
---|
200 | ;; |
---|
201 | x--help) |
---|
202 | usage |
---|
203 | exit 0 |
---|
204 | ;; |
---|
205 | esac |
---|
206 | shift |
---|
207 | done |
---|
208 | |
---|
209 | # |
---|
210 | # System-specific flags |
---|
211 | # |
---|
212 | SYSTEM=`uname -s` |
---|
213 | case $SYSTEM in |
---|
214 | BeOS) |
---|
215 | RELEASE=`uname -r` |
---|
216 | case $RELEASE in |
---|
217 | 6.0*|5.0.4) # Zeta or R5 / BONE beta 7 |
---|
218 | ;; |
---|
219 | 5.0*) # R5 / net_server |
---|
220 | BEOS_NETSERVER=yes |
---|
221 | ;; |
---|
222 | *) |
---|
223 | echo "Unsupported BeOS version" |
---|
224 | exit 1 |
---|
225 | ;; |
---|
226 | esac |
---|
227 | ;; |
---|
228 | |
---|
229 | Darwin) |
---|
230 | # Make sure the Universal SDK is installed |
---|
231 | if [ ! -d /Developer/SDKs/MacOSX10.4u.sdk ]; then |
---|
232 | cat << EOF |
---|
233 | You need to install the Universal SDK in order to build Transmission: |
---|
234 | Get your Xcode CD or package |
---|
235 | Restart the install |
---|
236 | When it gets to "Installation Type", select "Customize" |
---|
237 | Select "Mac OS X 10.4 (Universal) SDL" under "Cross Development" |
---|
238 | Finish the install. |
---|
239 | EOF |
---|
240 | exit 1 |
---|
241 | fi |
---|
242 | PTHREAD=yes |
---|
243 | ;; |
---|
244 | |
---|
245 | FreeBSD|NetBSD|OpenBSD|Linux) |
---|
246 | PTHREAD=yes |
---|
247 | ;; |
---|
248 | |
---|
249 | *) |
---|
250 | echo "Unsupported operating system" |
---|
251 | exit 1 ;; |
---|
252 | esac |
---|
253 | echo "System: $SYSTEM" |
---|
254 | |
---|
255 | # |
---|
256 | # First things first, check to see if there's a compiler installed |
---|
257 | # |
---|
258 | cc_test |
---|
259 | |
---|
260 | # |
---|
261 | # OpenSSL settings |
---|
262 | # |
---|
263 | echo -n "OpenSSL: " |
---|
264 | if [ "$OPENSSL" = no ]; then |
---|
265 | echo "disabled, using built-in SHA1 implementation" |
---|
266 | else |
---|
267 | openssl_test |
---|
268 | fi |
---|
269 | |
---|
270 | # |
---|
271 | # GTK+ settings |
---|
272 | # |
---|
273 | echo -n "GTK+: " |
---|
274 | if [ "$GTK" = no ]; then |
---|
275 | echo "disabled" |
---|
276 | else |
---|
277 | gtk_test |
---|
278 | fi |
---|
279 | |
---|
280 | # |
---|
281 | # Math functions |
---|
282 | # |
---|
283 | lm_test |
---|
284 | lrintf_test |
---|
285 | |
---|
286 | # |
---|
287 | # Generate config.mk |
---|
288 | # |
---|
289 | rm -f mk/config.mk |
---|
290 | cat > mk/config.mk << EOF |
---|
291 | SYSTEM = $SYSTEM |
---|
292 | PREFIX = $PREFIX |
---|
293 | LOCALEDIR = $LOCALEDIR |
---|
294 | BEOS_NETSERVER = $BEOS_NETSERVER |
---|
295 | PTHREAD = $PTHREAD |
---|
296 | OPENSSL = $OPENSSL |
---|
297 | GTK = $GTK |
---|
298 | CC = $CC |
---|
299 | CFLAGS = $CFLAGS |
---|
300 | CXX = $CXX |
---|
301 | CXXFLAGS = $CXXFLAGS |
---|
302 | LDFLAGS = $LDFLAGS |
---|
303 | CFLAGS_GTK = $CFLAGS_GTK |
---|
304 | LDFLAGS_GTK = $LDFLAGS_GTK |
---|
305 | EOF |
---|
306 | |
---|
307 | echo |
---|
308 | echo "Now use GNU make to build Transmission." |
---|
309 | echo "It may be called 'make' or 'gmake' depending on your system." |
---|