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