3 # This file is part of OpenTTD.
4 # OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
5 # OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
6 # See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
15 echo "$@" >> $config_log
19 ignore_extra_parameters="0"
20 # We set all kinds of defaults for params. Later on the user can override
21 # most of them; but if they don't, this default is used.
35 config_log="config.log"
36 prefix_dir="/usr/local"
38 data_dir="share/games/openttd"
40 icon_dir="share/pixmaps"
51 enable_desync_debug="0"
64 enable_cocoa_quartz="1"
65 enable_cocoa_quickdraw="1"
67 with_application_bundle="1"
77 enable_builtin_depend="1"
141 enable_cocoa_quickdraw
143 with_application_bundle
152 enable_builtin_depend
171 CC CXX CFLAGS CXXFLAGS LDFLAGS CFLAGS_BUILD CXXFLAGS_BUILD LDFLAGS_BUILD"
175 # Walk over all params from the user and override any default settings if
176 # needed. This also handles any invalid option.
178 if [ -n "$prev_p" ]; then
184 optarg=`expr "x$p" : 'x[^=]*=\(.*\)'`
187 --help | -h | -\?) showhelp; exit 0;;
189 --config-log) prev_p="config_log";;
190 --config-log=*) config_log="$optarg";;
192 --build) prev_p="build";;
193 --build=*) build="$optarg";;
195 --host) prev_p="host";;
196 --host=*) host="$optarg";;
199 --os=*) os="$optarg";;
201 --cpu-type) prev_p="cpu_type";;
202 --cpu-type=*) cpu_type="$optarg";;
204 --cc-build) prev_p="cc_build";;
205 --cc-build=*) cc_build="$optarg";;
206 --cc-host) prev_p="cc_host";;
207 --cc-host=*) cc_host="$optarg";;
208 --cxx-build) prev_p="cxx_build";;
209 --cxx-build=*) cxx_build="$optarg";;
210 --cxx-host) prev_p="cxx_host";;
211 --cxx-host=*) cxx_host="$optarg";;
212 --windres) prev_p="windres";;
213 --windres=*) windres="$optarg";;
214 --awk) prev_p="awk";;
215 --awk=*) awk="$optarg";;
216 --strip) prev_p="strip";;
217 --strip=*) strip="$optarg";;
218 --lipo) prev_p="lipo";;
219 --lipo=*) lipo="$optarg";;
221 --endian) prev_p="endian";;
222 --endian=*) endian="$optarg";;
226 # Alias --prefix with --prefix-dir, for compatibility with GNU autotools
227 --prefix-dir | --prefix) prev_p="prefix_dir";;
228 --prefix-dir=* | --prefix=*) prefix_dir="$optarg";;
230 --binary-dir) prev_p="binary_dir";;
231 --binary-dir=*) binary_dir="$optarg";;
233 --data-dir) prev_p="data_dir";;
234 --data-dir=*) data_dir="$optarg";;
236 --doc-dir) prev_p="doc_dir";;
237 --doc-dir=*) doc_dir="$optarg";;
239 --icon-dir) prev_p="icon_dir";;
240 --icon-dir=*) icon_dir="$optarg";;
242 --icon-theme-dir) prev_p="icon_theme_dir";;
243 --icon-theme-dir=*) icon_theme_dir="$optarg";;
244 --without-icon-theme) icon_theme_dir="";;
246 --menu-dir) prev_p="menu_dir";;
247 --menu-dir=*) menu_dir="$optarg";;
248 --without-menu-entry) menu_dir="";;
250 --menu-name) prev_p="menu_name";;
251 --menu-name=*) menu_name="$optarg";;
253 --binary-name) prev_p="binary_name";;
254 --binary-name=*) binary_name="$optarg";;
256 --man-dir) prev_p="man_dir";;
257 --man-dir=*) man_dir="$optarg";;
259 --personal-dir) prev_p="personal_dir";;
260 --personal-dir=*) personal_dir="$optarg";;
261 --without-personal-dir) personal_dir="";;
263 --shared-dir) prev_p="shared_dir";;
264 --shared-dir=*) shared_dir="$optarg";;
265 --without-shared-dir) shared_dir="";;
267 --install-dir) prev_p="install_dir";;
268 --install-dir=*) install_dir="$optarg";;
272 --menu-group) prev_p="menu_group";;
273 --menu-group=*) menu_group="$optarg";;
277 --enable-debug) enable_debug="1";;
278 --enable-debug=*) enable_debug="$optarg";;
279 --enable-desync-debug) enable_desync_debug="1";;
280 --enable-desync-debug=*) enable_desync_debug="$optarg";;
281 --enable-profiling) enable_profiling="1";;
282 --enable-profiling=*) enable_profiling="$optarg";;
283 --enable-lto) enable_lto="1";;
284 --enable-lto=*) enable_lto="$optarg";;
285 --enable-ipo) enable_lto="1";;
286 --enable-ipo=*) enable_lto="$optarg";;
287 --enable-dedicated) enable_dedicated="1";;
288 --enable-dedicated=*) enable_dedicated="$optarg";;
289 --enable-network) enable_network="2";;
290 --enable-network=*) enable_network="$optarg";;
291 --disable-network) enable_network="0";;
292 --disable-static) enable_static="0";;
293 --enable-static) enable_static="2";;
294 --enable-static=*) enable_static="$optarg";;
295 --disable-translator) enable_translator="0";;
296 --enable-translator) enable_translator="2";;
297 --enable-translator=*) enable_translator="$optarg";;
298 --disable-assert) enable_assert="0";;
299 --enable-assert) enable_assert="2";;
300 --enable-assert=*) enable_assert="$optarg";;
301 --disable-strip) enable_strip="0";;
302 --enable-strip) enable_strip="2";;
303 --enable-strip=*) enable_strip="$optarg";;
304 --disable-universal) enable_universal="0";;
305 --enable-universal) enable_universal="i386 ppc";;
306 --enable-universal=*) enable_universal="$optarg";;
307 --disable-osx-g5) enable_osx_g5="0";;
308 --enable-osx-g5) enable_osx_g5="2";;
309 --enable-osx-g5=*) enable_osx_g5="$optarg";;
310 --disable-unicode) enable_unicode="0";;
311 --enable-unicode) enable_unicode="2";;
312 --enable-unicode=*) enable_unicode="$optarg";;
313 --disable-console) enable_console="0";;
314 --enable-console) enable_console="2";;
315 --enable-console=*) enable_console="$optarg";;
317 --disable-cocoa-quartz) enable_cocoa_quartz="0";;
318 --enable-cocoa-quartz) enable_cocoa_quartz="2";;
319 --enable-cocoa-quartz=*) enable_cocoa_quartz="$optarg";;
320 --disable-cocoa-quickdraw) enable_cocoa_quickdraw="0";;
321 --enable-cocoa-quickdraw) enable_cocoa_quickdraw="2";;
322 --enable-cocoa-quickdraw=*) enable_cocoa_quickdraw="$optarg";;
324 --with-allegro) with_allegro="2";;
325 --without-allegro) with_allegro="0";;
326 --with-allegro=*) with_allegro="$optarg";;
328 --with-sdl) with_sdl="2";;
329 --without-sdl) with_sdl="0";;
330 --with-sdl=*) with_sdl="$optarg";;
332 --with-cocoa) with_cocoa="2";;
333 --without-cocoa) with_cocoa="0";;
334 --with-cocoa=*) with_cocoa="$optarg";;
336 --with-zlib) with_zlib="2";;
337 --without-zlib) with_zlib="0";;
338 --with-zlib=*) with_zlib="$optarg";;
340 --with-lzma) with_lzma="2";;
341 --without-lzma) with_lzma="0";;
342 --with-lzma=*) with_lzma="$optarg";;
343 --with-liblzma) with_lzma="2";;
344 --without-liblzma) with_lzma="0";;
345 --with-liblzma=*) with_lzma="$optarg";;
347 --with-lzo2) with_lzo2="2";;
348 --without-lzo2) with_lzo2="0";;
349 --with-lzo2=*) with_lzo2="$optarg";;
350 --with-liblzo2) with_lzo2="2";;
351 --without-liblzo2) with_lzo2="0";;
352 --with-liblzo2=*) with_lzo2="$optarg";;
354 --with-xdg-basedir) with_xdg_basedir="2";;
355 --without-xdg-basedir) with_xdg_basedir="0";;
356 --with-xdg-basedir=*) with_xdg_basedir="$optarg";;
357 --with-libxdg-basedir) with_xdg_basedir="2";;
358 --without-libxdg-basedir) with_xdg_basedir="0";;
359 --with-libxdg-basedir=*) with_xdg_basedir="$optarg";;
361 --with-png) with_png="2";;
362 --without-png) with_png="0";;
363 --with-png=*) with_png="$optarg";;
364 --with-libpng) with_png="2";;
365 --without-libpng) with_png="0";;
366 --with-libpng=*) with_png="$optarg";;
368 --with-libtimidity) with_libtimidity="2";;
369 --without-libtimidity) with_libtimidity="0";;
370 --with-libtimidity=*) with_libtimidity="$optarg";;
372 --with-freetype) with_freetype="2";;
373 --without-freetype) with_freetype="0";;
374 --with-freetype=*) with_freetype="$optarg";;
375 --with-libfreetype) with_freetype="2";;
376 --without-libfreetype) with_freetype="0";;
377 --with-libfreetype=*) with_freetype="$optarg";;
379 --with-fontconfig) with_fontconfig="2";;
380 --without-fontconfig) with_fontconfig="0";;
381 --with-fontconfig=*) with_fontconfig="$optarg";;
382 --with-libfontconfig) with_fontconfig="2";;
383 --without-libfontconfig) with_fontconfig="0";;
384 --with-libfontconfig=*) with_fontconfig="$optarg";;
386 --with-icu) with_icu="2";;
387 --without-icu) with_icu="0";;
388 --with-icu=*) with_icu="$optarg";;
389 --with-libicu) with_icu="2";;
390 --without-libicu) with_icu="0";;
391 --with-libicu=*) with_icu="$optarg";;
392 --static-icu) static_icu="1";;
393 --static-icu=*) static_icu="$optarg";;
394 --static-libicu) static_icu="1";;
395 --static-libicu=*) static_icu="$optarg";;
397 --with-psp-config) with_psp_config="2";;
398 --without-psp-config) with_psp_config="0";;
399 --with-psp-config=*) with_psp_config="$optarg";;
401 --disable-builtin-depend) enable_builtin_depend="0";;
402 --enable-builtin-depend) enable_builtin_depend="2";;
403 --enable-builtin-depend=*) enable_builtin_depend="$optarg";;
405 --with-makedepend) with_makedepend="2";;
406 --without-makedepend) with_makedepend="0";;
407 --with-makedepend=*) with_makedepend="$optarg";;
409 --with-direct-music) with_direct_music="2";;
410 --without-direct-music) with_direct_music="0";;
411 --with-direct-music=*) with_direct_music="$optarg";;
413 --with-sort) with_sort="2";;
414 --without-sort) with_sort="0";;
415 --with-sort=*) with_sort="$optarg";;
417 --with-iconv) with_iconv="2";;
418 --without-iconv) with_iconv="0";;
419 --with-iconv=*) with_iconv="$optarg";;
421 --with-midi=*) with_midi="$optarg";;
422 --with-midi-arg=*) with_midi_arg="$optarg";;
424 --without-distcc) with_distcc="0";;
425 --with-distcc) with_distcc="2";;
426 --with-distcc=*) with_distcc="$optarg";;
428 --without-ccache) with_ccache="0";;
429 --with-ccache) with_ccache="2";;
430 --with-ccache=*) with_ccache="$optarg";;
432 --without-nforenum) with_nforenum="0";;
433 --with-nforenum) with_nforenum="2";;
434 --with-nforenum=*) with_nforenum="$optarg";;
436 --without-grfcodec) with_grfcodec="0";;
437 --with-grfcodec) with_grfcodec="2";;
438 --with-grfcodec=*) with_grfcodec="$optarg";;
440 --without-osx-sysroot) with_osx_sysroot="0";;
441 --with-osx-sysroot) with_osx_sysroot="2";;
442 --with-osx-sysroot=*) with_osx_sysroot="$optarg";;
444 --without-application-bundle) with_application_bundle="0";;
445 --with-application-bundle) with_application_bundle="1";;
446 --with-application-bundle=*) with_application_bundle="$optarg";;
448 --without-threads) with_threads="0";;
449 --with-threads) with_threads="1";;
450 --with-threads=*) with_threads="$optarg";;
452 --without-sse) with_sse="0";;
453 --with-sse) with_sse="1";;
454 --with-sse=*) with_sse="$optarg";;
456 CC=* | --CC=*) CC="$optarg";;
457 CXX=* | --CXX=*) CXX="$optarg";;
458 CFLAGS=* | --CFLAGS=*) CFLAGS="$optarg";;
459 CXXFLAGS=* | --CXXFLAGS=*) CXXFLAGS="$optarg";;
460 LDFLAGS=* | --LDFLAGS=*) LDFLAGS="$optarg";;
461 CFLAGS_BUILD=* | --CFLAGS_BUILD=* | --CFLAGS-BUILD=*) CFLAGS_BUILD="$optarg";;
462 CXXFLAGS_BUILD=* | --CXXFLAGS_BUILD=* | --CXXFLAGS-BUILD=*) CXXFLAGS_BUILD="$optarg";;
463 LDFLAGS_BUILD=* | --LDFLAGS_BUILD=* | --LDFLAGS-BUILD=*) LDFLAGS_BUILD="$optarg";;
465 --ignore-extra-parameters) ignore_extra_parameters="1";;
468 if [ "$ignore_extra_parameters" = "0" ]; then
469 log 1 "Unknown option $p"
472 log 1 "Unknown option $p ignored"
478 if [ -n "$prev_p" ]; then
479 log 1 "configure: error: missing argument to --$prev_p"
484 echo "" > $config_log
485 log 2 "Invocation: $0 $*"
489 # Here we save all params, so we can later on do an exact redo of this
490 # configuration, without having the user to re-input stuff
492 echo "Running configure with following options:" >> $config_log
493 echo "" >> $config_log
495 configure="$CONFIGURE_EXECUTABLE --ignore-extra-parameters"
496 for p in $save_params_array; do
498 p=`echo "$p" | sed 's@_@-@g;s@\n@@g;s@ @\\ @g'`
499 # Only save those params that aren't empty
500 configure="$configure --$p=\"$v\""
503 echo "$configure" >> $config_log
504 echo "$configure" > config.cache
505 echo "" >> $config_log
509 # Some params want to be in full uppercase, else they might not work as
510 # expected.. fix that here
512 endian=`echo $endian | tr '[a-z]' '[A-Z]'`
513 os=`echo $os | tr '[a-z]' '[A-Z]'`
514 cpu_type=`echo $cpu_type | tr '[a-z]' '[A-Z]'`
516 # Check if all params have valid values
518 # Endian only allows AUTO, LE and, BE
519 if ! echo $endian | egrep -q '^(AUTO|LE|BE|PREPROCESSOR)$'; then
520 log 1 "configure: error: invalid option --endian=$endian"
521 log 1 " Available options are: --endian=[AUTO|LE|BE]"
524 if [ "$endian" = "PREPROCESSOR" ] && [ "$os" != "OSX" ]; then
525 log 1 "configure: error: invalid option --endian=$endian"
526 log 1 " PREPROCESSOR is only available for OSX"
529 # OS only allows DETECT, UNIX, OSX, FREEBSD, OPENBSD, MORPHOS, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP
530 if ! echo $os | egrep -q '^(DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP)$'; then
531 log 1 "configure: error: invalid option --os=$os"
532 log 1 " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP]"
535 # cpu_type can be either 32 or 64
536 if ! echo $cpu_type | egrep -q '^(32|64|DETECT)$'; then
537 log 1 "configure: error: invalid option --cpu-type=$cpu_type"
538 log 1 " Available options are: --cpu-type[=DETECT|32|64]"
541 # enable_debug should be between 0 and 4
542 if ! echo $enable_debug | egrep -q '^[0123]$'; then
543 log 1 "configure: error: invalid option --enable-debug=$enable_debug"
544 log 1 " Available options are: --enable-debug[=0123]"
548 # enable_desync_debug should be between 0 and 3
549 if ! echo $enable_desync_debug | egrep -q '^[012]$'; then
550 log 1 "configure: error: invalid option --enable-desync-debug=$enable_desync_debug"
551 log 1 " Available options are: --enable-desync-debug[=012]"
562 # Check for universal builds; they only make sense for OSX, so fail if enabled for another OS
563 if [ "$enable_universal" = "0" ]; then
564 log 1 "checking universal build... no"
566 if [ "$os" != "OSX" ]; then
567 log 1 "configure: error: --enable-universal only works on OSX"
570 log 1 "checking universal build... yes, for: $enable_universal"
573 # Already detected by check_build
574 log 1 "checking build cc... $cc_build"
575 log 1 "checking host cc... $cc_host"
580 if [ "$enable_strip" != "0" ]; then
583 log 1 "checking strip... disabled"
587 if [ "$enable_builtin_depend" != "0" ]; then
588 log 1 "checking builtin depend... yes"
589 makedepend="\$(SRC_OBJS_DIR)/\$(DEPEND)"
591 log 1 "checking builtin depend... no"
596 detect_sse_capable_architecture
598 if [ "$enable_static" = "1" ]; then
599 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "DOS" ]; then
606 if [ "$enable_static" != "0" ]; then
607 log 1 "checking static... yes"
609 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "OSX" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "DOS" ]; then
610 log 1 "WARNING: static is only known to work on Windows, DOS, MacOSX and MorphOS"
611 log 1 "WARNING: use static at your own risk on this platform"
616 log 1 "checking static... no"
619 if [ "$enable_unicode" = "1" ]; then
620 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "DOS" ]; then
627 if [ "$enable_unicode" != "0" ]; then
628 log 1 "checking unicode... yes"
630 log 1 "checking unicode... no"
633 # Show what we configured
634 if [ "$enable_debug" = "0" ]; then
635 log 1 "using debug level... no"
636 elif [ "$enable_profiling" != "0" ]; then
637 log 1 "using debug level... profiling (debug level $enable_debug)"
639 log 1 "using debug level... level $enable_debug"
642 if [ "$enable_desync_debug" = "0" ]; then
643 log 1 "using desync debug level... no"
645 log 1 "using desync debug level... level $enable_desync_debug"
646 log 1 "WARNING: desync debug functions slow down the game considerably."
647 log 1 "WARNING: use only when you are instructed to do so"
648 log 1 " or when you know what you are doing."
653 if [ "$enable_lto" != "0" ]; then
654 # GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
655 if $cxx_build -dumpspecs 2>&1 | grep -q '\%{flto' || $cxx_build -help ipo 2>&1 | grep -q '\-ipo'; then
656 log 1 "using link time optimization... yes"
659 log 1 "using link time optimization... no"
660 log 1 "WARNING: you selected link time optimization but it is not found."
664 log 1 "using link time optimization... no"
668 if [ "$os" != "OSX" ] && [ "$with_osx_sysroot" != "0" ]; then
669 if [ "$with_osx_sysroot" = "1" ]; then
672 log 1 "checking OSX sysroot... not OSX, skipping"
674 log 1 "configure: error: --with-osx-sysroot only works if OSX is the target"
679 if [ "$with_osx_sysroot" != "0" ]; then
680 if [ "$enable_universal" = "0" ] && [ "$with_osx_sysroot" != "1" ] && [ "$with_osx_sysroot" != "2" ]; then
681 # Sysroot manually specified? Check for usability
682 log 1 "checking OSX sysroot... $with_osx_sysroot"
683 if ! check_osx_sdk "$with_osx_sysroot"; then
684 log 1 "Passed sysroot not found/not functional"
688 # If autodetect and no universal, use system default
689 if [ "$with_osx_sysroot" = "1" ] && [ "$enable_universal" = "0" ]; then
690 log 1 "checking OSX sysroot... no (use system default)"
692 log 1 "checking OSX sysroot... automatically"
697 if [ -n "$osx_sdk_path" ]; then
698 if [ "$enable_universal" != "0" ]; then
699 if [ -z "$osx_sdk_104_path" ]; then
700 log 1 "WARNING: Could not find a usable 10.4u SDK, the resulting"
701 log 1 "WARNING: binary will only run on OSX 10.5 or later"
702 osx_sdk_104_path="$osx_sdk_path"
704 OSX_SYSROOT="-isysroot $osx_sdk_104_path"
705 OSX_LD_SYSROOT="-Wl,-syslibroot,$osx_sdk_104_path"
707 OSX_SYSROOT="-isysroot $osx_sdk_path"
708 OSX_LD_SYSROOT="-Wl,-syslibroot,$osx_sdk_path"
712 if [ "$os" = "OSX" ]; then
713 log 1 "checking OSX sysroot... no (use system default)"
721 if [ "$enable_dedicated" != "0" ]; then
722 log 1 "checking GDI video driver... dedicated server, skipping"
723 log 1 "checking dedicated... found"
725 if [ "$enable_network" = "0" ]; then
726 log 1 "configure: error: building a dedicated server without network support is pointless"
730 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
731 log 1 "checking GDI video driver... found"
733 log 1 "checking GDI video driver... not Windows, skipping"
736 if [ -z "$allegro_config" ] && [ -z "$sdl_config" ] && [ "$with_cocoa" = 0 ] && [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
737 log 1 "configure: error: no video driver development files found"
738 log 1 " If you want a dedicated server use --enable-dedicated as parameter"
741 log 1 "checking dedicated... not selected"
745 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
746 log 1 "checking console application... not Windows, skipping"
747 elif [ "$enable_console" = "1" ] && [ "$enable_dedicated" != "0" ]; then
748 log 1 "checking console application... dedicated server, enabled"
750 elif [ "$enable_console" = "1" ]; then
751 log 1 "checking console application... disabled (only used when forced)"
753 elif [ "$enable_console" = "0" ]; then
754 log 1 "checking console application... disabled"
756 log 1 "checking console application... enabled"
759 if [ "$enable_network" = "1" ] && [ "$os" = "DOS" ]; then
760 log 1 "checking network... DOS, skipping"
762 elif [ "$enable_network" != "0" ]; then
763 log 1 "checking network... found"
765 log 1 "checking network... disabled"
768 log 1 "checking squirrel... found"
769 SCRIPT_SRC_DIR="$ROOT_DIR/src/3rdparty/squirrel/include"
771 if [ "$enable_translator" != "0" ]; then
772 log 1 "checking translator... debug"
773 # -t shows TODO items, normally they are muted
776 log 1 "checking translator... no"
780 if [ "$enable_assert" != "0" ]; then
781 log 1 "checking assert... enabled"
783 log 1 "checking assert... disabled"
786 pre_detect_with_zlib=$with_zlib
789 if [ "$with_zlib" = "0" ] || [ -z "$zlib" ]; then
790 log 1 "WARNING: zlib was not detected or disabled"
791 log 1 "WARNING: OpenTTD doesn't require zlib, but it does mean that many features"
792 log 1 "WARNING: (like loading most old savegames/scenarios, loading heightmaps,"
793 log 1 "WARNING: using PNG, or using fonts, ...) will be disabled."
794 if [ "$pre_detect_with_zlib" = "0" ]; then
795 log 1 "WARNING: We strongly suggest you to install zlib."
797 log 1 "configure: error: no zlib detected"
798 log 1 " If you want to compile without zlib use --without-zlib as parameter"
803 pre_detect_with_lzma=$with_lzma
806 if [ "$with_lzma" = "0" ] || [ -z "$lzma_config" ]; then
807 log 1 "WARNING: lzma was not detected or disabled"
808 log 1 "WARNING: OpenTTD doesn't require lzma, but it does mean that many features"
809 log 1 "WARNING: (like loading most savegames/scenarios and joining most servers)"
810 log 1 "WARNING: will be disabled."
811 if [ "$pre_detect_with_lzma" = "0" ]; then
812 log 1 "WARNING: We strongly suggest you to install liblzma."
813 log 1 "configure: error: no liblzma detected"
815 log 1 " If you want to compile without lzma use --without-lzma as parameter"
820 pre_detect_with_lzo2=$with_lzo2
823 if [ "$with_lzo2" = "0" ] || [ -z "$lzo2" ]; then
824 log 1 "WARNING: liblzo2 was not detected or disabled"
825 log 1 "WARNING: OpenTTD doesn't require liblzo2, but it does mean that"
826 log 1 "WARNING: loading old savegames/scenarios will be disabled."
827 if [ "$pre_detect_with_lzo2" = "0" ]; then
828 log 1 "WARNING: We strongly suggest you to install liblzo2."
830 log 1 "configure: error: no liblzo2 detected"
831 log 1 " If you want to compile without liblzo2 use --without-liblzo2 as parameter"
844 if [ "$with_direct_music" != "0" ]; then
845 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
846 if [ "$with_direct_music" != "1" ]; then
847 log 1 "configure: error: direct-music is only supported on Win32 targets"
850 with_direct_music="0"
852 log 1 "checking direct-music... not Windows, skipping"
860 if [ "$os" = "OSX" ] && [ "$endian" = "AUTO" ]; then
861 endian="PREPROCESSOR"
864 log 1 "checking endianess... $endian"
866 # Suppress language errors when there is a version defined, indicating a release
867 # It just isn't pretty if any release produces warnings in the languages.
868 if [ -f "$ROOT_DIR/version" ]; then
870 log 1 "suppress language errors... yes"
873 log 1 "suppress language errors... no"
876 if [ "$enable_debug" = "0" ] && [ "$enable_profiling" = "0" ] && [ "$enable_strip" != "0" ]; then
877 if [ "$os" = "MORPHOS" ]; then
878 strip_arg="--strip-all --strip-unneeded --remove-section .comment"
879 elif [ "$os" = "OSX" ]; then
881 elif [ "$os" = "OS2" ]; then
883 # OS2 uses strip via gcc, because it needs to be feed to emxbind
884 LDFLAGS="$LDFLAGS -s"
885 elif [ "$os" = "SUNOS" ]; then
886 # The GNU strip does know -s, the non-GNU doesn't
887 # So try to detect it (in a bit of an ugly way)
888 strip_arg="`$strip -s strip.test 2>/dev/null && echo \"-s\"`"
893 log 1 "checking stripping... $strip $strip_arg"
896 log 1 "checking stripping... skipped"
899 if [ "$with_distcc" = "0" ]; then
900 log 1 "checking distcc... no"
901 elif [ "$with_distcc" = "1" ]; then
904 log 1 "checking distcc... no (only used when forced)"
905 elif [ "$with_distcc" = "2" ]; then
908 distcc="$with_distcc"
910 if [ "$with_distcc" != "0" ]; then
911 res="`$distcc --version 2>/dev/null | head -n 1 | cut -b 1-6`"
912 if [ "$res" != "distcc" ]; then
914 log 1 "checking distcc... no"
915 if [ "$with_distcc" = "2" ]; then
916 log 1 "configure: error: no distcc detected, but was forced to be used"
919 if [ "$with_distcc" != "1" ]; then
920 log 1 "configure: error: '$with_distcc' doesn't seem a distcc to me"
925 log 1 "checking distcc... $distcc"
928 if [ "$with_ccache" = "0" ]; then
929 log 1 "checking ccache... no"
930 elif [ "$with_ccache" = "1" ]; then
933 log 1 "checking ccache... no (only used when forced)"
934 elif [ "$with_ccache" = "2" ]; then
937 ccache="$with_ccache"
939 if [ "$with_ccache" != "0" ]; then
940 res="`$ccache --version 2>/dev/null | head -n 1 | cut -b 1-6`"
941 if [ "$res" != "ccache" ]; then
943 log 1 "checking ccache... no"
944 if [ "$with_ccache" = "2" ]; then
945 log 1 "configure: error: no ccache detected, but was forced to be used"
948 if [ "$with_ccache" != "1" ]; then
949 log 1 "configure: error: '$with_ccache' doesn't seem a ccache to me"
954 log 1 "checking ccache... $ccache"
960 if [ -z "$grfcodec" ] && [ -n "$nforenum" ]; then
961 log 1 "checking nforenum/grfcodec... nforenum needs grfcodec enabled, disabling nforenum"
965 if [ -z "$nforenum" ] && [ -n "$grfcodec" ]; then
966 log 1 "checking nforenum/grfcodec... grfcodec needs nforenum enabled, disabling grfcodec"
970 if [ "$os" = "DOS" ]; then
974 if [ "$os" != "OSX" ] && [ "$with_application_bundle" != "0" ]; then
975 if [ "$with_application_bundle" = "1" ]; then
976 with_application_bundle="0"
978 log 1 "checking OSX application bundle... not OSX, skipping"
980 log 1 "configure: error: --with-application-bundle only works if OSX is the target"
985 if [ "$os" = "OSX" ] && [ "$with_application_bundle" = "1" ]; then
991 if [ "$os" = "OSX" ]; then
992 # Test on ppc970 (G5) - we can optimize there
994 if [ "$enable_osx_g5" != "0" ]; then
995 log 1 "detecting ppc970 (G5)... yes (forced)"
997 # First, are we a real OSX system, else we can't detect it
998 native=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | grep darwin`
999 # If $host doesn't match $build , we are cross-compiling
1000 if [ -n "$native" ] && [ "$build" = "$host" ]; then
1001 $cxx_build $SRC_DIR/os/macosx/G5_detector.cpp -o G5_detector
1004 if [ -n "$res" ]; then
1005 # This is G5, add flags for it
1008 log 1 "detecting ppc970 (G5)... yes"
1012 log 1 "detecting ppc970 (G5)... no"
1017 log 1 "detecting ppc970 (G5)... no (cross-compiling)"
1021 if [ "$enable_osx_g5" != "0" ]; then
1022 log 1 "configure: error: ppc970 (OSX G5) selected, but not compiling for OSX"
1023 log 1 "configure: error: either select OSX as OS, or deselect ppc970"
1029 if [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then
1030 log 1 "checking revision... svn detection"
1031 elif [ -d "$ROOT_DIR/../.svn" ] && [ -n "`svn help 2>/dev/null`" ] && LC_ALL=C svn info $ROOT_DIR/.. | grep -q '^URL:.*tags$'; then
1032 # subversion changed its behaviour; now not all folders have a .svn folder,
1033 # but only the root folder. Since making tags requires a (sparse) checkout
1034 # of the tags folder, the folder of the tag does not have a .svn folder
1035 # anymore and this fails to detect the subversion repository checkout.
1036 log 1 "checking revision... svn detection (tag)"
1037 elif [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then
1038 log 1 "checking revision... git detection"
1039 elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`hg help 2>/dev/null`" ]; then
1040 log 1 "checking revision... hg detection"
1041 elif [ -f "$ROOT_DIR/.ottdrev" ]; then
1042 log 1 "checking revision... source tarball"
1044 log 1 "checking revision... no detection"
1045 log 1 "WARNING: there is no means to determine the version."
1046 log 1 "WARNING: please use a subversion, mercurial, or git checkout of OpenTTD."
1047 log 1 "WARNING: you can only join game servers that have been compiled without"
1048 log 1 "WARNING: version detection."
1049 log 1 "WARNING: there is a great chance you desync."
1050 log 1 "WARNING: USE WITH CAUTION!"
1055 if [ "$doc_dir" = "1" ]; then
1056 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
1057 doc_dir="share/doc/openttd"
1059 doc_dir="$data_dir/docs"
1062 doc_dir="`echo $doc_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1065 if [ "$icon_theme_dir" = "1" ]; then
1066 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
1067 icon_theme_dir="share/icons/hicolor"
1072 icon_theme_dir="`echo $icon_theme_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1075 if [ "$personal_dir" = "1" ]; then
1076 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ] || [ "$os" = "DOS" ] || [ "$os" = "HAIKU" ]; then
1077 personal_dir="OpenTTD"
1078 elif [ "$os" = "OSX" ]; then
1079 personal_dir="Documents/OpenTTD"
1081 personal_dir=".openttd"
1084 personal_dir="`echo $personal_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1087 if [ "$shared_dir" = "1" ]; then
1088 # we are using default values
1089 if [ "$os" = "OSX" ]; then
1090 shared_dir="/Library/Application\\\\ Support/OpenTTD"
1095 shared_dir="`echo $shared_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1098 if [ "$man_dir" = "1" ]; then
1099 # add manpage on UNIX systems
1100 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OSX" ]; then
1101 man_dir="share/man/man6"
1106 man_dir="`echo $man_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1109 if [ "$menu_dir" = "1" ]; then
1110 # add a freedesktop menu item only for some UNIX systems
1111 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
1112 menu_dir="share/applications"
1117 menu_dir="`echo $menu_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1122 if [ -n "$personal_dir" ]
1124 log 1 "personal home directory... $personal_dir"
1126 log 1 "personal home directory... none"
1129 if [ -n "$shared_dir" ]
1131 log 1 "shared data directory... $shared_dir"
1133 log 1 "shared data directory... none"
1136 if [ -n "$install_dir" ]
1138 log 1 "installation directory... $install_dir"
1140 log 1 "installation directory... none"
1143 if [ -n "$icon_theme_dir" ]
1145 log 1 "icon theme directory... $icon_theme_dir"
1147 log 1 "icon theme directory... none"
1150 if [ -n "$man_dir" ]
1152 log 1 "manual page directory... $man_dir"
1154 log 1 "manual page directory... none"
1157 if [ -n "$menu_dir" ]
1159 log 1 "menu item directory... $menu_dir"
1161 log 1 "menu item directory... none"
1165 make_compiler_cflags() {
1168 # $2 - name of the cflags variable
1169 # $3 - name of the cxxflags variable
1170 # $4 - name of the ldflags variable
1171 # $5 - name of the features variable
1173 eval eval "flags=\\\$$2"
1174 eval eval "cxxflags=\\\$$3"
1175 eval eval "ldflags=\\\$$4"
1176 eval eval "features=\\\$$5"
1178 if [ `basename $1 | cut -c 1-3` = "icc" ]; then
1179 # Enable some things only for certain ICC versions
1180 cc_version=`$1 -dumpversion | cut -c 1-4 | sed s@\\\.@@g`
1182 flags="$flags -rdynamic"
1183 ldflags="$ldflags -rdynamic"
1185 if [ -z "$first_time_icc_check" ]; then
1186 first_time_icc_check=no
1187 if [ $cc_version -lt 90 ]; then
1188 log 1 "WARNING: you seem to be using a very old version of ICC"
1189 log 1 "WARNING: OpenTTD hasn't been tested with this version"
1191 elif [ $cc_version -lt 120 ]; then
1192 log 1 "WARNING: you seem to be using an unsupported ICC version"
1193 log 1 "WARNING: ICC older than 12.0 is known to fail to compile OpenTTD"
1198 flags="$flags -Wall"
1199 # remark #111: statement is unreachable
1200 flags="$flags -wd111"
1201 # remark #181: argument is incompatible with corresponding format string conversion
1202 # ICC is very picky about signedness of operands, warnings provided by GCC are enough
1203 flags="$flags -wd181"
1204 # remark #271: trailing comma is nonstandard
1205 flags="$flags -wd271"
1206 # remark #280: selector expression is constant
1207 flags="$flags -wd280"
1208 # remark #304: access control not specified ("public" by default)
1209 flags="$flags -wd304"
1210 # remark #383: value copied to temporary, reference to temporary used
1211 flags="$flags -wd383"
1212 # remark #444: destructor for base class ... is not virtual
1213 flags="$flags -wd444"
1214 # remark #593: variable ... was set but never used
1215 flags="$flags -wd593"
1216 # warning #654: overloaded virtual function ... is only partially overridden in class ...
1217 flags="$flags -wd654"
1218 # remark #810: conversion from ... to ... may lose significant bits
1219 flags="$flags -wd810"
1220 # remark #869: parameter ... was never referenced
1221 flags="$flags -wd869"
1222 # warning #873: function ... ::operator new ... has no corresponding operator delete ...
1223 flags="$flags -wd873"
1224 # remark #981: operands are evaluated in unspecified order
1225 flags="$flags -wd981"
1226 # remark #1418: external function definition with no prior declaration
1227 flags="$flags -wd1418"
1228 # remark #1419: external declaration in primary source file
1229 flags="$flags -wd1419"
1230 # remark #1572: floating-point equality and inequality
1231 flags="$flags -wd1572"
1232 # remark #1599: declaration hides variable/parameter ...
1233 flags="$flags -wd1599"
1234 # remark #1720: function ... ::operator new ... has no corresponding member operator delete ...
1235 flags="$flags -wd1720"
1237 if [ $cc_version -lt 110 ]; then
1238 # warns about system headers with recent glibc:
1239 # warning #1292: attribute "__nonnull__" ignored
1240 flags="$flags -wd1292"
1243 if [ $cc_version -ge 100 ]; then
1244 # warning #1899: multicharacter character literal (potential portability problem)
1245 flags="$flags -wd1899"
1246 # vec report defaults to telling where it did loop vectorisation, which is not very important
1247 flags="$flags -vec-report=0 "
1250 if [ $cc_version -ge 110 ]; then
1251 # remark #2259: non-pointer conversion from ... to ... may lose significant bits
1252 flags="$flags -wd2259"
1253 # Use c++0x mode so static_assert() is available
1254 cxxflags="$cxxflags -std=c++0x"
1257 if [ "$enable_lto" != "0" ] && $1 -help ipo | grep -q '\-ipo'; then
1258 # Use IPO (only if we see IPO exists and is requested)
1260 features="$features lto"
1262 elif basename $1 | grep -q 'clang'; then
1263 # Enable some things only for certain clang versions
1264 cc_version="`$1 -v 2>&1 | head -n 1 | sed s@[^0-9]@@g | cut -c 1-2`"
1266 # aliasing rules are not held in openttd code
1267 flags="$flags -fno-strict-aliasing"
1269 # -W alone doesn't enable all warnings enabled by -Wall; on the other hand,
1270 # -Weverything enables too many useless warnings that can't be disabled (as of 3.0)
1271 flags="$flags -Wall -W"
1273 # warning: unused parameter '...'
1274 flags="$flags -Wno-unused-parameter"
1276 # warning: expression result unused
1277 flags="$flags -Wno-unused-value"
1279 # warning: multi-character character constant
1280 flags="$flags -Wno-multichar"
1282 # warning: explicitly assigning a variable of type '...' to itself
1283 # it happens when using the FOR_ALL_WINDOWS_FROM_BACK_FROM macro
1284 flags="$flags -Wno-self-assign"
1286 if [ "$cc_version" -lt "30" ]; then
1287 # warning: equality comparison with extraneous parentheses
1288 flags="$flags -Wno-parentheses"
1289 # warning: operands of ? are integers of different signs: 'unsigned int' and 'int'
1290 flags="$flags -Wno-sign-compare"
1293 if [ "$cc_version" -ge "30" ]; then
1294 # warning: equality comparison with extraneous parentheses
1295 # this warning could be useful, but it warns about code in squirrel
1296 flags="$flags -Wno-parentheses-equality"
1299 if [ "$with_ccache" != "0" -o "$with_distcc" != "0" ]; then
1300 # ccache and distcc run separate preprocess and compile passes,
1301 # both are fed with the same CFLAGS. Unfortunately, clang
1302 # complains about -I when compiling preprocessed files:
1303 # "clang: warning: argument unused during compilation: '-I /usr/include'"
1304 flags="$flags -Qunused-arguments"
1307 if [ "$enable_assert" -eq "0" ]; then
1308 # do not warn about unused variables when building without asserts
1309 flags="$flags -Wno-unused-variable"
1312 # rdynamic is used to get useful stack traces from crash reports.
1313 ldflags="$ldflags -rdynamic"
1315 # Enable some things only for certain GCC versions
1316 cc_version=`$1 -dumpversion | cut -c 1,3`
1318 if [ $cc_version -lt 33 ]; then
1319 log 1 "configure: error: gcc older than 3.3 can't compile OpenTTD because of its poor template support"
1323 flags="$flags -Wall -Wno-multichar -Wsign-compare -Wundef"
1324 flags="$flags -Wwrite-strings -Wpointer-arith"
1325 flags="$flags -W -Wno-unused-parameter -Wredundant-decls"
1326 flags="$flags -Wformat=2 -Wformat-security"
1328 if [ $enable_assert -eq 0 ]; then
1329 # Do not warn about unused variables when building without asserts
1330 flags="$flags -Wno-unused-variable"
1331 if [ $cc_version -ge 46 ]; then
1332 # GCC 4.6 gives more warnings, disable them too
1333 flags="$flags -Wno-unused-but-set-variable"
1334 flags="$flags -Wno-unused-but-set-parameter"
1338 if [ $cc_version -ge 34 ]; then
1339 # Warn when a variable is used to initialise itself:
1341 flags="$flags -Winit-self"
1344 if [ $cc_version -ge 40 ]; then
1345 # GCC 4.0+ complains about that we break strict-aliasing.
1346 # On most places we don't see how to fix it, and it doesn't
1347 # break anything. So disable strict-aliasing to make the
1348 # compiler all happy.
1349 flags="$flags -fno-strict-aliasing"
1350 # Warn about casting-out 'const' with regular C-style cast.
1351 # The preferred way is const_cast<>() which doesn't warn.
1352 flags="$flags -Wcast-qual"
1355 if [ $cc_version -ge 42 ]; then
1356 # GCC 4.2+ automatically assumes that signed overflows do
1357 # not occur in signed arithmetics, whereas we are not
1358 # sure that they will not happen. It furthermore complains
1359 # about its own optimized code in some places.
1360 flags="$flags -fno-strict-overflow"
1361 # GCC 4.2 no longer includes -Wnon-virtual-dtor in -Wall.
1362 # Enable it in order to be consistent with older GCC versions.
1363 flags="$flags -Wnon-virtual-dtor"
1366 if [ $cc_version -ge 43 ]; then
1367 # Use gnu++0x mode so static_assert() is available.
1368 # Don't use c++0x, it breaks mingw (with gcc 4.4.0).
1369 cxxflags="$cxxflags -std=gnu++0x"
1372 if [ $cc_version -eq 45 ]; then
1373 # Prevent optimisation supposing enums are in a range specified by the standard
1374 # For details, see http://gcc.gnu.org/PR43680
1375 flags="$flags -fno-tree-vrp"
1378 if [ $cc_version -ge 47 ]; then
1379 # Disable -Wnarrowing which gives many warnings, such as:
1380 # warning: narrowing conversion of '...' from 'unsigned int' to 'int' inside { } [-Wnarrowing]
1381 # They are valid according to the C++ standard, but useless.
1382 cxxflags="$cxxflags -Wno-narrowing"
1383 # Disable bogus 'attempt to free a non-heap object' warning
1384 flags="$flags -Wno-free-nonheap-object"
1387 # GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
1388 if [ "$enable_lto" != "0" ] && $1 -dumpspecs | grep -q '\%{flto'; then
1389 # Use LTO only if we see LTO exists and is requested
1390 if [ $cc_version -lt 46 ]; then
1391 flags="$flags -flto"
1393 flags="$flags -flto=jobserver"
1395 ldflags="$ldflags -fwhole-program"
1396 features="$features lto"
1399 if $1 -dumpspecs | grep -q rdynamic; then
1400 # rdynamic is used to get useful stack traces from crash reports.
1401 flags="$flags -rdynamic"
1402 ldflags="$ldflags -rdynamic"
1406 eval "$2=\"$flags\""
1407 eval "$3=\"$cxxflags\""
1408 eval "$4=\"$ldflags\""
1409 eval "$5=\"$features\""
1412 make_cflags_and_ldflags() {
1413 # General CFlags for BUILD
1414 CFLAGS_BUILD="$CFLAGS_BUILD"
1415 # Special CXXFlags for BUILD
1416 CXXFLAGS_BUILD="$CXXFLAGS_BUILD"
1418 LDFLAGS_BUILD="$LDFLAGS_BUILD"
1419 # FEATURES for BUILD (lto)
1421 # General CFlags for HOST
1423 # Special CXXFlags for HOST
1424 CXXFLAGS="$CXXFLAGS"
1425 # Libs to compile. In fact this is just LDFLAGS
1427 # LDFLAGS used for HOST
1429 # FEATURES for HOST (lto)
1432 make_compiler_cflags "$cc_build" "CFLAGS_BUILD" "CXXFLAGS_BUILD" "LDFLAGS_BUILD" "FEATURES_BUILD"
1433 make_compiler_cflags "$cc_host" "CFLAGS" "CXXFLAGS" "LDFLAGS" "FEATURES"
1435 CFLAGS="$CFLAGS -D$os"
1437 if [ "$enable_debug" = "0" ]; then
1438 # No debug, add default stuff
1439 OBJS_SUBDIR="release"
1440 if [ "$os" = "MORPHOS" ]; then
1441 CFLAGS="-I/gg/os-include -noixemul -fstrict-aliasing -fexpensive-optimizations -mcpu=604 -fno-inline -mstring -mmultiple $CFLAGS"
1442 LDFLAGS="$LDFLAGS -noixemul"
1445 CFLAGS="-O2 -fomit-frame-pointer $CFLAGS"
1449 # Each debug level reduces the optimization by a bit
1450 if [ $enable_debug -ge 1 ]; then
1451 CFLAGS="$CFLAGS -g -D_DEBUG"
1452 if [ "$os" = "PSP" ]; then
1453 CFLAGS="$CFLAGS -G0"
1456 if [ $enable_debug -ge 2 ]; then
1457 CFLAGS="$CFLAGS -fno-inline"
1459 if [ $enable_debug -ge 3 ]; then
1460 CFLAGS="$CFLAGS -O0"
1462 CFLAGS="$CFLAGS -O2"
1466 if [ $enable_debug -le 2 ]; then
1467 if basename "$cc_host" | grep -q "gcc"; then
1468 # Define only when compiling with GCC. Some GLIBC versions use GNU
1469 # extensions in a way that breaks build with at least ICC.
1470 # This requires -O1 or more, so debug level 3 (-O0) is excluded.
1471 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
1474 if basename "$cc_build" | grep -q "gcc"; then
1475 # Just add -O1 to the tools needed for building.
1476 CFLAGS_BUILD="$CFLAGS_BUILD -D_FORTIFY_SOURCE=2 -O1"
1480 if [ "$os" = "OSX" ] && [ $cc_version -eq 40 ]; then
1481 # Apple's GCC 4.0 has a compiler bug for x86_64 with (higher) optimization,
1482 # wrongly optimizing ^= in loops. This disables the failing optimisation.
1483 CFLAGS="$CFLAGS -fno-expensive-optimizations"
1486 if [ "$enable_profiling" != "0" ]; then
1488 LDFLAGS="$LDFLAGS -pg"
1491 if [ "$with_threads" = "0" ]; then
1492 CFLAGS="$CFLAGS -DNO_THREADS"
1494 if [ "$with_sse" = "1" ]; then
1495 CFLAGS="$CFLAGS -DWITH_SSE"
1498 if [ "`echo $1 | cut -c 1-3`" != "icc" ]; then
1499 if [ "$os" = "CYGWIN" ]; then
1500 flags="$flags -mwin32"
1501 LDFLAGS="$LDFLAGS -mwin32"
1503 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
1504 if [ $cc_version -lt 46 ]; then
1505 flags="$flags -mno-cygwin"
1506 LDFLAGS="$LDFLAGS -mno-cygwin"
1509 if [ "$enable_console" != "0" ]; then
1510 LDFLAGS="$LDFLAGS -Wl,--subsystem,console"
1512 LDFLAGS="$LDFLAGS -Wl,--subsystem,windows"
1515 LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32 -limm32"
1517 if [ $cc_version -ge 44 ]; then
1518 LDFLAGS_BUILD="$LDFLAGS_BUILD -static-libgcc -static-libstdc++"
1520 if [ $cc_version -ge 47 ]; then
1521 CFLAGS="$CFLAGS -mno-ms-bitfields"
1526 if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
1527 LIBS="$LIBS -lpthread"
1530 if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ]; then
1533 if [ "$os" = "WINCE" ]; then
1534 LIBS="$LIBS -lcoredll -lcorelibc -laygshell -lws2 -e WinMainCRTStartup"
1536 if [ "$os" = "PSP" ]; then
1537 CFLAGS="$CFLAGS -I`$psp_config -p`/include"
1538 LDFLAGS="$LDFLAGS -L`$psp_config -p`/lib"
1540 CFLAGS="$CFLAGS -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150"
1541 LIBS="$LIBS -D_PSP_FW_VERSION=150 -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -lm"
1544 if [ "$os" = "MORPHOS" ]; then
1545 # -Wstrict-prototypes generates much noise because of system headers
1546 CFLAGS="$CFLAGS -Wno-strict-prototypes"
1549 if [ "$os" = "OPENBSD" ]; then
1550 LIBS="$LIBS -pthread"
1553 if [ "$os" = "FREEBSD" ]; then
1554 LIBS="$LIBS -lpthread"
1557 if [ "$os" = "OSX" ]; then
1558 LDFLAGS="$LDFLAGS -framework Cocoa"
1560 # Add macports include dir which is not always set a default system dir. This avoids zillions of bogus warnings.
1561 CFLAGS="$CFLAGS -isystem/opt/local/include"
1563 if [ "$enable_dedicated" = "0" ] && ([ "$cpu_type" = "32" ] || [ "$enable_universal" != "0" ]); then
1564 LIBS="$LIBS -framework QuickTime"
1566 CFLAGS="$CFLAGS -DNO_QUICKTIME"
1569 if [ "$enable_universal" = "0" ]; then
1570 # Universal builds set this elsewhere
1571 CFLAGS="$OSX_SYSROOT $CFLAGS"
1572 LDFLAGS="$OSX_LD_SYSROOT $LDFLAGS"
1575 if [ "$enable_universal" = "0" ] && [ $cc_version -gt 40 ]; then
1576 # Only set the min version when not doing an universal build.
1577 # Universal builds set the version elsewhere.
1578 if [ "$cpu_type" = "64" ]; then
1579 CFLAGS="$CFLAGS -mmacosx-version-min=10.5"
1581 gcc_cpu=`$cc_host -dumpmachine`
1582 if [ "`echo $gcc_cpu | cut -c 1-3`" = "ppc" -o "`echo $gcc_cpu | cut -c 1-7`" = "powerpc" ]; then
1583 # PowerPC build can run on 10.3
1584 CFLAGS="$CFLAGS -mmacosx-version-min=10.3"
1586 # Intel is only available starting from 10.4
1587 CFLAGS="$CFLAGS -mmacosx-version-min=10.4"
1593 if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ]; then
1594 LIBS="$LIBS -lmidi -lbe"
1597 # Most targets act like UNIX, just with some additions
1598 if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then
1599 CFLAGS="$CFLAGS -DUNIX"
1601 # And others like Windows
1602 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
1603 CFLAGS="$CFLAGS -DWIN"
1606 if [ -n "$allegro_config" ]; then
1607 CFLAGS="$CFLAGS -DWITH_ALLEGRO"
1608 CFLAGS="$CFLAGS `$allegro_config --cflags`"
1609 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
1610 if [ "$enable_static" != "0" ]; then
1611 LIBS="$LIBS `$allegro_config --static --libs`"
1613 LIBS="$LIBS `$allegro_config --libs`"
1618 if [ -n "$sdl_config" ]; then
1619 CFLAGS="$CFLAGS -DWITH_SDL"
1620 # SDL must not add _GNU_SOURCE as it breaks many platforms
1621 CFLAGS="$CFLAGS `$sdl_config --cflags | sed 's@-D_GNU_SOURCE[^ ]*@@'`"
1622 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
1623 if [ "$enable_static" != "0" ]; then
1624 LIBS="$LIBS `$sdl_config --static-libs`"
1626 LIBS="$LIBS `$sdl_config --libs`"
1631 if [ "$with_cocoa" != "0" ]; then
1632 CFLAGS="$CFLAGS -DWITH_COCOA"
1633 LIBS="$LIBS -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox"
1635 if [ "$enable_cocoa_quartz" != "0" ]; then
1636 CFLAGS="$CFLAGS -DENABLE_COCOA_QUARTZ"
1639 if [ "$enable_cocoa_quickdraw" != "0" ]; then
1640 CFLAGS="$CFLAGS -DENABLE_COCOA_QUICKDRAW"
1644 if [ "$with_zlib" != "0" ]; then
1645 if [ "$enable_static" != "0" ] && [ "$os" != "OSX" ]; then
1650 CFLAGS="$CFLAGS -DWITH_ZLIB"
1653 if [ -n "$lzma_config" ]; then
1654 CFLAGS="$CFLAGS -DWITH_LZMA"
1655 CFLAGS="$CFLAGS `$lzma_config --cflags | tr '\n\r' ' '`"
1657 if [ "$enable_static" != "0" ]; then
1658 CFLAGS="$CFLAGS -DLZMA_API_STATIC"
1659 LIBS="$LIBS `$lzma_config --libs --static | tr '\n\r' ' '`"
1661 LIBS="$LIBS `$lzma_config --libs | tr '\n\r' ' '`"
1665 if [ "$with_lzo2" != "0" ]; then
1666 if [ "$enable_static" != "0" ] && [ "$os" != "OSX" ]; then
1671 CFLAGS="$CFLAGS -DWITH_LZO"
1674 if [ -n "$xdg_basedir_config" ]; then
1675 CFLAGS="$CFLAGS -DWITH_XDG_BASEDIR"
1676 CFLAGS="$CFLAGS `$xdg_basedir_config --cflags | tr '\n\r' ' '`"
1678 if [ "$enable_static" != "0" ]; then
1679 LIBS="$LIBS `$xdg_basedir_config --libs --static | tr '\n\r' ' '`"
1681 LIBS="$LIBS `$xdg_basedir_config --libs | tr '\n\r' ' '`"
1685 # 64bit machines need -D_SQ64
1686 if [ "$cpu_type" = "64" ] && [ "$enable_universal" = "0" ]; then
1687 CFLAGS="$CFLAGS -D_SQ64"
1689 CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR"
1691 if [ -n "$png_config" ]; then
1692 CFLAGS="$CFLAGS -DWITH_PNG"
1693 CFLAGS="$CFLAGS `$png_config --cppflags --I_opts | tr '\n\r' ' '`"
1695 # The extra flags are unneeded for latest libpng-config, but some versions are so broken...
1696 if [ "$enable_static" != "0" ]; then
1697 if [ "$os" = "OSX" ]; then
1698 LIBS="$LIBS `$png_config --prefix`/lib/libpng.a"
1700 LIBS="$LIBS `$png_config --static --ldflags | tr '\n\r' ' '`"
1703 LIBS="$LIBS `$png_config --ldflags | tr '\n\r' ' '`"
1707 if [ -n "$fontconfig_config" ]; then
1708 CFLAGS="$CFLAGS -DWITH_FONTCONFIG"
1709 CFLAGS="$CFLAGS `$fontconfig_config --cflags | tr '\n\r' ' '`"
1711 if [ "$enable_static" != "0" ]; then
1712 if [ "$os" = "OSX" ]; then
1713 # fontconfig_config goes via pkg-config on all systems, which doesn't know --prefix
1714 # Also, despite the reason we link to the .a file ourself (because we can't use -static), we do need to ask pkg-config about possible other deps
1715 LIBS="$LIBS `$fontconfig_config --variable=prefix`/lib/libfontconfig.a `$fontconfig_config --libs --static | sed s@-lfontconfig@@`"
1717 LIBS="$LIBS `$fontconfig_config --libs --static | tr '\n\r' ' '`"
1720 LIBS="$LIBS `$fontconfig_config --libs | tr '\n\r' ' '`"
1724 if [ -n "$freetype_config" ]; then
1725 CFLAGS="$CFLAGS -DWITH_FREETYPE"
1726 CFLAGS="$CFLAGS `$freetype_config --cflags | tr '\n\r' ' '`"
1728 if [ "$enable_static" != "0" ]; then
1729 if [ "$os" = "OSX" ]; then
1730 LIBS="$LIBS `$freetype_config --prefix`/lib/libfreetype.a"
1732 # Is it possible to do static with freetype, if so: how?
1733 LIBS="$LIBS `$freetype_config --libs | tr '\n\r' ' '`"
1736 LIBS="$LIBS `$freetype_config --libs | tr '\n\r' ' '`"
1740 if [ -n "$icu_config" ]; then
1741 CFLAGS="$CFLAGS -DWITH_ICU"
1742 CFLAGS="$CFLAGS `$icu_config --cppflags | tr '\n\r' ' '`"
1744 # Some icu-configs have the 'feature' of not adding a space where others do add the space
1745 if [ "$static_icu" != "0" ]; then
1746 LIBS="$LIBS `$icu_config --ldflags-searchpath` `($icu_config --ldflags-libsonly; $icu_config --ldflags-layout) | tr '\n\r' ' ' | sed s/licu/lsicu/g`"
1748 LIBS="$LIBS `$icu_config --ldflags-searchpath` `($icu_config --ldflags-libsonly; $icu_config --ldflags-layout) | tr '\n\r' ' '`"
1753 if [ "$with_direct_music" != "0" ]; then
1754 CFLAGS="$CFLAGS -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT"
1755 # GCC 4.0+ doesn't like the DirectX includes (gives tons of
1756 # warnings on it we won't be able to fix). For now just
1757 # suppress those warnings.
1758 if [ $cc_version -ge 40 ]; then
1759 CFLAGS="$CFLAGS -Wno-non-virtual-dtor"
1763 if [ -n "$libtimidity" ]; then
1764 if [ "$enable_static" != "0" ]; then
1765 LIBS="$LIBS $libtimidity"
1767 LIBS="$LIBS -ltimidity"
1769 CFLAGS="$CFLAGS -DLIBTIMIDITY"
1772 if [ "$with_iconv" != "0" ]; then
1773 CFLAGS="$CFLAGS -DWITH_ICONV"
1774 if [ "$link_to_iconv" = "yes" ]; then
1775 LIBS="$LIBS -liconv"
1776 if [ "$with_iconv" != "2" ]; then
1777 CFLAGS="$CFLAGS -I$with_iconv/include"
1778 LIBS="$LIBS -L$with_iconv/lib"
1782 if [ "$os" != "OSX" ] && [ "$have_non_const_iconv" != "no" ]; then
1783 CFLAGS="$CFLAGS -DHAVE_NON_CONST_ICONV"
1787 if [ -n "$with_midi" ]; then
1788 CFLAGS="$CFLAGS -DEXTERNAL_PLAYER=\\\\\"$with_midi\\\\\""
1790 if [ -n "$with_midi_arg" ]; then
1791 CFLAGS="$CFLAGS -DMIDI_ARG=\\\\\"$with_midi_arg\\\\\""
1794 if [ "$enable_dedicated" != "0" ]; then
1795 CFLAGS="$CFLAGS -DDEDICATED"
1798 if [ "$enable_unicode" != "0" ]; then
1799 CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"
1802 if [ "$enable_network" != "0" ]; then
1803 CFLAGS="$CFLAGS -DENABLE_NETWORK"
1805 if [ "$os" = "BEOS" ]; then
1806 LDFLAGS="$LDFLAGS -lbind -lsocket"
1809 if [ "$os" = "HAIKU" ]; then
1810 LDFLAGS="$LDFLAGS -lnetwork"
1813 if [ "$os" = "SUNOS" ]; then
1814 LDFLAGS="$LDFLAGS -lnsl -lsocket"
1818 if [ "$enable_static" != "0" ]; then
1819 # OSX can't handle -static in LDFLAGS
1820 if [ "$os" != "OSX" ]; then
1821 LDFLAGS="$LDFLAGS -static"
1825 if [ "$enable_assert" = "0" ]; then
1826 CFLAGS="$CFLAGS -DNDEBUG"
1827 CFLAGS_BUILD="$CFLAGS_BUILD -DNDEBUG"
1830 if [ "$enable_desync_debug" != "0" ]; then
1831 CFLAGS="$CFLAGS -DRANDOM_DEBUG"
1834 if [ "$enable_osx_g5" != "0" ]; then
1835 CFLAGS="$CFLAGS -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
1838 if [ -n "$personal_dir" ]; then
1839 CFLAGS="$CFLAGS -DWITH_PERSONAL_DIR -DPERSONAL_DIR=\\\\\"$personal_dir\\\\\""
1842 if [ -n "$shared_dir" ]; then
1843 CFLAGS="$CFLAGS -DWITH_SHARED_DIR -DSHARED_DIR=\\\\\"$shared_dir\\\\\""
1846 CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\""
1848 if [ "$enable_lto" != "0" ]; then
1850 if echo "$FEATURES_BUILD" | grep -q "lto"; then
1851 LDFLAGS_BUILD="$LDFLAGS_BUILD $CFLAGS_BUILD $CXXFLAGS_BUILD"
1854 if echo "$FEATURES" | grep -q "lto"; then
1855 LDFLAGS="$LDFLAGS $CFLAGS $CXXFLAGS"
1858 if [ "$lto_warn" != "0" ]; then
1859 log 1 "WARNING: you enabled LTO/IPO, but neither build nor host compiler supports it"
1860 log 1 "WARNING: LTO/IPO has been disabled"
1864 log 1 "using CFLAGS_BUILD... $CFLAGS_BUILD"
1865 log 1 "using CXXFLAGS_BUILD... $CXXFLAGS_BUILD"
1866 log 1 "using LDFLAGS_BUILD... $LDFLAGS_BUILD"
1867 log 1 "using CFLAGS... $CFLAGS"
1868 log 1 "using CXXFLAGS... $CXXFLAGS"
1869 log 1 "using LDFLAGS... $LIBS $LDFLAGS"
1871 # Makedepend doesn't like something like: -isysroot /OSX/blabla
1872 # so convert it to: -isysroot -OSX/blabla. makedepend just ignores
1873 # any - command it doesn't know, so we are pretty save.
1874 # Lovely hackish, not?
1875 # Btw, this almost always comes from outside the configure, so it is
1876 # not something we can control.
1877 # Also make makedepend aware of compiler's built-in defines.
1878 if [ "$with_makedepend" != "0" ] || [ "$enable_builtin_depend" != "0" ]; then
1879 # Append CXXFLAGS possibly containing -std=c++0x
1880 cflags_makedep="`echo | $cxx_host $CXXFLAGS -E -x c++ -dM - | sed 's@.define @-D@g;s@ .*@ @g;s@(.*)@@g' | tr -d '\r\n'`"
1882 # Please escape ALL " within ` because e.g. "" terminates the string in some sh implementations
1883 cflags_makedep="$cflags_makedep `echo \"$CFLAGS\" \"$CXXFLAGS\" | sed 's@ /@ -@g;s@-I[ ]*[^ ]*@@g'`"
1888 if [ "$with_distcc" != "0" ]; then
1889 cc_host="$distcc $cc_host"
1890 cxx_host="$distcc $cxx_host"
1892 log 1 " NOTICE: remind yourself to use 'make -jN' to make use of distcc"
1896 if [ "$with_ccache" != "0" ]; then
1897 cc_host="$ccache $cc_host"
1898 cxx_host="$ccache $cxx_host"
1904 # $1 - Type for message (build / host)
1905 # $2 - What to fill with the found compiler
1906 # $3 - System to try
1907 # $4 - Compiler to try
1908 # $5 - Env-setting to try
1909 # $6 - GCC alike to try
1910 # $7 - CC alike to try
1911 # $8 - "0" gcc, "1" g++, "2" windres, "3" strip, "4" lipo
1912 # $9 - What the command is to check for
1914 if [ -n "$3" ]; then
1916 if [ -z "$6" ]; then
1921 machine=`eval $compiler $9 2>/dev/null`
1923 eval "$2=\"$compiler\""
1925 log 2 "executing $compiler $9"
1926 log 2 " returned $machine"
1927 log 2 " exit code $ret"
1929 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1930 log 1 "checking $1... $compiler not found"
1931 log 1 "I couldn't detect any $6 binary for $3"
1935 if [ "$machine" != "$3" ] && ( [ "$8" = "0" ] || [ "$8" = "1" ] ); then
1936 log 1 "checking $1... expected $3, found $machine"
1937 log 1 "the compiler suggests it doesn't build code for the machine you specified"
1940 elif [ -n "$4" ]; then
1941 # Check for manual compiler
1942 machine=`$4 $9 2>/dev/null`
1946 log 2 "executing $4 $9"
1947 log 2 " returned $machine"
1948 log 2 " exit code $ret"
1950 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1951 log 1 "checking $1... $4 not found"
1952 log 1 "the selected binary doesn't seem to be a $6 binary"
1956 # Nothing given, autodetect
1958 if [ -n "$5" ]; then
1959 machine=`$5 $9 2>/dev/null`
1963 log 2 "executing $5 $9"
1964 log 2 " returned $machine"
1965 log 2 " exit code $ret"
1967 # The user defined a GCC that doesn't reply to $9.. abort
1968 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1969 log 1 "checking $1... $5 unusable"
1970 log 1 "the CC environment variable is set, but it doesn't seem to be a $6 binary"
1971 log 1 "please redefine the CC/CXX environment to a $6 binary"
1975 log 2 "checking $1... CC/CXX not set (skipping)"
1977 # No $5, so try '$6'
1978 machine=`$6 $9 2>/dev/null`
1982 log 2 "executing $6 $9"
1983 log 2 " returned $machine"
1984 log 2 " exit code $ret"
1986 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1988 machine=`$7 $9 2>/dev/null`
1992 log 2 "executing $7 $9"
1993 log 2 " returned $machine"
1994 log 2 " exit code $ret"
1997 if [ -z "$machine" ]; then
1998 log 1 "checking $1... $6 not found"
1999 log 1 "I couldn't detect any $6 binary on your system"
2000 log 1 "please define the CC/CXX environment to where it is located"
2008 if [ "$8" != "0" ]; then
2010 log 1 "checking $1... $res"
2012 log 1 "checking $1... $machine"
2017 if [ "$os" = "FREEBSD" ]; then
2018 # FreeBSD's C compiler does not support dump machine.
2019 # However, removing C support is not possible because PSP must be linked with the C compiler.
2020 check_compiler "build system type" "cc_build" "$build" "$cc_build" "$CXX" "g++" "c++" "0" "-dumpmachine"
2022 check_compiler "build system type" "cc_build" "$build" "$cc_build" "$CC" "gcc" "cc" "0" "-dumpmachine"
2027 # By default the host is the build
2028 if [ -z "$host" ]; then host="$build"; fi
2030 if [ "$os" = "FREEBSD" ]; then
2031 # FreeBSD's C compiler does not support dump machine.
2032 # However, removing C support is not possible because PSP must be linked with the C compiler.
2033 check_compiler "host system type" "cc_host" "$host" "$cc_host" "$CXX" "g++" "c++" "0" "-dumpmachine"
2035 check_compiler "host system type" "cc_host" "$host" "$cc_host" "$CC" "gcc" "cc" "0" "-dumpmachine"
2040 check_compiler "build c++" "cxx_build" "$build" "$cxx_build" "$CXX" "g++" "c++" 1 "-dumpmachine"
2044 # By default the host is the build
2045 if [ -z "$host" ]; then host="$build"; fi
2046 check_compiler "host c++" "cxx_host" "$host" "$cxx_host" "$CXX" "g++" "c++" 1 "-dumpmachine"
2050 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
2051 check_compiler "host windres" "windres" "$host" "$windres" "$WINDRES" "windres" "windres" "2" "-V"
2056 if [ "$os" = "OS2" ]; then
2057 # OS2 via gcc is a bit weird.. stripping HAS to be done via emxbind, which is via gcc directly
2058 log 1 "checking host strip... using gcc -s option"
2059 elif [ "$os" = "OSX" ]; then
2060 # Most targets have -V in strip, to see if they exists... OSX doesn't.. so execute something
2061 echo "int main(int argc, char *argv[]) { }" > strip.test.c
2062 $cxx_host strip.test.c -o strip.test
2063 check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "strip.test"
2064 rm -f strip.test.c strip.test
2066 check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "-V"
2071 if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ]; then
2072 echo "int main(int argc, char *argv[]) { }" > lipo.test.c
2073 $cxx_host lipo.test.c -o lipo.test
2074 check_compiler "host lipo" "lipo" "$host" "$lipo" "$LIPO" "lipo" "lipo" "4" "-info lipo.test"
2075 rm -f lipo.test.c lipo.test
2081 if [ -n "$1" ]; then
2082 if echo "$1" | grep -q / ; then
2083 # Seems to be a file system path
2086 osx_sdk_path="/Developer/SDKs/MacOSX$1.sdk"
2088 if [ ! -d "$osx_sdk_path" ]; then
2089 # No directory, not present or garbage
2093 # Set minimum version to 10.4 as that's when kCGBitmapByteOrder32Host was introduced
2094 sysroot="-isysroot $osx_sdk_path -Wl,-syslibroot,$osx_sdk_path -mmacosx-version-min=10.4"
2097 cat > tmp.osx.mm << EOF
2098 #include <Cocoa/Cocoa.h>
2100 kCGBitmapByteOrder32Host;
2104 execute="$cxx_host $sysroot $CFLAGS tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1"
2105 eval $execute > /dev/null
2107 log 2 "executing $execute"
2108 log 2 " exit code $ret"
2109 rm -f tmp.osx.mm tmp.osx
2113 check_direct_music() {
2115 #include <windows.h>
2116 #include <dmksctrl.h>
2117 #include <dmusici.h>
2118 #include <dmusicc.h>
2119 #include <dmusicf.h>
2120 int main(int argc, char *argv[]) { }" > direct_music.test.c
2121 $cxx_host $CFLAGS direct_music.test.c -o direct_music.test 2> /dev/null
2123 rm -f direct_music.test.c direct_music.test
2125 if [ "$res" != "0" ]; then
2126 if [ "$with_direct_music" != "1" ]; then
2127 log 1 "configure: error: direct-music is not available on this system"
2130 with_direct_music="0"
2132 log 1 "checking direct-music... not found"
2134 log 1 "checking direct-music... found"
2138 check_makedepend() {
2139 if [ "$enable_builtin_depend" != "0" ]; then
2143 if [ "$with_makedepend" = "0" ]; then
2144 log 1 "checking makedepend... disabled"
2148 if [ "$with_makedepend" = "1" ] || [ "$with_makedepend" = "2" ]; then
2149 makedepend="makedepend"
2151 makedepend="$with_makedepend"
2154 rm -f makedepend.tmp
2155 touch makedepend.tmp
2156 res=`$makedepend -fmakedepend.tmp 2>/dev/null`
2158 log 2 "executing $makedepend -f makedepend.tmp"
2159 log 2 " returned `cat makedepend.tmp`"
2160 log 2 " exit code $ret"
2162 if [ ! -s makedepend.tmp ]; then
2163 rm -f makedepend.tmp makedepend.tmp.bak
2165 if [ "$with_makedepend" = "2" ]; then
2166 log 1 "checking makedepend... not found"
2168 log 1 "I couldn't detect any makedepend on your system"
2169 log 1 "please locate it via --makedepend=[binary]"
2172 elif [ "$with_makedepend" != "1" ]; then
2173 log 1 "checking makedepend... $makedepend not found"
2175 log 1 "the selected file doesn't seem to be a valid makedepend binary"
2179 log 1 "checking makedepend... not found"
2186 rm -f makedepend.tmp makedepend.tmp.bak
2188 log 1 "checking makedepend... $makedepend"
2192 # $1 - requested version (major.minor)
2193 # $2 - version we got (major.minor)
2195 if [ -z "$2" ]; then
2199 req_major=`echo $1 | cut -d. -f1`
2200 got_major=`echo $2 | cut -d. -f1`
2201 if [ $got_major -lt $req_major ]; then
2203 elif [ $got_major -gt $req_major ]; then
2207 req_minor=`echo $1 | cut -d. -f2`
2208 got_minor=`echo $2 | cut -d. -f2`
2209 if [ $got_minor -lt $req_minor ]; then
2216 # Not all awks allow gsub(), so we test for that here! It is in fact all we need...
2218 # These awks are known to work. Test for them explicit
2219 awks="gawk mawk nawk"
2221 awk_prefix="echo \"a.c b.c c.c\" | tr ' ' \\\\n | "
2222 awk_param="' { ORS = \" \" } /\.c$/ { gsub(\".c$\", \".o\", \$0); print \$0; }' 2>/dev/null"
2223 awk_result="a.o b.o c.o "
2224 log 2 "Detecing awk..."
2226 log 2 "Trying: $awk_prefix $awk $awk_param"
2227 res=`eval $awk_prefix $awk $awk_param`
2228 log 2 "Result: '$res'"
2229 if [ "$res" != "$awk_result" ] && [ "$awk" = "awk" ]; then
2230 # User didn't supply his own awk, so try to detect some other known working names for an awk
2231 for awk in $awks; do
2232 log 2 "Trying: $awk_prefix $awk $awk_param"
2233 res=`eval $awk_prefix $awk $awk_param`
2234 log 2 "Result: '$res'"
2235 if [ "$res" = "$awk_result" ]; then break; fi
2238 if [ "$res" != "$awk_result" ]; then
2239 log 1 "checking awk... not found"
2240 log 1 "configure: error: no awk found"
2241 log 1 "configure: error: please install one of the following: $awks"
2245 if [ "$res" != "$awk_result" ]; then
2246 log 1 "checking awk... not found"
2247 log 1 "configure: error: you supplied '$awk' but it doesn't seem a valid gawk or mawk"
2251 log 1 "checking awk... $awk"
2255 if [ "$os" = "DETECT" ]; then
2256 # Detect UNIX, OSX, FREEBSD, OPENBSD, NETBSD, HPUX, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP
2258 # Try first via dumpmachine, then via uname
2259 os=`echo "$host" | tr '[A-Z]' '[a-z]' | $awk '
2260 /linux/ { print "UNIX"; exit}
2261 /darwin/ { print "OSX"; exit}
2262 /freebsd/ { print "FREEBSD"; exit}
2263 /openbsd/ { print "OPENBSD"; exit}
2264 /netbsd/ { print "NETBSD"; exit}
2265 /hp-ux/ { print "HPUX"; exit}
2266 /morphos/ { print "MORPHOS"; exit}
2267 /beos/ { print "BEOS"; exit}
2268 /haiku/ { print "HAIKU"; exit}
2269 /sunos/ { print "SUNOS"; exit}
2270 /solaris/ { print "SUNOS"; exit}
2271 /cygwin/ { print "CYGWIN"; exit}
2272 /mingw/ { print "MINGW"; exit}
2273 /os2/ { print "OS2"; exit}
2274 /dos/ { print "DOS"; exit}
2275 /wince/ { print "WINCE"; exit}
2276 /psp/ { print "PSP"; exit}
2279 if [ -z "$os" ]; then
2280 os=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | $awk '
2281 /linux/ { print "UNIX"; exit}
2282 /darwin/ { print "OSX"; exit}
2283 /freebsd/ { print "FREEBSD"; exit}
2284 /openbsd/ { print "OPENBSD"; exit}
2285 /netbsd/ { print "NETBSD"; exit}
2286 /hp-ux/ { print "HPUX"; exit}
2287 /morphos/ { print "MORPHOS"; exit}
2288 /beos/ { print "BEOS"; exit}
2289 /haiku/ { print "HAIKU"; exit}
2290 /sunos/ { print "SUNOS"; exit}
2291 /cygwin/ { print "CYGWIN"; exit}
2292 /mingw/ { print "MINGW"; exit}
2293 /os\/2/ { print "OS2"; exit}
2294 /gnu/ { print "UNIX"; exit}
2298 if [ -z "$os" ]; then
2299 log 1 "detecting OS... none detected"
2300 log 1 "I couldn't detect your OS. Please use --os=OS to force one"
2301 log 1 "Allowed values are: UNIX, OSX, FREEBSD, OPENBSD, NETBSD, MORPHOS, HPUX, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP"
2305 log 1 "detecting OS... $os"
2307 log 1 "forcing OS... $os"
2312 # 0 means no, 1 is auto-detect, 2 is force
2313 if [ "$with_allegro" = "0" ]; then
2314 log 1 "checking Allegro... disabled"
2320 if [ "$with_allegro" = "2" ] && [ "$with_cocoa" = "2" ]; then
2321 log 1 "configure: error: it is impossible to compile both Allegro and COCOA"
2322 log 1 "configure: error: please deselect one of them and try again"
2326 if [ "$with_allegro" = "2" ] && [ "$enable_dedicated" != "0" ]; then
2327 log 1 "configure: error: it is impossible to compile a dedicated with Allegro"
2328 log 1 "configure: error: please deselect one of them and try again"
2332 if [ "$enable_dedicated" != "0" ]; then
2333 log 1 "checking Allegro... dedicated server, skipping"
2339 # By default on OSX we don't use SDL. The rest is auto-detect
2340 if [ "$with_allegro" = "1" ] && [ "$os" = "OSX" ] && [ "$with_cocoa" != "0" ]; then
2341 log 1 "checking Allegro... OSX, skipping"
2347 if [ "$with_allegro" = "1" ] || [ "$with_allegro" = "" ] || [ "$with_allegro" = "2" ]; then
2348 allegro_config="allegro-config"
2350 allegro_config="$with_allegro"
2353 version=`$allegro_config --version 2>/dev/null`
2355 log 2 "executing $allegro_config --version"
2356 log 2 " returned $version"
2357 log 2 " exit code $ret"
2359 if [ -z "$version" ] || [ "$ret" != "0" ]; then
2360 log 1 "checking Allegro... not found"
2362 # It was forced, so it should be found.
2363 if [ "$with_allegro" != "1" ]; then
2364 log 1 "configure: error: allegro-config couldn't be found"
2365 log 1 "configure: error: you supplied '$with_allegro', but it seems invalid"
2373 log 1 "checking Allegro... found"
2378 # 0 means no, 1 is auto-detect, 2 is force
2379 if [ "$with_sdl" = "0" ]; then
2380 log 1 "checking SDL... disabled"
2386 if [ "$with_sdl" = "2" ] && [ "$with_cocoa" = "2" ]; then
2387 log 1 "configure: error: it is impossible to compile both SDL and COCOA"
2388 log 1 "configure: error: please deselect one of them and try again"
2392 if [ "$with_sdl" = "2" ] && [ "$enable_dedicated" != "0" ]; then
2393 log 1 "configure: error: it is impossible to compile a dedicated with SDL"
2394 log 1 "configure: error: please deselect one of them and try again"
2398 if [ "$enable_dedicated" != "0" ]; then
2399 log 1 "checking SDL... dedicated server, skipping"
2405 # By default on OSX we don't use SDL. The rest is auto-detect
2406 if [ "$with_sdl" = "1" ] && [ "$os" = "OSX" ] && [ "$with_cocoa" != "0" ]; then
2407 log 1 "checking SDL... OSX, skipping"
2413 if [ "$os" = "OSX" ]; then
2414 log 1 "WARNING: sdl is known to fail on some versions of Mac OS X"
2415 log 1 "WARNING: with some hardware configurations. Use at own risk!"
2419 if [ "$with_sdl" = "1" ] || [ "$with_sdl" = "" ] || [ "$with_sdl" = "2" ]; then
2420 sdl_config="sdl-config"
2422 sdl_config="$with_sdl"
2425 version=`$sdl_config --version 2>/dev/null`
2427 log 2 "executing $sdl_config --version"
2428 log 2 " returned $version"
2429 log 2 " exit code $ret"
2431 if [ -z "$version" ] || [ "$ret" != "0" ]; then
2432 log 1 "checking SDL... not found"
2434 # It was forced, so it should be found.
2435 if [ "$with_sdl" != "1" ]; then
2436 log 1 "configure: error: sdl-config couldn't be found"
2437 log 1 "configure: error: you supplied '$with_sdl', but it seems invalid"
2445 log 1 "checking SDL... found"
2449 # Try to find the best SDK available. For a normal build this
2450 # is currently the 10.5 SDK as this is needed to compile all
2451 # optional code. Because such an executable won't run on 10.4
2452 # or lower, also check for the 10.4u SDK when doing an universal
2455 # Check for the 10.5 SDK, but try 10.6 if that fails
2456 check_osx_sdk "10.5" || check_osx_sdk "10.6" || osx_sdk_path=""
2458 if [ -z "$osx_sdk_path" ] || [ "$enable_universal" != "0" ]; then
2459 # No better SDK or universal build enabled? Check 10.4u SDK as well
2460 local old_sdk="$osx_sdk_path"
2461 if check_osx_sdk "10.4u"; then
2462 osx_sdk_104_path="$osx_sdk_path"
2466 if [ -z "$old_sdk" ]; then
2467 osx_sdk_path="$osx_sdk_104_path"
2469 osx_sdk_path="$old_sdk"
2473 if [ -z "$osx_sdk_path" ]; then
2474 log 1 "Your system SDK is probably too old"
2475 log 1 "Please install/upgrade your Xcode to >= 2.5"
2482 # 0 means no, 1 is auto-detect, 2 is force
2483 if [ "$with_cocoa" = "0" ]; then
2484 log 1 "checking COCOA... disabled"
2489 if [ "$with_cocoa" = "2" ] && [ "$enable_dedicated" != "0" ]; then
2490 log 1 "configure: error: it is impossible to compile a dedicated with COCOA"
2491 log 1 "configure: error: please deselect one of them and try again"
2495 if [ "$enable_dedicated" != "0" ]; then
2496 log 1 "checking COCOA... dedicated server, skipping"
2502 # By default on OSX we use COCOA. The rest doesn't support it
2503 if [ "$with_cocoa" = "1" ] && [ "$os" != "OSX" ]; then
2504 log 1 "checking COCOA... not OSX, skipping"
2510 if [ "$os" != "OSX" ]; then
2511 log 1 "checking COCOA... not OSX"
2513 log 1 "configure: error: COCOA video driver is only supported for OSX"
2517 log 1 "checking COCOA... found"
2520 if [ "$enable_cocoa_quartz" != "0" ]; then
2521 log 1 "checking whether to enable the Quartz window subdriver... yes"
2523 log 1 "checking whether to enable the Quartz window subdriver... no"
2529 detect_quickdraw() {
2530 # 0 means no, 1 is auto-detect, 2 is force
2531 if [ "$enable_cocoa_quickdraw" = "0" ]; then
2532 log 1 "checking Quickdraw window subdriver... disabled"
2536 # Assume QuickDraw is available when doing an universal build
2537 if [ "$enable_universal" != "0" ]; then
2538 log 1 "checking Quickdraw window subdriver... found"
2542 # 64 bits doesn't have quickdraw
2543 if [ "$cpu_type" = "64" ]; then
2544 enable_cocoa_quickdraw="0"
2545 log 1 "checking Quickdraw window subdriver... disabled (64 bits)"
2549 cat > tmp.osx.mm << EOF
2550 #include <AvailabilityMacros.h>
2551 #import <Cocoa/Cocoa.h>
2552 int main(int argc, char *argv[]) { SetEmptyRgn(NULL); return 0; }
2554 execute="$cxx_host $OSX_SYSROOT $OSX_LD_SYSROOT $CFLAGS -mmacosx-version-min=10.3 tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1"
2555 eval $execute > /dev/null
2557 log 2 "executing $execute"
2558 log 2 " exit code $ret"
2559 rm -f tmp.osx.mm tmp.osx
2560 if [ "$ret" != "0" ]; then
2561 log 1 "checking Quickdraw window subdriver... not found"
2563 # It was forced, so it should be found.
2564 if [ "$enable_cocoa_quickdraw" != "1" ]; then
2565 log 1 "configure: error: Quickdraw window driver could not be found"
2569 enable_cocoa_quickdraw=0
2573 enable_cocoa_quickdraw=1
2574 log 1 "checking Quickdraw window subdriver... found"
2578 # $1 - config-param ($with_zlib value)
2579 # $2 - library name ('zlib', sets $zlib)
2580 # $3 - static library name (libz.a)
2581 # $4 - header directory ()
2582 # $5 - header name (zlib.h)
2583 # $6 - force static (if non-empty)
2585 if [ -n "$6" ]; then force_static="1"; fi
2587 # 0 means no, 1 is auto-detect, 2 is force
2588 if [ "$1" = "0" ]; then
2589 log 1 "checking $2... disabled"
2595 log 2 "detecting $2"
2597 if [ "$1" = "1" ] || [ "$1" = "" ] || [ "$1" = "2" ]; then
2598 eval "$2=`ls -1 /usr/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2600 if [ -z "$res" ]; then
2601 log 2 " trying /usr/include/$4$5... no"
2602 eval "$2=`ls -1 /usr/local/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2605 if [ -z "$res" ]; then
2606 log 2 " trying /usr/local/include/$4$5... no"
2607 eval "$2=`ls -1 /mingw/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2610 if [ -z "$res" ]; then
2611 log 2 " trying /mingw/include/$4$5... no"
2612 eval "$2=`ls -1 /opt/local/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2615 if [ -z "$res" ]; then
2616 log 2 " trying /opt/local/include/$4$5... no"
2618 if [ -z "$res" ] && [ "$os" = "NETBSD" ]; then
2619 eval "$2=`ls -1 /usr/pkg/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2621 if [ -z "$res" ]; then
2622 log 2 " trying /usr/pkg/include/$4$5... no"
2625 if [ -z "$res" ] && [ "$os" = "HAIKU" ]; then
2626 eval "$2=`ls -1 /boot/common/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2628 if [ -z "$res" ]; then
2629 log 2 " trying /boot/common/include/$4$5... no"
2634 if [ -n "$res" ] && ( [ -n "$force_static" ] || ( [ "$enable_static" != "0" ] && [ "$os" != "OSX" ] ) ); then
2636 log 2 " trying $res... found"
2637 # Now find the static lib, if needed
2638 eval "$2=`ls /lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2640 if [ -z "$res" ]; then
2641 log 2 " trying /lib/$3... no"
2642 eval "$2=`ls /usr/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2645 if [ -z "$res" ]; then
2646 log 2 " trying /usr/lib/$3... no"
2647 eval "$2=`ls /usr/local/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2650 if [ -z "$res" ]; then
2651 log 2 " trying /usr/local/lib/$3... no"
2652 eval "$2=`ls /mingw/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2655 if [ -z "$res" ]; then
2656 log 2 " trying /mingw/lib/$3... no"
2657 log 1 "configure: error: $2 couldn't be found"
2658 log 1 "configure: error: you requested a static link, but I can't find $3"
2664 # Make sure it exists
2665 if [ -f "$1" ]; then
2666 eval "$2=`ls $1 2>/dev/null`"
2668 eval "$2=`ls $1/$3 2>/dev/null`"
2673 if [ -z "$res" ]; then
2674 log 1 "checking $2... not found"
2675 if [ "$1" = "2" ]; then
2676 log 1 "configure: error: $2 couldn't be found"
2679 elif [ "$1" != "1" ]; then
2680 log 1 "configure: error: $2 couldn't be found"
2681 log 1 "configure: error: you supplied '$1', but it seems invalid"
2692 log 2 " trying $res... found"
2694 log 1 "checking $2... found"
2698 detect_library "$with_zlib" "zlib" "libz.a" "" "zlib.h"
2702 detect_library "$with_lzo2" "lzo2" "liblzo2.a" "lzo/" "lzo1x.h"
2705 detect_libtimidity() {
2706 detect_library "$with_libtimidity" "libtimidity" "libtimidity.a" "" "timidity.h"
2710 # 0 means no, 1 is auto-detect, 2 is force
2711 if [ "$with_lzma" = "0" ]; then
2712 log 1 "checking liblzma... disabled"
2718 if [ "$with_lzma" = "1" ] || [ "$with_lzma" = "" ] || [ "$with_lzma" = "2" ]; then
2719 lzma_config="pkg-config liblzma"
2721 lzma_config="$with_lzma"
2724 version=`$lzma_config --modversion 2>/dev/null`
2726 log 2 "executing $lzma_config --modversion"
2727 log 2 " returned $version"
2728 log 2 " exit code $ret"
2730 if [ -z "$version" ] || [ "$ret" != "0" ]; then
2731 log 1 "checking liblzma... not found"
2733 # It was forced, so it should be found.
2734 if [ "$with_lzma" != "1" ]; then
2735 log 1 "configure: error: pkg-config liblzma couldn't be found"
2736 log 1 "configure: error: you supplied '$with_lzma', but it seems invalid"
2744 log 1 "checking liblzma... found"
2747 detect_xdg_basedir() {
2748 # 0 means no, 1 is auto-detect, 2 is force
2749 if [ "$with_xdg_basedir" = "0" ]; then
2750 log 1 "checking libxdg_basedir... disabled"
2752 xdg_basedir_config=""
2756 if [ "$with_xdg_basedir" = "1" ] || [ "$with_xdg_basedir" = "" ] || [ "$with_xdg_basedir" = "2" ]; then
2757 xdg_basedir_config="pkg-config libxdg-basedir"
2759 xdg_basedir_config="$with_xdg_basedir"
2762 version=`$xdg_basedir_config --modversion 2>/dev/null`
2764 log 2 "executing $xdg_basedir_config --modversion"
2765 log 2 " returned $version"
2766 log 2 " exit code $ret"
2768 if [ -z "$version" ] || [ "$ret" != "0" ]; then
2769 log 1 "checking libxdg_basedir... not found"
2771 # It was forced, so it should be found.
2772 if [ "$with_xdg_basedir" != "1" ]; then
2773 log 1 "configure: error: pkg-config libxdg_basedir couldn't be found"
2774 log 1 "configure: error: you supplied '$with_xdg_basedir', but it seems invalid"
2778 xdg_basedir_config=""
2782 log 1 "checking libxdg_basedir... found"
2786 # 0 means no, 1 is auto-detect, 2 is force
2787 if [ "$with_png" = "0" ]; then
2788 log 1 "checking libpng... disabled"
2794 if [ "$with_zlib" = "0" ] || [ -z "$zlib" ]; then
2795 if [ "$with_png" != "1" ]; then
2796 log 1 "checking libpng... no zlib"
2797 log 1 "ERROR: libpng was forced, but zlib was not detected / disabled."
2798 log 1 "ERROR: libpng depends on zlib."
2803 log 1 "checking libpng... no zlib, skipping"
2809 if [ "$with_png" = "1" ] || [ "$with_png" = "" ] || [ "$with_png" = "2" ]; then
2810 png_config="libpng-config"
2812 png_config="$with_png"
2815 version=`$png_config --version 2>/dev/null`
2817 log 2 "executing $png_config --version"
2818 log 2 " returned $version"
2819 log 2 " exit code $ret"
2821 if [ -z "$version" ] || [ "$ret" != "0" ]; then
2822 log 1 "checking libpng... not found"
2824 # It was forced, so it should be found.
2825 if [ "$with_png" != "1" ]; then
2826 log 1 "configure: error: libpng-config couldn't be found"
2827 log 1 "configure: error: you supplied '$with_png', but it seems invalid"
2835 log 1 "checking libpng... found"
2839 # 0 means no, 1 is auto-detect, 2 is force
2840 if [ "$with_freetype" = "0" ]; then
2841 log 1 "checking libfreetype... disabled"
2846 if [ "$with_freetype" = "1" ] && [ "$enable_dedicated" != "0" ]; then
2847 log 1 "checking libfreetype... dedicated server, skipping"
2853 if [ "$with_zlib" = "0" ] || [ -z "$zlib" ]; then
2854 if [ "$with_freetype" != "1" ]; then
2855 log 1 "checking libfreetype... no zlib"
2856 log 1 "ERROR: libfreetype was forced, but zlib was not detected / disabled."
2857 log 1 "ERROR: libfreetype depends on zlib."
2862 log 1 "checking libfreetype... no zlib, skipping"
2868 if [ "$with_freetype" = "1" ] || [ "$with_freetype" = "" ] || [ "$with_freetype" = "2" ]; then
2869 freetype_config="freetype-config"
2871 freetype_config="$with_freetype"
2874 version=`$freetype_config --version 2>/dev/null`
2876 log 2 "executing freetype_config --version"
2877 log 2 " returned $version"
2878 log 2 " exit code $ret"
2880 if [ -z "$version" ] || [ "$ret" != "0" ]; then
2881 log 1 "checking libfreetype... not found"
2883 # It was forced, so it should be found.
2884 if [ "$with_freetype" != "1" ]; then
2885 log 1 "configure: error: freetype-config couldn't be found"
2886 log 1 "configure: error: you supplied '$with_freetype', but it seems invalid"
2894 log 1 "checking libfreetype... found"
2897 detect_fontconfig() {
2898 # 0 means no, 1 is auto-detect, 2 is force
2899 if [ "$with_fontconfig" = "0" ]; then
2900 log 1 "checking libfontconfig... disabled"
2902 fontconfig_config=""
2905 if [ "$with_fontconfig" = "1" ] && [ "$enable_dedicated" != "0" ]; then
2906 log 1 "checking libfontconfig... dedicated server, skipping"
2908 fontconfig_config=""
2911 if [ "$with_fontconfig" != "2" ] && [ -z "$freetype_config" ]; then
2912 log 1 "checking libfontconfig... no freetype, skipping"
2914 fontconfig_config=""
2918 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
2919 log 1 "checking libfontconfig... WIN32, skipping"
2920 fontconfig_config=""
2924 if [ "$os" = "OSX" ]; then
2925 log 1 "checking libfontconfig... OSX, skipping"
2926 fontconfig_config=""
2930 if [ "$with_fontconfig" = "1" ] || [ "$with_fontconfig" = "" ] || [ "$with_fontconfig" = "2" ]; then
2931 fontconfig_config="pkg-config fontconfig"
2933 fontconfig_config="$with_fontconfig"
2936 version=`$fontconfig_config --modversion 2>/dev/null`
2938 check_version '2.3' "$version"
2940 log 2 "executing $fontconfig_config --modversion"
2941 log 2 " returned $version"
2942 log 2 " exit code $ret"
2944 if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
2945 if [ -n "$version" ] && [ "$version_ok" != "1" ]; then
2946 log 1 "checking libfontconfig... needs at least version 2.3.0, fontconfig NOT enabled"
2948 log 1 "checking libfontconfig... not found"
2951 # It was forced, so it should be found.
2952 if [ "$with_fontconfig" != "1" ]; then
2953 log 1 "configure: error: fontconfig-config couldn't be found"
2954 log 1 "configure: error: you supplied '$with_fontconfig', but it seems invalid"
2958 fontconfig_config=""
2962 log 1 "checking libfontconfig... found"
2966 # 0 means no, 1 is auto-detect, 2 is force
2967 if [ "$with_icu" = "0" ]; then
2968 log 1 "checking libicu... disabled"
2973 if [ "$with_icu" = "1" ] && [ "$enable_dedicated" != "0" ]; then
2974 log 1 "checking libicu... dedicated server, skipping"
2980 if [ "$with_icu" = "1" ] || [ "$with_icu" = "" ] || [ "$with_icu" = "2" ]; then
2981 icu_config="icu-config"
2983 icu_config="$with_icu"
2986 version=`$icu_config --version 2>/dev/null`
2988 check_version '3.6' "$version"
2990 log 2 "executing $icu_config --version"
2991 log 2 " returned $version"
2992 log 2 " exit code $ret"
2994 if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
2995 if [ -n "$version" ] && [ "$version_ok" != "1" ]; then
2996 log 1 "checking libicu... needs at least version 3.6.0, icu NOT enabled"
2998 log 1 "checking libicu... not found"
3001 # It was forced, so it should be found.
3002 if [ "$with_icu" != "1" ]; then
3003 log 1 "configure: error: icu-config couldn't be found"
3004 log 1 "configure: error: you supplied '$with_icuconfig', but it seems invalid"
3012 log 1 "checking libicu... found"
3015 detect_pspconfig() {
3016 # 0 means no, 1 is auto-detect, 2 is force
3017 if [ "$with_psp_config" = "0" ]; then
3018 log 1 "checking psp-config... disabled"
3024 if [ "$with_psp_config" = "1" ] && [ "$os" != "PSP" ]; then
3025 log 1 "checking psp-config... not PSP, skipping"
3031 if [ "$os" != "PSP" ]; then
3032 log 1 "checking psp-config... not PSP"
3034 log 1 "configure: error: psp-config is only supported for PSP"
3038 if [ "$with_psp_config" = "1" ] || [ "$with_psp_config" = "" ] || [ "$with_psp_config" = "2" ]; then
3039 psp_config="psp-config"
3041 psp_config="$with_psp_config"
3044 version=`$psp_config -p 2>/dev/null`
3046 log 2 "executing $psp_config -p"
3047 log 2 " returned $version"
3048 log 2 " exit code $ret"
3050 if [ -z "$version" ] || [ "$ret" != "0" ]; then
3051 log 1 "checking psp-config... not found"
3052 log 1 "configure: error: psp-config couldn't be found"
3054 # It was forced, so it should be found.
3055 if [ "$with_psp_config" != "1" ]; then
3056 log 1 "configure: error: you supplied '$with_psp_config', but it seems invalid"
3061 log 1 "checking psp-config... found"
3065 # 0 means no, 1 is auto-detect, 2 is force
3066 if [ "$with_iconv" = "0" ]; then
3067 log 1 "checking iconv... disabled"
3072 if [ "$with_iconv" = "1" ] && [ "$os" != "OSX" ]; then
3073 log 1 "checking iconv... not OSX, skipping"
3079 # Try to find iconv.h, seems to only thing to detect iconv with
3081 if [ "$with_iconv" = "1" ] || [ "$with_iconv" = "" ] || [ "$with_iconv" = "2" ]; then
3082 iconv=`ls -1 /usr/include 2>/dev/null | grep "iconv.h"`
3083 if [ -z "$iconv" ]; then
3084 iconv=`ls -1 /usr/local/include 2>/dev/null | grep "iconv.h"`
3087 # Make sure it exists
3088 iconv=`ls $with_iconv/include/iconv.h 2>/dev/null`
3091 if [ -z "$iconv" ]; then
3092 log 1 "checking iconv... not found"
3093 if [ "$with_iconv" = "2" ]; then
3094 log 1 "configure: error: iconv couldn't be found"
3097 elif [ "$with_iconv" != "1" ]; then
3098 log 1 "configure: error: iconv couldn't be found"
3099 log 1 "configure: error: you supplied '$with_iconv', but I couldn't detect iconv in it"
3107 if [ "$with_iconv" = "1" ]; then
3111 log 2 "found iconv in $iconv"
3113 log 1 "checking iconv... found"
3115 # There are different implementations of iconv. The older ones,
3116 # e.g. SUSv2, pass a const pointer, whereas the newer ones, e.g.
3117 # IEEE 1003.1 (2004), pass a non-const pointer.
3119 cat > tmp.iconv.cpp << EOF
3120 #include "src/stdafx.h"
3123 static char buf[1024];
3125 const char *inbuf = "";
3127 size_t outlen = 1023;
3129 return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
3132 execute="$cxx_host $OSX_SYSROOT $CFLAGS -c tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
3133 eval $execute > /dev/null
3135 log 2 "executing $execute"
3136 log 2 " exit code $ret"
3137 if [ "$ret" = "0" ]; then have_non_const_iconv="no"; else have_non_const_iconv="yes"; fi
3138 log 1 "checking if iconv has non-const inbuf... $have_non_const_iconv"
3140 cat > tmp.iconv.cpp << EOF
3141 #include "src/stdafx.h"
3144 static char buf[1024];
3148 size_t outlen = 1023;
3150 return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
3153 execute="$cxx_host $OSX_SYSROOT $OSX_LD_SYSROOT $CFLAGS tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
3154 eval $execute > /dev/null
3156 log 2 "executing $execute"
3157 log 2 " exit code $ret"
3158 if [ "$ret" = "0" ]; then link_to_iconv="no"; else link_to_iconv="yes"; fi
3159 log 1 "checking whether to link to iconv... $link_to_iconv"
3160 rm -f tmp.iconv tmp.iconv.cpp
3174 log 2 "running echo <array> | $1"
3176 if [ "`echo \"$sort_test_in\" | $1 2>/dev/null`" = "$sort_test_out" ]; then
3178 log 2 " result was valid"
3180 log 2 " result was invalid"
3185 if [ "$with_sort" = "0" ]; then
3186 log 1 "checking sort... disabled"
3191 if [ "$with_sort" = "1" ] || [ "$with_sort" = "2" ]; then
3193 if [ -z "$sort" ]; then _detect_sort "/sbin/sort"; fi
3194 if [ -z "$sort" ]; then _detect_sort "/usr/sbin/sort"; fi
3195 if [ -z "$sort" ]; then _detect_sort "/usr/local/sbin/sort"; fi
3196 if [ -z "$sort" ]; then _detect_sort "/bin/sort"; fi
3197 if [ -z "$sort" ]; then _detect_sort "/usr/bin/sort"; fi
3198 if [ -z "$sort" ]; then _detect_sort "/usr/local/bin/sort"; fi
3200 _detect_sort "$with_sort"
3203 if [ -z "$sort" ]; then
3204 if [ "$with_sort" = "2" ]; then
3205 log 1 "checking sort... not found"
3207 log 1 "configure: error: couldn't detect sort on your system"
3209 elif [ "$with_sort" != "1" ]; then
3210 log 1 "checking sort... $with_sort not found"
3212 log 1 "configure: error: '$with_sort' doesn't look like a sort to me"
3213 log 1 "configure: error: please verify its location and function and try again"
3217 log 1 "checking sort... not found"
3220 log 1 "checking sort... $sort"
3225 # 0 means no, 1 is auto-detect, 2 is force
3226 if [ "$with_grfcodec" = "0" ]; then
3227 log 1 "checking grfcodec... disabled"
3233 if [ "$with_grfcodec" = "1" ] || [ "$with_grfcodec" = "" ] || [ "$with_grfcodec" = "2" ]; then
3236 grfcodec="$with_grfcodec"
3239 version=`$grfcodec -v 2>/dev/null | $awk '{print $3}' | sed 's/[rM]//g;s/-/0/'`
3241 log 2 "executing grfcodec -v"
3242 log 2 " returned $version"
3243 log 2 " exit code $ret"
3245 if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "949" ]; then
3246 if [ -n "$version" ] && [ "$version" -lt "949" ]; then
3247 log 1 "checking grfcodec... needs at least version 6.0.2 (r949), disabled"
3249 log 1 "checking grfcodec... not found"
3252 # It was forced, so it should be found.
3253 if [ "$with_grfcodec" != "1" ]; then
3254 log 1 "configure: error: grfcodec couldn't be found"
3255 log 1 "configure: error: you supplied '$with_grfcodec', but it seems invalid"
3263 log 1 "checking grfcodec... found"
3267 # 0 means no, 1 is auto-detect, 2 is force
3268 if [ "$with_nforenum" = "0" ]; then
3269 log 1 "checking nforenum... disabled"
3275 if [ "$with_nforenum" = "1" ] || [ "$with_nforenum" = "" ] || [ "$with_nforenum" = "2" ]; then
3278 nforenum="$with_nforenum"
3281 version=`$nforenum -v 2>/dev/null | $awk '{print $3}' | sed 's/[rM]//g;s/-/0/'`
3283 log 2 "executing nforenum -v"
3284 log 2 " returned $version"
3285 log 2 " exit code $ret"
3287 if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "949" ]; then
3288 if [ -n "$version" ] && [ "$version" -lt "949" ]; then
3289 log 1 "checking nforenum... needs at least version 6.0.2 (r949), disabled"
3291 log 1 "checking nforenum... not found"
3294 # It was forced, so it should be found.
3295 if [ "$with_nforenum" != "1" ]; then
3296 log 1 "configure: error: nforenum couldn't be found"
3297 log 1 "configure: error: you supplied '$with_nforenum', but it seems invalid"
3305 log 1 "checking nforenum... found"
3309 if [ -n "$cpu_type" ] && [ "$cpu_type" != "DETECT" ]; then
3310 log 1 "forcing cpu-type... $cpu_type bits"
3313 echo "#define _SQ64 1" > tmp.64bit.cpp
3314 echo "#include \"src/stdafx.h\"" >> tmp.64bit.cpp
3315 echo "assert_compile(sizeof(size_t) == 8);" >> tmp.64bit.cpp
3316 echo "int main() { return 0; }" >> tmp.64bit.cpp
3317 execute="$cxx_host $CFLAGS tmp.64bit.cpp -o tmp.64bit -DTESTING 2>&1"
3318 cpu_type="`eval $execute 2>/dev/null`"
3320 log 2 "executing $execute"
3321 log 2 " returned $cpu_type"
3322 log 2 " exit code $ret"
3323 if [ "$ret" = "0" ]; then cpu_type="64"; else cpu_type="32"; fi
3324 log 1 "detecting cpu-type... $cpu_type bits"
3325 rm -f tmp.64bit tmp.64bit.cpp
3328 detect_sse_capable_architecture() {
3329 # 0 means no, 1 is auto-detect, 2 is force
3330 if [ "$with_sse" = "0" ]; then
3331 log 1 "checking SSE... disabled"
3335 echo "#define _SQ64 1" > tmp.sse.cpp
3336 echo "#include <xmmintrin.h>" >> tmp.sse.cpp
3337 echo "#include <smmintrin.h>" >> tmp.sse.cpp
3338 echo "#include <tmmintrin.h>" >> tmp.sse.cpp
3339 echo "int main() { return 0; }" >> tmp.sse.cpp
3340 execute="$cxx_host -msse4.1 $CFLAGS tmp.sse.cpp -o tmp.sse 2>&1"
3341 sse="`eval $execute 2>/dev/null`"
3343 log 2 "executing $execute"
3344 log 2 " returned $sse"
3345 log 2 " exit code $ret"
3346 if [ "$ret" = "0" ]; then
3347 log 1 "detecting SSE... found"
3349 # It was forced, so it should be found.
3350 if [ "$with_sse" != "1" ]; then
3351 log 1 "configure: error: SSE couln't be found"
3352 log 1 "configure: error: you force enabled SSE, but it seems unavailable"
3356 log 1 "detecting SSE... not found"
3359 rm -f tmp.sse tmp.exe tmp.sse.cpp
3364 T_CXXFLAGS="$CXXFLAGS"
3365 T_LDFLAGS="$LDFLAGS"
3367 SRC_OBJS_DIR="$BASE_SRC_OBJS_DIR/$OBJS_SUBDIR"
3369 # All the data needed to compile a single target
3370 # Make sure if you compile multiple targets to
3371 # use multiple OBJS_DIR, because all in-between
3372 # binaries are stored in there, and nowhere else.
3374 s@!!CC_HOST!!@$cc_host@g;
3375 s@!!CXX_HOST!!@$cxx_host@g;
3376 s@!!CC_BUILD!!@$cc_build@g;
3377 s@!!CXX_BUILD!!@$cxx_build@g;
3378 s@!!WINDRES!!@$windres@g;
3379 s@!!STRIP!!@$strip $strip_arg@g;
3381 s@!!CFLAGS!!@$T_CFLAGS@g;
3382 s@!!CFLAGS_BUILD!!@$CFLAGS_BUILD@g;
3383 s@!!CXXFLAGS!!@$T_CXXFLAGS@g;
3384 s@!!CXXFLAGS_BUILD!!@$CXXFLAGS_BUILD@g;
3385 s@!!STRGEN_FLAGS!!@$strgen_flags@g;
3387 s@!!LDFLAGS!!@$T_LDFLAGS@g;
3388 s@!!LDFLAGS_BUILD!!@$LDFLAGS_BUILD@g;
3389 s@!!BIN_DIR!!@$BIN_DIR@g;
3390 s@!!ROOT_DIR!!@$ROOT_DIR@g;
3391 s@!!MEDIA_DIR!!@$MEDIA_DIR@g;
3392 s@!!SOURCE_LIST!!@$SOURCE_LIST@g;
3393 s@!!SRC_OBJS_DIR!!@$SRC_OBJS_DIR@g;
3394 s@!!LANG_OBJS_DIR!!@$LANG_OBJS_DIR@g;
3395 s@!!GRF_OBJS_DIR!!@$GRF_OBJS_DIR@g;
3396 s@!!SETTING_OBJS_DIR!!@$SETTING_OBJS_DIR@g;
3397 s@!!SRC_DIR!!@$SRC_DIR@g;
3398 s@!!SCRIPT_SRC_DIR!!@$SCRIPT_SRC_DIR@g;
3399 s@!!OSXAPP!!@$OSXAPP@g;
3400 s@!!LANG_DIR!!@$LANG_DIR@g;
3402 s@!!BINARY_DIR!!@$prefix_dir/$binary_dir@g;
3403 s@!!DATA_DIR!!@$prefix_dir/$data_dir@g;
3404 s@!!DOC_DIR!!@$prefix_dir/$doc_dir@g;
3405 s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
3406 s@!!ICON_DIR!!@$prefix_dir/$icon_dir@g;
3407 s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
3408 s@!!PERSONAL_DIR!!@$personal_dir@g;
3409 s@!!SHARED_DIR!!@$shared_dir@g;
3410 s@!!INSTALL_DIR!!@$install_dir@g;
3411 s@!!BINARY_NAME!!@$binary_name@g;
3412 s@!!STRGEN!!@$STRGEN@g;
3413 s@!!ENDIAN_CHECK!!@$ENDIAN_CHECK@g;
3414 s@!!DEPEND!!@$DEPEND@g;
3415 s@!!SETTINGSGEN!!@$SETTINGSGEN@g;
3416 s@!!ENDIAN_FORCE!!@$endian@g;
3417 s@!!STAGE!!@$STAGE@g;
3418 s@!!MAKEDEPEND!!@$makedepend@g;
3419 s@!!CFLAGS_MAKEDEP!!@$cflags_makedep@g;
3421 s@!!CONFIG_CACHE_COMPILER!!@config.cache.compiler@g;
3422 s@!!CONFIG_CACHE_LINKER!!@config.cache.linker@g;
3423 s@!!CONFIG_CACHE_ENDIAN!!@config.cache.endian@g;
3424 s@!!CONFIG_CACHE_SOURCE!!@config.cache.source@g;
3425 s@!!CONFIG_CACHE_VERSION!!@config.cache.version@g;
3426 s@!!CONFIG_CACHE_SOURCE_LIST!!@config.cache.source.list@g;
3427 s@!!CONFIG_CACHE_PWD!!@config.cache.pwd@g;
3428 s@!!LANG_SUPPRESS!!@$lang_suppress@g;
3429 s@!!OBJS_C!!@$OBJS_C@g;
3430 s@!!OBJS_CPP!!@$OBJS_CPP@g;
3431 s@!!OBJS_MM!!@$OBJS_MM@g;
3432 s@!!OBJS_RC!!@$OBJS_RC@g;
3435 s@!!CONFIGURE_FILES!!@$CONFIGURE_FILES@g;
3437 s@!!DISTCC!!@$distcc@g;
3438 s@!!NFORENUM!!@$nforenum@g;
3439 s@!!GRFCODEC!!@$grfcodec@g;
3442 if [ "$icon_theme_dir" != "" ]; then
3443 SRC_REPLACE="$SRC_REPLACE
3444 s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
3447 SRC_REPLACE="$SRC_REPLACE
3448 s@!!ICON_THEME_DIR!!@@g;
3452 if [ "$man_dir" != "" ]; then
3453 SRC_REPLACE="$SRC_REPLACE
3454 s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
3457 SRC_REPLACE="$SRC_REPLACE
3462 if [ "$menu_dir" != "" ]; then
3463 SRC_REPLACE="$SRC_REPLACE
3464 s@!!MENU_DIR!!@$prefix_dir/$menu_dir@g;
3467 SRC_REPLACE="$SRC_REPLACE
3473 generate_menu_item() {
3476 s@!!MENU_GROUP!!@$menu_group@g;
3477 s@!!MENU_NAME!!@$menu_name@g
3479 log 1 "Generating menu item..."
3481 < $ROOT_DIR/media/openttd.desktop.in sed "$MENU_REPLACE" > media/openttd.desktop
3489 # Create the main Makefile
3490 log 1 "Generating Makefile..."
3491 echo "# Auto-generated file from 'Makefile.in' -- DO NOT EDIT" > Makefile
3492 < $ROOT_DIR/Makefile.in sed "$SRC_REPLACE" >> Makefile
3493 cp $ROOT_DIR/Makefile.bundle.in Makefile.bundle
3494 echo "# Auto-generated file -- DO NOT EDIT" > Makefile.am
3496 # Make the copy of the source-list, so we don't trigger an unwanted recompile
3497 cp $SOURCE_LIST config.cache.source.list
3498 # Add the current directory, so we don't trigger an unwanted recompile
3499 echo "`pwd`" > config.cache.pwd
3500 # Make sure config.cache is OLDER then config.cache.source.list
3504 if [ "$menu_dir" != "" ]; then
3514 # Create the language file
3515 mkdir -p $LANG_OBJS_DIR
3517 log 1 "Generating lang/Makefile..."
3518 echo "# Auto-generated file from 'Makefile.lang.in' -- DO NOT EDIT" > $LANG_OBJS_DIR/Makefile
3519 < $ROOT_DIR/Makefile.lang.in sed "$SRC_REPLACE" >> $LANG_OBJS_DIR/Makefile
3520 echo "DIRS += $LANG_OBJS_DIR" >> Makefile.am
3521 echo "LANG_DIRS += $LANG_OBJS_DIR" >> Makefile.am
3524 generate_settings() {
3529 # Create the language file
3530 mkdir -p $SETTING_OBJS_DIR
3532 log 1 "Generating setting/Makefile..."
3533 echo "# Auto-generated file from 'Makefile.settings.in' -- DO NOT EDIT" > $SETTING_OBJS_DIR/Makefile
3534 < $ROOT_DIR/Makefile.setting.in sed "$SRC_REPLACE" >> $SETTING_OBJS_DIR/Makefile
3535 echo "DIRS += $SETTING_OBJS_DIR" >> Makefile.am
3543 # Create the language file
3544 mkdir -p $GRF_OBJS_DIR
3546 log 1 "Generating grf/Makefile..."
3547 echo "# Auto-generated file from 'Makefile.grf.in' -- DO NOT EDIT" > $GRF_OBJS_DIR/Makefile
3548 < $ROOT_DIR/Makefile.grf.in sed "$SRC_REPLACE" >> $GRF_OBJS_DIR/Makefile
3549 echo "DIRS += $GRF_OBJS_DIR" >> Makefile.am
3552 generate_src_normal() {
3557 # Create the source file
3558 mkdir -p $SRC_OBJS_DIR
3560 log 1 "Generating $2/Makefile..."
3561 echo "# Auto-generated file from 'Makefile.src.in' -- DO NOT EDIT" > $SRC_OBJS_DIR/Makefile
3562 < $ROOT_DIR/Makefile.src.in sed "$SRC_REPLACE" >> $SRC_OBJS_DIR/Makefile
3563 echo "DIRS += $SRC_OBJS_DIR" >> Makefile.am
3564 echo "SRC_DIRS += $SRC_OBJS_DIR" >> Makefile.am
3567 generate_src_osx() {
3568 cc_host_orig="$cc_host"
3569 cxx_host_orig="$cxx_host"
3570 CFLAGS_orig="$CFLAGS"
3571 LDFLAGS_orig="$LDFLAGS"
3573 for type in $enable_universal; do
3575 if [ -n "$osx_sdk_104_path" ]; then
3576 # Use 10.4 SDK for 32-bit targets
3577 CFLAGS="-isysroot $osx_sdk_104_path $CFLAGS_orig"
3578 LDFLAGS="-Wl,-syslibroot,$osx_sdk_104_path $LDFLAGS_orig"
3581 # We don't want to duplicate the x86_64 stuff for each target, so do it once here
3582 if [ "$type" = "ppc64" ] || [ "$type" = "x86_64" ]; then
3583 # 64 bits is always 10.5 or higher. Furthermore it has a non const ICONV
3584 # and they also removed support for QuickTime/QuickDraw
3585 if [ -n "$osx_sdk_path" ]; then
3586 CFLAGS="-isysroot $osx_sdk_path $CFLAGS_orig"
3587 LDFLAGS="-Wl,-syslibroot,$osx_sdk_path $LDFLAGS_orig"
3589 CFLAGS="$CFLAGS -D_SQ64 -DNO_QUICKTIME -UENABLE_COCOA_QUICKDRAW"
3590 LIBS="`echo $LIBS | sed 's/-framework QuickTime//'`"
3595 BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc"
3596 cc_host="$cc_host_orig -arch ppc -mmacosx-version-min=10.3"
3597 cxx_host="$cxx_host_orig -arch ppc -mmacosx-version-min=10.3"
3598 generate_src_normal "[ppc]" "objs/ppc";;
3600 BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc970"
3601 cc_host="$cc_host_orig -arch ppc970 -mmacosx-version-min=10.3 -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
3602 cxx_host="$cxx_host_orig -arch ppc970 -mmacosx-version-min=10.3 -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
3603 generate_src_normal "[ppc970]" "objs/ppc970";;
3605 BASE_SRC_OBJS_DIR="$OBJS_DIR/i386"
3606 cc_host="$cc_host_orig -arch i386 -mmacosx-version-min=10.4"
3607 cxx_host="$cxx_host_orig -arch i386 -mmacosx-version-min=10.4"
3608 generate_src_normal "[i386]" "objs/i386";;
3610 BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc64"
3611 cc_host="$cc_host_orig -arch ppc64 -mmacosx-version-min=10.5"
3612 cxx_host="$cxx_host_orig -arch ppc64 -mmacosx-version-min=10.5"
3613 generate_src_normal "[ppc64]" "objs/ppc64";;
3615 BASE_SRC_OBJS_DIR="$OBJS_DIR/x86_64"
3616 cc_host="$cc_host_orig -arch x86_64 -mmacosx-version-min=10.5"
3617 cxx_host="$cxx_host_orig -arch x86_64 -mmacosx-version-min=10.5"
3618 generate_src_normal "[x86_64]" "objs/x86_64";;
3619 *) log 1 "Unknown architecture requested for universal build: $type";;
3625 if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ]; then
3628 generate_src_normal "[SRC]" "objs"
3633 echo "'configure' configures OpenTTD."
3635 echo "Usage: $0 [OPTION]... [VAR=VALUE]..."
3637 echo "To assign environment variables (e.g., CC, CFLAGS...), specify them as"
3638 echo "VAR=VALUE. See below for descriptions of some of the useful variables."
3640 echo "Defaults for the options are specified in brackets."
3642 echo "Configuration:"
3643 echo " -h, --help display this help and exit"
3645 echo "System types:"
3646 echo " --build=BUILD configure for building on BUILD [guessed]"
3647 echo " --host=HOST cross-compile to build programs to run"
3648 echo " on HOST [BUILD]"
3649 echo " --windres=WINDRES the windres to use [HOST-windres]"
3650 echo " --strip=STRIP the strip to use [HOST-strip]"
3651 echo " --awk=AWK the awk to use in configure [awk]"
3652 echo " --lipo=LIPO the lipo to use (OSX ONLY) [HOST-lipo]"
3653 echo " --os=OS the OS we are compiling for [DETECT]"
3654 echo " DETECT/UNIX/OSX/FREEBSD/OPENBSD/NETBSD/"
3655 echo " MORPHOS/HPUX/BEOS/SUNOS/CYGWIN/MINGW/OS2/"
3656 echo " DOS/WINCE/PSP/HAIKU"
3657 echo " --endian=ENDIAN set the endian of the HOST (AUTO/LE/BE)"
3660 echo " --prefix-dir=dir specifies the prefix for all installed"
3661 echo " files [/usr/local]"
3662 echo " --binary-dir=dir location of the binary. Will be prefixed"
3663 echo " with the prefix-dir [games]"
3664 echo " --data-dir=dir location of data files (lang, data, gm)."
3665 echo " Will be prefixed with the prefix-dir"
3666 echo " [share/games/openttd]"
3667 echo " --doc-dir=dir location of the doc files"
3668 echo " Will be prefixed with the prefix-dir"
3670 echo " --icon-dir=dir location of icons. Will be prefixed"
3671 echo " with the prefix-dir [share/pixmaps]"
3672 echo " --icon-theme-dir=dir location of icon theme."
3673 echo " Will be prefixed with the prefix-dir"
3674 echo " and postfixed with size-dirs [$icon_theme_dir]"
3675 echo " --man-dir=dir location of the manual page (UNIX only)"
3676 echo " Will be prefixed with the prefix-dir"
3678 echo " --menu-dir=dir location of the menu item. (UNIX only, except OSX)"
3679 echo " Will be prefixed with the prefix-dir"
3680 echo " [share/applications]"
3681 echo " --personal-dir=dir location of the personal directory"
3682 echo " [os-dependent default]"
3683 echo " --shared-dir=dir location of shared data files"
3684 echo " [os-dependent default]"
3685 echo " --install-dir=dir specifies the root to install to."
3686 echo " Useful to install into jails [/]"
3687 echo " --binary-name the name used for the binary, icons,"
3688 echo " desktop file, etc. when installing [openttd]"
3690 echo "Features and packages:"
3691 echo " --enable-debug[=LVL] enable debug-mode (LVL=[0123], 0 is release)"
3692 echo " --enable-desync-debug=[LVL] enable desync debug options (LVL=[012], 0 is none"
3693 echo " --enable-profiling enables profiling"
3694 echo " --enable-lto enables GCC's Link Time Optimization (LTO)/ICC's"
3695 echo " Interprocedural Optimization if available"
3696 echo " --enable-dedicated compile a dedicated server (without video)"
3697 echo " --enable-static enable static compile (doesn't work for"
3699 echo " --enable-translator enable extra output for translators"
3700 echo " --enable-universal[=ARCH] enable universal builds (OSX ONLY). Allowed is any combination"
3701 echo " of architectures: i386 ppc ppc970 ppc64 x86_64"
3702 echo " Default architectures are: i386 ppc"
3703 echo " --enable-osx-g5 enables optimizations for ppc970 (G5) (OSX ONLY)"
3704 echo " --disable-cocoa-quartz disable the quartz window mode driver for Cocoa (OSX ONLY)"
3705 echo " --disable-cocoa-quickdraw disable the quickdraw window mode driver for Cocoa (OSX ONLY)"
3706 echo " --disable-unicode disable unicode support to build win9x"
3707 echo " version (Win32 ONLY)"
3708 echo " --enable-console compile as a console application instead of as a GUI application."
3709 echo " If this setting is active, debug output will appear in the same"
3710 echo " console instead of opening a new window. (Win32 ONLY)"
3711 echo " --disable-network disable network support"
3712 echo " --disable-assert disable asserts (continue on errors)"
3713 echo " --enable-strip enable any possible stripping"
3714 echo " --without-osx-sysroot disable the automatic adding of sysroot "
3716 echo " --without-application-bundle disable generation of application bundle"
3718 echo " --without-menu-entry Don't generate a menu item (Freedesktop based only)"
3719 echo " --menu-group=group Category in which the menu item will be placed (Freedesktop based only)"
3720 echo " --menu-name=name Name of the menu item when placed [OpenTTD]"
3721 echo " --with-direct-music enable direct music support (Win32 ONLY)"
3722 echo " --with-sort=sort define a non-default location for sort"
3723 echo " --with-midi=midi define which midi-player to use"
3724 echo " --with-midi-arg=arg define which args to use for the"
3726 echo " --with-libtimidity enables libtimidity support"
3727 echo " --with-allegro[=allegro-config]"
3728 echo " enables Allegro video driver support"
3729 echo " --with-cocoa enables COCOA video driver (OSX ONLY)"
3730 echo " --with-sdl[=sdl-config] enables SDL video driver support"
3731 echo " --with-zlib[=zlib.a] enables zlib support"
3732 echo " --with-liblzma[=\"pkg-config liblzma\"]"
3733 echo " enables liblzma support"
3734 echo " --with-liblzo2[=liblzo2.a] enables liblzo2 support"
3735 echo " --with-png[=libpng-config] enables libpng support"
3736 echo " --with-freetype[=freetype-config]"
3737 echo " enables libfreetype support"
3738 echo " --with-fontconfig[=\"pkg-config fontconfig\"]"
3739 echo " enables fontconfig support"
3740 echo " --with-xdg-basedir[=\"pkg-config libxdg-basedir\"]"
3741 echo " enables XDG base directory support"
3742 echo " --with-icu[=icu-config] enables icu (used for right-to-left support)"
3743 echo " --static-icu try to link statically (libsicu instead of"
3744 echo " libicu; can fail as the new name is guessed)"
3745 echo " --with-iconv[=iconv-path] enables iconv support"
3746 echo " --with-psp-config[=psp-config] enables psp-config support (PSP ONLY)"
3747 echo " --disable-builtin-depend disable use of builtin deps finder"
3748 echo " --with-makedepend[=makedepend] enables makedepend support"
3749 echo " --with-ccache enables ccache support"
3750 echo " --with-distcc enables distcc support"
3751 echo " --without-grfcodec disable usage of grfcodec and re-generation of base sets"
3752 echo " --without-threads disable threading support"
3753 echo " --without-sse disable SSE support (x86/x86_64 only)"
3755 echo "Some influential environment variables:"
3756 echo " CC C compiler command"
3757 echo " CXX C++ compiler command"
3758 echo " CFLAGS C compiler flags"
3759 echo " CXXFLAGS C++ compiler flags"
3760 echo " WINDRES windres command"
3761 echo " LDFLAGS linker flags, e.g. -L<lib dir> if you"
3762 echo " have libraries in a nonstandard"
3763 echo " directory <lib dir>"
3764 echo " CFLAGS_BUILD C compiler flags for build time tool generation"
3765 echo " CXXFLAGS_BUILD C++ compiler flags for build time tool generation"
3766 echo " LDFLAGS_BUILD linker flags for build time tool generation"
3768 echo "Use these variables to override the choices made by 'configure' or to help"
3769 echo "it to find libraries and programs with nonstandard names/locations."