Translations update
[openttd/fttd.git] / config.lib
blob048af89800263f668bf15ab1052a4297244aadea
1 # $Id$
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/>.
8 log() {
9         if [ $1 = "1" ]; then
10                 shift
11                 echo "$@"
12         else
13                 shift
14         fi
15         echo "$@" >> $config_log
18 set_default() {
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.
22         build=""
23         host=""
24         cc_build=""
25         cc_host=""
26         cxx_build=""
27         cxx_host=""
28         windres=""
29         strip=""
30         lipo=""
31         awk="awk"
32         pkg_config="pkg-config"
33         os="DETECT"
34         endian="AUTO"
35         cpu_type="DETECT"
36         config_log="config.log"
37         prefix_dir="/usr/local"
38         binary_dir="games"
39         data_dir="share/games/openttd"
40         doc_dir="1"
41         icon_dir="share/pixmaps"
42         icon_theme_dir="1"
43         personal_dir="1"
44         shared_dir="1"
45         install_dir="/"
46         man_dir="1"
47         menu_dir="1"
48         menu_group="Game;"
49         menu_name="OpenTTD"
50         binary_name="openttd"
51         enable_debug="0"
52         enable_desync_debug="0"
53         enable_profiling="0"
54         enable_lto="0"
55         enable_dedicated="0"
56         enable_network="1"
57         enable_static="1"
58         enable_translator="0"
59         enable_unicode="1"
60         enable_console="1";
61         enable_assert="1"
62         enable_strip="0"
63         enable_universal="0"
64         enable_osx_g5="0"
65         enable_cocoa_quartz="1"
66         enable_cocoa_quickdraw="1"
67         with_osx_sysroot="1"
68         with_application_bundle="1"
69         with_menu_entry="1"
70         with_allegro="1"
71         with_sdl="1"
72         with_cocoa="1"
73         with_zlib="1"
74         with_lzma="1"
75         with_lzo2="1"
76         with_xdg_basedir="1"
77         with_png="1"
78         enable_builtin_depend="1"
79         with_makedepend="0"
80         with_direct_music="1"
81         with_sort="1"
82         with_iconv="1"
83         with_midi=""
84         with_midi_arg=""
85         with_libtimidity="1"
86         with_freetype="1"
87         with_fontconfig="1"
88         with_icu="1"
89         static_icu="0"
90         with_psp_config="1"
91         with_threads="1"
92         with_distcc="1"
93         with_ccache="1"
94         with_nforenum="1"
95         with_grfcodec="1"
96         with_sse="1"
98         save_params_array="
99                 build
100                 host
101                 cc_build
102                 cc_host
103                 cxx_build
104                 cxx_host
105                 windres
106                 strip
107                 lipo
108                 awk
109                 pkg_config
110                 os
111                 endian
112                 cpu_type
113                 config_log
114                 prefix_dir
115                 binary_dir
116                 data_dir
117                 doc_dir
118                 icon_dir
119                 icon_theme_dir
120                 man_dir
121                 menu_dir
122                 personal_dir
123                 shared_dir
124                 install_dir
125                 menu_group
126                 menu_name
127                 binary_name
128                 enable_debug
129                 enable_desync_debug
130                 enable_profiling
131                 enable_lto
132                 enable_dedicated
133                 enable_network
134                 enable_static
135                 enable_translator
136                 enable_unicode
137                 enable_console
138                 enable_assert
139                 enable_strip
140                 enable_universal
141                 enable_osx_g5
142                 enable_cocoa_quartz
143                 enable_cocoa_quickdraw
144                 with_osx_sysroot
145                 with_application_bundle
146                 with_allegro
147                 with_sdl
148                 with_cocoa
149                 with_zlib
150                 with_lzma
151                 with_lzo2
152                 with_xdg_basedir
153                 with_png
154                 enable_builtin_depend
155                 with_makedepend
156                 with_direct_music
157                 with_sort
158                 with_iconv
159                 with_midi
160                 with_midi_arg
161                 with_libtimidity
162                 with_freetype
163                 with_fontconfig
164                 with_icu
165                 static_icu
166                 with_psp_config
167                 with_threads
168                 with_distcc
169                 with_ccache
170                 with_grfcodec
171                 with_nforenum
172                 with_sse
173         CC CXX CFLAGS CXXFLAGS LDFLAGS CFLAGS_BUILD CXXFLAGS_BUILD LDFLAGS_BUILD"
176 detect_params() {
177         # Walk over all params from the user and override any default settings if
178         #  needed. This also handles any invalid option.
179         for p in "$@"; do
180                 if [ -n "$prev_p" ]; then
181                         eval "$prev_p=\$p"
182                         prev_p=
183                         continue
184                 fi
186                 optarg=`expr "x$p" : 'x[^=]*=\(.*\)'`
188                 case "$p" in
189                         --help | -h | -\?)            showhelp; exit 0;;
191                         --config-log)                 prev_p="config_log";;
192                         --config-log=*)               config_log="$optarg";;
194                         --build)                      prev_p="build";;
195                         --build=*)                    build="$optarg";;
197                         --host)                       prev_p="host";;
198                         --host=*)                     host="$optarg";;
200                         --os)                         prev_p="os";;
201                         --os=*)                       os="$optarg";;
203                         --cpu-type)                   prev_p="cpu_type";;
204                         --cpu-type=*)                 cpu_type="$optarg";;
206                         --cc-build)                   prev_p="cc_build";;
207                         --cc-build=*)                 cc_build="$optarg";;
208                         --cc-host)                    prev_p="cc_host";;
209                         --cc-host=*)                  cc_host="$optarg";;
210                         --cxx-build)                  prev_p="cxx_build";;
211                         --cxx-build=*)                cxx_build="$optarg";;
212                         --cxx-host)                   prev_p="cxx_host";;
213                         --cxx-host=*)                 cxx_host="$optarg";;
214                         --windres)                    prev_p="windres";;
215                         --windres=*)                  windres="$optarg";;
216                         --awk)                        prev_p="awk";;
217                         --awk=*)                      awk="$optarg";;
218                         --pkg-config)                 prev_p="pkg_config";;
219                         --pkg-config=*)               pkg_config="$optarg";;
220                         --strip)                      prev_p="strip";;
221                         --strip=*)                    strip="$optarg";;
222                         --lipo)                       prev_p="lipo";;
223                         --lipo=*)                     lipo="$optarg";;
225                         --endian)                     prev_p="endian";;
226                         --endian=*)                   endian="$optarg";;
230                         # Alias --prefix with --prefix-dir, for compatibility with GNU autotools
231                         --prefix-dir | --prefix)      prev_p="prefix_dir";;
232                         --prefix-dir=* | --prefix=*)  prefix_dir="$optarg";;
234                         --binary-dir)                 prev_p="binary_dir";;
235                         --binary-dir=*)               binary_dir="$optarg";;
237                         --data-dir)                   prev_p="data_dir";;
238                         --data-dir=*)                 data_dir="$optarg";;
240                         --doc-dir)                    prev_p="doc_dir";;
241                         --doc-dir=*)                  doc_dir="$optarg";;
243                         --icon-dir)                   prev_p="icon_dir";;
244                         --icon-dir=*)                 icon_dir="$optarg";;
246                         --icon-theme-dir)             prev_p="icon_theme_dir";;
247                         --icon-theme-dir=*)           icon_theme_dir="$optarg";;
248                         --without-icon-theme)         icon_theme_dir="";;
250                         --menu-dir)                   prev_p="menu_dir";;
251                         --menu-dir=*)                 menu_dir="$optarg";;
252                         --without-menu-entry)         menu_dir="";;
254                         --menu-name)                  prev_p="menu_name";;
255                         --menu-name=*)                menu_name="$optarg";;
257                         --binary-name)                prev_p="binary_name";;
258                         --binary-name=*)              binary_name="$optarg";;
260                         --man-dir)                    prev_p="man_dir";;
261                         --man-dir=*)                  man_dir="$optarg";;
263                         --personal-dir)               prev_p="personal_dir";;
264                         --personal-dir=*)             personal_dir="$optarg";;
265                         --without-personal-dir)       personal_dir="";;
267                         --shared-dir)                 prev_p="shared_dir";;
268                         --shared-dir=*)               shared_dir="$optarg";;
269                         --without-shared-dir)         shared_dir="";;
271                         --install-dir)                prev_p="install_dir";;
272                         --install-dir=*)              install_dir="$optarg";;
276                         --menu-group)                 prev_p="menu_group";;
277                         --menu-group=*)               menu_group="$optarg";;
281                         --enable-debug)               enable_debug="1";;
282                         --enable-debug=*)             enable_debug="$optarg";;
283                         --enable-desync-debug)        enable_desync_debug="1";;
284                         --enable-desync-debug=*)      enable_desync_debug="$optarg";;
285                         --enable-profiling)           enable_profiling="1";;
286                         --enable-profiling=*)         enable_profiling="$optarg";;
287                         --enable-lto)                 enable_lto="1";;
288                         --enable-lto=*)               enable_lto="$optarg";;
289                         --enable-ipo)                 enable_lto="1";;
290                         --enable-ipo=*)               enable_lto="$optarg";;
291                         --enable-dedicated)           enable_dedicated="1";;
292                         --enable-dedicated=*)         enable_dedicated="$optarg";;
293                         --enable-network)             enable_network="2";;
294                         --enable-network=*)           enable_network="$optarg";;
295                         --disable-network)            enable_network="0";;
296                         --disable-static)             enable_static="0";;
297                         --enable-static)              enable_static="2";;
298                         --enable-static=*)            enable_static="$optarg";;
299                         --disable-translator)         enable_translator="0";;
300                         --enable-translator)          enable_translator="2";;
301                         --enable-translator=*)        enable_translator="$optarg";;
302                         --disable-assert)             enable_assert="0";;
303                         --enable-assert)              enable_assert="2";;
304                         --enable-assert=*)            enable_assert="$optarg";;
305                         --disable-strip)              enable_strip="0";;
306                         --enable-strip)               enable_strip="2";;
307                         --enable-strip=*)             enable_strip="$optarg";;
308                         --disable-universal)          enable_universal="0";;
309                         --enable-universal)           enable_universal="i386 ppc";;
310                         --enable-universal=*)         enable_universal="$optarg";;
311                         --disable-osx-g5)             enable_osx_g5="0";;
312                         --enable-osx-g5)              enable_osx_g5="2";;
313                         --enable-osx-g5=*)            enable_osx_g5="$optarg";;
314                         --disable-unicode)            enable_unicode="0";;
315                         --enable-unicode)             enable_unicode="2";;
316                         --enable-unicode=*)           enable_unicode="$optarg";;
317                         --disable-console)            enable_console="0";;
318                         --enable-console)             enable_console="2";;
319                         --enable-console=*)           enable_console="$optarg";;
321                         --disable-cocoa-quartz)       enable_cocoa_quartz="0";;
322                         --enable-cocoa-quartz)        enable_cocoa_quartz="2";;
323                         --enable-cocoa-quartz=*)      enable_cocoa_quartz="$optarg";;
324                         --disable-cocoa-quickdraw)    enable_cocoa_quickdraw="0";;
325                         --enable-cocoa-quickdraw)     enable_cocoa_quickdraw="2";;
326                         --enable-cocoa-quickdraw=*)   enable_cocoa_quickdraw="$optarg";;
328                         --with-allegro)               with_allegro="2";;
329                         --without-allegro)            with_allegro="0";;
330                         --with-allegro=*)             with_allegro="$optarg";;
332                         --with-sdl)                   with_sdl="2";;
333                         --without-sdl)                with_sdl="0";;
334                         --with-sdl=*)                 with_sdl="$optarg";;
336                         --with-cocoa)                 with_cocoa="2";;
337                         --without-cocoa)              with_cocoa="0";;
338                         --with-cocoa=*)               with_cocoa="$optarg";;
340                         --with-zlib)                  with_zlib="2";;
341                         --without-zlib)               with_zlib="0";;
342                         --with-zlib=*)                with_zlib="$optarg";;
344                         --with-lzma)                  with_lzma="2";;
345                         --without-lzma)               with_lzma="0";;
346                         --with-lzma=*)                with_lzma="$optarg";;
347                         --with-liblzma)               with_lzma="2";;
348                         --without-liblzma)            with_lzma="0";;
349                         --with-liblzma=*)             with_lzma="$optarg";;
351                         --with-lzo2)                  with_lzo2="2";;
352                         --without-lzo2)               with_lzo2="0";;
353                         --with-lzo2=*)                with_lzo2="$optarg";;
354                         --with-liblzo2)               with_lzo2="2";;
355                         --without-liblzo2)            with_lzo2="0";;
356                         --with-liblzo2=*)             with_lzo2="$optarg";;
358                         --with-xdg-basedir)           with_xdg_basedir="2";;
359                         --without-xdg-basedir)        with_xdg_basedir="0";;
360                         --with-xdg-basedir=*)         with_xdg_basedir="$optarg";;
361                         --with-libxdg-basedir)        with_xdg_basedir="2";;
362                         --without-libxdg-basedir)     with_xdg_basedir="0";;
363                         --with-libxdg-basedir=*)      with_xdg_basedir="$optarg";;
365                         --with-png)                   with_png="2";;
366                         --without-png)                with_png="0";;
367                         --with-png=*)                 with_png="$optarg";;
368                         --with-libpng)                with_png="2";;
369                         --without-libpng)             with_png="0";;
370                         --with-libpng=*)              with_png="$optarg";;
372                         --with-libtimidity)           with_libtimidity="2";;
373                         --without-libtimidity)        with_libtimidity="0";;
374                         --with-libtimidity=*)         with_libtimidity="$optarg";;
376                         --with-freetype)              with_freetype="2";;
377                         --without-freetype)           with_freetype="0";;
378                         --with-freetype=*)            with_freetype="$optarg";;
379                         --with-libfreetype)           with_freetype="2";;
380                         --without-libfreetype)        with_freetype="0";;
381                         --with-libfreetype=*)         with_freetype="$optarg";;
383                         --with-fontconfig)            with_fontconfig="2";;
384                         --without-fontconfig)         with_fontconfig="0";;
385                         --with-fontconfig=*)          with_fontconfig="$optarg";;
386                         --with-libfontconfig)         with_fontconfig="2";;
387                         --without-libfontconfig)      with_fontconfig="0";;
388                         --with-libfontconfig=*)       with_fontconfig="$optarg";;
390                         --with-icu)                   with_icu="2";;
391                         --without-icu)                with_icu="0";;
392                         --with-icu=*)                 with_icu="$optarg";;
393                         --with-libicu)                with_icu="2";;
394                         --without-libicu)             with_icu="0";;
395                         --with-libicu=*)              with_icu="$optarg";;
396                         --static-icu)                 static_icu="1";;
397                         --static-icu=*)               static_icu="$optarg";;
398                         --static-libicu)              static_icu="1";;
399                         --static-libicu=*)            static_icu="$optarg";;
401                         --with-psp-config)            with_psp_config="2";;
402                         --without-psp-config)         with_psp_config="0";;
403                         --with-psp-config=*)          with_psp_config="$optarg";;
405                         --disable-builtin-depend)     enable_builtin_depend="0";;
406                         --enable-builtin-depend)      enable_builtin_depend="2";;
407                         --enable-builtin-depend=*)    enable_builtin_depend="$optarg";;
409                         --with-makedepend)            with_makedepend="2";;
410                         --without-makedepend)         with_makedepend="0";;
411                         --with-makedepend=*)          with_makedepend="$optarg";;
413                         --with-direct-music)          with_direct_music="2";;
414                         --without-direct-music)       with_direct_music="0";;
415                         --with-direct-music=*)        with_direct_music="$optarg";;
417                         --with-sort)                  with_sort="2";;
418                         --without-sort)               with_sort="0";;
419                         --with-sort=*)                with_sort="$optarg";;
421                         --with-iconv)                 with_iconv="2";;
422                         --without-iconv)              with_iconv="0";;
423                         --with-iconv=*)               with_iconv="$optarg";;
425                         --with-midi=*)                with_midi="$optarg";;
426                         --with-midi-arg=*)            with_midi_arg="$optarg";;
428                         --without-distcc)             with_distcc="0";;
429                         --with-distcc)                with_distcc="2";;
430                         --with-distcc=*)              with_distcc="$optarg";;
432                         --without-ccache)             with_ccache="0";;
433                         --with-ccache)                with_ccache="2";;
434                         --with-ccache=*)              with_ccache="$optarg";;
436                         --without-nforenum)           with_nforenum="0";;
437                         --with-nforenum)              with_nforenum="2";;
438                         --with-nforenum=*)            with_nforenum="$optarg";;
440                         --without-grfcodec)           with_grfcodec="0";;
441                         --with-grfcodec)              with_grfcodec="2";;
442                         --with-grfcodec=*)            with_grfcodec="$optarg";;
444                         --without-osx-sysroot)        with_osx_sysroot="0";;
445                         --with-osx-sysroot)           with_osx_sysroot="2";;
446                         --with-osx-sysroot=*)         with_osx_sysroot="$optarg";;
448                         --without-application-bundle) with_application_bundle="0";;
449                         --with-application-bundle)    with_application_bundle="1";;
450                         --with-application-bundle=*)  with_application_bundle="$optarg";;
452                         --without-threads)            with_threads="0";;
453                         --with-threads)               with_threads="1";;
454                         --with-threads=*)             with_threads="$optarg";;
456                         --without-sse)                with_sse="0";;
457                         --with-sse)                   with_sse="1";;
458                         --with-sse=*)                 with_sse="$optarg";;
460                         CC=* | --CC=*)                CC="$optarg";;
461                         CXX=* | --CXX=*)              CXX="$optarg";;
462                         CFLAGS=* | --CFLAGS=*)        CFLAGS="$optarg";;
463                         CXXFLAGS=* | --CXXFLAGS=*)    CXXFLAGS="$optarg";;
464                         LDFLAGS=* | --LDFLAGS=*)      LDFLAGS="$optarg";;
465                         CFLAGS_BUILD=* | --CFLAGS_BUILD=* | --CFLAGS-BUILD=*)     CFLAGS_BUILD="$optarg";;
466                         CXXFLAGS_BUILD=* | --CXXFLAGS_BUILD=* | --CXXFLAGS-BUILD=*) CXXFLAGS_BUILD="$optarg";;
467                         LDFLAGS_BUILD=* | --LDFLAGS_BUILD=* | --LDFLAGS-BUILD=*)   LDFLAGS_BUILD="$optarg";;
469                         --ignore-extra-parameters)    ignore_extra_parameters="1";;
471                         --* | -*)
472                                 if [ "$ignore_extra_parameters" = "0" ]; then
473                                         log 1 "Unknown option $p"
474                                         exit 1
475                                 else
476                                         log 1 "Unknown option $p ignored"
477                                 fi
478                                 ;;
479                 esac
480         done
482         if [ -n "$prev_p" ]; then
483                 log 1 "configure: error: missing argument to --$prev_p"
484                 exit 1
485         fi
487         # Clean the logfile
488         echo "" > $config_log
489         log 2 "Invocation: $0 $*"
492 save_params() {
493         # Here we save all params, so we can later on do an exact redo of this
494         #  configuration, without having the user to re-input stuff
496         echo "Running configure with following options:" >> $config_log
497         echo "" >> $config_log
499         configure="$CONFIGURE_EXECUTABLE --ignore-extra-parameters"
500         for p in $save_params_array; do
501                 eval "v=\"\$$p\""
502                 p=`echo "$p" | sed 's@_@-@g;s@\n@@g;s@ @\\ @g'`
503                 # Only save those params that aren't empty
504                 configure="$configure --$p=\"$v\""
505         done
507         echo "$configure" >> $config_log
508         echo "$configure" > config.cache
509         echo "" >> $config_log
512 check_params() {
513         # Some params want to be in full uppercase, else they might not work as
514         # expected.. fix that here
516         endian=`echo $endian | tr '[a-z]' '[A-Z]'`
517         os=`echo $os | tr '[a-z]' '[A-Z]'`
518         cpu_type=`echo $cpu_type | tr '[a-z]' '[A-Z]'`
520         # Check if all params have valid values
522         # Endian only allows AUTO, LE and, BE
523         if ! echo $endian | egrep -q '^(AUTO|LE|BE|PREPROCESSOR)$'; then
524                 log 1 "configure: error: invalid option --endian=$endian"
525                 log 1 " Available options are: --endian=[AUTO|LE|BE]"
526                 exit 1
527         fi
528         if [ "$endian" = "PREPROCESSOR" ] && [ "$os" != "OSX" ]; then
529                 log 1 "configure: error: invalid option --endian=$endian"
530                 log 1 " PREPROCESSOR is only available for OSX"
531                 exit 1
532         fi
533         # OS only allows DETECT, UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, MORPHOS, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP
534         if ! echo $os | egrep -q '^(DETECT|UNIX|OSX|FREEBSD|DRAGONFLY|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP)$'; then
535                 log 1 "configure: error: invalid option --os=$os"
536                 log 1 " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|DRAGONFLY|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP]"
537                 exit 1
538         fi
539         # cpu_type can be either 32 or 64
540         if ! echo $cpu_type | egrep -q '^(32|64|DETECT)$'; then
541                 log 1 "configure: error: invalid option --cpu-type=$cpu_type"
542                 log 1 " Available options are: --cpu-type[=DETECT|32|64]"
543                 exit 1
544         fi
545         # enable_debug should be between 0 and 4
546         if ! echo $enable_debug | egrep -q '^[0123]$'; then
547                 log 1 "configure: error: invalid option --enable-debug=$enable_debug"
548                 log 1 " Available options are: --enable-debug[=0123]"
549                 exit 1
550         fi
552         # enable_desync_debug should be between 0 and 3
553         if ! echo $enable_desync_debug | egrep -q '^[012]$'; then
554                 log 1 "configure: error: invalid option --enable-desync-debug=$enable_desync_debug"
555                 log 1 " Available options are: --enable-desync-debug[=012]"
556                 exit 1
557         fi
559         detect_awk
561         detect_os
563         check_build
564         check_host
566         # Check for universal builds; they only make sense for OSX, so fail if enabled for another OS
567         if [ "$enable_universal" = "0" ]; then
568                 log 1 "checking universal build... no"
569         else
570                 if [ "$os" != "OSX" ]; then
571                         log 1 "configure: error: --enable-universal only works on OSX"
572                         exit 1
573                 fi
574                 log 1 "checking universal build... yes, for: $enable_universal"
575         fi
577         # Already detected by check_build
578         log 1 "checking build cc... $cc_build"
579         log 1 "checking host cc... $cc_host"
581         check_cxx_build
582         check_cxx_host
583         check_windres
584         if [ "$enable_strip" != "0" ]; then
585                 check_strip
586         else
587                 log 1 "checking strip... disabled"
588         fi
589         check_lipo
591         if [ "$enable_builtin_depend" != "0" ]; then
592                 log 1 "checking builtin depend... yes"
593                 makedepend="\$(SRC_OBJS_DIR)/\$(DEPEND)"
594         else
595                 log 1 "checking builtin depend... no"
596         fi
598         check_makedepend
599         detect_cputype
600         detect_sse_capable_architecture
602         if [ "$enable_static" = "1" ]; then
603                 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "DOS" ]; then
604                         enable_static="2"
605                 else
606                         enable_static="0"
607                 fi
608         fi
610         if [ "$enable_static" != "0" ]; then
611                 log 1 "checking static... yes"
613                 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "OSX" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "DOS" ]; then
614                         log 1 "WARNING: static is only known to work on Windows, DOS, MacOSX and MorphOS"
615                         log 1 "WARNING: use static at your own risk on this platform"
617                         sleep 5
618                 fi
619         else
620                 log 1 "checking static... no"
621         fi
623         if [ "$enable_unicode" = "1" ]; then
624                 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "DOS" ]; then
625                         enable_unicode="2"
626                 else
627                         enable_unicode="0"
628                 fi
629         fi
631         if [ "$enable_unicode" != "0" ]; then
632                 log 1 "checking unicode... yes"
633         else
634                 log 1 "checking unicode... no"
635         fi
637         # Show what we configured
638         if [ "$enable_debug" = "0" ]; then
639                 log 1 "using debug level... no"
640         elif [ "$enable_profiling" != "0" ]; then
641                 log 1 "using debug level... profiling (debug level $enable_debug)"
642         else
643                 log 1 "using debug level... level $enable_debug"
644         fi
646         if [ "$enable_desync_debug" = "0" ]; then
647                 log 1 "using desync debug level... no"
648         else
649                 log 1 "using desync debug level... level $enable_desync_debug"
650                 log 1 "WARNING: desync debug functions slow down the game considerably."
651                 log 1 "WARNING: use only when you are instructed to do so"
652                 log 1 "         or when you know what you are doing."
654                 sleep 5
655         fi
657         if [ "$enable_lto" != "0" ]; then
658                 # GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
659                 if $cxx_build -dumpspecs 2>&1 | grep -q '\%{flto' || $cxx_build -help ipo 2>&1 | grep -q '\-ipo'; then
660                         log 1 "using link time optimization... yes"
661                 else
662                         enable_lto="0"
663                         log 1 "using link time optimization... no"
664                         log 1 "WARNING: you selected link time optimization but it is not found."
665                         sleep 5
666                 fi
667         else
668                 log 1 "using link time optimization... no"
669         fi
672         if [ "$os" != "OSX" ] && [ "$with_osx_sysroot" != "0" ]; then
673                 if [ "$with_osx_sysroot" = "1" ]; then
674                         with_osx_sysroot="0"
676                         log 1 "checking OSX sysroot... not OSX, skipping"
677                 else
678                         log 1 "configure: error: --with-osx-sysroot only works if OSX is the target"
679                         exit 1
680                 fi
681         fi
683         if [ "$with_osx_sysroot" != "0" ]; then
684                 if [ "$enable_universal" = "0" ] && [ "$with_osx_sysroot" != "1" ] && [ "$with_osx_sysroot" != "2" ]; then
685                         # Sysroot manually specified? Check for usability
686                         log 1 "checking OSX sysroot... $with_osx_sysroot"
687                         if ! check_osx_sdk "$with_osx_sysroot"; then
688                                 log 1 "Passed sysroot not found/not functional"
689                                 exit 1
690                         fi
691                 else
692                         # If autodetect and no universal, use system default
693                         if [ "$with_osx_sysroot" = "1" ] && [ "$enable_universal" = "0" ]; then
694                                 log 1 "checking OSX sysroot... no (use system default)"
695                         else
696                                 log 1 "checking OSX sysroot... automatically"
697                                 detect_osx_sdk
698                         fi
699                 fi
701                 if [ -n "$osx_sdk_path" ]; then
702                         if [ "$enable_universal" != "0" ]; then
703                                 if [ -z "$osx_sdk_104_path" ]; then
704                                         log 1 "WARNING: Could not find a usable 10.4u SDK, the resulting"
705                                         log 1 "WARNING: binary will only run on OSX 10.5 or later"
706                                         osx_sdk_104_path="$osx_sdk_path"
707                                 fi
708                                 OSX_SYSROOT="-isysroot $osx_sdk_104_path"
709                                 OSX_LD_SYSROOT="-Wl,-syslibroot,$osx_sdk_104_path"
710                         else
711                                 OSX_SYSROOT="-isysroot $osx_sdk_path"
712                                 OSX_LD_SYSROOT="-Wl,-syslibroot,$osx_sdk_path"
713                         fi
714                 fi
715         else
716                 if [ "$os" = "OSX" ]; then
717                         log 1 "checking OSX sysroot... no (use system default)"
718                 fi
719         fi
721         detect_allegro
722         detect_sdl
723         detect_cocoa
725         if [ "$enable_dedicated" != "0" ]; then
726                 log 1 "checking GDI video driver... dedicated server, skipping"
727                 log 1 "checking dedicated... found"
729                 if [ "$enable_network" = "0" ]; then
730                         log 1 "configure: error: building a dedicated server without network support is pointless"
731                         exit 1
732                 fi
733         else
734                 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
735                         log 1 "checking GDI video driver... found"
736                 else
737                         log 1 "checking GDI video driver... not Windows, skipping"
738                 fi
740                 if [ -z "$allegro_config" ] && [ -z "$sdl_config" ] && [ "$with_cocoa" = 0 ] && [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
741                         log 1 "configure: error: no video driver development files found"
742                         log 1 " If you want a dedicated server use --enable-dedicated as parameter"
743                         exit 1
744                 else
745                         log 1 "checking dedicated... not selected"
746                 fi
747         fi
749         if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
750                 log 1 "checking console application... not Windows, skipping"
751         elif [ "$enable_console" = "1" ] && [ "$enable_dedicated" != "0" ]; then
752                 log 1 "checking console application... dedicated server, enabled"
753                 enable_console="2"
754         elif [ "$enable_console" = "1" ]; then
755                 log 1 "checking console application... disabled (only used when forced)"
756                 enable_console="0"
757         elif [ "$enable_console" = "0" ]; then
758                 log 1 "checking console application... disabled"
759         else
760                 log 1 "checking console application... enabled"
761         fi
763         if [ "$enable_network" = "1" ] && [ "$os" = "DOS" ]; then
764                 log 1 "checking network... DOS, skipping"
765                 enable_network=0
766         elif [ "$enable_network" != "0" ]; then
767                 log 1 "checking network... found"
768         else
769                 log 1 "checking network... disabled"
770         fi
772         log 1 "checking squirrel... found"
773         SCRIPT_SRC_DIR="$ROOT_DIR/src/3rdparty/squirrel/include"
775         if [ "$enable_translator" != "0" ]; then
776                 log 1 "checking translator... debug"
777                 # -t shows TODO items, normally they are muted
778                 strgen_flags="-t"
779         else
780                 log 1 "checking translator... no"
781                 strgen_flags=""
782         fi
784         if [ "$enable_assert" != "0" ]; then
785                 log 1 "checking assert... enabled"
786         else
787                 log 1 "checking assert... disabled"
788         fi
790         pre_detect_with_zlib=$with_zlib
791         detect_zlib
793         if [ "$with_zlib" = "0" ] || [ -z "$zlib-config" ]; then
794                 log 1 "WARNING: zlib was not detected or disabled"
795                 log 1 "WARNING: OpenTTD doesn't require zlib, but it does mean that many features"
796                 log 1 "WARNING: (like loading most old savegames/scenarios, loading heightmaps,"
797                 log 1 "WARNING: using PNG, or using fonts, ...) will be disabled."
798                 if [ "$pre_detect_with_zlib" = "0" ]; then
799                         log 1 "WARNING: We strongly suggest you to install zlib."
800                 else
801                         log 1 "configure: error: no zlib detected"
802                         log 1 " If you want to compile without zlib use --without-zlib as parameter"
803                         exit
804                 fi
805         fi
807         pre_detect_with_lzma=$with_lzma
808         detect_lzma
810         if [ "$with_lzma" = "0" ] || [ -z "$lzma_config" ]; then
811                 log 1 "WARNING: lzma was not detected or disabled"
812                 log 1 "WARNING: OpenTTD doesn't require lzma, but it does mean that many features"
813                 log 1 "WARNING: (like loading most savegames/scenarios and joining most servers)"
814                 log 1 "WARNING: will be disabled."
815                 if [ "$pre_detect_with_lzma" = "0" ]; then
816                         log 1 "WARNING: We strongly suggest you to install liblzma."
817                         log 1 "configure: error: no liblzma detected"
818                 else
819                         log 1 " If you want to compile without lzma use --without-lzma as parameter"
820                         exit
821                 fi
822         fi
824         pre_detect_with_lzo2=$with_lzo2
825         detect_lzo2
827         if [ "$with_lzo2" = "0" ] || [ -z "$lzo2" ]; then
828                 log 1 "WARNING: liblzo2 was not detected or disabled"
829                 log 1 "WARNING: OpenTTD doesn't require liblzo2, but it does mean that"
830                 log 1 "WARNING: loading old savegames/scenarios will be disabled."
831                 if [ "$pre_detect_with_lzo2" = "0" ]; then
832                         log 1 "WARNING: We strongly suggest you to install liblzo2."
833                 else
834                         log 1 "configure: error: no liblzo2 detected"
835                         log 1 " If you want to compile without liblzo2 use --without-liblzo2 as parameter"
836                         exit
837                 fi
838         fi
840         detect_xdg_basedir
841         detect_png
842         detect_freetype
843         detect_fontconfig
844         detect_icu
845         detect_pspconfig
846         detect_libtimidity
848         if [ "$with_direct_music" != "0" ]; then
849                 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
850                         if [ "$with_direct_music" != "1" ]; then
851                                 log 1 "configure: error: direct-music is only supported on Win32 targets"
852                                 exit 1
853                         fi
854                         with_direct_music="0"
856                         log 1 "checking direct-music... not Windows, skipping"
857                 else
858                         check_direct_music
859                 fi
860         fi
862         detect_sort
864         if [ "$os" = "OSX" ] && [ "$endian" = "AUTO" ]; then
865                 endian="PREPROCESSOR"
866         fi
868         log 1 "checking endianness... $endian"
870         # Suppress language errors when there is a version defined, indicating a release
871         #  It just isn't pretty if any release produces warnings in the languages.
872         if [ -f "$ROOT_DIR/version" ]; then
873                 lang_suppress="yes"
874                 log 1 "suppress language errors... yes"
875         else
876                 lang_suppress=""
877                 log 1 "suppress language errors... no"
878         fi
880         if [ "$enable_debug" = "0" ] && [ "$enable_profiling" = "0" ] && [ "$enable_strip" != "0" ]; then
881                 if [ "$os" = "MORPHOS" ]; then
882                         strip_arg="--strip-all --strip-unneeded --remove-section .comment"
883                 elif [ "$os" = "OSX" ]; then
884                         strip_arg=""
885                 elif [ "$os" = "OS2" ]; then
886                         strip_arg=""
887                         # OS2 uses strip via gcc, because it needs to be feed to emxbind
888                         LDFLAGS="$LDFLAGS -s"
889                 elif [ "$os" = "SUNOS" ]; then
890                         # The GNU strip does know -s, the non-GNU doesn't
891                         #  So try to detect it (in a bit of an ugly way)
892                         strip_arg="`$strip -s strip.test 2>/dev/null && echo \"-s\"`"
893                 else
894                         strip_arg="-s"
895                 fi
897                 log 1 "checking stripping... $strip $strip_arg"
898         else
899                 strip=""
900                 log 1 "checking stripping... skipped"
901         fi
903         if [ "$with_distcc" = "0" ]; then
904                 log 1 "checking distcc... no"
905         elif [ "$with_distcc" = "1" ]; then
906                 with_distcc="0"
908                 log 1 "checking distcc... no (only used when forced)"
909         elif [ "$with_distcc" = "2" ]; then
910                 distcc="distcc"
911         else
912                 distcc="$with_distcc"
913         fi
914         if [ "$with_distcc" != "0" ]; then
915                 res="`$distcc --version 2>/dev/null | head -n 1 | cut -b 1-6`"
916                 if [ "$res" != "distcc" ]; then
917                         distcc=""
918                         log 1 "checking distcc... no"
919                         if [ "$with_distcc" = "2" ]; then
920                                 log 1 "configure: error: no distcc detected, but was forced to be used"
921                                 exit 1
922                         fi
923                         if [ "$with_distcc" != "1" ]; then
924                                 log 1 "configure: error: '$with_distcc' doesn't seem a distcc to me"
925                                 exit 1
926                         fi
927                 fi
929                 log 1 "checking distcc... $distcc"
930         fi
932         if [ "$with_ccache" = "0" ]; then
933                 log 1 "checking ccache... no"
934         elif [ "$with_ccache" = "1" ]; then
935                 with_ccache="0"
937                 log 1 "checking ccache... no (only used when forced)"
938         elif [ "$with_ccache" = "2" ]; then
939                 ccache="ccache"
940         else
941                 ccache="$with_ccache"
942         fi
943         if [ "$with_ccache" != "0" ]; then
944                 res="`$ccache --version 2>/dev/null | head -n 1 | cut -b 1-6`"
945                 if [ "$res" != "ccache" ]; then
946                         ccache=""
947                         log 1 "checking ccache... no"
948                         if [ "$with_ccache" = "2" ]; then
949                                 log 1 "configure: error: no ccache detected, but was forced to be used"
950                                 exit 1
951                         fi
952                         if [ "$with_ccache" != "1" ]; then
953                                 log 1 "configure: error: '$with_ccache' doesn't seem a ccache to me"
954                                 exit 1
955                         fi
956                 fi
958                 log 1 "checking ccache... $ccache"
959         fi
961         detect_grfcodec
962         detect_nforenum
964         if [ -z "$grfcodec" ] && [ -n "$nforenum" ]; then
965                 log 1 "checking nforenum/grfcodec... nforenum needs grfcodec enabled, disabling nforenum"
966                 nforenum=""
967         fi
969         if [ -z "$nforenum" ] && [ -n "$grfcodec" ]; then
970                 log 1 "checking nforenum/grfcodec... grfcodec needs nforenum enabled, disabling grfcodec"
971                 grfcodec=""
972         fi
974         if [ "$os" = "DOS" ]; then
975                 with_threads="0"
976         fi
978         if [ "$os" != "OSX" ] && [ "$with_application_bundle" != "0" ]; then
979                 if [ "$with_application_bundle" = "1" ]; then
980                         with_application_bundle="0"
982                         log 1 "checking OSX application bundle... not OSX, skipping"
983                 else
984                         log 1 "configure: error: --with-application-bundle only works if OSX is the target"
985                         exit 1
986                 fi
987         fi
989         if [ "$os" = "OSX" ] && [ "$with_application_bundle" = "1" ]; then
990                 OSXAPP="OpenTTD.app"
991         else
992                 OSXAPP=""
993         fi
995         if [ "$os" = "OSX" ]; then
996                 # Test on ppc970 (G5) - we can optimize there
998                 if [ "$enable_osx_g5" != "0" ]; then
999                         log 1 "detecting ppc970 (G5)... yes (forced)"
1000                 else
1001                         # First, are we a real OSX system, else we can't detect it
1002                         native=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | grep darwin`
1003                         # If $host doesn't match $build , we are cross-compiling
1004                         if [ -n "$native" ] && [ "$build" = "$host" ]; then
1005                                 $cxx_build $SRC_DIR/os/macosx/G5_detector.cpp -o G5_detector
1006                                 res=`./G5_detector`
1007                                 rm -f G5_detector
1008                                 if [ -n "$res" ]; then
1009                                         # This is G5, add flags for it
1010                                         enable_osx_g5="2"
1012                                         log 1 "detecting ppc970 (G5)... yes"
1013                                 else
1014                                         enable_osx_g5="0"
1016                                         log 1 "detecting ppc970 (G5)... no"
1017                                 fi
1018                         else
1019                                 enable_osx_g5="0"
1021                                 log 1 "detecting ppc970 (G5)... no (cross-compiling)"
1022                         fi
1023                 fi
1024         else
1025                 if [ "$enable_osx_g5" != "0" ]; then
1026                         log 1 "configure: error: ppc970 (OSX G5) selected, but not compiling for OSX"
1027                         log 1 "configure: error: either select OSX as OS, or deselect ppc970"
1029                         exit 1
1030                 fi
1031         fi
1033         if [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then
1034                 log 1 "checking revision... svn detection"
1035         elif [ -d "$ROOT_DIR/../.svn" ] && [ -n "`svn help 2>/dev/null`" ] && LC_ALL=C svn info $ROOT_DIR/.. | grep -q '^URL:.*tags$'; then
1036                 # subversion changed its behaviour; now not all folders have a .svn folder,
1037                 # but only the root folder. Since making tags requires a (sparse) checkout
1038                 # of the tags folder, the folder of the tag does not have a .svn folder
1039                 # anymore and this fails to detect the subversion repository checkout.
1040                 log 1 "checking revision... svn detection (tag)"
1041         elif [ -e "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then
1042                 log 1 "checking revision... git detection"
1043         elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`HGPLAIN= hg help 2>/dev/null`" ]; then
1044                 log 1 "checking revision... hg detection"
1045         elif [ -f "$ROOT_DIR/.ottdrev" ]; then
1046                 log 1 "checking revision... source tarball"
1047         else
1048                 log 1 "checking revision... no detection"
1049                 log 1 "WARNING: there is no means to determine the version."
1050                 log 1 "WARNING: please use a subversion, mercurial, or git checkout of OpenTTD."
1051                 log 1 "WARNING: you can only join game servers that have been compiled without"
1052                 log 1 "WARNING:   version detection."
1053                 log 1 "WARNING: there is a great chance you desync."
1054                 log 1 "WARNING: USE WITH CAUTION!"
1056                 sleep 5
1057         fi
1059         if [ "$doc_dir" = "1" ]; then
1060                 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
1061                         doc_dir="share/doc/openttd"
1062                 else
1063                         doc_dir="$data_dir/docs"
1064                 fi
1065         else
1066                 doc_dir="`echo $doc_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1067         fi
1069         if [ "$icon_theme_dir" = "1" ]; then
1070                 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
1071                         icon_theme_dir="share/icons/hicolor"
1072                 else
1073                         icon_theme_dir=""
1074                 fi
1075         else
1076                 icon_theme_dir="`echo $icon_theme_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1077         fi
1079         if [ "$personal_dir" = "1" ]; then
1080                 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ] || [ "$os" = "DOS" ] || [ "$os" = "HAIKU" ]; then
1081                         personal_dir="OpenTTD"
1082                 elif [ "$os" = "OSX" ]; then
1083                         personal_dir="Documents/OpenTTD"
1084                 else
1085                         personal_dir=".openttd"
1086                 fi
1087         else
1088                 personal_dir="`echo $personal_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1089         fi
1091         if [ "$shared_dir" = "1" ]; then
1092                 # we are using default values
1093                 if [ "$os" = "OSX" ]; then
1094                         shared_dir="/Library/Application\\\\ Support/OpenTTD"
1095                 else
1096                         shared_dir=""
1097                 fi
1098         else
1099                 shared_dir="`echo $shared_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1100         fi
1102         if [ "$man_dir" = "1" ]; then
1103                 # add manpage on UNIX systems
1104                 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OSX" ]; then
1105                         man_dir="share/man/man6"
1106                 else
1107                         man_dir=""
1108                 fi
1109         else
1110                 man_dir="`echo $man_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1111         fi
1113         if [ "$menu_dir" = "1" ]; then
1114                 # add a freedesktop menu item only for some UNIX systems
1115                 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
1116                         menu_dir="share/applications"
1117                 else
1118                         menu_dir=""
1119                 fi
1120         else
1121                 menu_dir="`echo $menu_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1122         fi
1124         detect_iconv
1126         if [ -n "$personal_dir" ]
1127         then
1128                 log 1 "personal home directory... $personal_dir"
1129         else
1130                 log 1 "personal home directory... none"
1131         fi
1133         if [ -n "$shared_dir" ]
1134         then
1135                 log 1 "shared data directory... $shared_dir"
1136         else
1137                 log 1 "shared data directory... none"
1138         fi
1140         if [ -n "$install_dir" ]
1141         then
1142                 log 1 "installation directory... $install_dir"
1143         else
1144                 log 1 "installation directory... none"
1145         fi
1147         if [ -n "$icon_theme_dir" ]
1148         then
1149                 log 1 "icon theme directory... $icon_theme_dir"
1150         else
1151                 log 1 "icon theme directory... none"
1152         fi
1154         if [ -n "$man_dir" ]
1155         then
1156                 log 1 "manual page directory... $man_dir"
1157         else
1158                 log 1 "manual page directory... none"
1159         fi
1161         if [ -n "$menu_dir" ]
1162         then
1163                 log 1 "menu item directory... $menu_dir"
1164         else
1165                 log 1 "menu item directory... none"
1166         fi
1169 make_compiler_cflags() {
1170         # Params:
1171         # $1 - compiler
1172         # $2 - name of the cflags variable
1173         # $3 - name of the cxxflags variable
1174         # $4 - name of the ldflags variable
1175         # $5 - name of the features variable
1177         eval eval "flags=\\\$$2"
1178         eval eval "cxxflags=\\\$$3"
1179         eval eval "ldflags=\\\$$4"
1180         eval eval "features=\\\$$5"
1182         if [ `basename $1 | cut -c 1-3` = "icc" ]; then
1183                 # Enable some things only for certain ICC versions
1184                 cc_version=`$1 -dumpversion | cut -c 1-4 | sed s@\\\.@@g`
1186                 flags="$flags -rdynamic"
1187                 ldflags="$ldflags -rdynamic"
1189                 if [ -z "$first_time_icc_check" ]; then
1190                         first_time_icc_check=no
1191                         if [ $cc_version -lt 90 ]; then
1192                                 log 1 "WARNING: you seem to be using a very old version of ICC"
1193                                 log 1 "WARNING: OpenTTD hasn't been tested with this version"
1194                                 sleep 5
1195                         elif [ $cc_version -lt 120 ]; then
1196                                 log 1 "WARNING: you seem to be using an unsupported ICC version"
1197                                 log 1 "WARNING: ICC older than 12.0 is known to fail to compile OpenTTD"
1198                                 sleep 5
1199                         fi
1200                 fi
1202                 flags="$flags -Wall"
1203                 # remark #111: statement is unreachable
1204                 flags="$flags -wd111"
1205                 # remark #181: argument is incompatible with corresponding format string conversion
1206                 # ICC is very picky about signedness of operands, warnings provided by GCC are enough
1207                 flags="$flags -wd181"
1208                 # remark #271: trailing comma is nonstandard
1209                 flags="$flags -wd271"
1210                 # remark #280: selector expression is constant
1211                 flags="$flags -wd280"
1212                 # remark #304: access control not specified ("public" by default)
1213                 flags="$flags -wd304"
1214                 # remark #383: value copied to temporary, reference to temporary used
1215                 flags="$flags -wd383"
1216                 # remark #444: destructor for base class ... is not virtual
1217                 flags="$flags -wd444"
1218                 # remark #593: variable ... was set but never used
1219                 flags="$flags -wd593"
1220                 # warning #654: overloaded virtual function ... is only partially overridden in class ...
1221                 flags="$flags -wd654"
1222                 # remark #810: conversion from ... to ... may lose significant bits
1223                 flags="$flags -wd810"
1224                 # remark #869: parameter ... was never referenced
1225                 flags="$flags -wd869"
1226                 # warning #873: function ... ::operator new ... has no corresponding operator delete ...
1227                 flags="$flags -wd873"
1228                 # remark #981: operands are evaluated in unspecified order
1229                 flags="$flags -wd981"
1230                 # remark #1418: external function definition with no prior declaration
1231                 flags="$flags -wd1418"
1232                 # remark #1419: external declaration in primary source file
1233                 flags="$flags -wd1419"
1234                 # remark #1572: floating-point equality and inequality
1235                 flags="$flags -wd1572"
1236                 # remark #1599: declaration hides variable/parameter ...
1237                 flags="$flags -wd1599"
1238                 # remark #1720: function ... ::operator new ... has no corresponding member operator delete ...
1239                 flags="$flags -wd1720"
1241                 if [ $cc_version -lt 110 ]; then
1242                         # warns about system headers with recent glibc:
1243                         # warning #1292: attribute "__nonnull__" ignored
1244                         flags="$flags -wd1292"
1245                 fi
1247                 if [ $cc_version -ge 100 ]; then
1248                         # warning #1899: multicharacter character literal (potential portability problem)
1249                         flags="$flags -wd1899"
1250                         # vec report defaults to telling where it did loop vectorisation, which is not very important
1251                         flags="$flags -vec-report=0 "
1252                 fi
1254                 if [ $cc_version -ge 110 ]; then
1255                         # remark #2259: non-pointer conversion from ... to ... may lose significant bits
1256                         flags="$flags -wd2259"
1257                         # Use c++0x mode so static_assert() is available
1258                         cxxflags="$cxxflags -std=c++0x"
1259                 fi
1261                 if [ "$enable_lto" != "0" ] && $1 -help ipo | grep -q '\-ipo'; then
1262                         # Use IPO (only if we see IPO exists and is requested)
1263                         flags="$flags -ipo"
1264                         features="$features lto"
1265                 fi
1266         elif basename $1 | grep -q 'clang'; then
1267                 # Enable some things only for certain clang versions
1268                 cc_version="`$1 -v 2>&1 | head -n 1 | sed s@[^0-9]@@g | cut -c 1-2`"
1270                 # aliasing rules are not held in openttd code
1271                 flags="$flags -fno-strict-aliasing"
1273                 # -W alone doesn't enable all warnings enabled by -Wall; on the other hand,
1274                 # -Weverything enables too many useless warnings that can't be disabled (as of 3.0)
1275                 flags="$flags -Wall -W"
1277                 # warning: unused parameter '...'
1278                 flags="$flags -Wno-unused-parameter"
1280                 # warning: expression result unused
1281                 flags="$flags -Wno-unused-value"
1283                 # warning: multi-character character constant
1284                 flags="$flags -Wno-multichar"
1286                 # warning: explicitly assigning a variable of type '...' to itself
1287                 # it happens when using the FOR_ALL_WINDOWS_FROM_BACK_FROM macro
1288                 flags="$flags -Wno-self-assign"
1290                 if [ "$cc_version" -lt "30" ]; then
1291                         # warning: equality comparison with extraneous parentheses
1292                         flags="$flags -Wno-parentheses"
1293                         # warning: operands of ? are integers of different signs: 'unsigned int' and 'int'
1294                         flags="$flags -Wno-sign-compare"
1295                 fi
1297                 if [ "$cc_version" -ge "30" ]; then
1298                         # warning: equality comparison with extraneous parentheses
1299                         # this warning could be useful, but it warns about code in squirrel
1300                         flags="$flags -Wno-parentheses-equality"
1301                 fi
1303                 if [ "$with_ccache" != "0" -o "$with_distcc" != "0" ]; then
1304                         # ccache and distcc run separate preprocess and compile passes,
1305                         # both are fed with the same CFLAGS. Unfortunately, clang
1306                         # complains about -I when compiling preprocessed files:
1307                         # "clang: warning: argument unused during compilation: '-I /usr/include'"
1308                         flags="$flags -Qunused-arguments"
1309                 fi
1311                 if [ "$enable_assert" -eq "0" ]; then
1312                         # do not warn about unused variables when building without asserts
1313                         flags="$flags -Wno-unused-variable"
1314                 fi
1316                 # rdynamic is used to get useful stack traces from crash reports.
1317                 ldflags="$ldflags -rdynamic"
1318         else
1319                 # Enable some things only for certain GCC versions
1320                 cc_version=`$1 -dumpversion | cut -c 1,3`
1322                 if [ $cc_version -lt 33 ]; then
1323                         log 1 "configure: error: gcc older than 3.3 can't compile OpenTTD because of its poor template support"
1324                         exit 1
1325                 fi
1327                 flags="$flags -Wall -Wno-multichar -Wsign-compare -Wundef"
1328                 flags="$flags -Wwrite-strings -Wpointer-arith"
1329                 flags="$flags -W -Wno-unused-parameter -Wredundant-decls"
1330                 flags="$flags -Wformat=2 -Wformat-security"
1332                 if [ $enable_assert -eq 0 ]; then
1333                         # Do not warn about unused variables when building without asserts
1334                         flags="$flags -Wno-unused-variable"
1335                         if [ $cc_version -ge 46 ]; then
1336                                 # GCC 4.6 gives more warnings, disable them too
1337                                 flags="$flags -Wno-unused-but-set-variable"
1338                                 flags="$flags -Wno-unused-but-set-parameter"
1339                         fi
1340                 fi
1342                 if [ $cc_version -ge 34 ]; then
1343                         # Warn when a variable is used to initialise itself:
1344                         # int a = a;
1345                         flags="$flags -Winit-self"
1346                 fi
1348                 if [ $cc_version -ge 40 ]; then
1349                         # GCC 4.0+ complains about that we break strict-aliasing.
1350                         #  On most places we don't see how to fix it, and it doesn't
1351                         #  break anything. So disable strict-aliasing to make the
1352                         #  compiler all happy.
1353                         flags="$flags -fno-strict-aliasing"
1354                         # Warn about casting-out 'const' with regular C-style cast.
1355                         #  The preferred way is const_cast<>() which doesn't warn.
1356                         flags="$flags -Wcast-qual"
1357                 fi
1359                 if [ $cc_version -ge 42 ]; then
1360                         # GCC 4.2+ automatically assumes that signed overflows do
1361                         # not occur in signed arithmetics, whereas we are not
1362                         # sure that they will not happen. It furthermore complains
1363                         # about its own optimized code in some places.
1364                         flags="$flags -fno-strict-overflow"
1365                         # GCC 4.2 no longer includes -Wnon-virtual-dtor in -Wall.
1366                         # Enable it in order to be consistent with older GCC versions.
1367                         flags="$flags -Wnon-virtual-dtor"
1368                 fi
1370                 if [ $cc_version -ge 43 ]; then
1371                         # Use gnu++0x mode so static_assert() is available.
1372                         # Don't use c++0x, it breaks mingw (with gcc 4.4.0).
1373                         cxxflags="$cxxflags -std=gnu++0x"
1374                 fi
1376                 if [ $cc_version -eq 45 ]; then
1377                         # Prevent optimisation supposing enums are in a range specified by the standard
1378                         # For details, see http://gcc.gnu.org/PR43680
1379                         flags="$flags -fno-tree-vrp"
1380                 fi
1382                 if [ $cc_version -ge 47 ]; then
1383                         # Disable -Wnarrowing which gives many warnings, such as:
1384                         # warning: narrowing conversion of '...' from 'unsigned int' to 'int' inside { } [-Wnarrowing]
1385                         # They are valid according to the C++ standard, but useless.
1386                         cxxflags="$cxxflags -Wno-narrowing"
1387                         # Disable bogus 'attempt to free a non-heap object' warning
1388                         flags="$flags -Wno-free-nonheap-object"
1389                 fi
1391                 # GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
1392                 if [ "$enable_lto" != "0" ] && $1 -dumpspecs | grep -q '\%{flto'; then
1393                         # Use LTO only if we see LTO exists and is requested
1394                         if [ $cc_version -lt 46 ]; then
1395                                 flags="$flags -flto"
1396                         else
1397                                 flags="$flags -flto=jobserver"
1398                         fi
1399                         ldflags="$ldflags -fwhole-program"
1400                         features="$features lto"
1401                 fi
1403                 if $1 -dumpspecs | grep -q rdynamic; then
1404                         # rdynamic is used to get useful stack traces from crash reports.
1405                         flags="$flags -rdynamic"
1406                         ldflags="$ldflags -rdynamic"
1407                 fi
1408         fi
1410         eval "$2=\"$flags\""
1411         eval "$3=\"$cxxflags\""
1412         eval "$4=\"$ldflags\""
1413         eval "$5=\"$features\""
1416 make_cflags_and_ldflags() {
1417         # General CFlags for BUILD
1418         CFLAGS_BUILD="$CFLAGS_BUILD"
1419         # Special CXXFlags for BUILD
1420         CXXFLAGS_BUILD="$CXXFLAGS_BUILD"
1421         # LDFLAGS for BUILD
1422         LDFLAGS_BUILD="$LDFLAGS_BUILD"
1423         # FEATURES for BUILD (lto)
1424         FEATURES_BUILD=""
1425         # General CFlags for HOST
1426         CFLAGS="$CFLAGS"
1427         # Special CXXFlags for HOST
1428         CXXFLAGS="$CXXFLAGS"
1429         # Libs to compile. In fact this is just LDFLAGS
1430         LIBS="-lstdc++"
1431         # LDFLAGS used for HOST
1432         LDFLAGS="$LDFLAGS"
1433         # FEATURES for HOST (lto)
1434         FEATURES=""
1436         make_compiler_cflags "$cc_build" "CFLAGS_BUILD" "CXXFLAGS_BUILD" "LDFLAGS_BUILD" "FEATURES_BUILD"
1437         make_compiler_cflags "$cc_host" "CFLAGS" "CXXFLAGS" "LDFLAGS" "FEATURES"
1439         CFLAGS="$CFLAGS -D$os"
1440         CFLAGS_BUILD="$CFLAGS_BUILD -D$os"
1442         if [ "$enable_debug" = "0" ]; then
1443                 # No debug, add default stuff
1444                 OBJS_SUBDIR="release"
1445                 if [ "$os" = "MORPHOS" ]; then
1446                         CFLAGS="-I/gg/os-include -noixemul -fstrict-aliasing -fexpensive-optimizations -mcpu=604 -fno-inline -mstring -mmultiple $CFLAGS"
1447                         LDFLAGS="$LDFLAGS -noixemul"
1448                 fi
1450                 if [ "$enable_profiling" = "0" ]; then
1451                         # -fomit-frame-pointer and -pg do not go well together (gcc errors they are incompatible)
1452                         CFLAGS="-fomit-frame-pointer $CFLAGS"
1453                 fi
1454                 CFLAGS="-O2 $CFLAGS"
1455         else
1456                 OBJS_SUBDIR="debug"
1458                 # Each debug level reduces the optimization by a bit
1459                 if [ $enable_debug -ge 1 ]; then
1460                         CFLAGS="$CFLAGS -g -D_DEBUG"
1461                         if [ "$os" = "PSP" ]; then
1462                                 CFLAGS="$CFLAGS -G0"
1463                         fi
1464                 fi
1465                 if [ $enable_debug -ge 2 ]; then
1466                         CFLAGS="$CFLAGS -fno-inline"
1467                 fi
1468                 if [ $enable_debug -ge 3 ]; then
1469                         CFLAGS="$CFLAGS -O0"
1470                 else
1471                         CFLAGS="$CFLAGS -O2"
1472                 fi
1473         fi
1475         if [ $enable_debug -le 2 ]; then
1476                 if basename "$cc_host" | grep -q "gcc"; then
1477                         # Define only when compiling with GCC. Some GLIBC versions use GNU
1478                         # extensions in a way that breaks build with at least ICC.
1479                         # This requires -O1 or more, so debug level 3 (-O0) is excluded.
1480                         CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
1481                 fi
1483                 if basename "$cc_build" | grep -q "gcc"; then
1484                         # Just add -O1 to the tools needed for building.
1485                         CFLAGS_BUILD="$CFLAGS_BUILD -D_FORTIFY_SOURCE=2 -O1"
1486                 fi
1487         fi
1489         if [ "$os" = "OSX" ] && [ $cc_version -eq 40 ]; then
1490                 # Apple's GCC 4.0 has a compiler bug for x86_64 with (higher) optimization,
1491                 # wrongly optimizing ^= in loops. This disables the failing optimisation.
1492                 CFLAGS="$CFLAGS -fno-expensive-optimizations"
1493         fi
1495         if [ "$enable_profiling" != "0" ]; then
1496                 CFLAGS="$CFLAGS -pg"
1497                 LDFLAGS="$LDFLAGS -pg"
1498         fi
1500         if [ "$with_threads" = "0" ]; then
1501                 CFLAGS="$CFLAGS -DNO_THREADS"
1502         fi
1503         if [ "$with_sse" = "1" ]; then
1504                 CFLAGS="$CFLAGS -DWITH_SSE"
1505         fi
1507         if [ "`echo $1 | cut -c 1-3`" != "icc" ]; then
1508                 if [ "$os" = "CYGWIN" ]; then
1509                         flags="$flags -mwin32"
1510                         LDFLAGS="$LDFLAGS -mwin32"
1511                 fi
1512                 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
1513                         if [ $cc_version -lt 46 ]; then
1514                                 flags="$flags -mno-cygwin"
1515                                 LDFLAGS="$LDFLAGS -mno-cygwin"
1516                         fi
1518                         if [ "$enable_console" != "0" ]; then
1519                                 LDFLAGS="$LDFLAGS -Wl,--subsystem,console"
1520                         else
1521                                 LDFLAGS="$LDFLAGS -Wl,--subsystem,windows"
1522                         fi
1524                         LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32 -limm32"
1526                         if [ $cc_version -ge 44 ]; then
1527                                 LDFLAGS_BUILD="$LDFLAGS_BUILD -static-libgcc -static-libstdc++"
1528                         fi
1529                         if [ $cc_version -ge 47 ]; then
1530                                 CFLAGS="$CFLAGS -mno-ms-bitfields"
1531                         fi
1532                 fi
1533         fi
1535         if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
1536                 LIBS="$LIBS -lpthread"
1537         fi
1539         if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ]; then
1540                 LIBS="$LIBS -lc"
1541         fi
1542         if [ "$os" = "WINCE" ]; then
1543                 LIBS="$LIBS -lcoredll -lcorelibc -laygshell -lws2 -e WinMainCRTStartup"
1544         fi
1545         if [ "$os" = "PSP" ]; then
1546                 CFLAGS="$CFLAGS -I`$psp_config -p`/include"
1547                 LDFLAGS="$LDFLAGS -L`$psp_config -p`/lib"
1549                 CFLAGS="$CFLAGS -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150"
1550                 LIBS="$LIBS -D_PSP_FW_VERSION=150 -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -lm"
1551         fi
1553         if [ "$os" = "MORPHOS" ]; then
1554                 # -Wstrict-prototypes generates much noise because of system headers
1555                 CFLAGS="$CFLAGS -Wno-strict-prototypes"
1556         fi
1558         if [ "$os" = "OPENBSD" ]; then
1559                 LIBS="$LIBS -pthread"
1560         fi
1562         if [ "$os" = "OSX" ]; then
1563                 LDFLAGS="$LDFLAGS -framework Cocoa"
1565                 # Add macports include dir which is not always set a default system dir. This avoids zillions of bogus warnings.
1566                 CFLAGS="$CFLAGS -isystem/opt/local/include"
1568                 if [ "$enable_dedicated" = "0" ] && ([ "$cpu_type" = "32" ] || [ "$enable_universal" != "0" ]); then
1569                         LIBS="$LIBS -framework QuickTime"
1570                 else
1571                         CFLAGS="$CFLAGS -DNO_QUICKTIME"
1572                 fi
1574                 if [ "$enable_universal" = "0" ]; then
1575                         # Universal builds set this elsewhere
1576                         CFLAGS="$OSX_SYSROOT $CFLAGS"
1577                         LDFLAGS="$OSX_LD_SYSROOT $LDFLAGS"
1578                 fi
1580                 if [ "$enable_universal" = "0" ] && [ $cc_version -gt 40 ]; then
1581                         # Only set the min version when not doing an universal build.
1582                         # Universal builds set the version elsewhere.
1583                         if [ "$cpu_type" = "64" ]; then
1584                                 CFLAGS="$CFLAGS -mmacosx-version-min=10.5"
1585                         else
1586                                 gcc_cpu=`$cc_host -dumpmachine`
1587                                 if [ "`echo $gcc_cpu | cut -c 1-3`" = "ppc" -o "`echo $gcc_cpu | cut -c 1-7`" = "powerpc" ]; then
1588                                         # PowerPC build can run on 10.3
1589                                         CFLAGS="$CFLAGS -mmacosx-version-min=10.3"
1590                                 else
1591                                         # Intel is only available starting from 10.4
1592                                         CFLAGS="$CFLAGS -mmacosx-version-min=10.4"
1593                                 fi
1594                         fi
1595                 fi
1596         fi
1598         if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ]; then
1599                 LIBS="$LIBS -lmidi -lbe"
1600         fi
1602         # Most targets act like UNIX, just with some additions
1603         if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then
1604                 CFLAGS="$CFLAGS -DUNIX"
1605         fi
1606         # And others like Windows
1607         if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
1608                 CFLAGS="$CFLAGS -DWIN"
1609         fi
1611         if [ -n "$allegro_config" ]; then
1612                 CFLAGS="$CFLAGS -DWITH_ALLEGRO"
1613                 CFLAGS="$CFLAGS `$allegro_config --cflags`"
1614                 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
1615                         if [ "$enable_static" != "0" ]; then
1616                                 LIBS="$LIBS `$allegro_config --static --libs`"
1617                         else
1618                                 LIBS="$LIBS `$allegro_config --libs`"
1619                         fi
1620                 fi
1621         fi
1623         if [ -n "$sdl_config" ]; then
1624                 CFLAGS="$CFLAGS -DWITH_SDL"
1625                 # SDL must not add _GNU_SOURCE as it breaks many platforms
1626                 CFLAGS="$CFLAGS `$sdl_config --cflags | sed 's@-D_GNU_SOURCE[^ ]*@@'`"
1627                 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
1628                         if [ "$enable_static" != "0" ]; then
1629                                 LIBS="$LIBS `$sdl_config --static-libs`"
1630                         else
1631                                 LIBS="$LIBS `$sdl_config --libs`"
1632                         fi
1633                 fi
1634         fi
1636         if [ "$with_cocoa" != "0" ]; then
1637                 CFLAGS="$CFLAGS -DWITH_COCOA"
1638                 LIBS="$LIBS -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox"
1640                 if [ "$enable_cocoa_quartz" != "0" ]; then
1641                         CFLAGS="$CFLAGS -DENABLE_COCOA_QUARTZ"
1642                 fi
1644                 if [ "$enable_cocoa_quickdraw" != "0" ]; then
1645                         CFLAGS="$CFLAGS -DENABLE_COCOA_QUICKDRAW"
1646                 fi
1647         fi
1649         if [ "$with_zlib" != "0" ]; then
1650                 CFLAGS="$CFLAGS -DWITH_ZLIB"
1651                 CFLAGS="$CFLAGS `$zlib_config --cflags | tr '\n\r' '  '`"
1652                 if [ "$enable_static" != "0" ]; then
1653                         LIBS="$LIBS `$zlib_config --libs --static | tr '\n\r' '  '`"
1654                 else
1655                         LIBS="$LIBS `$zlib_config --libs | tr '\n\r' '  '`"
1656                 fi
1657         fi
1659         if [ -n "$lzma_config" ]; then
1660                 CFLAGS="$CFLAGS -DWITH_LZMA"
1661                 CFLAGS="$CFLAGS `$lzma_config --cflags | tr '\n\r' '  '`"
1663                 if [ "$enable_static" != "0" ]; then
1664                         CFLAGS="$CFLAGS -DLZMA_API_STATIC"
1665                         LIBS="$LIBS `$lzma_config --libs --static | tr '\n\r' '  '`"
1666                 else
1667                         LIBS="$LIBS `$lzma_config --libs | tr '\n\r' '  '`"
1668                 fi
1669         fi
1671         if [ "$with_lzo2" != "0" ]; then
1672                 if [ "$enable_static" != "0" ] && [ "$os" != "OSX" ]; then
1673                         LIBS="$LIBS $lzo2"
1674                 else
1675                         LIBS="$LIBS -llzo2"
1676                 fi
1677                 CFLAGS="$CFLAGS -DWITH_LZO"
1678         fi
1680         if [ -n "$xdg_basedir_config" ]; then
1681                 CFLAGS="$CFLAGS -DWITH_XDG_BASEDIR"
1682                 CFLAGS="$CFLAGS `$xdg_basedir_config --cflags | tr '\n\r' '  '`"
1684                 if [ "$enable_static" != "0" ]; then
1685                         LIBS="$LIBS `$xdg_basedir_config --libs --static | tr '\n\r' '  '`"
1686                 else
1687                         LIBS="$LIBS `$xdg_basedir_config --libs | tr '\n\r' '  '`"
1688                 fi
1689         fi
1691         # 64bit machines need -D_SQ64
1692         if [ "$cpu_type" = "64" ] && [ "$enable_universal" = "0" ]; then
1693                 CFLAGS="$CFLAGS -D_SQ64"
1694         fi
1695         CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR"
1697         if [ -n "$png_config" ]; then
1698                 CFLAGS="$CFLAGS -DWITH_PNG"
1699                 CFLAGS="$CFLAGS `$png_config --cflags | tr '\n\r' '  '`"
1701                 if [ "$enable_static" != "0" ]; then
1702                         LIBS="$LIBS `$png_config --libs --static | tr '\n\r' '  '`"
1703                 else
1704                         LIBS="$LIBS `$png_config --libs | tr '\n\r' '  '`"
1705                 fi
1706         fi
1708         if [ -n "$fontconfig_config" ]; then
1709                 CFLAGS="$CFLAGS -DWITH_FONTCONFIG"
1710                 CFLAGS="$CFLAGS `$fontconfig_config --cflags | tr '\n\r' '  '`"
1712                 if [ "$enable_static" != "0" ]; then
1713                         LIBS="$LIBS `$fontconfig_config --libs --static | tr '\n\r' '  '`"
1714                 else
1715                         LIBS="$LIBS `$fontconfig_config --libs | tr '\n\r' '  '`"
1716                 fi
1717         fi
1719         if [ -n "$freetype_config" ]; then
1720                 CFLAGS="$CFLAGS -DWITH_FREETYPE"
1721                 CFLAGS="$CFLAGS `$freetype_config --cflags | tr '\n\r' '  '`"
1723                 if [ "$enable_static" != "0" ]; then
1724                         LIBS="$LIBS `$freetype_config --libs --static | tr '\n\r' '  '`"
1725                 else
1726                         LIBS="$LIBS `$freetype_config --libs | tr '\n\r' '  '`"
1727                 fi
1728         fi
1730         if [ -n "$icu_config" ]; then
1731                 CFLAGS="$CFLAGS -DWITH_ICU"
1732                 CFLAGS="$CFLAGS `$icu_config --cppflags | tr '\n\r' '  '`"
1734                 # Some icu-configs have the 'feature' of not adding a space where others do add the space
1735                 if [ "$static_icu" != "0" ]; then
1736                         LIBS="$LIBS `$icu_config --ldflags-searchpath` `($icu_config --ldflags-libsonly; $icu_config --ldflags-layout) | tr '\n\r' '  ' | sed s/licu/lsicu/g`"
1737                 else
1738                         LIBS="$LIBS `$icu_config --ldflags-searchpath` `($icu_config --ldflags-libsonly; $icu_config --ldflags-layout) | tr '\n\r' '  '`"
1739                 fi
1740         fi
1743         if [ "$with_direct_music" != "0" ]; then
1744                 CFLAGS="$CFLAGS -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT"
1745                 # GCC 4.0+ doesn't like the DirectX includes (gives tons of
1746                 #  warnings on it we won't be able to fix). For now just
1747                 #  suppress those warnings.
1748                 if [ $cc_version -ge 40 ]; then
1749                         CFLAGS="$CFLAGS -Wno-non-virtual-dtor"
1750                 fi
1751         fi
1753         if [ -n "$libtimidity_config" ]; then
1754                 CFLAGS="$CFLAGS -DLIBTIMIDITY"
1755                 CFLAGS="$CFLAGS `$libtimidity_config --cflags | tr '\n\r' '  '`"
1757                 if [ "$enable_static" != "0" ]; then
1758                         LIBS="$LIBS `$libtimidity_config --libs --static | tr '\n\r' '  '`"
1759                 else
1760                         LIBS="$LIBS `$libtimidity_config --libs | tr '\n\r' '  '`"
1761                 fi
1762         fi
1764         if [ "$with_iconv" != "0" ]; then
1765                 CFLAGS="$CFLAGS -DWITH_ICONV"
1766                 if [ "$link_to_iconv" = "yes" ]; then
1767                         LIBS="$LIBS -liconv"
1768                         if [ "$with_iconv" != "2" ]; then
1769                                 CFLAGS="$CFLAGS -I$with_iconv/include"
1770                                 LIBS="$LIBS -L$with_iconv/lib"
1771                         fi
1772                 fi
1774                 if [ "$os" != "OSX" ] && [ "$have_non_const_iconv" != "no" ]; then
1775                         CFLAGS="$CFLAGS -DHAVE_NON_CONST_ICONV"
1776                 fi
1777         fi
1779         if [ -n "$with_midi" ]; then
1780                 CFLAGS="$CFLAGS -DEXTERNAL_PLAYER=\\\\\"$with_midi\\\\\""
1781         fi
1782         if [ -n "$with_midi_arg" ]; then
1783                 CFLAGS="$CFLAGS -DMIDI_ARG=\\\\\"$with_midi_arg\\\\\""
1784         fi
1786         if [ "$enable_dedicated" != "0" ]; then
1787                 CFLAGS="$CFLAGS -DDEDICATED"
1788         fi
1790         if [ "$enable_unicode" != "0" ]; then
1791                 CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"
1792         fi
1794         if [ "$enable_network" != "0" ]; then
1795                 CFLAGS="$CFLAGS -DENABLE_NETWORK"
1797                 if [ "$os" = "BEOS" ]; then
1798                         LDFLAGS="$LDFLAGS -lbind -lsocket"
1799                 fi
1801                 if [ "$os" = "HAIKU" ]; then
1802                         LDFLAGS="$LDFLAGS -lnetwork"
1803                 fi
1805                 if [ "$os" = "SUNOS" ]; then
1806                         LDFLAGS="$LDFLAGS -lnsl -lsocket"
1807                 fi
1808         fi
1810         if [ "$enable_static" != "0" ]; then
1811                 # OSX can't handle -static in LDFLAGS
1812                 if [ "$os" != "OSX" ]; then
1813                         LDFLAGS="$LDFLAGS -static"
1814                 fi
1815         fi
1817         if [ "$enable_assert" = "0" ]; then
1818                 CFLAGS="$CFLAGS -DNDEBUG"
1819                 CFLAGS_BUILD="$CFLAGS_BUILD -DNDEBUG"
1820         fi
1822         if [ "$enable_desync_debug" != "0" ]; then
1823                 CFLAGS="$CFLAGS -DRANDOM_DEBUG"
1824         fi
1826         if [ "$enable_osx_g5" != "0" ]; then
1827                 CFLAGS="$CFLAGS -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
1828         fi
1830         if [ -n "$personal_dir" ]; then
1831                 CFLAGS="$CFLAGS -DWITH_PERSONAL_DIR -DPERSONAL_DIR=\\\\\"$personal_dir\\\\\""
1832         fi
1834         if [ -n "$shared_dir" ]; then
1835                 CFLAGS="$CFLAGS -DWITH_SHARED_DIR -DSHARED_DIR=\\\\\"$shared_dir\\\\\""
1836         fi
1838         CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\""
1840         if [ "$enable_lto" != "0" ]; then
1841                 lto_warn=1
1842                 if echo "$FEATURES_BUILD" | grep -q "lto"; then
1843                         LDFLAGS_BUILD="$LDFLAGS_BUILD $CFLAGS_BUILD $CXXFLAGS_BUILD"
1844                         lto_warn=0
1845                 fi
1846                 if echo "$FEATURES" | grep -q "lto"; then
1847                         LDFLAGS="$LDFLAGS $CFLAGS $CXXFLAGS"
1848                         lto_warn=0
1849                 fi
1850                 if [ "$lto_warn" != "0" ]; then
1851                         log 1 "WARNING: you enabled LTO/IPO, but neither build nor host compiler supports it"
1852                         log 1 "WARNING: LTO/IPO has been disabled"
1853                 fi
1854         fi
1856         log 1 "using CFLAGS_BUILD... $CFLAGS_BUILD"
1857         log 1 "using CXXFLAGS_BUILD... $CXXFLAGS_BUILD"
1858         log 1 "using LDFLAGS_BUILD... $LDFLAGS_BUILD"
1859         log 1 "using CFLAGS... $CFLAGS"
1860         log 1 "using CXXFLAGS... $CXXFLAGS"
1861         log 1 "using LDFLAGS... $LIBS $LDFLAGS"
1863         # Makedepend doesn't like something like: -isysroot /OSX/blabla
1864         #  so convert it to: -isysroot -OSX/blabla. makedepend just ignores
1865         #  any - command it doesn't know, so we are pretty save.
1866         # Lovely hackish, not?
1867         # Btw, this almost always comes from outside the configure, so it is
1868         #  not something we can control.
1869         # Also make makedepend aware of compiler's built-in defines.
1870         if [ "$with_makedepend" != "0" ] || [ "$enable_builtin_depend" != "0" ]; then
1871                 # Append CXXFLAGS possibly containing -std=c++0x
1872                 cflags_makedep="`echo | $cxx_host $CXXFLAGS -E -x c++ -dM - | sed 's@.define @-D@g;s@ .*@ @g;s@(.*)@@g' | tr -d '\r\n'`"
1874                 # Please escape ALL " within ` because e.g. "" terminates the string in some sh implementations
1875                 cflags_makedep="$cflags_makedep `echo \"$CFLAGS\" \"$CXXFLAGS\" | sed 's@ /@ -@g;s@-I[ ]*[^ ]*@@g'`"
1876         else
1877                 makedepend=""
1878         fi
1880         if [ "$with_distcc" != "0" ]; then
1881                 cc_host="$distcc $cc_host"
1882                 cxx_host="$distcc $cxx_host"
1883                 log 1 ""
1884                 log 1 " NOTICE: remind yourself to use 'make -jN' to make use of distcc"
1885                 log 1 ""
1886         fi
1888         if [ "$with_ccache" != "0" ]; then
1889                 cc_host="$ccache $cc_host"
1890                 cxx_host="$ccache $cxx_host"
1891         fi
1894 check_compiler() {
1895         # Params:
1896         # $1 - Type for message (build / host)
1897         # $2 - What to fill with the found compiler
1898         # $3 - System to try
1899         # $4 - Compiler to try
1900         # $5 - Env-setting to try
1901         # $6 - GCC alike to try
1902         # $7 - CC alike to try
1903         # $8 - "0" gcc, "1" g++, "2" windres, "3" strip, "4" lipo
1904         # $9 - What the command is to check for
1906         if [ -n "$3" ]; then
1907                 # Check for system
1908                 if [ -z "$6" ]; then
1909                         compiler="$3"
1910                 else
1911                         compiler="$3-$6"
1912                 fi
1913                 machine=`eval $compiler $9 2>/dev/null`
1914                 ret=$?
1915                 eval "$2=\"$compiler\""
1917                 log 2 "executing $compiler $9"
1918                 log 2 "  returned $machine"
1919                 log 2 "  exit code $ret"
1921                 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1922                         if [ -z "$5" ]; then
1923                                 log 1 "checking $1... $compiler not found"
1924                                 log 1 "I couldn't detect any $6 binary for $3"
1925                                 exit 1
1926                         else
1927                                 compiler="$3-$5"
1928                         fi
1929                         machine=`eval $compiler $9 2>/dev/null`
1930                         ret=$?
1931                         eval "$2=\"$compiler\""
1933                         log 2 "executing $compiler $9"
1934                         log 2 "  returned $machine"
1935                         log 2 "  exit code $ret"
1937                         if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1938                                 log 1 "checking $1... $compiler not found"
1939                                 log 1 "I couldn't detect any $5 binary for $3"
1940                                 exit 1
1941                         fi
1942                 fi
1944                 if [ "$machine" != "$3" ] && ( [ "$8" = "0" ] || [ "$8" = "1" ] ); then
1945                         log 1 "checking $1... expected $3, found $machine"
1946                         log 1 "the compiler suggests it doesn't build code for the machine you specified"
1947                         exit 1
1948                 fi
1949         elif [ -n "$4" ]; then
1950                 # Check for manual compiler
1951                 machine=`$4 $9 2>/dev/null`
1952                 ret=$?
1953                 eval "$2=\"$4\""
1955                 log 2 "executing $4 $9"
1956                 log 2 "  returned $machine"
1957                 log 2 "  exit code $ret"
1959                 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1960                         log 1 "checking $1... $4 not found"
1961                         log 1 "the selected binary doesn't seem to be a $6 binary"
1962                         exit 1
1963                 fi
1964         else
1965                 # Nothing given, autodetect
1967                 if [ -n "$5" ]; then
1968                         machine=`$5 $9 2>/dev/null`
1969                         ret=$?
1970                         eval "$2=\"$5\""
1972                         log 2 "executing $5 $9"
1973                         log 2 "  returned $machine"
1974                         log 2 "  exit code $ret"
1976                         # The user defined a GCC that doesn't reply to $9.. abort
1977                         if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1978                                 log 1 "checking $1... $5 unusable"
1979                                 log 1 "the CC environment variable is set, but it doesn't seem to be a $6 binary"
1980                                 log 1 "please redefine the CC/CXX environment to a $6 binary"
1981                                 exit 1
1982                         fi
1983                 else
1984                         log 2 "checking $1... CC/CXX not set (skipping)"
1986                         # No $5, so try '$6'
1987                         machine=`$6 $9 2>/dev/null`
1988                         ret=$?
1989                         eval "$2=\"$6\""
1991                         log 2 "executing $6 $9"
1992                         log 2 "  returned $machine"
1993                         log 2 "  exit code $ret"
1995                         if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1996                                 # Maybe '$7'?
1997                                 machine=`$7 $9 2>/dev/null`
1998                                 ret=$?
1999                                 eval "$2=\"$7\""
2001                                 log 2 "executing $7 $9"
2002                                 log 2 "  returned $machine"
2003                                 log 2 "  exit code $ret"
2005                                 # All failed, abort
2006                                 if [ -z "$machine" ]; then
2007                                         log 1 "checking $1... $6 not found"
2008                                         log 1 "I couldn't detect any $6 binary on your system"
2009                                         log 1 "please define the CC/CXX environment to where it is located"
2011                                         exit 1
2012                                 fi
2013                         fi
2014                 fi
2015         fi
2017         if [ "$8" != "0" ]; then
2018                 eval "res=\$$2"
2019                 log 1 "checking $1... $res"
2020         else
2021                 log 1 "checking $1... $machine"
2022         fi
2025 check_build() {
2026         if [ "$os" = "FREEBSD" ]; then
2027                 # FreeBSD's C compiler does not support dump machine.
2028                 # However, removing C support is not possible because PSP must be linked with the C compiler.
2029                 check_compiler "build system type" "cc_build" "$build" "$cc_build" "$CXX" "g++" "c++" "0" "-dumpmachine"
2030         else
2031                 check_compiler "build system type" "cc_build" "$build" "$cc_build" "$CC" "gcc" "cc" "0" "-dumpmachine"
2032         fi
2035 check_host() {
2036         # By default the host is the build
2037         if [ -z "$host" ]; then host="$build"; fi
2039         if [ "$os" = "FREEBSD" ]; then
2040                 # FreeBSD's C compiler does not support dump machine.
2041                 # However, removing C support is not possible because PSP must be linked with the C compiler.
2042                 check_compiler "host system type" "cc_host" "$host" "$cc_host" "$CXX" "g++" "c++" "0" "-dumpmachine"
2043         else
2044                 check_compiler "host system type" "cc_host" "$host" "$cc_host" "$CC" "gcc" "cc" "0" "-dumpmachine"
2045         fi
2048 check_cxx_build() {
2049         check_compiler "build c++" "cxx_build" "$build" "$cxx_build" "$CXX" "g++" "c++" 1 "-dumpmachine"
2052 check_cxx_host() {
2053         # By default the host is the build
2054         if [ -z "$host" ]; then host="$build"; fi
2055         check_compiler "host c++" "cxx_host" "$host" "$cxx_host" "$CXX" "g++" "c++" 1 "-dumpmachine"
2058 check_windres() {
2059         if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
2060                 check_compiler "host windres" "windres" "$host" "$windres" "$WINDRES" "windres" "windres" "2" "-V"
2061         fi
2064 check_strip() {
2065         if [ "$os" = "OS2" ]; then
2066                 # OS2 via gcc is a bit weird.. stripping HAS to be done via emxbind, which is via gcc directly
2067                 log 1 "checking host strip... using gcc -s option"
2068         elif [ "$os" = "OSX" ]; then
2069                 # Most targets have -V in strip, to see if they exists... OSX doesn't.. so execute something
2070                 echo "int main(int argc, char *argv[]) { }" > strip.test.c
2071                 $cxx_host strip.test.c -o strip.test
2072                 check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "strip.test"
2073                 rm -f strip.test.c strip.test
2074         else
2075                 check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "-V"
2076         fi
2079 check_lipo() {
2080         if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ]; then
2081                 echo "int main(int argc, char *argv[]) { }" > lipo.test.c
2082                 $cxx_host lipo.test.c -o lipo.test
2083                 check_compiler "host lipo" "lipo" "$host" "$lipo" "$LIPO" "lipo" "lipo" "4" "-info lipo.test"
2084                 rm -f lipo.test.c lipo.test
2085         fi
2088 check_osx_sdk() {
2089         local sysroot=""
2090         if [ -n "$1" ]; then
2091                 if echo "$1" | grep -q / ; then
2092                         # Seems to be a file system path
2093                         osx_sdk_path="$1"
2094                 else
2095                         osx_sdk_path="/Developer/SDKs/MacOSX$1.sdk"
2096                 fi
2097                 if [ ! -d "$osx_sdk_path" ]; then
2098                         # No directory, not present or garbage
2099                         return 1
2100                 fi
2102                 # Set minimum version to 10.4 as that's when kCGBitmapByteOrder32Host was introduced
2103                 sysroot="-isysroot $osx_sdk_path -Wl,-syslibroot,$osx_sdk_path -mmacosx-version-min=10.4"
2104         fi
2106 cat > tmp.osx.mm << EOF
2107 #include <Cocoa/Cocoa.h>
2108 int main() {
2109         kCGBitmapByteOrder32Host;
2110         return 0;
2113         execute="$cxx_host $sysroot $CFLAGS tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1"
2114         eval $execute > /dev/null
2115         ret=$?
2116         log 2 "executing $execute"
2117         log 2 "  exit code $ret"
2118         rm -f tmp.osx.mm tmp.osx
2119         return $ret
2122 check_direct_music() {
2123         echo "
2124                 #include <windows.h>
2125                 #include <dmksctrl.h>
2126                 #include <dmusici.h>
2127                 #include <dmusicc.h>
2128                 #include <dmusicf.h>
2129                 int main(int argc, char *argv[]) { }" > direct_music.test.c
2130         $cxx_host $CFLAGS direct_music.test.c -o direct_music.test 2> /dev/null
2131         res=$?
2132         rm -f direct_music.test.c direct_music.test
2134         if [ "$res" != "0" ]; then
2135                 if [ "$with_direct_music" != "1" ]; then
2136                         log 1 "configure: error: direct-music is not available on this system"
2137                         exit 1
2138                 fi
2139                 with_direct_music="0"
2141                 log 1 "checking direct-music... not found"
2142         else
2143                 log 1 "checking direct-music... found"
2144         fi
2147 check_makedepend() {
2148         if [ "$enable_builtin_depend" != "0" ]; then
2149                 with_makedepend="0"
2150         fi
2152         if [ "$with_makedepend" = "0" ]; then
2153                 log 1 "checking makedepend... disabled"
2154                 return
2155         fi
2157         if [ "$with_makedepend" = "1" ] || [ "$with_makedepend" = "2" ]; then
2158                 makedepend="makedepend"
2159         else
2160                 makedepend="$with_makedepend"
2161         fi
2163         rm -f makedepend.tmp
2164         touch makedepend.tmp
2165         res=`$makedepend -fmakedepend.tmp 2>/dev/null`
2166         res=$?
2167         log 2 "executing $makedepend -f makedepend.tmp"
2168         log 2 "  returned `cat makedepend.tmp`"
2169         log 2 "  exit code $ret"
2171         if [ ! -s makedepend.tmp ]; then
2172                 rm -f makedepend.tmp makedepend.tmp.bak
2174                 if [ "$with_makedepend" = "2" ]; then
2175                         log 1 "checking makedepend... not found"
2177                         log 1 "I couldn't detect any makedepend on your system"
2178                         log 1 "please locate it via --makedepend=[binary]"
2180                         exit 1
2181                 elif [ "$with_makedepend" != "1" ]; then
2182                         log 1 "checking makedepend... $makedepend not found"
2184                         log 1 "the selected file doesn't seem to be a valid makedepend binary"
2186                         exit 1
2187                 else
2188                         log 1 "checking makedepend... not found"
2190                         with_makedepend="0"
2191                         return
2192                 fi
2193         fi
2195         rm -f makedepend.tmp makedepend.tmp.bak
2197         log 1 "checking makedepend... $makedepend"
2200 check_version() {
2201         # $1 - requested version (major.minor)
2202         # $2 - version we got (major.minor)
2204         if [ -z "$2" ]; then
2205                 return 0
2206         fi
2208         req_major=`echo $1 | cut -d. -f1`
2209         got_major=`echo $2 | cut -d. -f1`
2210         if [ $got_major -lt $req_major ]; then
2211                 return 0
2212         elif [ $got_major -gt $req_major ]; then
2213                 return 1
2214         fi
2216         req_minor=`echo $1 | cut -d. -f2`
2217         got_minor=`echo $2 | cut -d. -f2`
2218         if [ $got_minor -lt $req_minor ]; then
2219                 return 0
2220         fi
2221         return 1
2224 detect_awk() {
2225         # Not all awks allow gsub(), so we test for that here! It is in fact all we need...
2227         # These awks are known to work. Test for them explicit
2228         awks="gawk mawk nawk"
2230         awk_prefix="echo \"a.c b.c c.c\" | tr ' ' \\\\n | "
2231         awk_param="' { ORS = \" \" } /\.c$/   { gsub(\".c$\",   \".o\", \$0); print \$0; }' 2>/dev/null"
2232         awk_result="a.o b.o c.o "
2233         log 2 "Detecing awk..."
2235         log 2 "Trying: $awk_prefix $awk $awk_param"
2236         res=`eval $awk_prefix $awk $awk_param`
2237         log 2 "Result: '$res'"
2238         if [ "$res" != "$awk_result" ] && [ "$awk" = "awk" ]; then
2239                 # User didn't supply his own awk, so try to detect some other known working names for an awk
2240                 for awk in $awks; do
2241                         log 2 "Trying: $awk_prefix $awk $awk_param"
2242                         res=`eval $awk_prefix $awk $awk_param`
2243                         log 2 "Result: '$res'"
2244                         if [ "$res" = "$awk_result" ]; then break; fi
2245                 done
2247                 if [ "$res" != "$awk_result" ]; then
2248                         log 1 "checking awk... not found"
2249                         log 1 "configure: error: no awk found"
2250                         log 1 "configure: error: please install one of the following: $awks"
2251                         exit 1
2252                 fi
2253         fi
2254         if [ "$res" != "$awk_result" ]; then
2255                 log 1 "checking awk... not found"
2256                 log 1 "configure: error: you supplied '$awk' but it doesn't seem a valid gawk or mawk"
2257                 exit 1
2258         fi
2260         log 1 "checking awk... $awk"
2263 detect_os() {
2264         if [ "$os" = "DETECT" ]; then
2265                 # Detect UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, HPUX, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP
2267                 # Try first via dumpmachine, then via uname
2268                 case `echo "$host" | tr '[A-Z]' '[a-z]'` in
2269                         *linux*)     os=UNIX;;
2270                         *darwin*)    os=OSX;;
2271                         *freebsd*)   os=FREEBSD;;
2272                         *dragonfly*) os=DRAGONFLY;;
2273                         *openbsd*)   os=OPENBSD;;
2274                         *netbsd*)    os=NETBSD;;
2275                         *hp-ux*)     os=HPUX;;
2276                         *morphos*)   os=MORPHOS;;
2277                         *beos*)      os=BEOS;;
2278                         *haiku*)     os=HAIKU;;
2279                         *sunos*)     os=SUNOS;;
2280                         *solaris*)   os=SUNOS;;
2281                         *cygwin*)    os=CYGWIN;;
2282                         *mingw*)     os=MINGW;;
2283                         *os2*)       os=OS2;;
2284                         *dos*)       os=DOS;;
2285                         *wince*)     os=WINCE;;
2286                         *psp*)       os=PSP;;
2287                 esac
2289                 if [ "$os" = "DETECT" ]; then
2290                         case `LC_ALL=C uname | tr '[A-Z]' '[a-z]'` in
2291                                 *linux*)     os=UNIX;;
2292                                 *darwin*)    os=OSX;;
2293                                 *freebsd*)   os=FREEBSD;;
2294                                 *dragonfly*) os=DRAGONFLY;;
2295                                 *openbsd*)   os=OPENBSD;;
2296                                 *netbsd*)    os=NETBSD;;
2297                                 *hp-ux*)     os=HPUX;;
2298                                 *morphos*)   os=MORPHOS;;
2299                                 *beos*)      os=BEOS;;
2300                                 *haiku*)     os=HAIKU;;
2301                                 *sunos*)     os=SUNOS;;
2302                                 *cygwin*)    os=CYGWIN;;
2303                                 *mingw*)     os=MINGW;;
2304                                 *os/2*)      os=OS2;;
2305                                 *gnu*)       os=UNIX;;
2306                         esac
2307                 fi
2309                 if [ "$os" = "DETECT" ]; then
2310                         log 1 "detecting OS... none detected"
2311                         log 1 "I couldn't detect your OS. Please use --os=OS to force one"
2312                         log 1 "Allowed values are: UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, MORPHOS, HPUX, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP"
2313                         exit 1
2314                 fi
2316                 log 1 "detecting OS... $os"
2317         else
2318                 log 1 "forcing OS... $os"
2319         fi
2322 detect_allegro() {
2323         # 0 means no, 1 is auto-detect, 2 is force
2324         if [ "$with_allegro" = "0" ]; then
2325                 log 1 "checking Allegro... disabled"
2327                 allegro_config=""
2328                 return 0
2329         fi
2331         if [ "$with_allegro" = "2" ] && [ "$with_cocoa" = "2" ]; then
2332                 log 1 "configure: error: it is impossible to compile both Allegro and COCOA"
2333                 log 1 "configure: error: please deselect one of them and try again"
2334                 exit 1
2335         fi
2337         if [ "$with_allegro" = "2" ] && [ "$enable_dedicated" != "0" ]; then
2338                 log 1 "configure: error: it is impossible to compile a dedicated with Allegro"
2339                 log 1 "configure: error: please deselect one of them and try again"
2340                 exit 1
2341         fi
2343         if [ "$enable_dedicated" != "0" ]; then
2344                 log 1 "checking Allegro... dedicated server, skipping"
2346                 allegro_config=""
2347                 return 0
2348         fi
2350         # By default on OSX we don't use Allegro. The rest is auto-detect
2351         if [ "$with_allegro" = "1" ] && [ "$os" = "OSX" ] && [ "$with_cocoa" != "0" ]; then
2352                 log 1 "checking Allegro... OSX, skipping"
2354                 allegro_config=""
2355                 return 0
2356         fi
2358         detect_pkg_config "$with_allegro" "allegro" "allegro_config" "4.4"
2362 detect_sdl() {
2363         # 0 means no, 1 is auto-detect, 2 is force
2364         if [ "$with_sdl" = "0" ]; then
2365                 log 1 "checking SDL... disabled"
2367                 sdl_config=""
2368                 return 0
2369         fi
2371         if [ "$with_sdl" = "2" ] && [ "$with_cocoa" = "2" ]; then
2372                 log 1 "configure: error: it is impossible to compile both SDL and COCOA"
2373                 log 1 "configure: error: please deselect one of them and try again"
2374                 exit 1
2375         fi
2377         if [ "$with_sdl" = "2" ] && [ "$enable_dedicated" != "0" ]; then
2378                 log 1 "configure: error: it is impossible to compile a dedicated with SDL"
2379                 log 1 "configure: error: please deselect one of them and try again"
2380                 exit 1
2381         fi
2383         if [ "$enable_dedicated" != "0" ]; then
2384                 log 1 "checking SDL... dedicated server, skipping"
2386                 sdl_config=""
2387                 return 0
2388         fi
2390         # By default on OSX we don't use SDL. The rest is auto-detect
2391         if [ "$with_sdl" = "1" ] && [ "$os" = "OSX" ] && [ "$with_cocoa" != "0" ]; then
2392                 log 1 "checking SDL... OSX, skipping"
2394                 sdl_config=""
2395                 return 0
2396         fi
2398         if [ "$os" = "OSX" ]; then
2399                 log 1 "WARNING: sdl is known to fail on some versions of Mac OS X"
2400                 log 1 "WARNING: with some hardware configurations. Use at own risk!"
2401                 sleep 5
2402         fi
2404         detect_pkg_config "$with_sdl" "sdl" "sdl_config" "1.2"
2407 detect_osx_sdk() {
2408         # Try to find the best SDK available. For a normal build this
2409         # is currently the 10.5 SDK as this is needed to compile all
2410         # optional code. Because such an executable won't run on 10.4
2411         # or lower, also check for the 10.4u SDK when doing an universal
2412         # build.
2414         # Check for the 10.5 SDK, but try 10.6 if that fails
2415         check_osx_sdk "10.5" || check_osx_sdk "10.6" || osx_sdk_path=""
2417         if [ -z "$osx_sdk_path" ] || [ "$enable_universal" != "0" ]; then
2418                 # No better SDK or universal build enabled? Check 10.4u SDK as well
2419                 local old_sdk="$osx_sdk_path"
2420                 if check_osx_sdk "10.4u"; then
2421                         osx_sdk_104_path="$osx_sdk_path"
2422                 else
2423                         osx_sdk_104_path=""
2424                 fi
2425                 if [ -z "$old_sdk" ]; then
2426                         osx_sdk_path="$osx_sdk_104_path"
2427                 else
2428                         osx_sdk_path="$old_sdk"
2429                 fi
2430         fi
2432         if [ -z "$osx_sdk_path" ]; then
2433                 log 1 "Your system SDK is probably too old"
2434                 log 1 "Please install/upgrade your Xcode to >= 2.5"
2436                 exit 1
2437         fi
2440 detect_cocoa() {
2441         # 0 means no, 1 is auto-detect, 2 is force
2442         if [ "$with_cocoa" = "0" ]; then
2443                 log 1 "checking COCOA... disabled"
2445                 return 0
2446         fi
2448         if [ "$with_cocoa" = "2" ] && [ "$enable_dedicated" != "0" ]; then
2449                 log 1 "configure: error: it is impossible to compile a dedicated with COCOA"
2450                 log 1 "configure: error: please deselect one of them and try again"
2451                 exit 1
2452         fi
2454         if [ "$enable_dedicated" != "0" ]; then
2455                 log 1 "checking COCOA... dedicated server, skipping"
2457                 with_cocoa="0"
2458                 return 0
2459         fi
2461         # By default on OSX we use COCOA. The rest doesn't support it
2462         if [ "$with_cocoa" = "1" ] && [ "$os" != "OSX" ]; then
2463                 log 1 "checking COCOA... not OSX, skipping"
2465                 with_cocoa="0"
2466                 return 0
2467         fi
2469         if [ "$os" != "OSX" ]; then
2470                 log 1 "checking COCOA... not OSX"
2472                 log 1 "configure: error: COCOA video driver is only supported for OSX"
2473                 exit 1
2474         fi
2476         log 1 "checking COCOA... found"
2479         if [ "$enable_cocoa_quartz" != "0" ]; then
2480                 log 1 "checking whether to enable the Quartz window subdriver... yes"
2481         else
2482                 log 1 "checking whether to enable the Quartz window subdriver... no"
2483         fi
2485         detect_quickdraw
2488 detect_quickdraw() {
2489         # 0 means no, 1 is auto-detect, 2 is force
2490         if [ "$enable_cocoa_quickdraw" = "0" ]; then
2491                 log 1 "checking Quickdraw window subdriver... disabled"
2492                 return 0
2493         fi
2495         # Assume QuickDraw is available when doing an universal build
2496         if [ "$enable_universal" != "0" ]; then
2497                 log 1 "checking Quickdraw window subdriver... found"
2498                 return 0
2499         fi
2501         # 64 bits doesn't have quickdraw
2502         if [ "$cpu_type" = "64" ]; then
2503                 enable_cocoa_quickdraw="0"
2504                 log 1 "checking Quickdraw window subdriver... disabled (64 bits)"
2505                 return 0
2506         fi
2508 cat > tmp.osx.mm << EOF
2509 #include <AvailabilityMacros.h>
2510 #import <Cocoa/Cocoa.h>
2511 int main(int argc, char *argv[]) { SetEmptyRgn(NULL); return 0; }
2513         execute="$cxx_host $OSX_SYSROOT $OSX_LD_SYSROOT $CFLAGS -mmacosx-version-min=10.3 tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1"
2514         eval $execute > /dev/null
2515         ret=$?
2516         log 2 "executing $execute"
2517         log 2 "  exit code $ret"
2518         rm -f tmp.osx.mm tmp.osx
2519         if [ "$ret" != "0" ]; then
2520                 log 1 "checking Quickdraw window subdriver... not found"
2522                 # It was forced, so it should be found.
2523                 if [ "$enable_cocoa_quickdraw" != "1" ]; then
2524                         log 1 "configure: error: Quickdraw window driver could not be found"
2525                         exit 1
2526                 fi
2528                 enable_cocoa_quickdraw=0
2529                 return 0
2530         fi
2532         enable_cocoa_quickdraw=1
2533         log 1 "checking Quickdraw window subdriver... found"
2536 detect_library() {
2537         # $1 - config-param ($with_zlib value)
2538         # $2 - library name ('zlib', sets $zlib)
2539         # $3 - static library name (libz.a)
2540         # $4 - header directory ()
2541         # $5 - header name (zlib.h)
2542         # $6 - force static (if non-empty)
2544         if [ -n "$6" ]; then force_static="1"; fi
2546         # 0 means no, 1 is auto-detect, 2 is force
2547         if [ "$1" = "0" ]; then
2548                 log 1 "checking $2... disabled"
2550                 eval "$2=\"\""
2551                 return 0
2552         fi
2554         log 2 "detecting $2"
2556         if [ "$1" = "1" ] || [ "$1" = "" ] || [ "$1" = "2" ]; then
2557                 eval "$2=`ls -1 /usr/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2558                 eval "res=\$$2"
2559                 if [ -z "$res" ]; then
2560                         log 2 "  trying /usr/include/$4$5... no"
2561                         eval "$2=`ls -1 /usr/local/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2562                 fi
2563                 eval "res=\$$2"
2564                 if [ -z "$res" ]; then
2565                         log 2 "  trying /usr/local/include/$4$5... no"
2566                         eval "$2=`ls -1 /mingw/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2567                 fi
2568                 eval "res=\$$2"
2569                 if [ -z "$res" ]; then
2570                         log 2 "  trying /mingw/include/$4$5... no"
2571                         eval "$2=`ls -1 /opt/local/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2572                 fi
2573                 eval "res=\$$2"
2574                 if [ -z "$res" ]; then
2575                         log 2 "  trying /opt/local/include/$4$5... no"
2576                 fi
2577                 if [ -z "$res" ] && [ "$os" = "NETBSD" ]; then
2578                         eval "$2=`ls -1 /usr/pkg/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2579                         eval "res=\$$2"
2580                         if [ -z "$res" ]; then
2581                                 log 2 "  trying /usr/pkg/include/$4$5... no"
2582                         fi
2583                 fi
2584                 if [ -z "$res" ] && [ "$os" = "HAIKU" ]; then
2585                         if [ -z "$includeDir" ]; then
2586                                 includeDir=`finddir B_SYSTEM_HEADERS_DIRECTORY`
2587                         fi
2588                         eval "$2=`ls -1 $includeDir/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2589                         eval "res=\$$2"
2590                         if [ -z "$res" ]; then
2591                                 log 2 "  trying $includeDir/$4$5... no"
2592                         fi
2593                 fi
2595                 eval "res=\$$2"
2596                 if [ -n "$res" ] && ( [ -n "$force_static" ] || ( [ "$enable_static" != "0" ] && [ "$os" != "OSX" ] ) ); then
2597                         eval "res=\$$2"
2598                         log 2 "  trying $res... found"
2599                         # Now find the static lib, if needed
2600                         eval "$2=`ls /lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2601                         eval "res=\$$2"
2602                         if [ -z "$res" ]; then
2603                                 log 2 "  trying /lib/$3... no"
2604                                 eval "$2=`ls /usr/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2605                         fi
2606                         eval "res=\$$2"
2607                         if [ -z "$res" ]; then
2608                                 log 2 "  trying /usr/lib/$3... no"
2609                                 eval "$2=`ls /usr/local/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2610                         fi
2611                         eval "res=\$$2"
2612                         if [ -z "$res" ]; then
2613                                 log 2 "  trying /usr/local/lib/$3... no"
2614                                 eval "$2=`ls /mingw/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2615                         fi
2616                         eval "res=\$$2"
2617                         if [ -z "$res" ]; then
2618                                 log 2 "  trying /mingw/lib/$3... no"
2619                                 log 1 "configure: error: $2 couldn't be found"
2620                                 log 1 "configure: error: you requested a static link, but I can't find $3"
2622                                 exit 1
2623                         fi
2624                 fi
2625         else
2626                 # Make sure it exists
2627                 if [ -f "$1" ]; then
2628                         eval "$2=`ls $1 2>/dev/null`"
2629                 else
2630                         eval "$2=`ls $1/$3 2>/dev/null`"
2631                 fi
2632         fi
2634         eval "res=\$$2"
2635         if [ -z "$res" ]; then
2636                 log 1 "checking $2... not found"
2637                 if [ "$1" = "2" ]; then
2638                         log 1 "configure: error: $2 couldn't be found"
2640                         exit 1
2641                 elif [ "$1" != "1" ]; then
2642                         log 1 "configure: error: $2 couldn't be found"
2643                         log 1 "configure: error: you supplied '$1', but it seems invalid"
2645                         exit 1
2646                 fi
2648                 eval "with_$2=0"
2650                 return 0
2651         fi
2653         eval "res=\$$2"
2654         log 2 "  trying $res... found"
2656         log 1 "checking $2... found"
2659 detect_zlib() {
2660         detect_pkg_config "$with_zlib" "zlib" "zlib_config" "1.2"
2663 detect_lzo2() {
2664         detect_library "$with_lzo2" "lzo2" "liblzo2.a" "lzo/" "lzo1x.h"
2667 detect_libtimidity() {
2668         detect_pkg_config "$with_libtimidity" "libtimidity" "libtimidity_config" "0.1" "1"
2671 detect_pkg_config() {
2672         # $1 - config-param ($with_lzma value)
2673         # $2 - package name ('liblzma')
2674         # $3 - config name ('lzma_config', sets $lzma_config)
2675         # $4 - minimum module version ('2.3')
2676         # $5 - check for dedicated, 1 is "skif if dedicated"
2678         # 0 means no, 1 is auto-detect, 2 is force
2679         if [ "$1" = "0" ]; then
2680                 log 1 "checking $2... disabled"
2682                 eval "$3=\"\""
2683                 return 0
2684         fi
2686         if [ "$5" = "1" ] && [ "$1" = "1" ] && [ "$enable_dedicated" != "0" ]; then
2687                 log 1 "checking $2... dedicated server, skipping"
2689                 eval "$3=\"\""
2690                 return 0
2691         fi
2693         log 2 "detecting $2"
2695         if [ "$1" = "1" ] || [ "$1" = "" ] || [ "$1" = "2" ]; then
2696                 pkg_config_call="$pkg_config $2"
2697         else
2698                 pkg_config_call="$1"
2699         fi
2701         version=`$pkg_config_call --modversion 2>/dev/null`
2702         ret=$?
2703         check_version "$4" "$version"
2704         version_ok=$?
2705         log 2 "executing $pkg_config_call --modversion"
2706         log 2 "  returned $version"
2707         log 2 "  exit code $ret"
2709         if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
2710                 if [ -n "$version" ] && [ "$version_ok" != "1" ]; then
2711                         log 1 "checking $2... needs at least version $4, $2 NOT enabled"
2712                 else
2713                         log 1 "checking $2... not found"
2714                 fi
2716                 # It was forced, so it should be found.
2717                 if [ "$1" != "1" ]; then
2718                         log 1 "configure: error: $pkg_config $2 couldn't be found"
2719                         log 1 "configure: error: you supplied '$1', but it seems invalid"
2720                         exit 1
2721                 fi
2723                 eval "$3=\"\""
2724                 return 0
2725         fi
2727         eval "$3=\"$pkg_config_call\""
2728         log 1 "checking $2... found"
2731 detect_lzma() {
2732         detect_pkg_config "$with_lzma" "liblzma" "lzma_config" "5.0"
2735 detect_xdg_basedir() {
2736         detect_pkg_config "$with_xdg_basedir" "libxdg-basedir" "xdg_basedir_config" "1.2"
2739 detect_png() {
2740         detect_pkg_config "$with_png" "libpng" "png_config" "1.2"
2743 detect_freetype() {
2744         detect_pkg_config "$with_freetype" "freetype2" "freetype_config" "2.2" "1"
2747 detect_fontconfig() {
2748         # 0 means no, 1 is auto-detect, 2 is force
2749         if [ "$with_fontconfig" = "0" ]; then
2750                 log 1 "checking libfontconfig... disabled"
2752                 fontconfig_config=""
2753                 return 0
2754         fi
2755         if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
2756                 log 1 "checking libfontconfig... WIN32, skipping"
2757                 fontconfig_config=""
2758                 return 0
2759         fi
2761         if [ "$os" = "OSX" ]; then
2762                 log 1 "checking libfontconfig... OSX, skipping"
2763                 fontconfig_config=""
2764                 return 0
2765         fi
2767         detect_pkg_config "$with_fontconfig" "fontconfig" "fontconfig_config" "2.3" "1"
2770 detect_icu() {
2771         # 0 means no, 1 is auto-detect, 2 is force
2772         if [ "$with_icu" = "0" ]; then
2773                 log 1 "checking libicu... disabled"
2775                 icu_config=""
2776                 return 0
2777         fi
2778         if [ "$with_icu" = "1" ] && [ "$enable_dedicated" != "0" ]; then
2779                 log 1 "checking libicu... dedicated server, skipping"
2781                 icu_config=""
2782                 return 0
2783         fi
2785         if [ "$with_icu" = "1" ] || [ "$with_icu" = "" ] || [ "$with_icu" = "2" ]; then
2786                 icu_config="icu-config"
2787         else
2788                 icu_config="$with_icu"
2789         fi
2791         version=`$icu_config --version 2>/dev/null`
2792         ret=$?
2793         check_version '3.6' "$version"
2794         version_ok=$?
2795         log 2 "executing $icu_config --version"
2796         log 2 "  returned $version"
2797         log 2 "  exit code $ret"
2799         if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
2800                 if [ -n "$version" ] && [ "$version_ok" != "1" ]; then
2801                         log 1 "checking libicu... needs at least version 3.6.0, icu NOT enabled"
2802                 else
2803                         log 1 "checking libicu... not found"
2804                 fi
2806                 # It was forced, so it should be found.
2807                 if [ "$with_icu" != "1" ]; then
2808                         log 1 "configure: error: icu-config couldn't be found"
2809                         log 1 "configure: error: you supplied '$with_icu', but it seems invalid"
2810                         exit 1
2811                 fi
2813                 icu_config=""
2814                 return 0
2815         fi
2817         log 1 "checking libicu... found"
2820 detect_pspconfig() {
2821         # 0 means no, 1 is auto-detect, 2 is force
2822         if [ "$with_psp_config" = "0" ]; then
2823                 log 1 "checking psp-config... disabled"
2825                 psp_config=""
2826                 return 0
2827         fi
2829         if [ "$with_psp_config" = "1" ] && [ "$os" != "PSP" ]; then
2830                 log 1 "checking psp-config... not PSP, skipping"
2832                 psp_config="";
2833                 return 0
2834         fi
2836         if [ "$os" != "PSP" ]; then
2837                 log 1 "checking psp-config... not PSP"
2839                 log 1 "configure: error: psp-config is only supported for PSP"
2840                 exit 1
2841         fi
2843         if [ "$with_psp_config" = "1" ] || [ "$with_psp_config" = "" ] || [ "$with_psp_config" = "2" ]; then
2844                 psp_config="psp-config"
2845         else
2846                 psp_config="$with_psp_config"
2847         fi
2849         version=`$psp_config -p 2>/dev/null`
2850         ret=$?
2851         log 2 "executing $psp_config -p"
2852         log 2 "  returned $version"
2853         log 2 "  exit code $ret"
2855         if [ -z "$version" ] || [ "$ret" != "0" ]; then
2856                 log 1 "checking psp-config... not found"
2857                 log 1 "configure: error: psp-config couldn't be found"
2859                 # It was forced, so it should be found.
2860                 if [ "$with_psp_config" != "1" ]; then
2861                         log 1 "configure: error: you supplied '$with_psp_config', but it seems invalid"
2862                 fi
2863                 exit 1
2864         fi
2866         log 1 "checking psp-config... found"
2869 detect_iconv() {
2870         # 0 means no, 1 is auto-detect, 2 is force
2871         if [ "$with_iconv" = "0" ]; then
2872                 log 1 "checking iconv... disabled"
2874                 return 0
2875         fi
2877         if [ "$with_iconv" = "1" ] && [ "$os" != "OSX" ]; then
2878                 log 1 "checking iconv... not OSX, skipping"
2879                 with_iconv="0"
2881                 return 0
2882         fi
2884         # Try to find iconv.h, seems to only thing to detect iconv with
2886         if [ "$with_iconv" = "1" ] || [ "$with_iconv" = "" ] || [ "$with_iconv" = "2" ]; then
2887                 iconv=`ls -1 /usr/include 2>/dev/null | grep "iconv.h"`
2888                 if [ -z "$iconv" ]; then
2889                         iconv=`ls -1 /usr/local/include 2>/dev/null | grep "iconv.h"`
2890                 fi
2891         else
2892                 # Make sure it exists
2893                 iconv=`ls $with_iconv/include/iconv.h 2>/dev/null`
2894         fi
2896         if [ -z "$iconv" ]; then
2897                 log 1 "checking iconv... not found"
2898                 if [ "$with_iconv" = "2" ]; then
2899                         log 1 "configure: error: iconv couldn't be found"
2901                         exit 1
2902                 elif [ "$with_iconv" != "1" ]; then
2903                         log 1 "configure: error: iconv couldn't be found"
2904                         log 1 "configure: error: you supplied '$with_iconv', but I couldn't detect iconv in it"
2906                         exit 1
2907                 fi
2909                 return 0
2910         fi
2912         if [ "$with_iconv" = "1" ]; then
2913                 with_iconv="2"
2914         fi
2916         log 2 "found iconv in $iconv"
2918         log 1 "checking iconv... found"
2920         # There are different implementations of iconv. The older ones,
2921         # e.g. SUSv2, pass a const pointer, whereas the newer ones, e.g.
2922         # IEEE 1003.1 (2004), pass a non-const pointer.
2924         cat > tmp.iconv.cpp << EOF
2925 #include "src/stdafx.h"
2926 #include <iconv.h>
2927 int main() {
2928         static char buf[1024];
2929         iconv_t convd = 0;
2930         const char *inbuf = "";
2931         char *outbuf  = buf;
2932         size_t outlen = 1023;
2933         size_t inlen  = 0;
2934         return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
2937         execute="$cxx_host $OSX_SYSROOT $CFLAGS -c tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
2938         eval $execute > /dev/null
2939         ret=$?
2940         log 2 "executing $execute"
2941         log 2 "  exit code $ret"
2942         if [ "$ret" = "0" ]; then have_non_const_iconv="no"; else have_non_const_iconv="yes"; fi
2943         log 1 "checking if iconv has non-const inbuf... $have_non_const_iconv"
2945         cat > tmp.iconv.cpp << EOF
2946 #include "src/stdafx.h"
2947 #include <iconv.h>
2948 int main() {
2949         static char buf[1024];
2950         iconv_t convd = 0;
2951         char *inbuf = "";
2952         char *outbuf  = buf;
2953         size_t outlen = 1023;
2954         size_t inlen  = 0;
2955         return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
2958         execute="$cxx_host $OSX_SYSROOT $OSX_LD_SYSROOT $CFLAGS tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
2959         eval $execute > /dev/null
2960         ret=$?
2961         log 2 "executing $execute"
2962         log 2 "  exit code $ret"
2963         if [ "$ret" = "0" ]; then link_to_iconv="no"; else link_to_iconv="yes"; fi
2964         log 1 "checking whether to link to iconv... $link_to_iconv"
2965         rm -f tmp.iconv tmp.iconv.cpp
2968 _detect_sort() {
2969         sort_test_in="d
2974         sort_test_out="a
2979         log 2 "running echo <array> | $1"
2981         if [ "`echo \"$sort_test_in\" | $1 2>/dev/null`" = "$sort_test_out" ]; then
2982                 sort="$1"
2983                 log 2 "  result was valid"
2984         else
2985                 log 2 "  result was invalid"
2986         fi
2989 detect_sort() {
2990         if [ "$with_sort" = "0" ]; then
2991                 log 1 "checking sort... disabled"
2993                 return
2994         fi
2996         if [ "$with_sort" = "1" ] || [ "$with_sort" = "2" ]; then
2997                 _detect_sort "sort"
2998                 if [ -z "$sort" ]; then _detect_sort "/sbin/sort"; fi
2999                 if [ -z "$sort" ]; then _detect_sort "/usr/sbin/sort"; fi
3000                 if [ -z "$sort" ]; then _detect_sort "/usr/local/sbin/sort"; fi
3001                 if [ -z "$sort" ]; then _detect_sort "/bin/sort"; fi
3002                 if [ -z "$sort" ]; then _detect_sort "/usr/bin/sort"; fi
3003                 if [ -z "$sort" ]; then _detect_sort "/usr/local/bin/sort"; fi
3004         else
3005                 _detect_sort "$with_sort"
3006         fi
3008         if [ -z "$sort" ]; then
3009                 if [ "$with_sort" = "2" ]; then
3010                         log 1 "checking sort... not found"
3012                         log 1 "configure: error: couldn't detect sort on your system"
3013                         exit 1
3014                 elif [ "$with_sort" != "1" ]; then
3015                         log 1 "checking sort... $with_sort not found"
3017                         log 1 "configure: error: '$with_sort' doesn't look like a sort to me"
3018                         log 1 "configure: error: please verify its location and function and try again"
3020                         exit 1
3021                 else
3022                         log 1 "checking sort... not found"
3023                 fi
3024         else
3025                 log 1 "checking sort... $sort"
3026         fi
3029 detect_grfcodec() {
3030         # 0 means no, 1 is auto-detect, 2 is force
3031         if [ "$with_grfcodec" = "0" ]; then
3032                 log 1 "checking grfcodec... disabled"
3034                 grfcodec=""
3035                 return 0
3036         fi
3038         if [ "$with_grfcodec" = "1" ] || [ "$with_grfcodec" = "" ] || [ "$with_grfcodec" = "2" ]; then
3039                 grfcodec="grfcodec"
3040         else
3041                 grfcodec="$with_grfcodec"
3042         fi
3044         version=`$grfcodec -v 2>/dev/null | $awk '{print $3}' | sed 's/[rM]//g;s/-/0/'`
3045         ret=$?
3046         log 2 "executing grfcodec -v"
3047         log 2 "  returned $version"
3048         log 2 "  exit code $ret"
3050         if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "985" ]; then
3051                 if [ -n "$version" ] && [ "$version" -lt "985" ]; then
3052                         log 1 "checking grfcodec... needs at least version 6.0.5 (r985), disabled"
3053                 else
3054                         log 1 "checking grfcodec... not found"
3055                 fi
3057                 # It was forced, so it should be found.
3058                 if [ "$with_grfcodec" != "1" ]; then
3059                         log 1 "configure: error: grfcodec couldn't be found"
3060                         log 1 "configure: error: you supplied '$with_grfcodec', but it seems invalid"
3061                         exit 1
3062                 fi
3064                 grfcodec=""
3065                 return 0
3066         fi
3068         log 1 "checking grfcodec... found"
3071 detect_nforenum() {
3072         # 0 means no, 1 is auto-detect, 2 is force
3073         if [ "$with_nforenum" = "0" ]; then
3074                 log 1 "checking nforenum... disabled"
3076                 nforenum=""
3077                 return 0
3078         fi
3080         if [ "$with_nforenum" = "1" ] || [ "$with_nforenum" = "" ] || [ "$with_nforenum" = "2" ]; then
3081                 nforenum="nforenum"
3082         else
3083                 nforenum="$with_nforenum"
3084         fi
3086         version=`$nforenum -v 2>/dev/null | $awk '{print $3}' | sed 's/[rM]//g;s/-/0/'`
3087         ret=$?
3088         log 2 "executing nforenum -v"
3089         log 2 "  returned $version"
3090         log 2 "  exit code $ret"
3092         if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "985" ]; then
3093                 if [ -n "$version" ] && [ "$version" -lt "985" ]; then
3094                         log 1 "checking nforenum... needs at least version 6.0.5 (r985), disabled"
3095                 else
3096                         log 1 "checking nforenum... not found"
3097                 fi
3099                 # It was forced, so it should be found.
3100                 if [ "$with_nforenum" != "1" ]; then
3101                         log 1 "configure: error: nforenum couldn't be found"
3102                         log 1 "configure: error: you supplied '$with_nforenum', but it seems invalid"
3103                         exit 1
3104                 fi
3106                 nforenum=""
3107                 return 0
3108         fi
3110         log 1 "checking nforenum... found"
3113 detect_cputype() {
3114         if [ -n "$cpu_type" ] && [ "$cpu_type" != "DETECT" ]; then
3115                 log 1 "forcing cpu-type... $cpu_type bits"
3116                 return;
3117         fi
3118         echo "#define _SQ64 1" > tmp.64bit.cpp
3119         echo "#include \"src/stdafx.h\"" >> tmp.64bit.cpp
3120         echo "assert_compile(sizeof(size_t) == 8);" >> tmp.64bit.cpp
3121         echo "int main() { return 0; }" >> tmp.64bit.cpp
3122         execute="$cxx_host $CFLAGS tmp.64bit.cpp -o tmp.64bit -DTESTING 2>&1"
3123         cpu_type="`eval $execute 2>/dev/null`"
3124         ret=$?
3125         log 2 "executing $execute"
3126         log 2 "  returned $cpu_type"
3127         log 2 "  exit code $ret"
3128         if [ "$ret" = "0" ]; then cpu_type="64"; else cpu_type="32"; fi
3129         log 1 "detecting cpu-type... $cpu_type bits"
3130         rm -f tmp.64bit tmp.64bit.cpp
3133 detect_sse_capable_architecture() {
3134         # 0 means no, 1 is auto-detect, 2 is force
3135         if [ "$with_sse" = "0" ]; then
3136                 log 1 "checking SSE... disabled"
3137                 return
3138         fi
3140         echo "#define _SQ64 1" > tmp.sse.cpp
3141         echo "#include <xmmintrin.h>" >> tmp.sse.cpp
3142         echo "#include <smmintrin.h>" >> tmp.sse.cpp
3143         echo "#include <tmmintrin.h>" >> tmp.sse.cpp
3144         echo "int main() { return 0; }" >> tmp.sse.cpp
3145         execute="$cxx_host -msse4.1 $CFLAGS tmp.sse.cpp -o tmp.sse 2>&1"
3146         sse="`eval $execute 2>/dev/null`"
3147         ret=$?
3148         log 2 "executing $execute"
3149         log 2 "  returned $sse"
3150         log 2 "  exit code $ret"
3151         if [ "$ret" = "0" ]; then
3152                 log 1 "detecting SSE... found"
3153         else
3154                 # It was forced, so it should be found.
3155                 if [ "$with_sse" != "1" ]; then
3156                         log 1 "configure: error: SSE couln't be found"
3157                         log 1 "configure: error: you force enabled SSE, but it seems unavailable"
3158                         exit 1
3159                 fi
3161                 log 1 "detecting SSE... not found"
3162                 with_sse="0"
3163         fi
3164         rm -f tmp.sse tmp.exe tmp.sse.cpp
3167 make_sed() {
3168         T_CFLAGS="$CFLAGS"
3169         T_CXXFLAGS="$CXXFLAGS"
3170         T_LDFLAGS="$LDFLAGS"
3172         SRC_OBJS_DIR="$BASE_SRC_OBJS_DIR/$OBJS_SUBDIR"
3174         # All the data needed to compile a single target
3175         #  Make sure if you compile multiple targets to
3176         #  use multiple OBJS_DIR, because all in-between
3177         #  binaries are stored in there, and nowhere else.
3178         SRC_REPLACE="
3179                 s@!!CC_HOST!!@$cc_host@g;
3180                 s@!!CXX_HOST!!@$cxx_host@g;
3181                 s@!!CC_BUILD!!@$cc_build@g;
3182                 s@!!CXX_BUILD!!@$cxx_build@g;
3183                 s@!!WINDRES!!@$windres@g;
3184                 s@!!STRIP!!@$strip $strip_arg@g;
3185                 s@!!LIPO!!@$lipo@g;
3186                 s@!!CFLAGS!!@$T_CFLAGS@g;
3187                 s@!!CFLAGS_BUILD!!@$CFLAGS_BUILD@g;
3188                 s@!!CXXFLAGS!!@$T_CXXFLAGS@g;
3189                 s@!!CXXFLAGS_BUILD!!@$CXXFLAGS_BUILD@g;
3190                 s@!!STRGEN_FLAGS!!@$strgen_flags@g;
3191                 s@!!LIBS!!@$LIBS@g;
3192                 s@!!LDFLAGS!!@$T_LDFLAGS@g;
3193                 s@!!LDFLAGS_BUILD!!@$LDFLAGS_BUILD@g;
3194                 s@!!BIN_DIR!!@$BIN_DIR@g;
3195                 s@!!ROOT_DIR!!@$ROOT_DIR@g;
3196                 s@!!MEDIA_DIR!!@$MEDIA_DIR@g;
3197                 s@!!SOURCE_LIST!!@$SOURCE_LIST@g;
3198                 s@!!SRC_OBJS_DIR!!@$SRC_OBJS_DIR@g;
3199                 s@!!LANG_OBJS_DIR!!@$LANG_OBJS_DIR@g;
3200                 s@!!GRF_OBJS_DIR!!@$GRF_OBJS_DIR@g;
3201                 s@!!SETTING_OBJS_DIR!!@$SETTING_OBJS_DIR@g;
3202                 s@!!SRC_DIR!!@$SRC_DIR@g;
3203                 s@!!SCRIPT_SRC_DIR!!@$SCRIPT_SRC_DIR@g;
3204                 s@!!OSXAPP!!@$OSXAPP@g;
3205                 s@!!LANG_DIR!!@$LANG_DIR@g;
3206                 s@!!TTD!!@$TTD@g;
3207                 s@!!BINARY_DIR!!@$prefix_dir/$binary_dir@g;
3208                 s@!!DATA_DIR!!@$prefix_dir/$data_dir@g;
3209                 s@!!DOC_DIR!!@$prefix_dir/$doc_dir@g;
3210                 s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
3211                 s@!!ICON_DIR!!@$prefix_dir/$icon_dir@g;
3212                 s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
3213                 s@!!PERSONAL_DIR!!@$personal_dir@g;
3214                 s@!!SHARED_DIR!!@$shared_dir@g;
3215                 s@!!INSTALL_DIR!!@$install_dir@g;
3216                 s@!!BINARY_NAME!!@$binary_name@g;
3217                 s@!!STRGEN!!@$STRGEN@g;
3218                 s@!!ENDIAN_CHECK!!@$ENDIAN_CHECK@g;
3219                 s@!!DEPEND!!@$DEPEND@g;
3220                 s@!!SETTINGSGEN!!@$SETTINGSGEN@g;
3221                 s@!!ENDIAN_FORCE!!@$endian@g;
3222                 s@!!STAGE!!@$STAGE@g;
3223                 s@!!MAKEDEPEND!!@$makedepend@g;
3224                 s@!!CFLAGS_MAKEDEP!!@$cflags_makedep@g;
3225                 s@!!SORT!!@$sort@g;
3226                 s@!!CONFIG_CACHE_COMPILER!!@config.cache.compiler@g;
3227                 s@!!CONFIG_CACHE_LINKER!!@config.cache.linker@g;
3228                 s@!!CONFIG_CACHE_ENDIAN!!@config.cache.endian@g;
3229                 s@!!CONFIG_CACHE_SOURCE!!@config.cache.source@g;
3230                 s@!!CONFIG_CACHE_VERSION!!@config.cache.version@g;
3231                 s@!!CONFIG_CACHE_SOURCE_LIST!!@config.cache.source.list@g;
3232                 s@!!CONFIG_CACHE_PWD!!@config.cache.pwd@g;
3233                 s@!!LANG_SUPPRESS!!@$lang_suppress@g;
3234                 s@!!OBJS_C!!@$OBJS_C@g;
3235                 s@!!OBJS_CPP!!@$OBJS_CPP@g;
3236                 s@!!OBJS_MM!!@$OBJS_MM@g;
3237                 s@!!OBJS_RC!!@$OBJS_RC@g;
3238                 s@!!SRCS!!@$SRCS@g;
3239                 s@!!OS!!@$os@g;
3240                 s@!!CONFIGURE_FILES!!@$CONFIGURE_FILES@g;
3241                 s@!!AWK!!@$awk@g;
3242                 s@!!DISTCC!!@$distcc@g;
3243                 s@!!NFORENUM!!@$nforenum@g;
3244                 s@!!GRFCODEC!!@$grfcodec@g;
3245         "
3247         if [ "$icon_theme_dir" != "" ]; then
3248                 SRC_REPLACE="$SRC_REPLACE
3249                         s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
3250                 "
3251         else
3252                 SRC_REPLACE="$SRC_REPLACE
3253                         s@!!ICON_THEME_DIR!!@@g;
3254                 "
3255         fi
3257         if [ "$man_dir" != "" ]; then
3258                 SRC_REPLACE="$SRC_REPLACE
3259                         s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
3260                 "
3261         else
3262                 SRC_REPLACE="$SRC_REPLACE
3263                         s@!!MAN_DIR!!@@g;
3264                 "
3265         fi
3267         if [ "$menu_dir" != "" ]; then
3268                 SRC_REPLACE="$SRC_REPLACE
3269                         s@!!MENU_DIR!!@$prefix_dir/$menu_dir@g;
3270                 "
3271         else
3272                 SRC_REPLACE="$SRC_REPLACE
3273                         s@!!MENU_DIR!!@@g;
3274                 "
3275         fi
3278 generate_menu_item() {
3279         MENU_REPLACE="
3280                 s@!!TTD!!@$TTD@g;
3281                 s@!!MENU_GROUP!!@$menu_group@g;
3282                 s@!!MENU_NAME!!@$menu_name@g
3283         "
3284         log 1 "Generating menu item..."
3285         mkdir -p media
3286         < $ROOT_DIR/media/openttd.desktop.in sed "$MENU_REPLACE" > media/openttd.desktop
3289 generate_main() {
3290         STAGE="[MAIN]"
3292         make_sed
3294         # Create the main Makefile
3295         log 1 "Generating Makefile..."
3296         echo "# Auto-generated file from 'Makefile.in' -- DO NOT EDIT" > Makefile
3297         < $ROOT_DIR/Makefile.in sed "$SRC_REPLACE" >> Makefile
3298         cp $ROOT_DIR/Makefile.bundle.in Makefile.bundle
3299         echo "# Auto-generated file -- DO NOT EDIT" > Makefile.am
3300         echo >> Makefile.am
3301         # Make the copy of the source-list, so we don't trigger an unwanted recompile
3302         cp $SOURCE_LIST config.cache.source.list
3303         # Add the current directory, so we don't trigger an unwanted recompile
3304         echo "`pwd`" > config.cache.pwd
3305         # Make sure config.cache is OLDER then config.cache.source.list
3306         touch config.cache
3307         touch config.pwd
3309         if [ "$menu_dir" != "" ]; then
3310                 generate_menu_item
3311         fi
3314 generate_lang() {
3315         STAGE="[LANG]"
3317         make_sed
3319         # Create the language file
3320         mkdir -p $LANG_OBJS_DIR
3322         log 1 "Generating lang/Makefile..."
3323         echo "# Auto-generated file from 'Makefile.lang.in' -- DO NOT EDIT" > $LANG_OBJS_DIR/Makefile
3324         < $ROOT_DIR/Makefile.lang.in sed "$SRC_REPLACE" >> $LANG_OBJS_DIR/Makefile
3325         echo "DIRS += $LANG_OBJS_DIR" >> Makefile.am
3326         echo "LANG_DIRS += $LANG_OBJS_DIR" >> Makefile.am
3329 generate_settings() {
3330         STAGE="[SETTING]"
3332         make_sed
3334         # Create the language file
3335         mkdir -p $SETTING_OBJS_DIR
3337         log 1 "Generating setting/Makefile..."
3338         echo "# Auto-generated file from 'Makefile.settings.in' -- DO NOT EDIT" > $SETTING_OBJS_DIR/Makefile
3339         < $ROOT_DIR/Makefile.setting.in sed "$SRC_REPLACE" >> $SETTING_OBJS_DIR/Makefile
3340         echo "DIRS += $SETTING_OBJS_DIR" >> Makefile.am
3343 generate_grf() {
3344         STAGE="[BASESET]"
3346         make_sed
3348         # Create the language file
3349         mkdir -p $GRF_OBJS_DIR
3351         log 1 "Generating grf/Makefile..."
3352         echo "# Auto-generated file from 'Makefile.grf.in' -- DO NOT EDIT" > $GRF_OBJS_DIR/Makefile
3353         < $ROOT_DIR/Makefile.grf.in sed "$SRC_REPLACE" >> $GRF_OBJS_DIR/Makefile
3354         echo "DIRS += $GRF_OBJS_DIR" >> Makefile.am
3357 generate_src_normal() {
3358         STAGE=$1
3360         make_sed
3362         # Create the source file
3363         mkdir -p $SRC_OBJS_DIR
3365         log 1 "Generating $2/Makefile..."
3366         echo "# Auto-generated file from 'Makefile.src.in' -- DO NOT EDIT" > $SRC_OBJS_DIR/Makefile
3367         < $ROOT_DIR/Makefile.src.in sed "$SRC_REPLACE" >> $SRC_OBJS_DIR/Makefile
3368         echo "DIRS += $SRC_OBJS_DIR" >> Makefile.am
3369         echo "SRC_DIRS += $SRC_OBJS_DIR" >> Makefile.am
3372 generate_src_osx() {
3373         cc_host_orig="$cc_host"
3374         cxx_host_orig="$cxx_host"
3375         CFLAGS_orig="$CFLAGS"
3376         LDFLAGS_orig="$LDFLAGS"
3378         for type in $enable_universal; do
3380                 if [ -n "$osx_sdk_104_path" ]; then
3381                         # Use 10.4 SDK for 32-bit targets
3382                         CFLAGS="-isysroot $osx_sdk_104_path $CFLAGS_orig"
3383                         LDFLAGS="-Wl,-syslibroot,$osx_sdk_104_path $LDFLAGS_orig"
3384                 fi
3386                 # We don't want to duplicate the x86_64 stuff for each target, so do it once here
3387                 if [ "$type" = "ppc64" ] || [ "$type" = "x86_64" ]; then
3388                         # 64 bits is always 10.5 or higher. Furthermore it has a non const ICONV
3389                         # and they also removed support for QuickTime/QuickDraw
3390                         if [ -n "$osx_sdk_path" ]; then
3391                                 CFLAGS="-isysroot $osx_sdk_path $CFLAGS_orig"
3392                                 LDFLAGS="-Wl,-syslibroot,$osx_sdk_path $LDFLAGS_orig"
3393                         fi
3394                         CFLAGS="$CFLAGS -D_SQ64 -DNO_QUICKTIME -UENABLE_COCOA_QUICKDRAW"
3395                         LIBS="`echo $LIBS | sed 's/-framework QuickTime//'`"
3396                 fi
3398                 case $type in
3399                         ppc)
3400                                 BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc"
3401                                 cc_host="$cc_host_orig -arch ppc -mmacosx-version-min=10.3"
3402                                 cxx_host="$cxx_host_orig -arch ppc -mmacosx-version-min=10.3"
3403                                 generate_src_normal "[ppc]" "objs/ppc";;
3404                         ppc970)
3405                                 BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc970"
3406                                 cc_host="$cc_host_orig -arch ppc970 -mmacosx-version-min=10.3 -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
3407                                 cxx_host="$cxx_host_orig -arch ppc970 -mmacosx-version-min=10.3 -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
3408                                 generate_src_normal "[ppc970]" "objs/ppc970";;
3409                         i386)
3410                                 BASE_SRC_OBJS_DIR="$OBJS_DIR/i386"
3411                                 cc_host="$cc_host_orig -arch i386 -mmacosx-version-min=10.4"
3412                                 cxx_host="$cxx_host_orig -arch i386 -mmacosx-version-min=10.4"
3413                                 generate_src_normal "[i386]" "objs/i386";;
3414                         ppc64)
3415                                 BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc64"
3416                                 cc_host="$cc_host_orig -arch ppc64 -mmacosx-version-min=10.5"
3417                                 cxx_host="$cxx_host_orig -arch ppc64 -mmacosx-version-min=10.5"
3418                                 generate_src_normal "[ppc64]" "objs/ppc64";;
3419                         x86_64)
3420                                 BASE_SRC_OBJS_DIR="$OBJS_DIR/x86_64"
3421                                 cc_host="$cc_host_orig -arch x86_64 -mmacosx-version-min=10.5"
3422                                 cxx_host="$cxx_host_orig -arch x86_64 -mmacosx-version-min=10.5"
3423                                 generate_src_normal "[x86_64]" "objs/x86_64";;
3424                         *) log 1 "Unknown architecture requested for universal build: $type";;
3425                 esac
3426         done
3429 generate_src() {
3430         if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ]; then
3431                 generate_src_osx
3432         else
3433                 generate_src_normal "[SRC]" "objs"
3434         fi
3437 showhelp() {
3438         echo "'configure' configures OpenTTD."
3439         echo ""
3440         echo "Usage: $0 [OPTION]... [VAR=VALUE]..."
3441         echo ""
3442         echo "To assign environment variables (e.g., CC, CFLAGS...), specify them as"
3443         echo "VAR=VALUE.  See below for descriptions of some of the useful variables."
3444         echo ""
3445         echo "Defaults for the options are specified in brackets."
3446         echo ""
3447         echo "Configuration:"
3448         echo "  -h, --help                     display this help and exit"
3449         echo ""
3450         echo "System types:"
3451         echo "  --build=BUILD                  configure for building on BUILD [guessed]"
3452         echo "  --host=HOST                    cross-compile to build programs to run"
3453         echo "                                 on HOST [BUILD]"
3454         echo "  --windres=WINDRES              the windres to use [HOST-windres]"
3455         echo "  --strip=STRIP                  the strip to use [HOST-strip]"
3456         echo "  --awk=AWK                      the awk to use in configure [awk]"
3457         echo "  --pkg-config=PKG-CONFIG        the pkg-config to use in configure [pkg-config]"
3458         echo "  --lipo=LIPO                    the lipo to use (OSX ONLY) [HOST-lipo]"
3459         echo "  --os=OS                        the OS we are compiling for [DETECT]"
3460         echo "                                 DETECT/UNIX/OSX/FREEBSD/DRAGONFLY/OPENBSD/"
3461         echo "                                 NETBSD/MORPHOS/HPUX/BEOS/SUNOS/CYGWIN/"
3462         echo "                                 MINGW/OS2/DOS/WINCE/PSP/HAIKU"
3463         echo "  --endian=ENDIAN                set the endian of the HOST (AUTO/LE/BE)"
3464         echo ""
3465         echo "Paths:"
3466         echo "  --prefix-dir=dir               specifies the prefix for all installed"
3467         echo "                                 files [/usr/local]"
3468         echo "  --binary-dir=dir               location of the binary. Will be prefixed"
3469         echo "                                 with the prefix-dir [games]"
3470         echo "  --data-dir=dir                 location of data files (lang, data, gm)."
3471         echo "                                 Will be prefixed with the prefix-dir"
3472         echo "                                 [share/games/openttd]"
3473         echo "  --doc-dir=dir                  location of the doc files"
3474         echo "                                 Will be prefixed with the prefix-dir"
3475         echo "                                 [$doc_dir]"
3476         echo "  --icon-dir=dir                 location of icons. Will be prefixed"
3477         echo "                                 with the prefix-dir [share/pixmaps]"
3478         echo "  --icon-theme-dir=dir           location of icon theme."
3479         echo "                                 Will be prefixed with the prefix-dir"
3480         echo "                                 and postfixed with size-dirs [$icon_theme_dir]"
3481         echo "  --man-dir=dir                  location of the manual page (UNIX only)"
3482         echo "                                 Will be prefixed with the prefix-dir"
3483         echo "                                 [$man_dir]"
3484         echo "  --menu-dir=dir                 location of the menu item. (UNIX only, except OSX)"
3485         echo "                                 Will be prefixed with the prefix-dir"
3486         echo "                                 [share/applications]"
3487         echo "  --personal-dir=dir             location of the personal directory"
3488         echo "                                 [os-dependent default]"
3489         echo "  --shared-dir=dir               location of shared data files"
3490         echo "                                 [os-dependent default]"
3491         echo "  --install-dir=dir              specifies the root to install to."
3492         echo "                                 Useful to install into jails [/]"
3493         echo "  --binary-name                  the name used for the binary, icons,"
3494         echo "                                 desktop file, etc. when installing [openttd]"
3495         echo ""
3496         echo "Features and packages:"
3497         echo "  --enable-debug[=LVL]           enable debug-mode (LVL=[0123], 0 is release)"
3498         echo "  --enable-desync-debug=[LVL]    enable desync debug options (LVL=[012], 0 is none"
3499         echo "  --enable-profiling             enables profiling"
3500         echo "  --enable-lto                   enables GCC's Link Time Optimization (LTO)/ICC's"
3501         echo "                                 Interprocedural Optimization if available"
3502         echo "  --enable-dedicated             compile a dedicated server (without video)"
3503         echo "  --enable-static                enable static compile (doesn't work for"
3504         echo "                                 all HOSTs)"
3505         echo "  --enable-translator            enable extra output for translators"
3506         echo "  --enable-universal[=ARCH]      enable universal builds (OSX ONLY). Allowed is any combination"
3507         echo "                                 of architectures: i386 ppc ppc970 ppc64 x86_64"
3508         echo "                                 Default architectures are: i386 ppc"
3509         echo "  --enable-osx-g5                enables optimizations for ppc970 (G5) (OSX ONLY)"
3510         echo "  --disable-cocoa-quartz         disable the quartz window mode driver for Cocoa (OSX ONLY)"
3511         echo "  --disable-cocoa-quickdraw      disable the quickdraw window mode driver for Cocoa (OSX ONLY)"
3512         echo "  --disable-unicode              disable unicode support to build win9x"
3513         echo "                                 version (Win32 ONLY)"
3514         echo "  --enable-console               compile as a console application instead of as a GUI application."
3515         echo "                                 If this setting is active, debug output will appear in the same"
3516         echo "                                 console instead of opening a new window. (Win32 ONLY)"
3517         echo "  --disable-network              disable network support"
3518         echo "  --disable-assert               disable asserts (continue on errors)"
3519         echo "  --enable-strip                 enable any possible stripping"
3520         echo "  --without-osx-sysroot          disable the automatic adding of sysroot "
3521         echo "                                 (OSX ONLY)"
3522         echo "  --without-application-bundle   disable generation of application bundle"
3523         echo "                                 (OSX ONLY)"
3524         echo "  --without-menu-entry           Don't generate a menu item (Freedesktop based only)"
3525         echo "  --menu-group=group             Category in which the menu item will be placed (Freedesktop based only)"
3526         echo "  --menu-name=name               Name of the menu item when placed [OpenTTD]"
3527         echo "  --with-direct-music            enable direct music support (Win32 ONLY)"
3528         echo "  --with-sort=sort               define a non-default location for sort"
3529         echo "  --with-midi=midi               define which midi-player to use"
3530         echo "  --with-midi-arg=arg            define which args to use for the"
3531         echo "                                 midi-player"
3532         echo "  --with-libtimidity[=\"pkg-config libtimidity\"]"
3533         echo "                                 enables libtimidity support"
3534         echo "  --with-allegro[=\"pkg-config allegro\"]"
3535         echo "                                 enables Allegro video driver support"
3536         echo "  --with-cocoa                   enables COCOA video driver (OSX ONLY)"
3537         echo "  --with-sdl[=\"pkg-config sdl\"]  enables SDL video driver support"
3538         echo "  --with-zlib[=\"pkg-config zlib\"]"
3539         echo "                                 enables zlib support"
3540         echo "  --with-liblzma[=\"pkg-config liblzma\"]"
3541         echo "                                 enables liblzma support"
3542         echo "  --with-liblzo2[=liblzo2.a]     enables liblzo2 support"
3543         echo "  --with-png[=\"pkg-config libpng\"]"
3544         echo "                                 enables libpng support"
3545         echo "  --with-freetype[=\"pkg-config freetype2\"]"
3546         echo "                                 enables libfreetype support"
3547         echo "  --with-fontconfig[=\"pkg-config fontconfig\"]"
3548         echo "                                 enables fontconfig support"
3549         echo "  --with-xdg-basedir[=\"pkg-config libxdg-basedir\"]"
3550         echo "                                 enables XDG base directory support"
3551         echo "  --with-icu[=icu-config]        enables icu (used for right-to-left support)"
3552         echo "  --static-icu                   try to link statically (libsicu instead of"
3553         echo "                                 libicu; can fail as the new name is guessed)"
3554         echo "  --with-iconv[=iconv-path]      enables iconv support"
3555         echo "  --with-psp-config[=psp-config] enables psp-config support (PSP ONLY)"
3556         echo "  --disable-builtin-depend       disable use of builtin deps finder"
3557         echo "  --with-makedepend[=makedepend] enables makedepend support"
3558         echo "  --with-ccache                  enables ccache support"
3559         echo "  --with-distcc                  enables distcc support"
3560         echo "  --without-grfcodec             disable usage of grfcodec and re-generation of base sets"
3561         echo "  --without-threads              disable threading support"
3562         echo "  --without-sse                  disable SSE support (x86/x86_64 only)"
3563         echo ""
3564         echo "Some influential environment variables:"
3565         echo "  CC                             C compiler command"
3566         echo "  CXX                            C++ compiler command"
3567         echo "  CFLAGS                         C compiler flags"
3568         echo "  CXXFLAGS                       C++ compiler flags"
3569         echo "  WINDRES                        windres command"
3570         echo "  LDFLAGS                        linker flags, e.g. -L<lib dir> if you"
3571         echo "                                 have libraries in a nonstandard"
3572         echo "                                 directory <lib dir>"
3573         echo "  CFLAGS_BUILD                   C compiler flags for build time tool generation"
3574         echo "  CXXFLAGS_BUILD                 C++ compiler flags for build time tool generation"
3575         echo "  LDFLAGS_BUILD                  linker flags for build time tool generation"
3576         echo ""
3577         echo "Use these variables to override the choices made by 'configure' or to help"
3578         echo "it to find libraries and programs with nonstandard names/locations."