|
1 |
|
2 log() { |
|
3 if [ $1 = "1" ]; then echo "$2"; fi |
|
4 echo "$2" >> $config_log |
|
5 } |
|
6 |
|
7 set_default() { |
|
8 ignore_extra_parameters="0" |
|
9 # We set all kinds of defaults for params. Later on the user can override |
|
10 # most of them; but if they don't, this default is used. |
|
11 build="" |
|
12 host="" |
|
13 cc_build="" |
|
14 cc_host="" |
|
15 cxx_host="" |
|
16 windres="" |
|
17 strip="" |
|
18 lipo="" |
|
19 os="DETECT" |
|
20 endian="AUTO" |
|
21 revision="" |
|
22 config_log="config.log" |
|
23 prefix_dir="/usr/local" |
|
24 binary_dir="games" |
|
25 data_dir="share/games/openttd" |
|
26 icon_dir="share/pixmaps" |
|
27 personal_dir="" |
|
28 custom_lang_dir="" |
|
29 second_data_dir="" |
|
30 install_dir="/" |
|
31 enable_install="0" |
|
32 enable_debug="0" |
|
33 enable_profiling="0" |
|
34 enable_dedicated="0" |
|
35 enable_network="1" |
|
36 enable_static="1" |
|
37 enable_translator="0" |
|
38 enable_assert="1" |
|
39 enable_strip="1" |
|
40 enable_universal="1" |
|
41 enable_osx_g5="0" |
|
42 with_osx_sysroot="1" |
|
43 with_application_bundle="1" |
|
44 with_sdl="1" |
|
45 with_cocoa="1" |
|
46 with_zlib="1" |
|
47 with_png="1" |
|
48 with_makedepend="1" |
|
49 with_direct_music="1" |
|
50 with_sort="1" |
|
51 with_iconv="1" |
|
52 with_midi="" |
|
53 with_midi_arg="" |
|
54 with_freetpye="1" |
|
55 with_fontconfig="1" |
|
56 |
|
57 save_params_array="build host cc_build cc_host cxx_host windres strip lipo os revision endian config_log prefix_dir binary_dir data_dir icon_dir personal_dir install_dir custom_lang_dir second_data_dir enable_install enable_debug enable_profiling enable_dedicated enable_network enable_static enable_translator enable_assert enable_strip with_osx_sysroot enable_universal enable_osx_g5 with_application_bundle with_sdl with_cocoa with_zlib with_png with_makedepend with_direct_music with_sort with_iconv with_midi with_midi_arg with_freetype with_fontconfig CC CXX CFLAGS LDFLAGS" |
|
58 } |
|
59 |
|
60 detect_params() { |
|
61 # Walk over all params from the user and override any default settings if |
|
62 # needed. This also handles any invalid option. |
|
63 for p in "$@" |
|
64 do |
|
65 if [ -n "$prev_p" ] |
|
66 then |
|
67 eval "$prev_p=\$p" |
|
68 prev_p= |
|
69 continue |
|
70 fi |
|
71 |
|
72 optarg=`expr "x$p" : 'x[^=]*=\(.*\)'` |
|
73 |
|
74 case "$p" in |
|
75 --help | -h) |
|
76 showhelp |
|
77 exit 0 |
|
78 ;; |
|
79 |
|
80 --config-log) |
|
81 prev_p="config_log" |
|
82 ;; |
|
83 --config-log=*) |
|
84 config_log="$optarg" |
|
85 ;; |
|
86 |
|
87 --build) |
|
88 prev_p="build" |
|
89 ;; |
|
90 --build=*) |
|
91 build="$optarg" |
|
92 ;; |
|
93 |
|
94 --host) |
|
95 prev_p="host" |
|
96 ;; |
|
97 --host=*) |
|
98 host="$optarg" |
|
99 ;; |
|
100 |
|
101 --os) |
|
102 prev_p="os" |
|
103 ;; |
|
104 --os=*) |
|
105 os="$optarg" |
|
106 ;; |
|
107 |
|
108 --revision=*) |
|
109 revision="$optarg" |
|
110 ;; |
|
111 |
|
112 --cc-build) |
|
113 prevp_p="cc_build" |
|
114 ;; |
|
115 --cc-build=*) |
|
116 cc_build="$optarg" |
|
117 ;; |
|
118 --cc-host) |
|
119 prevp_p="cc_host" |
|
120 ;; |
|
121 --cc-host=*) |
|
122 cc_host="$optarg" |
|
123 ;; |
|
124 --cxx-host) |
|
125 prevp_p="cxx_host" |
|
126 ;; |
|
127 --cxx-host=*) |
|
128 cxx_host="$optarg" |
|
129 ;; |
|
130 --windres) |
|
131 prevp_p="windres" |
|
132 ;; |
|
133 --windres=*) |
|
134 windres="$optarg" |
|
135 ;; |
|
136 --strip) |
|
137 prevp_p="strip" |
|
138 ;; |
|
139 --strip=*) |
|
140 strip="$optarg" |
|
141 ;; |
|
142 --lipo) |
|
143 prevp_p="lipo" |
|
144 ;; |
|
145 --lipo=*) |
|
146 lipo="$optarg" |
|
147 ;; |
|
148 |
|
149 --endian) |
|
150 prev_p="endian" |
|
151 ;; |
|
152 --endian=*) |
|
153 endian="$optarg" |
|
154 ;; |
|
155 |
|
156 |
|
157 |
|
158 --prefix-dir) |
|
159 prevp_p="prefix-dir" |
|
160 ;; |
|
161 --prefix-dir=*) |
|
162 prefix_dir="$optarg" |
|
163 ;; |
|
164 |
|
165 --binary-dir) |
|
166 prevp_p="binary-dir" |
|
167 ;; |
|
168 --binary-dir=*) |
|
169 binary_dir="$optarg" |
|
170 ;; |
|
171 |
|
172 --data-dir) |
|
173 prevp_p="data-dir" |
|
174 ;; |
|
175 --data-dir=*) |
|
176 data_dir="$optarg" |
|
177 ;; |
|
178 |
|
179 --icon-dir) |
|
180 prevp_p="icon-dir" |
|
181 ;; |
|
182 --icon-dir=*) |
|
183 icon_dir="$optarg" |
|
184 ;; |
|
185 |
|
186 --personal-dir) |
|
187 prevp_p="personal-dir" |
|
188 ;; |
|
189 --personal-dir=*) |
|
190 personal_dir="$optarg" |
|
191 ;; |
|
192 |
|
193 --install-dir) |
|
194 prevp_p="install-dir" |
|
195 ;; |
|
196 --install-dir=*) |
|
197 install_dir="$optarg" |
|
198 ;; |
|
199 |
|
200 # TODO: The next few cases will be removed when the search path patch is applied |
|
201 --custom-lang-dir) |
|
202 prevp_p="custom-lang-dir" |
|
203 ;; |
|
204 --custom-lang-dir=*) |
|
205 custom_lang_dir="$optarg" |
|
206 ;; |
|
207 |
|
208 --second-data-dir) |
|
209 prevp_p="second-data-dir" |
|
210 ;; |
|
211 --second-data-dir=*) |
|
212 second_data_dir="$optarg" |
|
213 ;; |
|
214 |
|
215 --enable-install) |
|
216 enable_install="1" |
|
217 ;; |
|
218 --enable-install=*) |
|
219 enable_install="$optarg" |
|
220 ;; |
|
221 # TODO: End of to be removed cases |
|
222 |
|
223 |
|
224 --enable-debug) |
|
225 enable_debug="1" |
|
226 ;; |
|
227 --enable-debug=*) |
|
228 enable_debug="$optarg" |
|
229 ;; |
|
230 --enable-profiling) |
|
231 enable_profiling="1" |
|
232 ;; |
|
233 --enable-profiling=*) |
|
234 enable_profiling="$optarg" |
|
235 ;; |
|
236 --enable-dedicated) |
|
237 enable_dedicated="1" |
|
238 ;; |
|
239 --enable-dedicated=*) |
|
240 enable_dedicated="$optarg" |
|
241 ;; |
|
242 --enable-network=*) |
|
243 enable_network="$optarg" |
|
244 ;; |
|
245 --disable-network) |
|
246 enable_network="0" |
|
247 ;; |
|
248 --disable-static) |
|
249 enable_static="0" |
|
250 ;; |
|
251 --enable-static) |
|
252 enable_static="2" |
|
253 ;; |
|
254 --enable-static=*) |
|
255 enable_static="$optarg" |
|
256 ;; |
|
257 --disable-translator) |
|
258 enable_translator="0" |
|
259 ;; |
|
260 --enable-translator) |
|
261 enable_translator="2" |
|
262 ;; |
|
263 --enable-translator=*) |
|
264 enable_translator="$optarg" |
|
265 ;; |
|
266 --disable-assert) |
|
267 enable_assert="0" |
|
268 ;; |
|
269 --enable-assert) |
|
270 enable_assert="2" |
|
271 ;; |
|
272 --enable-assert=*) |
|
273 enable_assert="$optarg" |
|
274 ;; |
|
275 --disable-strip) |
|
276 enable_strip="0" |
|
277 ;; |
|
278 --enable-strip) |
|
279 enable_strip="2" |
|
280 ;; |
|
281 --enable-strip=*) |
|
282 enable_strip="$optarg" |
|
283 ;; |
|
284 --disable-universal) |
|
285 enable_universal="0" |
|
286 ;; |
|
287 --enable-universal) |
|
288 enable_universal="2" |
|
289 ;; |
|
290 --enable-universal=*) |
|
291 enable_universal="$optarg" |
|
292 ;; |
|
293 --disable-osx-g5) |
|
294 enable_osx_g5="0" |
|
295 ;; |
|
296 --enable-osx-g5) |
|
297 enable_osx_g5="2" |
|
298 ;; |
|
299 --enable-osx-g5=*) |
|
300 enable_osx_g5="$optarg" |
|
301 ;; |
|
302 |
|
303 --with-sdl) |
|
304 with_sdl="2" |
|
305 ;; |
|
306 --without-sdl) |
|
307 with_sdl="0" |
|
308 ;; |
|
309 --with-sdl=*) |
|
310 with_sdl="$optarg" |
|
311 ;; |
|
312 |
|
313 --with-cocoa) |
|
314 with_cocoa="2" |
|
315 ;; |
|
316 --without-cocoa) |
|
317 with_cocoa="0" |
|
318 ;; |
|
319 --with-cocoa=*) |
|
320 with_cocoa="$optarg" |
|
321 ;; |
|
322 |
|
323 --with-zlib) |
|
324 with_zlib="2" |
|
325 ;; |
|
326 --without-zlib) |
|
327 with_zlib="0" |
|
328 ;; |
|
329 --with-zlib=*) |
|
330 with_zlib="$optarg" |
|
331 ;; |
|
332 |
|
333 --with-png) |
|
334 with_png="2" |
|
335 ;; |
|
336 --without-png) |
|
337 with_png="0" |
|
338 ;; |
|
339 --with-png=*) |
|
340 with_png="$optarg" |
|
341 ;; |
|
342 --with-libpng) |
|
343 with_png="2" |
|
344 ;; |
|
345 --without-libpng) |
|
346 with_png="0" |
|
347 ;; |
|
348 --with-libpng=*) |
|
349 with_png="$optarg" |
|
350 ;; |
|
351 |
|
352 --with-freetype) |
|
353 with_freetype="2" |
|
354 ;; |
|
355 --without-freetype) |
|
356 with_freetype="0" |
|
357 ;; |
|
358 --with-freetype=*) |
|
359 with_freetype="$optarg" |
|
360 ;; |
|
361 --with-libfreetype) |
|
362 with_freetype="2" |
|
363 ;; |
|
364 --without-libfreetype) |
|
365 with_freetype="0" |
|
366 ;; |
|
367 --with-libfreetype=*) |
|
368 with_freetype="$optarg" |
|
369 ;; |
|
370 |
|
371 --with-fontconfig) |
|
372 with_fontconfig="2" |
|
373 ;; |
|
374 --without-fontconfig) |
|
375 with_fontconfig="0" |
|
376 ;; |
|
377 --with-fontconfig=*) |
|
378 with_fontconfig="$optarg" |
|
379 ;; |
|
380 --with-libfontconfig) |
|
381 with_fontconfig="2" |
|
382 ;; |
|
383 --without-libfontconfig) |
|
384 with_fontconfig="0" |
|
385 ;; |
|
386 --with-libfontconfig=*) |
|
387 with_fontconfig="$optarg" |
|
388 ;; |
|
389 |
|
390 --with-makedepend) |
|
391 with_makedepend="2" |
|
392 ;; |
|
393 --without-makedepend) |
|
394 with_makedepend="0" |
|
395 ;; |
|
396 --with-makedepend=*) |
|
397 with_makedepend="$optarg" |
|
398 ;; |
|
399 |
|
400 --with-direct-music) |
|
401 with_direct_music="2" |
|
402 ;; |
|
403 --without-direct-music) |
|
404 with_direct_music="0" |
|
405 ;; |
|
406 --with-direct-music=*) |
|
407 with_direct_music="$optarg" |
|
408 ;; |
|
409 |
|
410 --with-sort) |
|
411 with_sort="2" |
|
412 ;; |
|
413 --without-sort) |
|
414 with_sort="0" |
|
415 ;; |
|
416 --with-sort=*) |
|
417 with_sort="$optarg" |
|
418 ;; |
|
419 |
|
420 --with-iconv) |
|
421 with_iconv="2" |
|
422 ;; |
|
423 --without-iconv) |
|
424 with_iconv="0" |
|
425 ;; |
|
426 --with-iconv=*) |
|
427 with_iconv="$optarg" |
|
428 ;; |
|
429 |
|
430 --with-midi=*) |
|
431 with_midi="$optarg" |
|
432 ;; |
|
433 --with-midi-arg=*) |
|
434 with_midi_arg="$optarg" |
|
435 ;; |
|
436 |
|
437 --without-osx-sysroot) |
|
438 with_osx_sysroot="0" |
|
439 ;; |
|
440 --with-osx-sysroot) |
|
441 with_osx_sysroot="2" |
|
442 ;; |
|
443 --with-osx-sysroot=*) |
|
444 with_osx_sysroot="$optarg" |
|
445 ;; |
|
446 |
|
447 --without-application-bundle) |
|
448 with_applicant_bundle="0" |
|
449 ;; |
|
450 --with-application-bundle) |
|
451 with_applicant_bundle="1" |
|
452 ;; |
|
453 --with-application-bundle=*) |
|
454 with_applicant_bundle="$optarg" |
|
455 ;; |
|
456 |
|
457 CC=* | --CC=*) |
|
458 CC="$optarg" |
|
459 ;; |
|
460 CXX=* | --CXX=*) |
|
461 CXX="$optarg" |
|
462 ;; |
|
463 CFLAGS=* | --CFLAGS=*) |
|
464 CFLAGS="$optarg" |
|
465 ;; |
|
466 LDFLAGS=* | --LDFLAGS=*) |
|
467 LDFLAGS="$optarg" |
|
468 ;; |
|
469 |
|
470 --ignore-extra-parameters) |
|
471 ignore_extra_parameters="1" |
|
472 ;; |
|
473 |
|
474 --*) |
|
475 if [ "$ignore_extra_parameters" = "0" ] |
|
476 then |
|
477 echo "Unknown option $p" |
|
478 exit 1 |
|
479 else |
|
480 echo "Unknown option $p ignored" |
|
481 fi |
|
482 ;; |
|
483 esac |
|
484 done |
|
485 |
|
486 if [ -n "$prev_p" ] |
|
487 then |
|
488 echo "configure: error: missing argument to --$prev_p" |
|
489 exit 1 |
|
490 fi |
|
491 |
|
492 # Clean the logfile |
|
493 echo "" > $config_log |
|
494 } |
|
495 |
|
496 save_params() { |
|
497 # Here we save all params, so we can later on do an exact redo of this |
|
498 # configuration, without having the user to re-input stuff |
|
499 |
|
500 echo "Running configure with following options:" >> $config_log |
|
501 echo "" >> $config_log |
|
502 |
|
503 configure="$0 --ignore-extra-parameters" |
|
504 for p in $save_params_array |
|
505 do |
|
506 eval "v=\$$p" |
|
507 p=`echo "$p" | sed 's/_/-/g;s/\n//g;'` |
|
508 # Only save those params that aren't empty |
|
509 configure="$configure --$p=$v" |
|
510 done |
|
511 |
|
512 echo "$configure" >> $config_log |
|
513 echo "$configure" > config.cache |
|
514 echo "" >> $config_log |
|
515 } |
|
516 |
|
517 check_params() { |
|
518 # Some params want to be in full uppercase, else they might not work as |
|
519 # expected.. fix that here |
|
520 |
|
521 endian=`echo $endian | tr [:lower:] [:upper:]` |
|
522 os=`echo $os | tr [:lower:] [:upper:]` |
|
523 |
|
524 # Check if all params have valid values |
|
525 |
|
526 # Endian only allows AUTO, LE and, BE |
|
527 if ! echo $endian | grep -q "^AUTO$\|^LE$\|^BE$" |
|
528 then |
|
529 echo "configure: error: invalid option --endian=$endian" |
|
530 echo " Available options are: --endian=[AUTO|LE|BE]" |
|
531 exit 1 |
|
532 fi |
|
533 # OS only allows DETECT, UNIX, OSX, FREEBSD, MORPHOS, BEOS, SUNOS, CYGWIN, and MINGW, OS2 |
|
534 if ! echo $os | grep -q "^DETECT$\|^UNIX$\|^OSX$\|^FREEBSD$\|^MORPHOS$\|^BEOS$\|^SUNOS$\|^CYGWIN$\|^MINGW$\|^OS2" |
|
535 then |
|
536 echo "configure: error: invalid option --os=$os" |
|
537 echo " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|MORPHOS|BEOS|SUNOS|CYGWIN|MINGW|OS2]" |
|
538 exit 1 |
|
539 fi |
|
540 # enable_debug should be between 0 and 4 |
|
541 if ! echo $enable_debug | grep -q "^0$\|^1$\|^2$\|^3$" |
|
542 then |
|
543 echo "configure: error: invalid option --enable-debug=$enable_debug" |
|
544 echo " Available options are: --enable-debug[=0123]" |
|
545 exit 1 |
|
546 fi |
|
547 |
|
548 check_build |
|
549 check_host |
|
550 |
|
551 detect_os |
|
552 |
|
553 # We might enable universal builds always on OSX targets.. but currently we don't |
|
554 # if [ "$enable_universal" = "1" ] && [ "$os" != "OSX" ] |
|
555 if [ "$enable_universal" = "1" ] |
|
556 then |
|
557 enable_universal="0" |
|
558 fi |
|
559 if [ "$enable_universal" = "2" ] && [ "$os" != "OSX" ] |
|
560 then |
|
561 log 1 "configure: error: --enable-universal only works on OSX" |
|
562 exit 1 |
|
563 fi |
|
564 if [ "$enable_universal" = "0" ] |
|
565 then |
|
566 log 1 "checking universal build... no" |
|
567 else |
|
568 log 1 "checking universal build... yes" |
|
569 fi |
|
570 |
|
571 # Already detected by check_build |
|
572 log 1 "checking for build gcc... $cc_build" |
|
573 log 1 "checking for host gcc... $cc_host" |
|
574 |
|
575 check_cxx |
|
576 check_windres |
|
577 check_strip |
|
578 check_lipo |
|
579 check_makedepend |
|
580 |
|
581 if [ "$enable_static" = "1" ] |
|
582 then |
|
583 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "OSX" ] |
|
584 then |
|
585 enable_static="2" |
|
586 else |
|
587 enable_static="0" |
|
588 fi |
|
589 fi |
|
590 |
|
591 if [ "$enable_static" != "0" ] |
|
592 then |
|
593 log 1 "checking for static... yes" |
|
594 |
|
595 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "OSX" ] && [ "$os" != "MORPHOS" ] |
|
596 then |
|
597 log 1 "WARNING: static is only known to work on Windows, MacOSX and MorphOS" |
|
598 log 1 "WARNING: use static at your own risk on this platform" |
|
599 |
|
600 sleep 5 |
|
601 fi |
|
602 else |
|
603 log 1 "checking for static... no" |
|
604 fi |
|
605 |
|
606 # Show what we configured |
|
607 if [ "$enable_debug" = "0" ] |
|
608 then |
|
609 log 1 "using debug level... no" |
|
610 elif [ "$enable_profiling" != "0" ] |
|
611 then |
|
612 log 1 "using debug level... profiling (debug level $enable_debug)" |
|
613 else |
|
614 log 1 "using debug level... level $enable_debug" |
|
615 fi |
|
616 |
|
617 detect_sdl |
|
618 detect_cocoa |
|
619 |
|
620 if [ "$enable_dedicated" != "0" ] |
|
621 then |
|
622 log 1 "checking GDI video driver... skipping" |
|
623 log 1 "checking dedicated... found" |
|
624 |
|
625 if [ "$enable_network" != "0" ] |
|
626 then |
|
627 log 1 "WARNING: compiling a dedicated server without network is pointless" |
|
628 sleep 5 |
|
629 fi |
|
630 else |
|
631 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] |
|
632 then |
|
633 log 1 "checking GDI video driver... found" |
|
634 else |
|
635 log 1 "checking GDI video driver... not Windows, skipping" |
|
636 fi |
|
637 |
|
638 if [ -z "$sdl_config" ] && [ "$with_cocoa" = 0 ] && [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] |
|
639 then |
|
640 log 1 "WARNING: no video driver found, building dedicated only" |
|
641 enable_dedicated="1" |
|
642 sleep 1 |
|
643 |
|
644 log 1 "checking dedicated... found" |
|
645 else |
|
646 log 1 "checking dedicated... not selected" |
|
647 fi |
|
648 fi |
|
649 |
|
650 if [ "$enable_network" != "0" ] |
|
651 then |
|
652 log 1 "checking network... found" |
|
653 else |
|
654 log 1 "checking network... disabled" |
|
655 fi |
|
656 |
|
657 if [ "$enable_translator" != "0" ] |
|
658 then |
|
659 log 1 "checking translator... debug" |
|
660 strgen_flags="" |
|
661 else |
|
662 log 1 "checking translator... no" |
|
663 # -t shows TODO items, normally they are muted |
|
664 strgen_flags="-t" |
|
665 fi |
|
666 |
|
667 if [ "$enable_assert" != "0" ] |
|
668 then |
|
669 log 1 "checking assert... enabled" |
|
670 else |
|
671 log 1 "checking assert... disabled" |
|
672 fi |
|
673 |
|
674 detect_zlib |
|
675 detect_png |
|
676 detect_freetype |
|
677 detect_fontconfig |
|
678 detect_iconv |
|
679 |
|
680 if [ "$with_direct_music" = "1" ] || [ "$with_direct_music" = "2" ] |
|
681 then |
|
682 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] |
|
683 then |
|
684 if [ "$with_direct_music" = "2" ] |
|
685 then |
|
686 log 1 "configure: error: direct-music is only supported on Win32 targets" |
|
687 exit 1 |
|
688 fi |
|
689 with_direct_music="0" |
|
690 |
|
691 log 1 "checking direct-music... not Windows, skipping" |
|
692 else |
|
693 check_direct_music |
|
694 fi |
|
695 fi |
|
696 |
|
697 detect_sort |
|
698 |
|
699 if [ "$os" = "OSX" ] && [ "$endian" = "AUTO" ] |
|
700 then |
|
701 endian="PREPROCESSOR" |
|
702 fi |
|
703 |
|
704 log 1 "checking endianess... $endian" |
|
705 |
|
706 # Suppress language errors when there is a version defined, indicating a release |
|
707 # It just isn't pretty if any release produces warnings in the languages. |
|
708 if [ -f "$ROOT_DIR/version" ] |
|
709 then |
|
710 lang_suppress="yes" |
|
711 log 1 "suppress language errors... yes" |
|
712 else |
|
713 lang_suppress="" |
|
714 log 1 "suppress language errors... no" |
|
715 fi |
|
716 |
|
717 if [ "$enable_debug" = "0" ] && [ "$enable_profiling" = "0" ] && [ "$enable_strip" != "0" ] |
|
718 then |
|
719 if [ "$os" = "MORPHOS" ] |
|
720 then |
|
721 strip_arg="--strip-all --strip-unneeded --remove-section .comment" |
|
722 elif [ "$os" = "OSX" ] |
|
723 then |
|
724 strip_arg="" |
|
725 else |
|
726 strip_arg="-s" |
|
727 fi |
|
728 |
|
729 log 1 "checking stripping... $strip $strip_arg" |
|
730 else |
|
731 strip="" |
|
732 log 1 "checking stripping... skipped" |
|
733 fi |
|
734 |
|
735 if [ "$os" != "OSX" ] && [ "$with_osx_sysroot" != "0" ] |
|
736 then |
|
737 if [ "$with_osx_sysroot" = "1" ] |
|
738 then |
|
739 with_osx_sysroot="0" |
|
740 |
|
741 log 1 "checking OSX sysroot... not OSX, skipping" |
|
742 else |
|
743 log 1 "configure: error: --with-osx-sysroot only works if OSX is the target" |
|
744 exit 1 |
|
745 fi |
|
746 fi |
|
747 |
|
748 if [ "$with_osx_sysroot" != "0" ] |
|
749 then |
|
750 if [ "$enable_universal" = "0" ] && [ "$with_osx_sysroot" != "1" ] && [ "$with_osx_sysroot" != "2" ] |
|
751 then |
|
752 log 1 "checking OSX sysroot... $with_osx_sysroot" |
|
753 else |
|
754 # If autodetect and no universal, use system default |
|
755 if [ "$with_osx_sysroot" = "1" ] && [ "$enable_universal" = "0" ] |
|
756 then |
|
757 log 1 "checking OSX sysroot... no (use system default)" |
|
758 with_osx_sysroot="0" |
|
759 else |
|
760 log 1 "checking OSX sysroot... automaticly" |
|
761 with_osx_sysroot="3" |
|
762 fi |
|
763 fi |
|
764 else |
|
765 if [ "$os" = "OSX" ] |
|
766 then |
|
767 log 1 "checking OSX sysroot... no (use system default)" |
|
768 fi |
|
769 fi |
|
770 |
|
771 if [ "$os" != "OSX" ] && [ "$with_application_bundle" != "0" ] |
|
772 then |
|
773 if [ "$with_application_bundle" = "1" ] |
|
774 then |
|
775 with_application_bundle="0" |
|
776 |
|
777 log 1 "checking OSX application bundle... not OSX, skipping" |
|
778 else |
|
779 log 1 "configure: error: --with-application-bundle only works if OSX is the target" |
|
780 exit 1 |
|
781 fi |
|
782 fi |
|
783 |
|
784 if [ "$os" = "OSX" ] && [ "$with_application_bundle" = "1" ] |
|
785 then |
|
786 OSXAPP="OpenTTD.app" |
|
787 |
|
788 # TODO: remove next few lines of code when the search path patch has been applied |
|
789 if [ -n "$custom_lang_dir" ] && [ "$custom_lang_dir" != "$(OSXAPP)/Contents/Lang/" ] |
|
790 then |
|
791 log 1 "configure: error: --custom-lang-dir and --with-application-bundle are not compatible |
|
792 exit 1 |
|
793 fi |
|
794 |
|
795 if [ -n "$custom_lang_dir" ] && [ "$second_data_dir" != "$(OSXAPP)/Contents/Data/" ] |
|
796 then |
|
797 log 1 "configure: error: --second-data-dir and --with-application-bundle are not compatible |
|
798 exit 1 |
|
799 fi |
|
800 |
|
801 custom_lang_dir="${OSXAPP}/Contents/Lang/" |
|
802 second_data_dir="${OSXAPP}/Contents/Data/" |
|
803 # TODO: remove till here |
|
804 else |
|
805 OSXAPP="" |
|
806 fi |
|
807 |
|
808 if [ "$os" = "OSX" ] |
|
809 then |
|
810 # Test on G5 |
|
811 |
|
812 if [ "$enable_osx_g5" != "0" ] |
|
813 then |
|
814 log 1 "detecting G5... yes (forced)" |
|
815 else |
|
816 # First, are we a real OSX system, else we can't detect it |
|
817 native=`LC_ALL=C uname | tr [:upper:] [:lower:] | grep darwin` |
|
818 # If $host doesn't match $build , we are cross-compiling |
|
819 if [ -n "$native" ] && [ "$build" != "$host" ] |
|
820 then |
|
821 $cc_build $SRC_DIR/os/macosx/G5_detector.c -o G5_detector |
|
822 res=`./G5_detector` |
|
823 rm -f G5_detector |
|
824 if [ -n "$res" ] |
|
825 then |
|
826 # This is G5, add flags for it |
|
827 enable_osx_g5="2" |
|
828 |
|
829 log 1 "detecting G5... yes" |
|
830 else |
|
831 enable_osx_g5="0" |
|
832 |
|
833 log 1 "detecting G5... no" |
|
834 fi |
|
835 else |
|
836 enable_osx_g5="0" |
|
837 |
|
838 log 1 "detecting G5... no (cross-compiling)" |
|
839 fi |
|
840 fi |
|
841 else |
|
842 if [ "$enable_osx_g5" != "0" ] |
|
843 then |
|
844 log 1 "configure: error: OSX G5 selected, but not compiling for OSX" |
|
845 log 1 "configure: error: either select OSX as OS, or deselect OSX G5" |
|
846 |
|
847 exit 1 |
|
848 fi |
|
849 fi |
|
850 } |
|
851 |
|
852 make_cflags_and_ldflags() { |
|
853 # General CFlags for BUILD |
|
854 CFLAGS_BUILD="" |
|
855 # General CFlags for HOST |
|
856 CFLAGS="$CFLAGS -D$os -DWITH_REV" |
|
857 # CFlags for HOST and C-Compiler |
|
858 CC_FLAGS="" |
|
859 # Libs to compile. In fact this is just LDFLAGS |
|
860 LIBS="-lstdc++" |
|
861 # LDFLAGS used for HOST |
|
862 LDFLAGS="$LDFLAGS" |
|
863 |
|
864 # Each debug level reduces the optimalization by a bit |
|
865 if [ $enable_debug -ge 1 ] |
|
866 then |
|
867 CFLAGS="$CFLAGS -g -D_DEBUG" |
|
868 OBJS_SUBDIR="debug" |
|
869 else |
|
870 OBJS_SUBDIR="release" |
|
871 fi |
|
872 if [ $enable_debug -ge 2 ] |
|
873 then |
|
874 CFLAGS="$CFLAGS -fno-inline" |
|
875 fi |
|
876 if [ $enable_debug -ge 3 ] |
|
877 then |
|
878 CFLAGS="$CFLAGS -O0" |
|
879 fi |
|
880 if [ $enable_debug = 0 ] |
|
881 then |
|
882 # No debug, add default stuff |
|
883 if [ "$os" = "OSX" ] |
|
884 then |
|
885 # these compilerflags makes the app run as fast as possible without making the app unstable. It works on G3 or newer |
|
886 CFLAGS="$CFLAGS -O3 -funroll-loops -fsched-interblock -falign-loops=16 -falign-jumps=16 -falign-functions=16 -falign-jumps-max-skip=15 -falign-loops-max-skip=15 -mdynamic-no-pic" |
|
887 else |
|
888 if [ "$os" = "MORPHOS" ] |
|
889 then |
|
890 CFLAGS="$CFLAGS -I/gg/os-include -noixemul -fstrict-aliasing -fexpensive-optimizations" |
|
891 CFLAGS="$CFLAGS -mcpu=604 -fno-inline -mstring -mmultiple" |
|
892 fi |
|
893 |
|
894 CFLAGS="$CFLAGS -O2 -fomit-frame-pointer" |
|
895 fi |
|
896 |
|
897 if [ "$enable_profiling" != "0" ] |
|
898 then |
|
899 CFLAGS="$CFLAGS -pg" |
|
900 LDFLAGS="$LDFLAGS -pg" |
|
901 fi |
|
902 else |
|
903 if [ "$enable_profiling" != "0" ] |
|
904 then |
|
905 CFLAGS="$CFLAGS -p" |
|
906 LDFLAGS="$LDFLAGS -pg" |
|
907 fi |
|
908 fi |
|
909 |
|
910 # Enable some things only for certain GCC versions |
|
911 cc_version=`$cc_host -dumpversion | cut -c 1,3` |
|
912 |
|
913 if [ $cc_version -ge 29 ] |
|
914 then |
|
915 CFLAGS="$CFLAGS -O -Wall -Wno-multichar -Wsign-compare -Wundef" |
|
916 CFLAGS="$CFLAGS -Wwrite-strings -Wpointer-arith" |
|
917 |
|
918 CC_CFLAGS="$CC_CFLAGS -Wstrict-prototypes" |
|
919 fi |
|
920 |
|
921 if [ $cc_version -ge 30 ] |
|
922 then |
|
923 CFLAGS="$CFLAGS -W -Wno-unused-parameter" |
|
924 fi |
|
925 |
|
926 if [ $cc_version -ge 34 ] |
|
927 then |
|
928 CC_CFLAGS="$CC_CFLAGS -Wdeclaration-after-statement -Wold-style-definition" |
|
929 fi |
|
930 |
|
931 if [ "$os" = "CYGWIN" ] |
|
932 then |
|
933 CFLAGS="$CFLAGS -mwin32" |
|
934 LDFLAGS="$LDFLAGS -mwin32" |
|
935 fi |
|
936 if [ "$os" = "MINGW" ] |
|
937 then |
|
938 CFLAGS="$CFLAGS -mno-cygwin" |
|
939 LDFLAGS="$LDFLAGS -mno-cygwin" |
|
940 fi |
|
941 |
|
942 if [ "$os" = "CYGWIN" ] || [ "$os" = "MINGW" ] |
|
943 then |
|
944 LDFLAGS="$LDFLAGS -Wl,--subsystem,windows" |
|
945 LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32" |
|
946 fi |
|
947 |
|
948 if [ "$os" != "CYGWIN" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] |
|
949 then |
|
950 LIBS="$LIBS -lpthread" |
|
951 LIBS="$LIBS -lrt" |
|
952 fi |
|
953 |
|
954 if [ "$os" != "MINGW" ] |
|
955 then |
|
956 LIBS="$LIBS -lc" |
|
957 fi |
|
958 |
|
959 if [ "$os" = "MORPHOS" ] |
|
960 then |
|
961 # -Wstrict-prototypes generates much noise because of system headers |
|
962 CFLAGS="$CFLAGS -Wno-strict-prototypes" |
|
963 fi |
|
964 |
|
965 if [ "$os" = "OSX" ] |
|
966 then |
|
967 LDFLAGS="$LDFLAGS -framework Cocoa" |
|
968 if [ "$enable_dedicated" = "0" ] |
|
969 then |
|
970 LIBS="$LIBS -framework QuickTime" |
|
971 fi |
|
972 fi |
|
973 |
|
974 if [ "$os" = "BEOS" ] |
|
975 then |
|
976 LIBS="$LIBS -lmidi -lbe" |
|
977 fi |
|
978 |
|
979 # Most targets act like UNIX, just with some additions |
|
980 if [ "$os" = "BEOS" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ] |
|
981 then |
|
982 CFLAGS="$CFLAGS -DUNIX" |
|
983 fi |
|
984 # And others like Windows |
|
985 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] |
|
986 then |
|
987 CFLAGS="$CFLAGS -DWIN" |
|
988 fi |
|
989 |
|
990 if [ -n "$sdl_config" ] |
|
991 then |
|
992 CFLAGS="$CFLAGS -DWITH_SDL" |
|
993 CFLAGS="$CFLAGS `$sdl_config --cflags`" |
|
994 if [ "$enable_static" != "0" ] |
|
995 then |
|
996 LIBS="$LIBS `$sdl_config --static-libs`" |
|
997 else |
|
998 LIBS="$LIBS `$sdl_config --libs`" |
|
999 fi |
|
1000 fi |
|
1001 |
|
1002 if [ "$with_cocoa" != "0" ] |
|
1003 then |
|
1004 CFLAGS="$CFLAGS -DWITH_COCOA" |
|
1005 LIBS="$LIBS -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit" |
|
1006 fi |
|
1007 |
|
1008 if [ "$with_zlib" != "0" ] |
|
1009 then |
|
1010 if [ "$enable_static" != "0" ] && [ "$os" != "OSX" ] |
|
1011 then |
|
1012 LIBS="$LIBS $zlib" |
|
1013 else |
|
1014 LIBS="$LIBS -lz" |
|
1015 fi |
|
1016 CFLAGS="$CFLAGS -DWITH_ZLIB" |
|
1017 fi |
|
1018 |
|
1019 if [ -n "$png_config" ] |
|
1020 then |
|
1021 CFLAGS="$CFLAGS -DWITH_PNG" |
|
1022 CFLAGS="$CFLAGS `$png_config --cppflags --I_opts | tr '\n\r' ' '`" |
|
1023 |
|
1024 # The extra flags are unneeded for latest libpng-config, but some versions are so broken... |
|
1025 if [ "$enable_static" != "0" ] |
|
1026 then |
|
1027 if [ "$os" = "OSX" ] |
|
1028 then |
|
1029 LIBS="$LIBS `$png_config --prefix`/lib/libpng.a" |
|
1030 else |
|
1031 LIBS="$LIBS `$png_config --static --ldflags --libs --L_opts | tr '\n\r' ' '`" |
|
1032 fi |
|
1033 else |
|
1034 LIBS="$LIBS `$png_config --ldflags --libs --L_opts | tr '\n\r' ' '`" |
|
1035 fi |
|
1036 fi |
|
1037 |
|
1038 if [ -n "$freetype_config" ] |
|
1039 then |
|
1040 CFLAGS="$CFLAGS -DWITH_FREETYPE" |
|
1041 CFLAGS="$CFLAGS `$freetype_config --cflags | tr '\n\r' ' '`" |
|
1042 |
|
1043 if [ "$enable_static" != "0" ] |
|
1044 then |
|
1045 if [ "$os" = "OSX" ] |
|
1046 then |
|
1047 LIBS="$LIBS `$freetype_config --prefix`/lib/libfreetype.a" |
|
1048 else |
|
1049 # Is it possible to do static with freetype, if so: how? |
|
1050 LIBS="$LIBS `$freetype_config --libs | tr '\n\r' ' '`" |
|
1051 fi |
|
1052 else |
|
1053 LIBS="$LIBS `$freetype_config --libs | tr '\n\r' ' '`" |
|
1054 fi |
|
1055 fi |
|
1056 |
|
1057 if [ -n "$fontconfig_config" ] |
|
1058 then |
|
1059 CFLAGS="$CFLAGS -DWITH_FONTCONFIG" |
|
1060 CFLAGS="$CFLAGS `$fontconfig_config --cflags | tr '\n\r' ' '`" |
|
1061 |
|
1062 if [ "$enable_static" != "0" ] |
|
1063 then |
|
1064 if [ "$os" = "OSX" ] |
|
1065 then |
|
1066 LIBS="$LIBS `$fontconfig_config --prefix`/lib/libfontconfig.a" |
|
1067 else |
|
1068 LIBS="$LIBS `$fontconfig_config --libs --static | tr '\n\r' ' '`" |
|
1069 fi |
|
1070 else |
|
1071 LIBS="$LIBS `$fontconfig_config --libs | tr '\n\r' ' '`" |
|
1072 fi |
|
1073 fi |
|
1074 |
|
1075 if [ "$with_direct_music" != "0" ] |
|
1076 then |
|
1077 CFLAGS="$CFLAGS -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT" |
|
1078 fi |
|
1079 |
|
1080 if [ "$with_iconv" != "0" ] |
|
1081 then |
|
1082 CFLAGS="$CFLAGS -DWITH_ICONV" |
|
1083 LIBS="$LIBS -liconv" |
|
1084 if [ "$with_iconv" != "2" ] |
|
1085 then |
|
1086 CFLAGS="$CFLAGS -I$with_iconv/include" |
|
1087 LIBS="$LIBS -L$with_iconv/lib" |
|
1088 fi |
|
1089 fi |
|
1090 |
|
1091 if [ -n "$with_midi" ] |
|
1092 then |
|
1093 CFLAGS="$CFLAGS -DEXTERNAL_PLAYER=\"$with_midi\"" |
|
1094 fi |
|
1095 if [ -n "$with_midi_arg" ] |
|
1096 then |
|
1097 CFLAGS="$CFLAGS -DMIDI_ARG=\"$with_midi_arg\"" |
|
1098 fi |
|
1099 |
|
1100 if [ "$enable_dedicated" != "0" ] |
|
1101 then |
|
1102 CFLAGS="$CFLAGS -DDEDICATED" |
|
1103 fi |
|
1104 |
|
1105 if [ "$enable_network" != "0" ] |
|
1106 then |
|
1107 CFLAGS="$CFLAGS -DENABLE_NETWORK" |
|
1108 |
|
1109 if [ "$os" = "BEOS" ] |
|
1110 then |
|
1111 LDFLAGS="$LDFLAGS -lbind -lsocket" |
|
1112 fi |
|
1113 |
|
1114 if [ "$os" = "SUNOS" ] |
|
1115 then |
|
1116 LDFLAGS="$LDFLAGS -lnsl -lsocket" |
|
1117 fi |
|
1118 fi |
|
1119 |
|
1120 if [ "$enable_static" != "0" ] |
|
1121 then |
|
1122 # OSX can't handle -static in LDFLAGS |
|
1123 if [ "$os" != "OSX" ] |
|
1124 then |
|
1125 LDFLAGS="$LDFLAGS -static" |
|
1126 fi |
|
1127 fi |
|
1128 |
|
1129 if [ "$enable_assert" = "0" ] |
|
1130 then |
|
1131 CFLAGS="$CFLAGS -DNDEBUG" |
|
1132 fi |
|
1133 |
|
1134 if [ "$enable_osx_g5" != "0" ] |
|
1135 then |
|
1136 CFLAGS="$CFLAGS -mtune=970 -mcpu=970 -mpowerpc-gpopt" |
|
1137 fi |
|
1138 |
|
1139 if [ "$with_osx_sysroot" != "0" ] && [ "$with_osx_sysroot" != "3" ] |
|
1140 then |
|
1141 CFLAGS="$CFLAGS -isysroot /Developer/SDKs/MacOSX$with_osx_sysroot.sdk" |
|
1142 LDFLAGS="$LDFLAGS -Wl,-syslibroot,/Developer/SDKs/MacOSX$with_osx_sysroot.sdk" |
|
1143 fi |
|
1144 |
|
1145 # TODO: remove next few lines of code when the search path patch has been applied |
|
1146 if [ -n "$second_data_dir" ] |
|
1147 then |
|
1148 CFLAGS="$CFLAGS -DSECOND_DATA_DIR=\\\\\"$second_data_dir\\\\\"" |
|
1149 fi |
|
1150 |
|
1151 if [ -n "$custom_lang_dir" ] |
|
1152 then |
|
1153 CFLAGS="$CFLAGS -DCUSTOM_LANG_DIR=\\\\\"$custom_lang_dir\\\\\"" |
|
1154 fi |
|
1155 # TODO: remove till here |
|
1156 |
|
1157 if [ "$enable_install" = "1" ] |
|
1158 then |
|
1159 if [ -n "$personal_dir" ] |
|
1160 then |
|
1161 CFLAGS="$CFLAGS -DUSE_HOMEDIR=1 -DPERSONAL_DIR=\\\\\"$personal_dir/\\\\\"" |
|
1162 fi |
|
1163 |
|
1164 if [ -n "$data_dir" ] |
|
1165 then |
|
1166 CFLAGS="$CFLAGS -DGAME_DATA_DIR=\\\\\"$prefix_dir/$data_dir/\\\\\"" |
|
1167 fi |
|
1168 |
|
1169 if [ -n "$icon_dir" ] |
|
1170 then |
|
1171 CFLAGS="$CFLAGS -DICON_DIR=\\\\\"$prefix_dir/$icon_dir/\\\\\"" |
|
1172 fi |
|
1173 fi |
|
1174 |
|
1175 if [ -n "$revision" ] |
|
1176 then |
|
1177 log 1 "checking revision... $revision" |
|
1178 log 1 "WARNING: we do not advise you to use this setting" |
|
1179 log 1 "WARNING: in most cases it is not safe for network use" |
|
1180 log 1 "WARNING: USE WITH CAUTION!" |
|
1181 |
|
1182 sleep 5 |
|
1183 elif [ -f "$ROOT_DIR/version" ] |
|
1184 then |
|
1185 revision="`cat $ROOT_DIR/version`" |
|
1186 |
|
1187 log 1 "checking revision... $revision" |
|
1188 else |
|
1189 revision="" |
|
1190 |
|
1191 log 1 "checking revision... svn detection" |
|
1192 fi |
|
1193 |
|
1194 log 1 "using CFLAGS... $CFLAGS $CC_CFLAGS" |
|
1195 log 1 "using LDFLAGS... $LIBS $LDFLAGS" |
|
1196 |
|
1197 # Makedepend doesn't like something like: -isysroot /OSX/blabla |
|
1198 # so convert it to: -isysroot -OSX/blabla. makedepend just ignores |
|
1199 # any - command it doesn't know, so we are pretty save. |
|
1200 # Lovely hackish, not? |
|
1201 # Btw, this almost always comes from outside the configure, so it is |
|
1202 # not something we can control. |
|
1203 if [ "$with_makedepend" != "0" ] |
|
1204 then |
|
1205 cflags_makedep="` echo "$CFLAGS" | sed 's# /# -#g'`" |
|
1206 else |
|
1207 makedepend="" |
|
1208 fi |
|
1209 } |
|
1210 |
|
1211 check_compiler() { |
|
1212 # Params: |
|
1213 # $1 - Type for message (build / host) |
|
1214 # $2 - What to fill with the found compiler |
|
1215 # $3 - System to try |
|
1216 # $4 - Compiler to try |
|
1217 # $5 - Env-setting to try |
|
1218 # $6 - GCC alike to try |
|
1219 # $7 - CC alike to try |
|
1220 # $8 - "0" gcc, "1" g++, "2" windres, "3" strip, "4" lipo |
|
1221 # $9 - What the command is to check for |
|
1222 |
|
1223 if [ -n "$3" ] |
|
1224 then |
|
1225 # Check for system |
|
1226 machine=`$3-$6 $9 2>/dev/null` |
|
1227 ret=$? |
|
1228 eval "$2=$3-$6" |
|
1229 |
|
1230 log 2 "executing $3-$6 $9" |
|
1231 log 2 " returned $machine" |
|
1232 log 2 " exit code $ret" |
|
1233 |
|
1234 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ] |
|
1235 then |
|
1236 log 1 "checking $1... $3-$6 not found" |
|
1237 log 1 "I couldn't detect any $6 binary for $3" |
|
1238 exit 1 |
|
1239 fi |
|
1240 |
|
1241 if [ "$machine" != "$3" ] && ( [ "$8" = "0" ] || [ "$8" = "1" ] ) |
|
1242 then |
|
1243 log 1 "checking $1... expected $3, found $machine" |
|
1244 log 1 "the compiler suggests it doesn't build code for the machine you specified" |
|
1245 exit 1 |
|
1246 fi |
|
1247 elif [ -n "$4" ] |
|
1248 then |
|
1249 # Check for manual compiler |
|
1250 machine=`$4 $9 2>/dev/null` |
|
1251 ret=$? |
|
1252 eval "$2=$4" |
|
1253 |
|
1254 log 2 "executing $4 $9" |
|
1255 log 2 " returned $machine" |
|
1256 log 2 " exit code $ret" |
|
1257 |
|
1258 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ] |
|
1259 then |
|
1260 log 1 "checking $1... $4 not found" |
|
1261 log 1 "the selected binary doesn't seem to be a $6 binary" |
|
1262 exit 1 |
|
1263 fi |
|
1264 else |
|
1265 # Nothing given, autodetect |
|
1266 |
|
1267 if [ -n "$5" ] |
|
1268 then |
|
1269 machine=`$5 $9 2>/dev/null` |
|
1270 ret=$? |
|
1271 eval "$2=$5" |
|
1272 |
|
1273 log 2 "executing $5 $9" |
|
1274 log 2 " returned $machine" |
|
1275 log 2 " exit code $ret" |
|
1276 |
|
1277 # The user defined a GCC that doesn't reply to $9.. abort |
|
1278 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ] |
|
1279 then |
|
1280 log 1 "checking $1... $5 unusable" |
|
1281 log 1 "the CC environment variable is set, but it doesn't seem to be a $6 binary" |
|
1282 log 1 "please redefine the CC/CXX environment to a $6 binary" |
|
1283 exit 1 |
|
1284 fi |
|
1285 else |
|
1286 log 2 "checking $1... CC/CXX not set (skipping)" |
|
1287 |
|
1288 # No $5, so try '$6' |
|
1289 machine=`$6 $9 2>/dev/null` |
|
1290 ret=$? |
|
1291 eval "$2=$6" |
|
1292 |
|
1293 log 2 "executing $6 $9" |
|
1294 log 2 " returned $machine" |
|
1295 log 2 " exit code $ret" |
|
1296 |
|
1297 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ] |
|
1298 then |
|
1299 # Maybe '$7'? |
|
1300 machine=`$7 $9 2>/dev/null` |
|
1301 ret=$? |
|
1302 eval "$2=$7" |
|
1303 |
|
1304 log 2 "executing $7 $9" |
|
1305 log 2 " returned $machine" |
|
1306 log 2 " exit code $ret" |
|
1307 |
|
1308 # All failed, abort |
|
1309 if [ -z "$machine" ] |
|
1310 then |
|
1311 log 1 "checking $1... $6 not found" |
|
1312 log 1 "I couldn't detect any $6 binary on your system" |
|
1313 log 1 "please define the CC/CXX environment to where it is located" |
|
1314 |
|
1315 exit 1 |
|
1316 fi |
|
1317 fi |
|
1318 fi |
|
1319 fi |
|
1320 |
|
1321 if [ "$8" != "0" ] |
|
1322 then |
|
1323 eval "res=\$$2" |
|
1324 log 1 "checking $1... $res" |
|
1325 else |
|
1326 log 1 "checking $1... $machine" |
|
1327 fi |
|
1328 } |
|
1329 |
|
1330 check_build() { |
|
1331 check_compiler "build system type" "cc_build" "$build" "$cc_build" "$CC" "gcc" "cc" "0" "-dumpmachine" |
|
1332 } |
|
1333 |
|
1334 check_host() { |
|
1335 # By default the host is the build |
|
1336 if [ -z "$host" ]; then host="$build"; fi |
|
1337 check_compiler "host system type" "cc_host" "$host" "$cc_host" "$CC" "gcc" "cc" "0" "-dumpmachine" |
|
1338 } |
|
1339 |
|
1340 check_cxx() { |
|
1341 check_compiler "host g++" "cxx_host" "$host" "$cxx_host" "$CXX" "g++" "c++" 1 "-dumpmachine" |
|
1342 } |
|
1343 |
|
1344 check_windres() { |
|
1345 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] |
|
1346 then |
|
1347 check_compiler "host windres" "windres" "$host" "$windres" "$WINDRES" "windres" "windres" "2" "-V" |
|
1348 fi |
|
1349 } |
|
1350 |
|
1351 check_strip() { |
|
1352 if [ "$os" = "OSX" ] |
|
1353 then |
|
1354 # Most targets have -V in strip, to see if they exists... OSX doesn't.. so execute something |
|
1355 echo "int main(int argc, char *argv[]) { }" > strip.test.c |
|
1356 $cc_host strip.test.c -o strip.test |
|
1357 check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "strip.test" |
|
1358 rm -f strip.test.c strip.test |
|
1359 else |
|
1360 check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "-V" |
|
1361 fi |
|
1362 } |
|
1363 |
|
1364 check_lipo() { |
|
1365 if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ] |
|
1366 then |
|
1367 echo "int main(int argc, char *argv[]) { }" > lipo.test.c |
|
1368 $cc_host lipo.test.c -o lipo.test |
|
1369 check_compiler "host lipo" "lipo" "$host" "$lipo" "$LIPO" "lipo" "lipo" "4" "-info lipo.test" |
|
1370 rm -f lipo.test.c lipo.test |
|
1371 fi |
|
1372 } |
|
1373 |
|
1374 check_direct_music() { |
|
1375 echo " |
|
1376 #include <windows.h> |
|
1377 #include <dmksctrl.h> |
|
1378 #include <dmusici.h> |
|
1379 #include <dmusicc.h> |
|
1380 #include <dmusicf.h> |
|
1381 int main(int argc, char *argv[]) { }" > direct_music.test.c |
|
1382 $cxx_host $CFLAGS direct_music.test.c -o direct_music.test 2> /dev/null |
|
1383 res=$? |
|
1384 rm -f direct_music.test.c direct_music.test |
|
1385 |
|
1386 if [ "$res" != "0" ] |
|
1387 then |
|
1388 if [ "$with_direct_music" = "2" ] |
|
1389 then |
|
1390 log 1 "configure: error: direct-music is not available on this system" |
|
1391 exit 1 |
|
1392 fi |
|
1393 with_direct_music="0" |
|
1394 |
|
1395 log 1 "checking direct-music... not found" |
|
1396 else |
|
1397 log 1 "checking direct-music... found" |
|
1398 fi |
|
1399 } |
|
1400 |
|
1401 check_makedepend() { |
|
1402 if [ "$with_makedepend" = "0" ] |
|
1403 then |
|
1404 log 1 "checking makedepend... disabled" |
|
1405 return |
|
1406 fi |
|
1407 |
|
1408 if [ "$with_makedepend" = "1" ] || [ "$with_makedepend" = "2" ] |
|
1409 then |
|
1410 makedepend="makedepend" |
|
1411 else |
|
1412 makedepend="$with_makedepend" |
|
1413 fi |
|
1414 |
|
1415 rm -f makedepend.tmp |
|
1416 touch makedepend.tmp |
|
1417 res=`$makedepend -fmakedepend.tmp 2>/dev/null` |
|
1418 res=$? |
|
1419 log 2 "executing $makedepend -f makedepend.tmp" |
|
1420 log 2 " returned `cat makedepend.tmp`" |
|
1421 log 2 " exit code $ret" |
|
1422 |
|
1423 if [ -z "`cat makedepend.tmp`" ] |
|
1424 then |
|
1425 rm -f makedepend.tmp makedepend.tmp.bak |
|
1426 |
|
1427 if [ "$with_makedepend" = "2" ] |
|
1428 then |
|
1429 log 1 "checking makedepend... not found" |
|
1430 |
|
1431 log 1 "I couldn't detect any makedepend on your system" |
|
1432 log 1 "please locate it via --makedepend=[binary]" |
|
1433 |
|
1434 exit 1 |
|
1435 elif [ "$with_makedepend" != "1" ] |
|
1436 then |
|
1437 log 1 "checking makedepend... $makedepend not found" |
|
1438 |
|
1439 log 1 "the selected file doesn't seem to be a valid makedepend binary" |
|
1440 |
|
1441 exit 1 |
|
1442 else |
|
1443 log 1 "checking makedepend... not found" |
|
1444 |
|
1445 with_makedepend="0" |
|
1446 return |
|
1447 fi |
|
1448 fi |
|
1449 |
|
1450 rm -f makedepend.tmp makedepend.tmp.bak |
|
1451 |
|
1452 log 1 "checking makedepend... $makedepend" |
|
1453 } |
|
1454 |
|
1455 detect_os() { |
|
1456 if [ $os = "DETECT" ] |
|
1457 then |
|
1458 # Detect UNIX, OSX, FREEBSD, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW and OS2 |
|
1459 |
|
1460 # Try first via dumpmachine, then via uname |
|
1461 os=`echo "$host" | tr [:upper:] [:lower:] | awk ' |
|
1462 /linux/ { print "UNIX"; exit} |
|
1463 /darwin/ { print "OSX"; exit} |
|
1464 /freebsd/ { print "FREEBSD"; exit} |
|
1465 /morphos/ { print "MORPHOS"; exit} |
|
1466 /beos/ { print "BEOS"; exit} |
|
1467 /sunos/ { print "SUNOS"; exit} |
|
1468 /cygwin/ { print "CYGWIN"; exit} |
|
1469 /mingw/ { print "MINGW"; exit} |
|
1470 /os\/2/ { print "OS2"; exit} |
|
1471 '` |
|
1472 |
|
1473 if [ -z "$os" ] |
|
1474 then |
|
1475 os=`LC_ALL=C uname | tr [:upper:] [:lower:] | awk ' |
|
1476 /linux/ { print "UNIX"; exit} |
|
1477 /darwin/ { print "OSX"; exit} |
|
1478 /freebsd/ { print "FREEBSD"; exit} |
|
1479 /morphos/ { print "MORPHOS"; exit} |
|
1480 /beos/ { print "BEOS"; exit} |
|
1481 /sunos/ { print "SUNOS"; exit} |
|
1482 /cygwin/ { print "CYGWIN"; exit} |
|
1483 /mingw/ { print "MINGW"; exit} |
|
1484 /os\/2/ { print "OS2"; exit} |
|
1485 '` |
|
1486 fi |
|
1487 |
|
1488 if [ -z "$os" ] |
|
1489 then |
|
1490 log 1 "detecting OS... none detected" |
|
1491 log 1 "I couldn't detect your OS. Please use --with-os=OS to force one" |
|
1492 log 1 "Allowed values are: UNIX, OSX, FREEBSD, MORPHOS, BEOS, SUNOS, CYGWIN, and MINGW" |
|
1493 exit 1 |
|
1494 fi |
|
1495 |
|
1496 log 1 "detecting OS... $os" |
|
1497 else |
|
1498 log 1 "forcing OS... $os" |
|
1499 fi |
|
1500 } |
|
1501 |
|
1502 detect_sdl() { |
|
1503 # 0 means no, 1 is auto-detect, 2 is force |
|
1504 if [ "$with_sdl" = "0" ] |
|
1505 then |
|
1506 log 1 "checking SDL... disabled" |
|
1507 |
|
1508 sdl_config="" |
|
1509 return 0 |
|
1510 fi |
|
1511 |
|
1512 if [ "$with_sdl" = "2" ] && [ "$with_cocoa" = "2" ] |
|
1513 then |
|
1514 log 1 "configure: error: it is impossible to compile both SDL and COCOA" |
|
1515 log 1 "configure: error: please deselect one of them and try again" |
|
1516 exit 1 |
|
1517 fi |
|
1518 |
|
1519 if [ "$with_sdl" = "2" ] && [ "$enable_dedicated" != "0" ] |
|
1520 then |
|
1521 log 1 "configure: error: it is impossible to compile a dedicated with SDL" |
|
1522 log 1 "configure: error: please deselect one of them and try again" |
|
1523 exit 1 |
|
1524 fi |
|
1525 |
|
1526 if [ "$enable_dedicated" != "0" ] |
|
1527 then |
|
1528 log 1 "checking SDL... skipping" |
|
1529 |
|
1530 sdl_config="" |
|
1531 return 0 |
|
1532 fi |
|
1533 |
|
1534 # By default on OSX we don't use SDL. The rest is auto-detect |
|
1535 if [ "$with_sdl" = "1" ] && [ "$os" = "OSX" ] && [ "$with_cocoa" != "0" ] |
|
1536 then |
|
1537 log 1 "checking SDL... OSX, skipping" |
|
1538 |
|
1539 sdl_config="" |
|
1540 return 0 |
|
1541 fi |
|
1542 |
|
1543 if [ "$with_sdl" = "1" ] || [ "$with_sdl" = "" ] || [ "$with_sdl" = "2" ] |
|
1544 then |
|
1545 if [ "$os" = "FREEBSD" ] |
|
1546 then |
|
1547 sdl_config="sdl11-config" |
|
1548 else |
|
1549 sdl_config="sdl-config" |
|
1550 fi |
|
1551 else |
|
1552 sdl_config="$with_sdl" |
|
1553 fi |
|
1554 |
|
1555 version=`$sdl_config --version 2>/dev/null` |
|
1556 ret=$? |
|
1557 log 2 "executing $sdl_config --version" |
|
1558 log 2 " returned $version" |
|
1559 log 2 " exit code $ret" |
|
1560 |
|
1561 if [ -z $version ] || [ "$ret" != "0" ] |
|
1562 then |
|
1563 log 1 "checking SDL... not found" |
|
1564 |
|
1565 # It was forced, so it should be found. |
|
1566 if [ "$with_sdl" != "1" ] |
|
1567 then |
|
1568 log 1 "configure: error: sdl-config couldn't be found" |
|
1569 log 1 "configure: error: you supplied '$with_sdl', but it seems invalid" |
|
1570 exit 1 |
|
1571 fi |
|
1572 |
|
1573 sdl_config="" |
|
1574 return 0 |
|
1575 fi |
|
1576 |
|
1577 log 1 "checking SDL... found" |
|
1578 } |
|
1579 |
|
1580 detect_cocoa() { |
|
1581 # 0 means no, 1 is auto-detect, 2 is force |
|
1582 if [ "$with_cocoa" = "0" ] |
|
1583 then |
|
1584 log 1 "checking COCOA... disabled" |
|
1585 |
|
1586 return 0 |
|
1587 fi |
|
1588 |
|
1589 if [ "$with_cocoa" = "2" ] && [ "$enable_dedicated" != "0" ] |
|
1590 then |
|
1591 log 1 "configure: error: it is impossible to compile a dedicated with COCOA" |
|
1592 log 1 "configure: error: please deselect one of them and try again" |
|
1593 exit 1 |
|
1594 fi |
|
1595 |
|
1596 if [ "$enable_dedicated" != "0" ] |
|
1597 then |
|
1598 log 1 "checking COCOA... skipping" |
|
1599 |
|
1600 with_cocoa="0" |
|
1601 return 0 |
|
1602 fi |
|
1603 |
|
1604 # By default on OSX we use COCOA. The rest doesn't support it |
|
1605 if [ "$with_cocoa" = "1" ] && [ "$os" != "OSX" ] |
|
1606 then |
|
1607 log 1 "checking COCOA... not OSX, skipping" |
|
1608 |
|
1609 with_cocoa="0" |
|
1610 return 0 |
|
1611 fi |
|
1612 |
|
1613 if [ "$os" != "OSX" ] |
|
1614 then |
|
1615 log 1 "checking COCOA... not OSX" |
|
1616 |
|
1617 log 1 "configure: error: COCOA video driver is only supported for OSX" |
|
1618 exit 1 |
|
1619 fi |
|
1620 |
|
1621 log 1 "checking COCOA... found" |
|
1622 } |
|
1623 |
|
1624 detect_zlib() { |
|
1625 # 0 means no, 1 is auto-detect, 2 is force |
|
1626 if [ "$with_zlib" = "0" ] |
|
1627 then |
|
1628 log 1 "checking zlib... disabled" |
|
1629 |
|
1630 zlib="" |
|
1631 return 0 |
|
1632 fi |
|
1633 |
|
1634 log 2 "detecting zlib" |
|
1635 |
|
1636 if [ "$with_zlib" = "1" ] || [ "$with_zlib" = "" ] || [ "$with_zlib" = "2" ] |
|
1637 then |
|
1638 zlib=`ls -1 /usr/include/*.h 2>/dev/null | grep "\/zlib.h$"` |
|
1639 if [ -z "$zlib" ] |
|
1640 then |
|
1641 log 2 " trying /usr/include/zlib.h... no" |
|
1642 zlib=`ls -1 /usr/local/include/*.h 2>/dev/null | grep "\/zlib.h$"` |
|
1643 fi |
|
1644 if [ -z "$zlib" ] |
|
1645 then |
|
1646 log 2 " trying /usr/local/include/zlib.h... no" |
|
1647 fi |
|
1648 |
|
1649 if [ -n "$zlib" ] && [ "$enable_static" != "0" ] && [ "$os" != "OSX" ] |
|
1650 then |
|
1651 log 2 " trying $zlib... found" |
|
1652 # Now find the static lib, if needed |
|
1653 zlib=`ls /lib/*.a 2>/dev/null | grep "\/libz.a$"` |
|
1654 if [ -z "$zlib" ] |
|
1655 then |
|
1656 log 2 " trying /lib/libz.a... no" |
|
1657 zlib=`ls /usr/lib/*.a 2>/dev/null | grep "\/libz.a$"` |
|
1658 fi |
|
1659 if [ -z "$zlib" ] |
|
1660 then |
|
1661 log 2 " trying /usr/lib/libz.a... no" |
|
1662 zlib=`ls /usr/local/lib/*.a 2>/dev/null | grep "\/libz.a$"` |
|
1663 fi |
|
1664 if [ -z "$zlib" ] |
|
1665 then |
|
1666 log 2 " trying /usr/local/lib/libz.a... no" |
|
1667 log 1 "configure: error: zlib couldn't be found" |
|
1668 log 1 "configure: error: you requested a static link, but I can't find zlib.a" |
|
1669 |
|
1670 exit 1 |
|
1671 fi |
|
1672 fi |
|
1673 else |
|
1674 # Make sure it exists |
|
1675 zlib=`ls $with_zlib 2>/dev/null` |
|
1676 fi |
|
1677 |
|
1678 if [ -z "$zlib" ] |
|
1679 then |
|
1680 log 1 "checking zlib... not found" |
|
1681 if [ "$with_zlib" = "2" ] |
|
1682 then |
|
1683 log 1 "configure: error: zlib couldn't be found" |
|
1684 |
|
1685 exit 1 |
|
1686 elif [ "$with_zlib" != "1" ] |
|
1687 then |
|
1688 log 1 "configure: error: zlib couldn't be found" |
|
1689 log 1 "configure: error: you supplied '$with_zlib', but it seems invalid" |
|
1690 |
|
1691 exit 1 |
|
1692 fi |
|
1693 |
|
1694 return 0 |
|
1695 fi |
|
1696 |
|
1697 log 2 " trying $zlib... found" |
|
1698 |
|
1699 log 1 "checking zlib... found" |
|
1700 } |
|
1701 |
|
1702 detect_png() { |
|
1703 # 0 means no, 1 is auto-detect, 2 is force |
|
1704 if [ "$with_png" = "0" ] |
|
1705 then |
|
1706 log 1 "checking libpng... disabled" |
|
1707 |
|
1708 png_config="" |
|
1709 return 0 |
|
1710 fi |
|
1711 |
|
1712 if [ "$with_zlib" = "0" ] || [ "$zlib" = "" ] |
|
1713 then |
|
1714 log 1 "configure: error: libpng depends on zlib, which couldn't be found / was disabled" |
|
1715 log 1 "configure: error: please supply --with-zlib, with a valid zlib location" |
|
1716 exit 1 |
|
1717 fi |
|
1718 |
|
1719 if [ "$with_png" = "1" ] || [ "$with_png" = "" ] || [ "$with_png" = "2" ] |
|
1720 then |
|
1721 png_config="libpng-config" |
|
1722 else |
|
1723 png_config="$with_png" |
|
1724 fi |
|
1725 |
|
1726 version=`$png_config --version 2>/dev/null` |
|
1727 ret=$? |
|
1728 log 2 "executing $png_config --version" |
|
1729 log 2 " returned $version" |
|
1730 log 2 " exit code $ret" |
|
1731 |
|
1732 if [ -z "$version" ] || [ "$ret" != "0" ] |
|
1733 then |
|
1734 log 1 "checking libpng... not found" |
|
1735 |
|
1736 # It was forced, so it should be found. |
|
1737 if [ "$with_png" != "1" ] |
|
1738 then |
|
1739 log 1 "configure: error: libpng-config couldn't be found" |
|
1740 log 1 "configure: error: you supplied '$with_png', but it seems invalid" |
|
1741 exit 1 |
|
1742 fi |
|
1743 |
|
1744 png_config="" |
|
1745 return 0 |
|
1746 fi |
|
1747 |
|
1748 log 1 "checking libpng... found" |
|
1749 } |
|
1750 |
|
1751 detect_freetype() { |
|
1752 # 0 means no, 1 is auto-detect, 2 is force |
|
1753 if [ "$with_freetype" = "0" ] |
|
1754 then |
|
1755 log 1 "checking libfreetype... disabled" |
|
1756 |
|
1757 freetype_config="" |
|
1758 return 0 |
|
1759 fi |
|
1760 |
|
1761 if [ "$with_zlib" = "0" ] || [ "$zlib" = "" ] |
|
1762 then |
|
1763 log 1 "configure: error: libfreetype depends on zlib, which couldn't be found / was disabled" |
|
1764 log 1 "configure: error: please supply --with-zlib, with a valid zlib location" |
|
1765 exit 1 |
|
1766 fi |
|
1767 |
|
1768 if [ "$with_freetype" = "1" ] || [ "$with_freetype" = "" ] || [ "$with_freetype" = "2" ] |
|
1769 then |
|
1770 freetype_config="freetype-config" |
|
1771 else |
|
1772 freetype_config="$with_freetype" |
|
1773 fi |
|
1774 |
|
1775 version=`$freetype_config --version 2>/dev/null` |
|
1776 ret=$? |
|
1777 log 2 "executing freetype_config --version" |
|
1778 log 2 " returned $version" |
|
1779 log 2 " exit code $ret" |
|
1780 |
|
1781 if [ -z "$version" ] || [ "$ret" != "0" ] |
|
1782 then |
|
1783 log 1 "checking libfreetype... not found" |
|
1784 |
|
1785 # It was forced, so it should be found. |
|
1786 if [ "$with_freetype" != "1" ] |
|
1787 then |
|
1788 log 1 "configure: error: freetype-config couldn't be found" |
|
1789 log 1 "configure: error: you supplied '$with_freetype', but it seems invalid" |
|
1790 exit 1 |
|
1791 fi |
|
1792 |
|
1793 freetype_config="" |
|
1794 return 0 |
|
1795 fi |
|
1796 |
|
1797 log 1 "checking libfreetype... found" |
|
1798 } |
|
1799 |
|
1800 detect_fontconfig() { |
|
1801 # 0 means no, 1 is auto-detect, 2 is force |
|
1802 if [ "$with_fontconfig" = "0" ] |
|
1803 then |
|
1804 log 1 "checking libfontconfig... disabled" |
|
1805 |
|
1806 fontconfig_config="" |
|
1807 return 0 |
|
1808 fi |
|
1809 |
|
1810 if [ "$with_fontconfig" = "1" ] || [ "$with_fontconfig" = "" ] || [ "$with_fontconfig" = "2" ] |
|
1811 then |
|
1812 fontconfig_config="pkg-config fontconfig" |
|
1813 else |
|
1814 fontconfig_config="$with_fontconfig" |
|
1815 fi |
|
1816 |
|
1817 version=`$fontconfig_config --modversion 2>/dev/null` |
|
1818 ret=$? |
|
1819 shortversion=`echo $version | cut -c 1,3` |
|
1820 log 2 "executing $fontconfig_config --modversion" |
|
1821 log 2 " returned $version" |
|
1822 log 2 " exit code $ret" |
|
1823 |
|
1824 if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$shortversion" -le "22" ] |
|
1825 then |
|
1826 if [ -n "$shortversion" ] && [ "$shortversion" -le "22" ] |
|
1827 then |
|
1828 log 1 "checking libfontconfig... needs at least version 2.3.0, fontconfig NOT enabled" |
|
1829 else |
|
1830 log 1 "checking libfontconfig... not found" |
|
1831 fi |
|
1832 |
|
1833 # It was forced, so it should be found. |
|
1834 if [ "$with_fontconfig" != "1" ] |
|
1835 then |
|
1836 log 1 "configure: error: fontconfig-config couldn't be found" |
|
1837 log 1 "configure: error: you supplied '$with_fontconfig', but it seems invalid" |
|
1838 exit 1 |
|
1839 fi |
|
1840 |
|
1841 fontconfig_config="" |
|
1842 return 0 |
|
1843 fi |
|
1844 |
|
1845 log 1 "checking libfontconfig... found" |
|
1846 } |
|
1847 |
|
1848 detect_iconv() { |
|
1849 # 0 means no, 1 is auto-detect, 2 is force |
|
1850 if [ "$with_iconv" = "0" ] |
|
1851 then |
|
1852 log 1 "checking iconv... disabled" |
|
1853 |
|
1854 return 0 |
|
1855 fi |
|
1856 |
|
1857 if [ "$with_iconv" = "1" ] && [ "$os" != "OSX" ] |
|
1858 then |
|
1859 log 1 "checking iconv... not OSX, skipping" |
|
1860 with_iconv="0" |
|
1861 |
|
1862 return 0 |
|
1863 fi |
|
1864 |
|
1865 # Try to find iconv.h, seems to only thing to detect iconv with |
|
1866 |
|
1867 if [ "$with_iconv" = "1" ] || [ "$with_iconv" = "" ] || [ "$with_iconv" = "2" ] |
|
1868 then |
|
1869 iconv=`ls -1 /usr/include 2>/dev/null | grep "iconv.h"` |
|
1870 if [ -z "$iconv" ] |
|
1871 then |
|
1872 iconv=`ls -1 /usr/local/include 2>/dev/null | grep "iconv.h"` |
|
1873 fi |
|
1874 else |
|
1875 # Make sure it exists |
|
1876 iconv=`ls $with_iconv/include/iconv.h 2>/dev/null` |
|
1877 fi |
|
1878 |
|
1879 if [ -z "$iconv" ] |
|
1880 then |
|
1881 log 1 "checking iconv... not found" |
|
1882 if [ "$with_iconv" = "2" ] |
|
1883 then |
|
1884 log 1 "configure: error: iconv couldn't be found" |
|
1885 |
|
1886 exit 1 |
|
1887 elif [ "$with_iconv" != "1" ] |
|
1888 then |
|
1889 log 1 "configure: error: iconv couldn't be found" |
|
1890 log 1 "configure: error: you supplied '$with_iconv', but I couldn't detect iconv in it" |
|
1891 |
|
1892 exit 1 |
|
1893 fi |
|
1894 |
|
1895 return 0 |
|
1896 fi |
|
1897 |
|
1898 if [ "$with_iconv" = "1" ] |
|
1899 then |
|
1900 with_iconv="2" |
|
1901 fi |
|
1902 |
|
1903 log 2 "found iconv in $iconv" |
|
1904 |
|
1905 log 1 "checking iconv... found" |
|
1906 } |
|
1907 |
|
1908 _detect_sort() { |
|
1909 sort_test_in="d |
|
1910 a |
|
1911 c |
|
1912 b" |
|
1913 |
|
1914 sort_test_out="a |
|
1915 b |
|
1916 c |
|
1917 d" |
|
1918 |
|
1919 log 2 "running echo <array> | $1" |
|
1920 |
|
1921 if [ "`echo \"$sort_test_in\" | $1 2>/dev/null`" = "$sort_test_out" ] |
|
1922 then |
|
1923 sort="$1" |
|
1924 log 2 " result was valid" |
|
1925 else |
|
1926 log 2 " result was invalid" |
|
1927 fi |
|
1928 } |
|
1929 |
|
1930 detect_sort() { |
|
1931 if [ "$with_sort" = "0" ] |
|
1932 then |
|
1933 log 1 "checking sort... disabled" |
|
1934 |
|
1935 return |
|
1936 fi |
|
1937 |
|
1938 if [ "$with_sort" = "1" ] || [ "$with_sort" = "2" ] |
|
1939 then |
|
1940 _detect_sort "sort" |
|
1941 if [ -z "$sort" ]; then _detect_sort "/sbin/sort"; fi |
|
1942 if [ -z "$sort" ]; then _detect_sort "/usr/sbin/sort"; fi |
|
1943 if [ -z "$sort" ]; then _detect_sort "/usr/local/sbin/sort"; fi |
|
1944 if [ -z "$sort" ]; then _detect_sort "/bin/sort"; fi |
|
1945 if [ -z "$sort" ]; then _detect_sort "/usr/bin/sort"; fi |
|
1946 if [ -z "$sort" ]; then _detect_sort "/usr/local/bin/sort"; fi |
|
1947 else |
|
1948 _detect_sort "$with_sort" |
|
1949 fi |
|
1950 |
|
1951 if [ -z "$sort" ] |
|
1952 then |
|
1953 if [ "$with_sort" = "2" ] |
|
1954 then |
|
1955 log 1 "checking sort... not found" |
|
1956 |
|
1957 log 1 "configure: error: couldn't detect sort on your system" |
|
1958 exit 1 |
|
1959 elif [ "$with_sort" != "1" ] |
|
1960 then |
|
1961 log 1 "checking sort... $with_sort not found" |
|
1962 |
|
1963 log 1 "configure: error: '$with_sort' doesn't look like a sort to me" |
|
1964 log 1 "configure: error: please verify its location and function and try again" |
|
1965 |
|
1966 exit 1 |
|
1967 else |
|
1968 log 1 "checking sort... not found" |
|
1969 fi |
|
1970 else |
|
1971 log 1 "checking sort... $sort" |
|
1972 fi |
|
1973 } |
|
1974 |
|
1975 make_sed() { |
|
1976 # We check here if we are PPC, because then we need to enable FOUR_BYTE_BOOL |
|
1977 # We do this here, and not sooner, so universal builds also have this |
|
1978 # automaticly correct |
|
1979 # FOUR_BYTE_BOOL is needed, because C++ uses 4byte for a bool on PPC, where |
|
1980 # we use 1 byte per bool normally in C part. So convert that last one to 4 |
|
1981 # bytes too, but only for PPC. |
|
1982 ppc=`$cc_host -dumpmachine | grep "powerpc\|ppc"` |
|
1983 if [ -n "$ppc" ] |
|
1984 then |
|
1985 T_CFLAGS="$CFLAGS -DFOUR_BYTE_BOOL" |
|
1986 osx_sysroot_version=10.3.9 |
|
1987 else |
|
1988 T_CFLAGS="$CFLAGS" |
|
1989 osx_sysroot_version=10.4u |
|
1990 fi |
|
1991 |
|
1992 T_LDFLAGS="$LDFLAGS" |
|
1993 if [ "$with_osx_sysroot" = "3" ] |
|
1994 then |
|
1995 T_CFLAGS="$T_CFLAGS -isysroot /Developer/SDKs/MacOSX$osx_sysroot_version.sdk" |
|
1996 T_LDFLAGS="$T_LDFLAGS -Wl,-syslibroot,/Developer/SDKs/MacOSX$osx_sysroot_version.sdk" |
|
1997 fi |
|
1998 |
|
1999 SRC_OBJS_DIR="$BASE_SRC_OBJS_DIR/$OBJS_SUBDIR" |
|
2000 |
|
2001 # All the data needed to compile a single target |
|
2002 # Make sure if you compile multiple targets to |
|
2003 # use multiple OBJS_DIR, because all in-between |
|
2004 # binaries are stored in there, and nowhere else. |
|
2005 SRC_REPLACE=" |
|
2006 s#!!CC_HOST!!#$cc_host#g; |
|
2007 s#!!CXX_HOST!!#$cxx_host#g; |
|
2008 s#!!CC_BUILD!!#$cc_build#g; |
|
2009 s#!!WINDRES!!#$windres#g; |
|
2010 s#!!STRIP!!#$strip $strip_arg#g; |
|
2011 s#!!LIPO!!#$lipo#g; |
|
2012 s#!!CC_CFLAGS!!#$CC_CFLAGS#g; |
|
2013 s#!!CFLAGS!!#$T_CFLAGS#g; |
|
2014 s#!!CFLAGS_BUILD!!#$CFLAGS_BUILD#g; |
|
2015 s#!!STRGEN_FLAGS!!#$strgen_flags#g; |
|
2016 s#!!LIBS!!#$LIBS#g; |
|
2017 s#!!LDFLAGS!!#$T_LDFLAGS#g; |
|
2018 s#!!BIN_DIR!!#$BIN_DIR#g; |
|
2019 s#!!ROOT_DIR!!#$ROOT_DIR#g; |
|
2020 s#!!MEDIA_DIR!!#$MEDIA_DIR#g; |
|
2021 s#!!SOURCE_LIST!!#$SOURCE_LIST#g; |
|
2022 s#!!SRC_OBJS_DIR!!#$SRC_OBJS_DIR#g; |
|
2023 s#!!LANG_OBJS_DIR!!#$LANG_OBJS_DIR#g; |
|
2024 s#!!SRC_DIR!!#$SRC_DIR#g; |
|
2025 s#!!OSXAPP!!#$OSXAPP#g; |
|
2026 s#!!LANG_DIR!!#$LANG_DIR#g; |
|
2027 s#!!TTD!!#$TTD#g; |
|
2028 s#!!BINARY_DIR!!#$prefix_dir/$binary_dir#g; |
|
2029 s#!!DATA_DIR!!#$prefix_dir/$data_dir#g; |
|
2030 s#!!ICON_DIR!!#$prefix_dir/$icon_dir#g; |
|
2031 s#!!PERSONAL_DIR!!#$personal_dir#g; |
|
2032 s#!!INSTALL_DIR!!#$install_dir#g; |
|
2033 s#!!STRGEN!!#$STRGEN#g; |
|
2034 s#!!ENDIAN_CHECK!!#$ENDIAN_CHECK#g; |
|
2035 s#!!ENDIAN_FORCE!!#$endian#g; |
|
2036 s#!!STAGE!!#$STAGE#g; |
|
2037 s#!!MAKEDEPEND!!#$makedepend#g; |
|
2038 s#!!CFLAGS_MAKEDEP!!#$cflags_makedep#g; |
|
2039 s#!!SORT!!#$sort#g; |
|
2040 s#!!CONFIG_CACHE_COMPILER!!#config.cache.compiler#g; |
|
2041 s#!!CONFIG_CACHE_LINKER!!#config.cache.linker#g; |
|
2042 s#!!CONFIG_CACHE_ENDIAN!!#config.cache.endian#g; |
|
2043 s#!!CONFIG_CACHE_SOURCE!!#config.cache.source#g; |
|
2044 s#!!CONFIG_CACHE_VERSION!!#config.cache.version#g; |
|
2045 s#!!CONFIG_CACHE_SOURCE_LIST!!#config.cache.source.list#g; |
|
2046 s#!!LANG_SUPPRESS!!#$lang_suppress#g; |
|
2047 s#!!OBJS_C!!#$OBJS_C#g; |
|
2048 s#!!OBJS_CPP!!#$OBJS_CPP#g; |
|
2049 s#!!OBJS_M!!#$OBJS_M#g; |
|
2050 s#!!OBJS_RC!!#$OBJS_RC#g; |
|
2051 s#!!SRCS!!#$SRCS#g; |
|
2052 s#!!OS!!#$os#g; |
|
2053 s#!!CONFIGURE_FILES!!#$CONFIGURE_FILES#g; |
|
2054 s#!!REVISION!!#$revision#g; |
|
2055 s#!!ENABLE_INSTALL!!#$enable_install#g; |
|
2056 " |
|
2057 } |
|
2058 |
|
2059 generate_main() { |
|
2060 STAGE="[MAIN]" |
|
2061 |
|
2062 make_sed |
|
2063 |
|
2064 # Create the main Makefile |
|
2065 echo "Generating Makefile..." |
|
2066 cat $ROOT_DIR/Makefile.in | sed "$SRC_REPLACE" > Makefile |
|
2067 echo "# Auto-generated file -- DO NOT EDIT" > Makefile.am |
|
2068 echo "" > Makefile.am |
|
2069 # Make the copy of the source-list, so we don't trigger an unwanted recompile |
|
2070 cp $SOURCE_LIST config.cache.source.list |
|
2071 # Make sure config.cache is OLDER then config.cache.source.list |
|
2072 touch config.cache |
|
2073 } |
|
2074 |
|
2075 generate_lang() { |
|
2076 STAGE="[LANG]" |
|
2077 |
|
2078 make_sed |
|
2079 |
|
2080 # Create the language file |
|
2081 mkdir -p $LANG_OBJS_DIR |
|
2082 |
|
2083 echo "Generating lang/Makefile..." |
|
2084 cat $ROOT_DIR/Makefile.lang.in | sed "$SRC_REPLACE" > $LANG_OBJS_DIR/Makefile |
|
2085 echo "DIRS += $LANG_OBJS_DIR" >> Makefile.am |
|
2086 echo "LANG_DIRS += $LANG_OBJS_DIR" >> Makefile.am |
|
2087 } |
|
2088 |
|
2089 generate_src_normal() { |
|
2090 STAGE=$1 |
|
2091 |
|
2092 make_sed |
|
2093 |
|
2094 # Create the source file |
|
2095 mkdir -p $SRC_OBJS_DIR |
|
2096 |
|
2097 echo "Generating $2/Makefile..." |
|
2098 cat $ROOT_DIR/Makefile.src.in | sed "$SRC_REPLACE" > $SRC_OBJS_DIR/Makefile |
|
2099 echo "DIRS += $SRC_OBJS_DIR" >> Makefile.am |
|
2100 echo "SRC_DIRS += $SRC_OBJS_DIR" >> Makefile.am |
|
2101 } |
|
2102 |
|
2103 generate_src_osx() { |
|
2104 cc_host_orig="$cc_host" |
|
2105 cxx_host_orig="$cxx_host" |
|
2106 |
|
2107 BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc" |
|
2108 cc_host="$cc_host_orig -arch ppc" |
|
2109 cxx_host="$cxx_host_orig -arch ppc" |
|
2110 generate_src_normal "[PowerPC]" "objs/ppc" |
|
2111 |
|
2112 BASE_SRC_OBJS_DIR="$OBJS_DIR/i386" |
|
2113 cc_host="$cc_host_orig -arch i386" |
|
2114 cxx_host="$cxx_host_orig -arch i386" |
|
2115 generate_src_normal "[i386]" "objs/i386" |
|
2116 |
|
2117 BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc970" |
|
2118 cc_host="$cc_host_orig -arch ppc970" |
|
2119 cxx_host="$cxx_host_orig -arch ppc970" |
|
2120 CFLAGS="$CFLAGS -mtune=970 -mcpu=970 -mpowerpc-gpopt" |
|
2121 generate_src_normal "[PowerPC G5]" "objs/ppc970" |
|
2122 } |
|
2123 |
|
2124 generate_src() { |
|
2125 if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ] |
|
2126 then |
|
2127 generate_src_osx |
|
2128 else |
|
2129 generate_src_normal "[SRC]" "objs" |
|
2130 fi |
|
2131 } |
|
2132 |
|
2133 showhelp() { |
|
2134 echo "'configure' configures OpenTTD." |
|
2135 echo "" |
|
2136 echo "Usage: $0 [OPTION]... [VAR=VALUE]..." |
|
2137 echo "" |
|
2138 echo "To assign environment variables (e.g., CC, CFLAGS...), specify them as" |
|
2139 echo "VAR=VALUE. See below for descriptions of some of the useful variables." |
|
2140 echo "" |
|
2141 echo "Defaults for the options are specified in brackets." |
|
2142 echo "" |
|
2143 echo "Configuration:" |
|
2144 echo " -h, --help display this help and exit" |
|
2145 echo "" |
|
2146 echo "System types:" |
|
2147 echo " --build=BUILD configure for building on BUILD [guessed]" |
|
2148 echo " --host=HOST cross-compile to build programs to run on HOST [BUILD]" |
|
2149 echo " --windres=WINDRES the windres to use [HOST-windres]" |
|
2150 echo " --strip=STRIP the strip to use [HOST-strip]" |
|
2151 echo " --lipo=LIPO the lipo to use (OSX ONLY) [HOST-lipo]" |
|
2152 echo " --os=OS the OS we are compiling for [DETECT]" |
|
2153 echo " DETECT/UNIX/OSX/FREEBSD/MORPHOS/BEOS/SUNOS/CYGWIN/MINGW" |
|
2154 echo " --endian=ENDIAN set the endian of the HOST (AUTO/LE/BE) [AUTO]" |
|
2155 echo " --revision=rXXXX overwrite the revision detection. Use with care!" |
|
2156 echo "" |
|
2157 echo "Paths:" |
|
2158 echo " --prefix-dir=dir specifies the prefix for all installed files [/usr/local]" |
|
2159 echo " --binary-dir=dir location of the binary. Will be prefixed with the" |
|
2160 echo " prefix-dir [games]" |
|
2161 echo " --data-dir=dir location of data files (lang, data, gm, scenario)." |
|
2162 echo " Will be prefixed with the prefix-dir [share/games/openttd]" |
|
2163 echo " --icon-dir=dir location of icons. Will be prefixed with the" |
|
2164 echo " prefix-dir [share/pixmaps]" |
|
2165 echo " --personal-dir=dir location of the personal directory []" |
|
2166 echo " --install-dir=dir specifies the root to install to. Useful to install" |
|
2167 echo " into jails [/]" |
|
2168 echo "" |
|
2169 # TODO: The Following 3 tags will be removed when the 'search path patch' is applied |
|
2170 echo " --second-data-dir=dir specifies a second directory for the data files" |
|
2171 echo " --custom-lang-dir=dir specifies a custom directory for the language files" |
|
2172 echo " --enable-install make a binary that uses the specified data-dir and icon-dir" |
|
2173 echo "" |
|
2174 echo "Features and packages:" |
|
2175 echo " --enable-debug[=LVL] enable debug-mode (LVL=[0123], 0 is release) [LVL=0]" |
|
2176 echo " --enable-profiling enables profiling (can be mixed with --enable-debug)" |
|
2177 echo " --enable-dedicated compile a dedicated server (without video-drivers)" |
|
2178 echo " --enable-static enable static compile (doesn't work for all HOSTs)" |
|
2179 echo " --enable-translator enable extra output for translators" |
|
2180 echo " --enable-universal enable universal builds (OSX ONLY)" |
|
2181 echo " --enable-osx-g5 enables optimalizations for G5 (OSX ONLY)" |
|
2182 echo " --disable-network disable network support" |
|
2183 echo " --disable-assert disable asserts (on error, program just continues)" |
|
2184 echo " --disable-strip disable any possible stripping" |
|
2185 echo " --without-osx-sysroot disable the automatic adding of sysroot (OSX ONLY)" |
|
2186 echo " --without-application-bundle disable generation of application bundle (OSX ONLY)" |
|
2187 echo " --with-direct-music enable direct music support (Win32 ONLY)" |
|
2188 echo " --with-sort=sort define a non-default location for sort" |
|
2189 echo " --with-midi=midi define which midi-player to use" |
|
2190 echo " --with-midi-arg=arg define which args to use for the midi-player" |
|
2191 echo " --with-cocoa enables COCOA video driver (OSX ONLY) support" |
|
2192 echo " --with-sdl[=sdl-config] enables SDL video driver support" |
|
2193 echo " --with-zlib[=zlib.a] enables zlib support" |
|
2194 echo " --with-png[=libpng-config] enables libpng support" |
|
2195 echo " --with-freetype[=freetype-config]" |
|
2196 echo " enables libfreetype support" |
|
2197 echo " --with-fontconfig[=pkg-config fontconfig]" |
|
2198 echo " enables fontconfig support" |
|
2199 echo " --with-iconv[=iconv-path] enables iconv support" |
|
2200 echo " --with-makedepend[=makedepend] enables makedepend support" |
|
2201 echo "" |
|
2202 echo "Some influential environment variables:" |
|
2203 echo " CC C compiler command" |
|
2204 echo " CXX C++ compiler command" |
|
2205 echo " CFLAGS C compiler flags" |
|
2206 echo " WINDRES windres command" |
|
2207 echo " LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries" |
|
2208 echo " in a nonstandard directory <lib dir>" |
|
2209 echo "" |
|
2210 echo "Use these variables to override the choices made by 'configure' or to help" |
|
2211 echo "it to find libraries and programs with nonstandard names/locations." |
|
2212 } |