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