(svn r24554) -Add: Hotkeys for widgets in AI Debug window
[openttd/fttd.git] / config.lib
blob1e0d184f5cc4ef5e4bddd017953481bd5bb43ad8
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         os="DETECT"
33         endian="AUTO"
34         cpu_type="DETECT"
35         config_log="config.log"
36         prefix_dir="/usr/local"
37         binary_dir="games"
38         data_dir="share/games/openttd"
39         doc_dir="1"
40         icon_dir="share/pixmaps"
41         icon_theme_dir="1"
42         personal_dir="1"
43         shared_dir="1"
44         install_dir="/"
45         man_dir="1"
46         menu_dir="1"
47         menu_group="Game;"
48         menu_name="OpenTTD"
49         binary_name="openttd"
50         enable_debug="0"
51         enable_desync_debug="0"
52         enable_profiling="0"
53         enable_lto="0"
54         enable_dedicated="0"
55         enable_network="1"
56         enable_static="1"
57         enable_translator="0"
58         enable_unicode="1"
59         enable_console="1";
60         enable_assert="1"
61         enable_strip="0"
62         enable_universal="0"
63         enable_osx_g5="0"
64         enable_cocoa_quartz="1"
65         enable_cocoa_quickdraw="1"
66         with_osx_sysroot="1"
67         with_application_bundle="1"
68         with_menu_entry="1"
69         with_allegro="1"
70         with_sdl="1"
71         with_cocoa="1"
72         with_zlib="1"
73         with_lzma="1"
74         with_lzo2="1"
75         with_png="1"
76         enable_builtin_depend="1"
77         with_makedepend="0"
78         with_direct_music="1"
79         with_sort="1"
80         with_iconv="1"
81         with_midi=""
82         with_midi_arg=""
83         with_libtimidity="1"
84         with_freetype="1"
85         with_fontconfig="1"
86         with_icu="1"
87         static_icu="0"
88         with_psp_config="1"
89         with_threads="1"
90         with_distcc="1"
91         with_ccache="1"
92         with_nforenum="1"
93         with_grfcodec="1"
95         save_params_array="
96                 build
97                 host
98                 cc_build
99                 cc_host
100                 cxx_build
101                 cxx_host
102                 windres
103                 strip
104                 lipo
105                 awk
106                 os
107                 endian
108                 cpu_type
109                 config_log
110                 prefix_dir
111                 binary_dir
112                 data_dir
113                 doc_dir
114                 icon_dir
115                 icon_theme_dir
116                 man_dir
117                 menu_dir
118                 personal_dir
119                 shared_dir
120                 install_dir
121                 menu_group
122                 menu_name
123                 binary_name
124                 enable_debug
125                 enable_desync_debug
126                 enable_profiling
127                 enable_lto
128                 enable_dedicated
129                 enable_network
130                 enable_static
131                 enable_translator
132                 enable_unicode
133                 enable_console
134                 enable_assert
135                 enable_strip
136                 enable_universal
137                 enable_osx_g5
138                 enable_cocoa_quartz
139                 enable_cocoa_quickdraw
140                 with_osx_sysroot
141                 with_application_bundle
142                 with_allegro
143                 with_sdl
144                 with_cocoa
145                 with_zlib
146                 with_lzma
147                 with_lzo2
148                 with_png
149                 enable_builtin_depend
150                 with_makedepend
151                 with_direct_music
152                 with_sort
153                 with_iconv
154                 with_midi
155                 with_midi_arg
156                 with_libtimidity
157                 with_freetype
158                 with_fontconfig
159                 with_icu
160                 static_icu
161                 with_psp_config
162                 with_threads
163                 with_distcc
164                 with_ccache
165                 with_grfcodec
166                 with_nforenum
167         CC CXX CFLAGS CXXFLAGS LDFLAGS CFLAGS_BUILD CXXFLAGS_BUILD LDFLAGS_BUILD"
170 detect_params() {
171         # Walk over all params from the user and override any default settings if
172         #  needed. This also handles any invalid option.
173         for p in "$@"; do
174                 if [ -n "$prev_p" ]; then
175                         eval "$prev_p=\$p"
176                         prev_p=
177                         continue
178                 fi
180                 optarg=`expr "x$p" : 'x[^=]*=\(.*\)'`
182                 case "$p" in
183                         --help | -h | -\?)            showhelp; exit 0;;
185                         --config-log)                 prev_p="config_log";;
186                         --config-log=*)               config_log="$optarg";;
188                         --build)                      prev_p="build";;
189                         --build=*)                    build="$optarg";;
191                         --host)                       prev_p="host";;
192                         --host=*)                     host="$optarg";;
194                         --os)                         prev_p="os";;
195                         --os=*)                       os="$optarg";;
197                         --cpu-type)                   prev_p="cpu_type";;
198                         --cpu-type=*)                 cpu_type="$optarg";;
200                         --cc-build)                   prev_p="cc_build";;
201                         --cc-build=*)                 cc_build="$optarg";;
202                         --cc-host)                    prev_p="cc_host";;
203                         --cc-host=*)                  cc_host="$optarg";;
204                         --cxx-build)                  prev_p="cxx_build";;
205                         --cxx-build=*)                cxx_build="$optarg";;
206                         --cxx-host)                   prev_p="cxx_host";;
207                         --cxx-host=*)                 cxx_host="$optarg";;
208                         --windres)                    prev_p="windres";;
209                         --windres=*)                  windres="$optarg";;
210                         --awk)                        prev_p="awk";;
211                         --awk=*)                      awk="$optarg";;
212                         --strip)                      prev_p="strip";;
213                         --strip=*)                    strip="$optarg";;
214                         --lipo)                       prev_p="lipo";;
215                         --lipo=*)                     lipo="$optarg";;
217                         --endian)                     prev_p="endian";;
218                         --endian=*)                   endian="$optarg";;
222                         # Alias --prefix with --prefix-dir, for compatibility with GNU autotools
223                         --prefix-dir | --prefix)      prev_p="prefix_dir";;
224                         --prefix-dir=* | --prefix=*)  prefix_dir="$optarg";;
226                         --binary-dir)                 prev_p="binary_dir";;
227                         --binary-dir=*)               binary_dir="$optarg";;
229                         --data-dir)                   prev_p="data_dir";;
230                         --data-dir=*)                 data_dir="$optarg";;
232                         --doc-dir)                    prev_p="doc_dir";;
233                         --doc-dir=*)                  doc_dir="$optarg";;
235                         --icon-dir)                   prev_p="icon_dir";;
236                         --icon-dir=*)                 icon_dir="$optarg";;
238                         --icon-theme-dir)             prev_p="icon_theme_dir";;
239                         --icon-theme-dir=*)           icon_theme_dir="$optarg";;
240                         --without-icon-theme)         icon_theme_dir="";;
242                         --menu-dir)                   prev_p="menu_dir";;
243                         --menu-dir=*)                 menu_dir="$optarg";;
244                         --without-menu-entry)         menu_dir="";;
246                         --menu-name)                  prev_p="menu_name";;
247                         --menu-name=*)                menu_name="$optarg";;
249                         --binary-name)                prev_p="binary_name";;
250                         --binary-name=*)              binary_name="$optarg";;
252                         --man-dir)                    prev_p="man_dir";;
253                         --man-dir=*)                  man_dir="$optarg";;
255                         --personal-dir)               prev_p="personal_dir";;
256                         --personal-dir=*)             personal_dir="$optarg";;
257                         --without-personal-dir)       personal_dir="";;
259                         --shared-dir)                 prev_p="shared_dir";;
260                         --shared-dir=*)               shared_dir="$optarg";;
261                         --without-shared-dir)         shared_dir="";;
263                         --install-dir)                prev_p="install_dir";;
264                         --install-dir=*)              install_dir="$optarg";;
268                         --menu-group)                 prev_p="menu_group";;
269                         --menu-group=*)               menu_group="$optarg";;
273                         --enable-debug)               enable_debug="1";;
274                         --enable-debug=*)             enable_debug="$optarg";;
275                         --enable-desync-debug)        enable_desync_debug="1";;
276                         --enable-desync-debug=*)      enable_desync_debug="$optarg";;
277                         --enable-profiling)           enable_profiling="1";;
278                         --enable-profiling=*)         enable_profiling="$optarg";;
279                         --enable-lto)                 enable_lto="1";;
280                         --enable-lto=*)               enable_lto="$optarg";;
281                         --enable-ipo)                 enable_lto="1";;
282                         --enable-ipo=*)               enable_lto="$optarg";;
283                         --enable-dedicated)           enable_dedicated="1";;
284                         --enable-dedicated=*)         enable_dedicated="$optarg";;
285                         --enable-network)             enable_network="2";;
286                         --enable-network=*)           enable_network="$optarg";;
287                         --disable-network)            enable_network="0";;
288                         --disable-static)             enable_static="0";;
289                         --enable-static)              enable_static="2";;
290                         --enable-static=*)            enable_static="$optarg";;
291                         --disable-translator)         enable_translator="0";;
292                         --enable-translator)          enable_translator="2";;
293                         --enable-translator=*)        enable_translator="$optarg";;
294                         --disable-assert)             enable_assert="0";;
295                         --enable-assert)              enable_assert="2";;
296                         --enable-assert=*)            enable_assert="$optarg";;
297                         --disable-strip)              enable_strip="0";;
298                         --enable-strip)               enable_strip="2";;
299                         --enable-strip=*)             enable_strip="$optarg";;
300                         --disable-universal)          enable_universal="0";;
301                         --enable-universal)           enable_universal="i386 ppc";;
302                         --enable-universal=*)         enable_universal="$optarg";;
303                         --disable-osx-g5)             enable_osx_g5="0";;
304                         --enable-osx-g5)              enable_osx_g5="2";;
305                         --enable-osx-g5=*)            enable_osx_g5="$optarg";;
306                         --disable-unicode)            enable_unicode="0";;
307                         --enable-unicode)             enable_unicode="2";;
308                         --enable-unicode=*)           enable_unicode="$optarg";;
309                         --disable-console)            enable_console="0";;
310                         --enable-console)             enable_console="2";;
311                         --enable-console=*)           enable_console="$optarg";;
313                         --disable-cocoa-quartz)       enable_cocoa_quartz="0";;
314                         --enable-cocoa-quartz)        enable_cocoa_quartz="2";;
315                         --enable-cocoa-quartz=*)      enable_cocoa_quartz="$optarg";;
316                         --disable-cocoa-quickdraw)    enable_cocoa_quickdraw="0";;
317                         --enable-cocoa-quickdraw)     enable_cocoa_quickdraw="2";;
318                         --enable-cocoa-quickdraw=*)   enable_cocoa_quickdraw="$optarg";;
320                         --with-allegro)               with_allegro="2";;
321                         --without-allegro)            with_allegro="0";;
322                         --with-allegro=*)             with_allegro="$optarg";;
324                         --with-sdl)                   with_sdl="2";;
325                         --without-sdl)                with_sdl="0";;
326                         --with-sdl=*)                 with_sdl="$optarg";;
328                         --with-cocoa)                 with_cocoa="2";;
329                         --without-cocoa)              with_cocoa="0";;
330                         --with-cocoa=*)               with_cocoa="$optarg";;
332                         --with-zlib)                  with_zlib="2";;
333                         --without-zlib)               with_zlib="0";;
334                         --with-zlib=*)                with_zlib="$optarg";;
336                         --with-lzma)                  with_lzma="2";;
337                         --without-lzma)               with_lzma="0";;
338                         --with-lzma=*)                with_lzma="$optarg";;
339                         --with-liblzma)               with_lzma="2";;
340                         --without-liblzma)            with_lzma="0";;
341                         --with-liblzma=*)             with_lzma="$optarg";;
343                         --with-lzo2)                  with_lzo2="2";;
344                         --without-lzo2)               with_lzo2="0";;
345                         --with-lzo2=*)                with_lzo2="$optarg";;
346                         --with-liblzo2)               with_lzo2="2";;
347                         --without-liblzo2)            with_lzo2="0";;
348                         --with-liblzo2=*)             with_lzo2="$optarg";;
350                         --with-png)                   with_png="2";;
351                         --without-png)                with_png="0";;
352                         --with-png=*)                 with_png="$optarg";;
353                         --with-libpng)                with_png="2";;
354                         --without-libpng)             with_png="0";;
355                         --with-libpng=*)              with_png="$optarg";;
357                         --with-libtimidity)           with_libtimidity="2";;
358                         --without-libtimidity)        with_libtimidity="0";;
359                         --with-libtimidity=*)         with_libtimidity="$optarg";;
361                         --with-freetype)              with_freetype="2";;
362                         --without-freetype)           with_freetype="0";;
363                         --with-freetype=*)            with_freetype="$optarg";;
364                         --with-libfreetype)           with_freetype="2";;
365                         --without-libfreetype)        with_freetype="0";;
366                         --with-libfreetype=*)         with_freetype="$optarg";;
368                         --with-fontconfig)            with_fontconfig="2";;
369                         --without-fontconfig)         with_fontconfig="0";;
370                         --with-fontconfig=*)          with_fontconfig="$optarg";;
371                         --with-libfontconfig)         with_fontconfig="2";;
372                         --without-libfontconfig)      with_fontconfig="0";;
373                         --with-libfontconfig=*)       with_fontconfig="$optarg";;
375                         --with-icu)                   with_icu="2";;
376                         --without-icu)                with_icu="0";;
377                         --with-icu=*)                 with_icu="$optarg";;
378                         --with-libicu)                with_icu="2";;
379                         --without-libicu)             with_icu="0";;
380                         --with-libicu=*)              with_icu="$optarg";;
381                         --static-icu)                 static_icu="1";;
382                         --static-icu=*)               static_icu="$optarg";;
383                         --static-libicu)              static_icu="1";;
384                         --static-libicu=*)            static_icu="$optarg";;
386                         --with-psp-config)            with_psp_config="2";;
387                         --without-psp-config)         with_psp_config="0";;
388                         --with-psp-config=*)          with_psp_config="$optarg";;
390                         --disable-builtin-depend)     enable_builtin_depend="0";;
391                         --enable-builtin-depend)      enable_builtin_depend="2";;
392                         --enable-builtin-depend=*)    enable_builtin_depend="$optarg";;
394                         --with-makedepend)            with_makedepend="2";;
395                         --without-makedepend)         with_makedepend="0";;
396                         --with-makedepend=*)          with_makedepend="$optarg";;
398                         --with-direct-music)          with_direct_music="2";;
399                         --without-direct-music)       with_direct_music="0";;
400                         --with-direct-music=*)        with_direct_music="$optarg";;
402                         --with-sort)                  with_sort="2";;
403                         --without-sort)               with_sort="0";;
404                         --with-sort=*)                with_sort="$optarg";;
406                         --with-iconv)                 with_iconv="2";;
407                         --without-iconv)              with_iconv="0";;
408                         --with-iconv=*)               with_iconv="$optarg";;
410                         --with-midi=*)                with_midi="$optarg";;
411                         --with-midi-arg=*)            with_midi_arg="$optarg";;
413                         --without-distcc)             with_distcc="0";;
414                         --with-distcc)                with_distcc="2";;
415                         --with-distcc=*)              with_distcc="$optarg";;
417                         --without-ccache)             with_ccache="0";;
418                         --with-ccache)                with_ccache="2";;
419                         --with-ccache=*)              with_ccache="$optarg";;
421                         --without-nforenum)           with_nforenum="0";;
422                         --with-nforenum)              with_nforenum="2";;
423                         --with-nforenum=*)            with_nforenum="$optarg";;
425                         --without-grfcodec)           with_grfcodec="0";;
426                         --with-grfcodec)              with_grfcodec="2";;
427                         --with-grfcodec=*)            with_grfcodec="$optarg";;
429                         --without-osx-sysroot)        with_osx_sysroot="0";;
430                         --with-osx-sysroot)           with_osx_sysroot="2";;
431                         --with-osx-sysroot=*)         with_osx_sysroot="$optarg";;
433                         --without-application-bundle) with_application_bundle="0";;
434                         --with-application-bundle)    with_application_bundle="1";;
435                         --with-application-bundle=*)  with_application_bundle="$optarg";;
437                         --without-threads)            with_threads="0";;
438                         --with-threads)               with_threads="1";;
439                         --with-threads=*)             with_threads="$optarg";;
441                         CC=* | --CC=*)                CC="$optarg";;
442                         CXX=* | --CXX=*)              CXX="$optarg";;
443                         CFLAGS=* | --CFLAGS=*)        CFLAGS="$optarg";;
444                         CXXFLAGS=* | --CXXFLAGS=*)    CXXFLAGS="$optarg";;
445                         LDFLAGS=* | --LDFLAGS=*)      LDFLAGS="$optarg";;
446                         CFLAGS_BUILD=* | --CFLAGS_BUILD=*)     CFLAGS_BUILD="$optarg";;
447                         CXXFLAGS_BUILD=* | --CXXFLAGS_BUILD=*) CXXFLAGS_BUILD="$optarg";;
448                         LDFLAGS_BUILD=* | --LDFLAGS_BUILD=*)   LDFLAGS_BUILD="$optarg";;
450                         --ignore-extra-parameters)    ignore_extra_parameters="1";;
452                         --* | -*)
453                                 if [ "$ignore_extra_parameters" = "0" ]; then
454                                         log 1 "Unknown option $p"
455                                         exit 1
456                                 else
457                                         log 1 "Unknown option $p ignored"
458                                 fi
459                                 ;;
460                 esac
461         done
463         if [ -n "$prev_p" ]; then
464                 log 1 "configure: error: missing argument to --$prev_p"
465                 exit 1
466         fi
468         # Clean the logfile
469         echo "" > $config_log
470         log 2 "Invocation: $0 $*"
473 save_params() {
474         # Here we save all params, so we can later on do an exact redo of this
475         #  configuration, without having the user to re-input stuff
477         echo "Running configure with following options:" >> $config_log
478         echo "" >> $config_log
480         configure="$CONFIGURE_EXECUTABLE --ignore-extra-parameters"
481         for p in $save_params_array; do
482                 eval "v=\"\$$p\""
483                 p=`echo "$p" | sed 's@_@-@g;s@\n@@g;s@ @\\ @g'`
484                 # Only save those params that aren't empty
485                 configure="$configure --$p=\"$v\""
486         done
488         echo "$configure" >> $config_log
489         echo "$configure" > config.cache
490         echo "" >> $config_log
493 check_params() {
494         # Some params want to be in full uppercase, else they might not work as
495         # expected.. fix that here
497         endian=`echo $endian | tr '[a-z]' '[A-Z]'`
498         os=`echo $os | tr '[a-z]' '[A-Z]'`
499         cpu_type=`echo $cpu_type | tr '[a-z]' '[A-Z]'`
501         # Check if all params have valid values
503         # Endian only allows AUTO, LE and, BE
504         if [ -z "`echo $endian | egrep '^(AUTO|LE|BE|PREPROCESSOR)$'`" ]; then
505                 log 1 "configure: error: invalid option --endian=$endian"
506                 log 1 " Available options are: --endian=[AUTO|LE|BE]"
507                 exit 1
508         fi
509         if [ "$endian" = "PREPROCESSOR" ] && [ "$os" != "OSX" ]; then
510                 log 1 "configure: error: invalid option --endian=$endian"
511                 log 1 " PREPROCESSOR is only available for OSX"
512                 exit 1
513         fi
514         # OS only allows DETECT, UNIX, OSX, FREEBSD, OPENBSD, MORPHOS, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP
515         if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP)$'`" ]; then
516                 log 1 "configure: error: invalid option --os=$os"
517                 log 1 " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|OPENBSD|NETBSD|HPUX|MORPHOS|BEOS|HAIKU|SUNOS|CYGWIN|MINGW|OS2|DOS|WINCE|PSP]"
518                 exit 1
519         fi
520         # cpu_type can be either 32 or 64
521         if [ -z "`echo $cpu_type | egrep '^(32|64|DETECT)$'`" ]; then
522                 log 1 "configure: error: invalid option --cpu-type=$cpu_type"
523                 log 1 " Available options are: --cpu-type[=DETECT|32|64]"
524                 exit 1
525         fi
526         # enable_debug should be between 0 and 4
527         if [ -z "`echo $enable_debug | egrep '^[0123]$'`" ]; then
528                 log 1 "configure: error: invalid option --enable-debug=$enable_debug"
529                 log 1 " Available options are: --enable-debug[=0123]"
530                 exit 1
531         fi
533         # enable_desync_debug should be between 0 and 3
534         if [ -z "`echo $enable_desync_debug | egrep '^[012]$'`" ]; then
535                 log 1 "configure: error: invalid option --enable-desync-debug=$enable_desync_debug"
536                 log 1 " Available options are: --enable-desync-debug[=012]"
537                 exit 1
538         fi
540         detect_awk
542         detect_os
544         check_build
545         check_host
547         # Check for universal builds; they only make sense for OSX, so fail if enabled for another OS
548         if [ "$enable_universal" = "0" ]; then
549                 log 1 "checking universal build... no"
550         else
551                 if [ "$os" != "OSX" ]; then
552                         log 1 "configure: error: --enable-universal only works on OSX"
553                         exit 1
554                 fi
555                 log 1 "checking universal build... yes, for: $enable_universal"
556         fi
558         # Already detected by check_build
559         log 1 "checking build cc... $cc_build"
560         log 1 "checking host cc... $cc_host"
562         check_cxx_build
563         check_cxx_host
564         check_windres
565         if [ "$enable_strip" != "0" ]; then
566                 check_strip
567         else
568                 log 1 "checking strip... disabled"
569         fi
570         check_lipo
572         if [ "$enable_builtin_depend" != "0" ]; then
573                 log 1 "checking builtin depend... yes"
574                 makedepend="\$(SRC_OBJS_DIR)/\$(DEPEND)"
575         else
576                 log 1 "checking builtin depend... no"
577         fi
579         check_makedepend
580         detect_cputype
582         if [ "$enable_static" = "1" ]; then
583                 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "DOS" ]; then
584                         enable_static="2"
585                 else
586                         enable_static="0"
587                 fi
588         fi
590         if [ "$enable_static" != "0" ]; then
591                 log 1 "checking static... yes"
593                 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "OSX" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "DOS" ]; then
594                         log 1 "WARNING: static is only known to work on Windows, DOS, MacOSX and MorphOS"
595                         log 1 "WARNING: use static at your own risk on this platform"
597                         sleep 5
598                 fi
599         else
600                 log 1 "checking static... no"
601         fi
603         if [ "$enable_unicode" = "1" ]; then
604                 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "DOS" ]; then
605                         enable_unicode="2"
606                 else
607                         enable_unicode="0"
608                 fi
609         fi
611         if [ "$enable_unicode" != "0" ]; then
612                 log 1 "checking unicode... yes"
613         else
614                 log 1 "checking unicode... no"
615         fi
617         # Show what we configured
618         if [ "$enable_debug" = "0" ]; then
619                 log 1 "using debug level... no"
620         elif [ "$enable_profiling" != "0" ]; then
621                 log 1 "using debug level... profiling (debug level $enable_debug)"
622         else
623                 log 1 "using debug level... level $enable_debug"
624         fi
626         if [ "$enable_desync_debug" = "0" ]; then
627                 log 1 "using desync debug level... no"
628         else
629                 log 1 "using desync debug level... level $enable_desync_debug"
630                 log 1 "WARNING: desync debug functions slow down the game considerably."
631                 log 1 "WARNING: use only when you are instructed to do so"
632                 log 1 "         or when you know what you are doing."
634                 sleep 5
635         fi
637         if [ "$enable_lto" != "0" ]; then
638                 # GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
639                 has_lto=`($cxx_build -dumpspecs 2>&1 | grep '\%{flto') || ($cxx_build -help ipo 2>&1 | grep '\-ipo')`
640                 if [ -n "$has_lto" ]; then
641                         log 1 "using link time optimization... yes"
642                 else
643                         enable_lto="0"
644                         log 1 "using link time optimization... no"
645                         log 1 "WARNING: you selected link time optimization but it is not found."
646                         sleep 5
647                 fi
648         else
649                 log 1 "using link time optimization... no"
650         fi
653         if [ "$os" != "OSX" ] && [ "$with_osx_sysroot" != "0" ]; then
654                 if [ "$with_osx_sysroot" = "1" ]; then
655                         with_osx_sysroot="0"
657                         log 1 "checking OSX sysroot... not OSX, skipping"
658                 else
659                         log 1 "configure: error: --with-osx-sysroot only works if OSX is the target"
660                         exit 1
661                 fi
662         fi
664         if [ "$with_osx_sysroot" != "0" ]; then
665                 if [ "$enable_universal" = "0" ] && [ "$with_osx_sysroot" != "1" ] && [ "$with_osx_sysroot" != "2" ]; then
666                         # Sysroot manually specified? Check for usability
667                         log 1 "checking OSX sysroot... $with_osx_sysroot"
668                         if ! check_osx_sdk "$with_osx_sysroot"; then
669                                 log 1 "Passed sysroot not found/not functional"
670                                 exit 1
671                         fi
672                 else
673                         # If autodetect and no universal, use system default
674                         if [ "$with_osx_sysroot" = "1" ] && [ "$enable_universal" = "0" ]; then
675                                 log 1 "checking OSX sysroot... no (use system default)"
676                         else
677                                 log 1 "checking OSX sysroot... automatically"
678                                 detect_osx_sdk
679                         fi
680                 fi
682                 if [ -n "$osx_sdk_path" ]; then
683                         if [ "$enable_universal" != "0" ]; then
684                                 if [ -z "$osx_sdk_104_path" ]; then
685                                         log 1 "WARNING: Could not find a usable 10.4u SDK, the resulting"
686                                         log 1 "WARNING: binary will only run on OSX 10.5 or later"
687                                         osx_sdk_104_path="$osx_sdk_path"
688                                 fi
689                                 OSX_SYSROOT="-isysroot $osx_sdk_104_path"
690                                 OSX_LD_SYSROOT="-Wl,-syslibroot,$osx_sdk_104_path"
691                         else
692                                 OSX_SYSROOT="-isysroot $osx_sdk_path"
693                                 OSX_LD_SYSROOT="-Wl,-syslibroot,$osx_sdk_path"
694                         fi
695                 fi
696         else
697                 if [ "$os" = "OSX" ]; then
698                         log 1 "checking OSX sysroot... no (use system default)"
699                 fi
700         fi
702         detect_allegro
703         detect_sdl
704         detect_cocoa
706         if [ "$enable_dedicated" != "0" ]; then
707                 log 1 "checking GDI video driver... dedicated server, skipping"
708                 log 1 "checking dedicated... found"
710                 if [ "$enable_network" = "0" ]; then
711                         log 1 "configure: error: building a dedicated server without network support is pointless"
712                         exit 1
713                 fi
714         else
715                 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
716                         log 1 "checking GDI video driver... found"
717                 else
718                         log 1 "checking GDI video driver... not Windows, skipping"
719                 fi
721                 if [ -z "$allegro_config" ] && [ -z "$sdl_config" ] && [ "$with_cocoa" = 0 ] && [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
722                         log 1 "configure: error: no video driver development files found"
723                         log 1 " If you want a dedicated server use --enable-dedicated as parameter"
724                         exit 1
725                 else
726                         log 1 "checking dedicated... not selected"
727                 fi
728         fi
730         if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
731                 log 1 "checking console application... not Windows, skipping"
732         elif [ "$enable_console" = "1" ] && [ "$enable_dedicated" != "0" ]; then
733                 log 1 "checking console application... dedicated server, enabled"
734                 enable_console="2"
735         elif [ "$enable_console" = "1" ]; then
736                 log 1 "checking console application... disabled (only used when forced)"
737                 enable_console="0"
738         elif [ "$enable_console" = "0" ]; then
739                 log 1 "checking console application... disabled"
740         else
741                 log 1 "checking console application... enabled"
742         fi
744         if [ "$enable_network" = "1" ] && [ "$os" = "DOS" ]; then
745                 log 1 "checking network... DOS, skipping"
746                 enable_network=0
747         elif [ "$enable_network" != "0" ]; then
748                 log 1 "checking network... found"
749         else
750                 log 1 "checking network... disabled"
751         fi
753         log 1 "checking squirrel... found"
754         SCRIPT_SRC_DIR="$ROOT_DIR/src/3rdparty/squirrel/include"
756         if [ "$enable_translator" != "0" ]; then
757                 log 1 "checking translator... debug"
758                 # -t shows TODO items, normally they are muted
759                 strgen_flags="-t"
760         else
761                 log 1 "checking translator... no"
762                 strgen_flags=""
763         fi
765         if [ "$enable_assert" != "0" ]; then
766                 log 1 "checking assert... enabled"
767         else
768                 log 1 "checking assert... disabled"
769         fi
771         pre_detect_with_zlib=$with_zlib
772         detect_zlib
774         if [ "$with_zlib" = "0" ] || [ -z "$zlib" ]; then
775                 log 1 "WARNING: zlib was not detected or disabled"
776                 log 1 "WARNING: OpenTTD doesn't require zlib, but it does mean that many features"
777                 log 1 "WARNING: (like loading most old savegames/scenarios, loading heightmaps,"
778                 log 1 "WARNING: using PNG, or using fonts, ...) will be disabled."
779                 if [ "$pre_detect_with_zlib" = "0" ]; then
780                         log 1 "WARNING: We strongly suggest you to install zlib."
781                 else
782                         log 1 "configure: error: no zlib detected"
783                         log 1 " If you want to compile without zlib use --without-zlib as parameter"
784                         exit
785                 fi
786         fi
788         pre_detect_with_lzma=$with_lzma
789         detect_lzma
791         if [ "$with_lzma" = "0" ] || [ -z "$lzma_config" ]; then
792                 log 1 "WARNING: lzma was not detected or disabled"
793                 log 1 "WARNING: OpenTTD doesn't require lzma, but it does mean that many features"
794                 log 1 "WARNING: (like loading most savegames/scenarios and joining most servers)"
795                 log 1 "WARNING: will be disabled."
796                 if [ "$pre_detect_with_lzma" = "0" ]; then
797                         log 1 "WARNING: We strongly suggest you to install liblzma."
798                         log 1 "configure: error: no liblzma detected"
799                 else
800                         log 1 " If you want to compile without lzma use --without-lzma as parameter"
801                         exit
802                 fi
803         fi
805         pre_detect_with_lzo2=$with_lzo2
806         detect_lzo2
808         if [ "$with_lzo2" = "0" ] || [ -z "$lzo2" ]; then
809                 log 1 "WARNING: liblzo2 was not detected or disabled"
810                 log 1 "WARNING: OpenTTD doesn't require liblzo2, but it does mean that"
811                 log 1 "WARNING: loading old savegames/scenarios will be disabled."
812                 if [ "$pre_detect_with_lzo2" = "0" ]; then
813                         log 1 "WARNING: We strongly suggest you to install liblzo2."
814                 else
815                         log 1 "configure: error: no liblzo2 detected"
816                         log 1 " If you want to compile without liblzo2 use --without-liblzo2 as parameter"
817                         exit
818                 fi
819         fi
821         detect_png
822         detect_freetype
823         detect_fontconfig
824         detect_icu
825         detect_pspconfig
826         detect_libtimidity
828         if [ "$with_direct_music" != "0" ]; then
829                 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
830                         if [ "$with_direct_music" != "1" ]; then
831                                 log 1 "configure: error: direct-music is only supported on Win32 targets"
832                                 exit 1
833                         fi
834                         with_direct_music="0"
836                         log 1 "checking direct-music... not Windows, skipping"
837                 else
838                         check_direct_music
839                 fi
840         fi
842         detect_sort
844         if [ "$os" = "OSX" ] && [ "$endian" = "AUTO" ]; then
845                 endian="PREPROCESSOR"
846         fi
848         log 1 "checking endianess... $endian"
850         # Suppress language errors when there is a version defined, indicating a release
851         #  It just isn't pretty if any release produces warnings in the languages.
852         if [ -f "$ROOT_DIR/version" ]; then
853                 lang_suppress="yes"
854                 log 1 "suppress language errors... yes"
855         else
856                 lang_suppress=""
857                 log 1 "suppress language errors... no"
858         fi
860         if [ "$enable_debug" = "0" ] && [ "$enable_profiling" = "0" ] && [ "$enable_strip" != "0" ]; then
861                 if [ "$os" = "MORPHOS" ]; then
862                         strip_arg="--strip-all --strip-unneeded --remove-section .comment"
863                 elif [ "$os" = "OSX" ]; then
864                         strip_arg=""
865                 elif [ "$os" = "OS2" ]; then
866                         strip_arg=""
867                         # OS2 uses strip via gcc, because it needs to be feed to emxbind
868                         LDFLAGS="$LDFLAGS -s"
869                 elif [ "$os" = "SUNOS" ]; then
870                         # The GNU strip does know -s, the non-GNU doesn't
871                         #  So try to detect it (in a bit of an ugly way)
872                         strip_arg="`$strip -s strip.test 2>/dev/null && echo \"-s\"`"
873                 else
874                         strip_arg="-s"
875                 fi
877                 log 1 "checking stripping... $strip $strip_arg"
878         else
879                 strip=""
880                 log 1 "checking stripping... skipped"
881         fi
883         if [ "$with_distcc" = "0" ]; then
884                 log 1 "checking distcc... no"
885         elif [ "$with_distcc" = "1" ]; then
886                 with_distcc="0"
888                 log 1 "checking distcc... no (only used when forced)"
889         elif [ "$with_distcc" = "2" ]; then
890                 distcc="distcc"
891         else
892                 distcc="$with_distcc"
893         fi
894         if [ "$with_distcc" != "0" ]; then
895                 res="`$distcc --version 2>/dev/null | head -n 1 | cut -b 1-6`"
896                 if [ "$res" != "distcc" ]; then
897                         distcc=""
898                         log 1 "checking distcc... no"
899                         if [ "$with_distcc" = "2" ]; then
900                                 log 1 "configure: error: no distcc detected, but was forced to be used"
901                                 exit 1
902                         fi
903                         if [ "$with_distcc" != "1" ]; then
904                                 log 1 "configure: error: '$with_distcc' doesn't seem a distcc to me"
905                                 exit 1
906                         fi
907                 fi
909                 log 1 "checking distcc... $distcc"
910         fi
912         if [ "$with_ccache" = "0" ]; then
913                 log 1 "checking ccache... no"
914         elif [ "$with_ccache" = "1" ]; then
915                 with_ccache="0"
917                 log 1 "checking ccache... no (only used when forced)"
918         elif [ "$with_ccache" = "2" ]; then
919                 ccache="ccache"
920         else
921                 ccache="$with_ccache"
922         fi
923         if [ "$with_ccache" != "0" ]; then
924                 res="`$ccache --version 2>/dev/null | head -n 1 | cut -b 1-6`"
925                 if [ "$res" != "ccache" ]; then
926                         ccache=""
927                         log 1 "checking ccache... no"
928                         if [ "$with_ccache" = "2" ]; then
929                                 log 1 "configure: error: no ccache detected, but was forced to be used"
930                                 exit 1
931                         fi
932                         if [ "$with_ccache" != "1" ]; then
933                                 log 1 "configure: error: '$with_ccache' doesn't seem a ccache to me"
934                                 exit 1
935                         fi
936                 fi
938                 log 1 "checking ccache... $ccache"
939         fi
941         detect_grfcodec
942         detect_nforenum
944         if [ -z "$grfcodec" ] && [ -n "$nforenum" ]; then
945                 log 1 "checking nforenum/grfcodec... nforenum needs grfcodec enabled, disabling nforenum"
946                 nforenum=""
947         fi
949         if [ -z "$nforenum" ] && [ -n "$grfcodec" ]; then
950                 log 1 "checking nforenum/grfcodec... grfcodec needs nforenum enabled, disabling grfcodec"
951                 grfcodec=""
952         fi
954         if [ "$os" = "DOS" ]; then
955                 with_threads="0"
956         fi
958         if [ "$os" != "OSX" ] && [ "$with_application_bundle" != "0" ]; then
959                 if [ "$with_application_bundle" = "1" ]; then
960                         with_application_bundle="0"
962                         log 1 "checking OSX application bundle... not OSX, skipping"
963                 else
964                         log 1 "configure: error: --with-application-bundle only works if OSX is the target"
965                         exit 1
966                 fi
967         fi
969         if [ "$os" = "OSX" ] && [ "$with_application_bundle" = "1" ]; then
970                 OSXAPP="OpenTTD.app"
971         else
972                 OSXAPP=""
973         fi
975         if [ "$os" = "OSX" ]; then
976                 # Test on ppc970 (G5) - we can optimize there
978                 if [ "$enable_osx_g5" != "0" ]; then
979                         log 1 "detecting ppc970 (G5)... yes (forced)"
980                 else
981                         # First, are we a real OSX system, else we can't detect it
982                         native=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | grep darwin`
983                         # If $host doesn't match $build , we are cross-compiling
984                         if [ -n "$native" ] && [ "$build" = "$host" ]; then
985                                 $cxx_build $SRC_DIR/os/macosx/G5_detector.cpp -o G5_detector
986                                 res=`./G5_detector`
987                                 rm -f G5_detector
988                                 if [ -n "$res" ]; then
989                                         # This is G5, add flags for it
990                                         enable_osx_g5="2"
992                                         log 1 "detecting ppc970 (G5)... yes"
993                                 else
994                                         enable_osx_g5="0"
996                                         log 1 "detecting ppc970 (G5)... no"
997                                 fi
998                         else
999                                 enable_osx_g5="0"
1001                                 log 1 "detecting ppc970 (G5)... no (cross-compiling)"
1002                         fi
1003                 fi
1004         else
1005                 if [ "$enable_osx_g5" != "0" ]; then
1006                         log 1 "configure: error: ppc970 (OSX G5) selected, but not compiling for OSX"
1007                         log 1 "configure: error: either select OSX as OS, or deselect ppc970"
1009                         exit 1
1010                 fi
1011         fi
1013         if [ -d "$ROOT_DIR/.svn" ] && [ -n "`svn help 2>/dev/null`" ]; then
1014                 log 1 "checking revision... svn detection"
1015         elif [ -d "$ROOT_DIR/.git" ] && [ -n "`git help 2>/dev/null`" ]; then
1016                 log 1 "checking revision... git detection"
1017         elif [ -d "$ROOT_DIR/.hg" ] && [ -n "`hg help 2>/dev/null`" ]; then
1018                 log 1 "checking revision... hg detection"
1019         elif [ -f "$ROOT_DIR/.ottdrev" ]; then
1020                 log 1 "checking revision... source tarball"
1021         else
1022                 log 1 "checking revision... no detection"
1023                 log 1 "WARNING: there is no means to determine the version."
1024                 log 1 "WARNING: please use a subversion, mercurial, or git checkout of OpenTTD."
1025                 log 1 "WARNING: you can only join game servers that have been compiled without"
1026                 log 1 "WARNING:   version detection."
1027                 log 1 "WARNING: there is a great chance you desync."
1028                 log 1 "WARNING: USE WITH CAUTION!"
1030                 sleep 5
1031         fi
1033         if [ "$doc_dir" = "1" ]; then
1034                 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
1035                         doc_dir="share/doc/openttd"
1036                 else
1037                         doc_dir="$data_dir/docs"
1038                 fi
1039         else
1040                 doc_dir="`echo $doc_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1041         fi
1043         if [ "$icon_theme_dir" = "1" ]; then
1044                 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
1045                         icon_theme_dir="share/icons/hicolor"
1046                 else
1047                         icon_theme_dir=""
1048                 fi
1049         else
1050                 icon_theme_dir="`echo $icon_theme_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1051         fi
1053         if [ "$personal_dir" = "1" ]; then
1054                 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ] || [ "$os" = "DOS" ] || [ "$os" = "HAIKU" ]; then
1055                         personal_dir="OpenTTD"
1056                 elif [ "$os" = "OSX" ]; then
1057                         personal_dir="Documents/OpenTTD"
1058                 else
1059                         personal_dir=".openttd"
1060                 fi
1061         else
1062                 personal_dir="`echo $personal_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1063         fi
1065         if [ "$shared_dir" = "1" ]; then
1066                 # we are using default values
1067                 if [ "$os" = "OSX" ]; then
1068                         shared_dir="/Library/Application\\\\ Support/OpenTTD"
1069                 else
1070                         shared_dir=""
1071                 fi
1072         else
1073                 shared_dir="`echo $shared_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1074         fi
1076         if [ "$man_dir" = "1" ]; then
1077                 # add manpage on UNIX systems
1078                 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OSX" ]; then
1079                         man_dir="share/man/man6"
1080                 else
1081                         man_dir=""
1082                 fi
1083         else
1084                 man_dir="`echo $man_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1085         fi
1087         if [ "$menu_dir" = "1" ]; then
1088                 # add a freedesktop menu item only for some UNIX systems
1089                 if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
1090                         menu_dir="share/applications"
1091                 else
1092                         menu_dir=""
1093                 fi
1094         else
1095                 menu_dir="`echo $menu_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
1096         fi
1098         detect_iconv
1100         if [ -n "$personal_dir" ]
1101         then
1102                 log 1 "personal home directory... $personal_dir"
1103         else
1104                 log 1 "personal home directory... none"
1105         fi
1107         if [ -n "$shared_dir" ]
1108         then
1109                 log 1 "shared data directory... $shared_dir"
1110         else
1111                 log 1 "shared data directory... none"
1112         fi
1114         if [ -n "$install_dir" ]
1115         then
1116                 log 1 "installation directory... $install_dir"
1117         else
1118                 log 1 "installation directory... none"
1119         fi
1121         if [ -n "$icon_theme_dir" ]
1122         then
1123                 log 1 "icon theme directory... $icon_theme_dir"
1124         else
1125                 log 1 "icon theme directory... none"
1126         fi
1128         if [ -n "$man_dir" ]
1129         then
1130                 log 1 "manual page directory... $man_dir"
1131         else
1132                 log 1 "manual page directory... none"
1133         fi
1135         if [ -n "$menu_dir" ]
1136         then
1137                 log 1 "menu item directory... $menu_dir"
1138         else
1139                 log 1 "menu item directory... none"
1140         fi
1143 make_compiler_cflags() {
1144         # Params:
1145         # $1 - compiler
1146         # $2 - name of the cflags variable
1147         # $3 - name of the cxxflags variable
1148         # $4 - name of the ldflags variable
1149         # $5 - name of the features variable
1151         eval eval "flags=\\\$$2"
1152         eval eval "cxxflags=\\\$$3"
1153         eval eval "ldflags=\\\$$4"
1154         eval eval "features=\\\$$5"
1156         if [ `basename $1 | cut -c 1-3` = "icc" ]; then
1157                 # Enable some things only for certain ICC versions
1158                 cc_version=`$1 -dumpversion | cut -c 1-4 | sed s@\\\.@@g`
1160                 flags="$flags -rdynamic"
1161                 ldflags="$ldflags -rdynamic"
1163                 if [ -z "$first_time_icc_check" ]; then
1164                         first_time_icc_check=no
1165                         if [ $cc_version -lt 90 ]; then
1166                                 log 1 "WARNING: you seem to be using a very old version of ICC"
1167                                 log 1 "WARNING: OpenTTD hasn't been tested with this version"
1168                                 sleep 5
1169                         elif [ $cc_version -lt 120 ]; then
1170                                 log 1 "WARNING: you seem to be using an unsupported ICC version"
1171                                 log 1 "WARNING: ICC older than 12.0 is known to fail to compile OpenTTD"
1172                                 sleep 5
1173                         fi
1174                 fi
1176                 flags="$flags -Wall"
1177                 # remark #111: statement is unreachable
1178                 flags="$flags -wd111"
1179                 # remark #181: argument is incompatible with corresponding format string conversion
1180                 # ICC is very picky about signedness of operands, warnings provided by GCC are enough
1181                 flags="$flags -wd181"
1182                 # remark #271: trailing comma is nonstandard
1183                 flags="$flags -wd271"
1184                 # remark #280: selector expression is constant
1185                 flags="$flags -wd280"
1186                 # remark #304: access control not specified ("public" by default)
1187                 flags="$flags -wd304"
1188                 # remark #383: value copied to temporary, reference to temporary used
1189                 flags="$flags -wd383"
1190                 # remark #444: destructor for base class ... is not virtual
1191                 flags="$flags -wd444"
1192                 # remark #593: variable ... was set but never used
1193                 flags="$flags -wd593"
1194                 # warning #654: overloaded virtual function ... is only partially overridden in class ...
1195                 flags="$flags -wd654"
1196                 # remark #810: conversion from ... to ... may lose significant bits
1197                 flags="$flags -wd810"
1198                 # remark #869: parameter ... was never referenced
1199                 flags="$flags -wd869"
1200                 # warning #873: function ... ::operator new ... has no corresponding operator delete ...
1201                 flags="$flags -wd873"
1202                 # remark #981: operands are evaluated in unspecified order
1203                 flags="$flags -wd981"
1204                 # remark #1418: external function definition with no prior declaration
1205                 flags="$flags -wd1418"
1206                 # remark #1419: external declaration in primary source file
1207                 flags="$flags -wd1419"
1208                 # remark #1572: floating-point equality and inequality
1209                 flags="$flags -wd1572"
1210                 # remark #1599: declaration hides variable/parameter ...
1211                 flags="$flags -wd1599"
1212                 # remark #1720: function ... ::operator new ... has no corresponding member operator delete ...
1213                 flags="$flags -wd1720"
1215                 if [ $cc_version -lt 110 ]; then
1216                         # warns about system headers with recent glibc:
1217                         # warning #1292: attribute "__nonnull__" ignored
1218                         flags="$flags -wd1292"
1219                 fi
1221                 if [ $cc_version -ge 100 ]; then
1222                         # warning #1899: multicharacter character literal (potential portability problem)
1223                         flags="$flags -wd1899"
1224                         # vec report defaults to telling where it did loop vectorisation, which is not very important
1225                         flags="$flags -vec-report=0 "
1226                 fi
1228                 if [ $cc_version -ge 110 ]; then
1229                         # remark #2259: non-pointer conversion from ... to ... may lose significant bits
1230                         flags="$flags -wd2259"
1231                         # Use c++0x mode so static_assert() is available
1232                         cxxflags="$cxxflags -std=c++0x"
1233                 fi
1235                 if [ "$enable_lto" != "0" ]; then
1236                         has_ipo=`$1 -help ipo | grep '\-ipo'`
1237                         if [ -n "$has_ipo" ]; then
1238                                 # Use IPO (only if we see IPO exists and is requested)
1239                                 flags="$flags -ipo"
1240                                 features="$features lto"
1241                         fi
1242                 fi
1243         elif [ `basename $1 | grep 'clang'` ]; then
1244                 # Enable some things only for certain clang versions
1245                 cc_version="`$1 -v 2>&1 | head -n 1 | sed s@[^0-9]@@g | cut -c 1-2`"
1247                 # aliasing rules are not held in openttd code
1248                 flags="$flags -fno-strict-aliasing"
1250                 # -W alone doesn't enable all warnings enabled by -Wall; on the other hand,
1251                 # -Weverything enables too many useless warnings that can't be disabled (as of 3.0)
1252                 flags="$flags -Wall -W"
1254                 # warning: unused parameter '...'
1255                 flags="$flags -Wno-unused-parameter"
1257                 # warning: expression result unused
1258                 flags="$flags -Wno-unused-value"
1260                 # warning: multi-character character constant
1261                 flags="$flags -Wno-multichar"
1263                 # warning: explicitly assigning a variable of type '...' to itself
1264                 # it happens when using the FOR_ALL_WINDOWS_FROM_BACK_FROM macro
1265                 flags="$flags -Wno-self-assign"
1267                 if [ "$cc_version" -lt "30" ]; then
1268                         # warning: equality comparison with extraneous parentheses
1269                         flags="$flags -Wno-parentheses"
1270                         # warning: operands of ? are integers of different signs: 'unsigned int' and 'int'
1271                         flags="$flags -Wno-sign-compare"
1272                 fi
1274                 if [ "$cc_version" -ge "30" ]; then
1275                         # warning: equality comparison with extraneous parentheses
1276                         # this warning could be useful, but it warns about code in squirrel
1277                         flags="$flags -Wno-parentheses-equality"
1278                 fi
1280                 if [ "$with_ccache" != "0" -o "$with_distcc" != "0" ]; then
1281                         # ccache and distcc run separate preprocess and compile passes,
1282                         # both are fed with the same CFLAGS. Unfortunately, clang
1283                         # complains about -I when compiling preprocessed files:
1284                         # "clang: warning: argument unused during compilation: '-I /usr/include'"
1285                         flags="$flags -Qunused-arguments"
1286                 fi
1288                 if [ "$enable_assert" -eq "0" ]; then
1289                         # do not warn about unused variables when building without asserts
1290                         flags="$flags -Wno-unused-variable"
1291                 fi
1293                 # rdynamic is used to get useful stack traces from crash reports.
1294                 ldflags="$ldflags -rdynamic"
1295         else
1296                 # Enable some things only for certain GCC versions
1297                 cc_version=`$1 -dumpversion | cut -c 1,3`
1299                 if [ $cc_version -lt 33 ]; then
1300                         log 1 "configure: error: gcc older than 3.3 can't compile OpenTTD because of its poor template support"
1301                         exit 1
1302                 fi
1304                 flags="$flags -Wall -Wno-multichar -Wsign-compare -Wundef"
1305                 flags="$flags -Wwrite-strings -Wpointer-arith"
1306                 flags="$flags -W -Wno-unused-parameter -Wredundant-decls"
1307                 flags="$flags -Wformat=2 -Wformat-security"
1309                 if [ $enable_assert -eq 0 ]; then
1310                         # Do not warn about unused variables when building without asserts
1311                         flags="$flags -Wno-unused-variable"
1312                         if [ $cc_version -ge 46 ]; then
1313                                 # GCC 4.6 gives more warnings, disable them too
1314                                 flags="$flags -Wno-unused-but-set-variable"
1315                                 flags="$flags -Wno-unused-but-set-parameter"
1316                         fi
1317                 fi
1319                 if [ $cc_version -ge 34 ]; then
1320                         # Warn when a variable is used to initialise itself:
1321                         # int a = a;
1322                         flags="$flags -Winit-self"
1323                 fi
1325                 if [ $cc_version -ge 40 ]; then
1326                         # GCC 4.0+ complains about that we break strict-aliasing.
1327                         #  On most places we don't see how to fix it, and it doesn't
1328                         #  break anything. So disable strict-aliasing to make the
1329                         #  compiler all happy.
1330                         flags="$flags -fno-strict-aliasing"
1331                         # Warn about casting-out 'const' with regular C-style cast.
1332                         #  The preferred way is const_cast<>() which doesn't warn.
1333                         flags="$flags -Wcast-qual"
1334                 fi
1336                 if [ $cc_version -ge 42 ]; then
1337                         # GCC 4.2+ automatically assumes that signed overflows do
1338                         # not occur in signed arithmetics, whereas we are not
1339                         # sure that they will not happen. It furthermore complains
1340                         # about its own optimized code in some places.
1341                         flags="$flags -fno-strict-overflow"
1342                         # GCC 4.2 no longer includes -Wnon-virtual-dtor in -Wall.
1343                         # Enable it in order to be consistent with older GCC versions.
1344                         flags="$flags -Wnon-virtual-dtor"
1345                 fi
1347                 if [ $cc_version -ge 43 ]; then
1348                         # Use gnu++0x mode so static_assert() is available.
1349                         # Don't use c++0x, it breaks mingw (with gcc 4.4.0).
1350                         cxxflags="$cxxflags -std=gnu++0x"
1351                 fi
1353                 if [ $cc_version -ge 47 ]; then
1354                         # Disable -Wnarrowing which gives many warnings, such as:
1355                         # warning: narrowing conversion of '...' from 'unsigned int' to 'int' inside { } [-Wnarrowing]
1356                         # They are valid according to the C++ standard, but useless.
1357                         cxxflags="$cxxflags -Wno-narrowing"
1358                         # Disable bogus 'attempt to free a non-heap object' warning
1359                         flags="$flags -Wno-free-nonheap-object"
1360                 fi
1362                 if [ "$enable_lto" != "0" ]; then
1363                         # GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
1364                         has_lto=`$1 -dumpspecs | grep '\%{flto'`
1365                         if [ -n "$has_lto" ]; then
1366                                 # Use LTO only if we see LTO exists and is requested
1367                                 if [ $cc_version -lt 46 ]; then
1368                                         flags="$flags -flto"
1369                                 else
1370                                         flags="$flags -flto=jobserver"
1371                                 fi
1372                                 ldflags="$ldflags -fwhole-program"
1373                                 features="$features lto"
1374                         fi
1375                 fi
1377                 has_rdynamic=`$1 -dumpspecs | grep rdynamic`
1378                 if [ -n "$has_rdynamic" ]; then
1379                         # rdynamic is used to get useful stack traces from crash reports.
1380                         flags="$flags -rdynamic"
1381                         ldflags="$ldflags -rdynamic"
1382                 fi
1383         fi
1385         eval "$2=\"$flags\""
1386         eval "$3=\"$cxxflags\""
1387         eval "$4=\"$ldflags\""
1388         eval "$5=\"$features\""
1391 make_cflags_and_ldflags() {
1392         # General CFlags for BUILD
1393         CFLAGS_BUILD="$CFLAGS_BUILD"
1394         # Special CXXFlags for BUILD
1395         CXXFLAGS_BUILD="$CXXFLAGS_BUILD"
1396         # LDFLAGS for BUILD
1397         LDFLAGS_BUILD="$LDFLAGS_BUILD"
1398         # FEATURES for BUILD (lto)
1399         FEATURES_BUILD=""
1400         # General CFlags for HOST
1401         CFLAGS="$CFLAGS"
1402         # Special CXXFlags for HOST
1403         CXXFLAGS="$CXXFLAGS"
1404         # Libs to compile. In fact this is just LDFLAGS
1405         LIBS="-lstdc++"
1406         # LDFLAGS used for HOST
1407         LDFLAGS="$LDFLAGS"
1408         # FEATURES for HOST (lto)
1409         FEATURES=""
1411         make_compiler_cflags "$cc_build" "CFLAGS_BUILD" "CXXFLAGS_BUILD" "LDFLAGS_BUILD" "FEATURES_BUILD"
1412         make_compiler_cflags "$cc_host" "CFLAGS" "CXXFLAGS" "LDFLAGS" "FEATURES"
1414         CFLAGS="$CFLAGS -D$os"
1416         if [ "$enable_debug" = "0" ]; then
1417                 # No debug, add default stuff
1418                 OBJS_SUBDIR="release"
1419                 if [ "$os" = "MORPHOS" ]; then
1420                         CFLAGS="-I/gg/os-include -noixemul -fstrict-aliasing -fexpensive-optimizations -mcpu=604 -fno-inline -mstring -mmultiple $CFLAGS"
1421                         LDFLAGS="$LDFLAGS -noixemul"
1422                 fi
1424                 CFLAGS="-O2 -fomit-frame-pointer $CFLAGS"
1425         else
1426                 OBJS_SUBDIR="debug"
1428                 # Each debug level reduces the optimization by a bit
1429                 if [ $enable_debug -ge 1 ]; then
1430                         CFLAGS="$CFLAGS -g -D_DEBUG"
1431                         if [ "$os" = "PSP" ]; then
1432                                 CFLAGS="$CFLAGS -G0"
1433                         fi
1434                 fi
1435                 if [ $enable_debug -ge 2 ]; then
1436                         CFLAGS="$CFLAGS -fno-inline"
1437                 fi
1438                 if [ $enable_debug -ge 3 ]; then
1439                         CFLAGS="$CFLAGS -O0"
1440                 else
1441                         CFLAGS="$CFLAGS -O2"
1442                 fi
1443         fi
1445         if [ $enable_debug -le 2 ]; then
1446                 if basename "$cc_host" | grep "gcc" &>/dev/null; then
1447                         # Define only when compiling with GCC. Some GLIBC versions use GNU
1448                         # extensions in a way that breaks build with at least ICC.
1449                         # This requires -O1 or more, so debug level 3 (-O0) is excluded.
1450                         CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
1452                         # Just add -O1 to the tools needed for building.
1453                         CFLAGS_BUILD="$CFLAGS_BUILD -D_FORTIFY_SOURCE=2 -O1"
1454                 fi
1455         fi
1457         if [ "$os" = "OSX" ] && [ $cc_version -eq 40 ]; then
1458                 # Apple's GCC 4.0 has a compiler bug for x86_64 with (higher) optimization,
1459                 # wrongly optimizing ^= in loops. This disables the failing optimisation.
1460                 CFLAGS="$CFLAGS -fno-expensive-optimizations"
1461         fi
1463         if [ "$enable_profiling" != "0" ]; then
1464                 CFLAGS="$CFLAGS -p"
1465                 LDFLAGS="$LDFLAGS -pg"
1466         fi
1468         if [ "$with_threads" = "0" ]; then
1469                 CFLAGS="$CFLAGS -DNO_THREADS"
1470         fi
1472         if [ "`echo $1 | cut -c 1-3`" != "icc" ]; then
1473                 if [ "$os" = "CYGWIN" ]; then
1474                         flags="$flags -mwin32"
1475                         LDFLAGS="$LDFLAGS -mwin32"
1476                 fi
1477                 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
1478                         flags="$flags -mno-cygwin"
1480                         if [ "$enable_console" != "0" ]; then
1481                                 LDFLAGS="$LDFLAGS -mno-cygwin -Wl,--subsystem,console"
1482                         else
1483                                 LDFLAGS="$LDFLAGS -mno-cygwin -Wl,--subsystem,windows"
1484                         fi
1486                         LIBS="$LIBS -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32"
1488                         if [ $cc_version -ge 44 ]; then
1489                                 LDFLAGS_BUILD="$LDFLAGS_BUILD -static-libgcc -static-libstdc++"
1490                         fi
1491                 fi
1492         fi
1494         if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "FREEBSD" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
1495                 LIBS="$LIBS -lpthread"
1496         fi
1498         if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ]; then
1499                 LIBS="$LIBS -lc"
1500         fi
1501         if [ "$os" = "WINCE" ]; then
1502                 LIBS="$LIBS -lcoredll -lcorelibc -laygshell -lws2 -e WinMainCRTStartup"
1503         fi
1504         if [ "$os" = "PSP" ]; then
1505                 CFLAGS="$CFLAGS -I`$psp_config -p`/include"
1506                 LDFLAGS="$LDFLAGS -L`$psp_config -p`/lib"
1508                 CFLAGS="$CFLAGS -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150"
1509                 LIBS="$LIBS -D_PSP_FW_VERSION=150 -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -lm"
1510         fi
1512         if [ "$os" = "MORPHOS" ]; then
1513                 # -Wstrict-prototypes generates much noise because of system headers
1514                 CFLAGS="$CFLAGS -Wno-strict-prototypes"
1515         fi
1517         if [ "$os" = "OPENBSD" ]; then
1518                 LIBS="$LIBS -pthread"
1519         fi
1521         if [ "$os" = "FREEBSD" ]; then
1522                 LIBS="$LIBS -lpthread"
1523         fi
1525         if [ "$os" = "OSX" ]; then
1526                 LDFLAGS="$LDFLAGS -framework Cocoa"
1528                 # Add macports include dir which is not always set a default system dir. This avoids zillions of bogus warnings.
1529                 CFLAGS="$CFLAGS -isystem/opt/local/include"
1531                 if [ "$enable_dedicated" = "0" ] && ([ "$cpu_type" = "32" ] || [ "$enable_universal" != "0" ]); then
1532                         LIBS="$LIBS -framework QuickTime"
1533                 else
1534                         CFLAGS="$CFLAGS -DNO_QUICKTIME"
1535                 fi
1537                 if [ "$enable_universal" = "0" ]; then
1538                         # Universal builds set this elsewhere
1539                         CFLAGS="$OSX_SYSROOT $CFLAGS"
1540                         LDFLAGS="$OSX_LD_SYSROOT $LDFLAGS"
1541                 fi
1543                 if [ "$enable_universal" = "0" ] && [ $cc_version -ge 40 ]; then
1544                         # Only set the min version when not doing an universal build.
1545                         # Universal builds set the version elsewhere.
1546                         if [ "$cpu_type" = "64" ]; then
1547                                 CFLAGS="$CFLAGS -mmacosx-version-min=10.5"
1548                         else
1549                                 gcc_cpu=`$cc_host -dumpmachine`
1550                                 if [ "`echo $gcc_cpu | cut -c 1-3`" = "ppc" -o "`echo $gcc_cpu | cut -c 1-7`" = "powerpc" ]; then
1551                                         # PowerPC build can run on 10.3
1552                                         CFLAGS="$CFLAGS -mmacosx-version-min=10.3"
1553                                 else
1554                                         # Intel is only available starting from 10.4
1555                                         CFLAGS="$CFLAGS -mmacosx-version-min=10.4"
1556                                 fi
1557                         fi
1558                 fi
1559         fi
1561         if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ]; then
1562                 LIBS="$LIBS -lmidi -lbe"
1563         fi
1565         # Most targets act like UNIX, just with some additions
1566         if [ "$os" = "BEOS" ] || [ "$os" = "HAIKU" ] || [ "$os" = "OSX" ] || [ "$os" = "MORPHOS" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then
1567                 CFLAGS="$CFLAGS -DUNIX"
1568         fi
1569         # And others like Windows
1570         if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
1571                 CFLAGS="$CFLAGS -DWIN"
1572         fi
1574         if [ -n "$allegro_config" ]; then
1575                 CFLAGS="$CFLAGS -DWITH_ALLEGRO"
1576                 CFLAGS="$CFLAGS `$allegro_config --cflags`"
1577                 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
1578                         if [ "$enable_static" != "0" ]; then
1579                                 LIBS="$LIBS `$allegro_config --static --libs`"
1580                         else
1581                                 LIBS="$LIBS `$allegro_config --libs`"
1582                         fi
1583                 fi
1584         fi
1586         if [ -n "$sdl_config" ]; then
1587                 CFLAGS="$CFLAGS -DWITH_SDL"
1588                 # SDL must not add _GNU_SOURCE as it breaks many platforms
1589                 CFLAGS="$CFLAGS `$sdl_config --cflags | sed 's@-D_GNU_SOURCE[^ ]*@@'`"
1590                 if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "WINCE" ]; then
1591                         if [ "$enable_static" != "0" ]; then
1592                                 LIBS="$LIBS `$sdl_config --static-libs`"
1593                         else
1594                                 LIBS="$LIBS `$sdl_config --libs`"
1595                         fi
1596                 fi
1597         fi
1599         if [ "$with_cocoa" != "0" ]; then
1600                 CFLAGS="$CFLAGS -DWITH_COCOA"
1601                 LIBS="$LIBS -F/System/Library/Frameworks -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox"
1603                 if [ "$enable_cocoa_quartz" != "0" ]; then
1604                         CFLAGS="$CFLAGS -DENABLE_COCOA_QUARTZ"
1605                 fi
1607                 if [ "$enable_cocoa_quickdraw" != "0" ]; then
1608                         CFLAGS="$CFLAGS -DENABLE_COCOA_QUICKDRAW"
1609                 fi
1610         fi
1612         if [ "$with_zlib" != "0" ]; then
1613                 if [ "$enable_static" != "0" ] && [ "$os" != "OSX" ]; then
1614                         LIBS="$LIBS $zlib"
1615                 else
1616                         LIBS="$LIBS -lz"
1617                 fi
1618                 CFLAGS="$CFLAGS -DWITH_ZLIB"
1619         fi
1621         if [ -n "$lzma_config" ]; then
1622                 CFLAGS="$CFLAGS -DWITH_LZMA"
1623                 CFLAGS="$CFLAGS `$lzma_config --cflags | tr '\n\r' '  '`"
1625                 if [ "$enable_static" != "0" ]; then
1626                         CFLAGS="$CFLAGS -DLZMA_API_STATIC"
1627                         LIBS="$LIBS `$lzma_config --libs --static | tr '\n\r' '  '`"
1628                 else
1629                         LIBS="$LIBS `$lzma_config --libs | tr '\n\r' '  '`"
1630                 fi
1631         fi
1633         if [ "$with_lzo2" != "0" ]; then
1634                 if [ "$enable_static" != "0" ] && [ "$os" != "OSX" ]; then
1635                         LIBS="$LIBS $lzo2"
1636                 else
1637                         LIBS="$LIBS -llzo2"
1638                 fi
1639                 CFLAGS="$CFLAGS -DWITH_LZO"
1640         fi
1642         # 64bit machines need -D_SQ64
1643         if [ "$cpu_type" = "64" ] && [ "$enable_universal" = "0" ]; then
1644                 CFLAGS="$CFLAGS -D_SQ64"
1645         fi
1646         CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR"
1648         if [ -n "$png_config" ]; then
1649                 CFLAGS="$CFLAGS -DWITH_PNG"
1650                 CFLAGS="$CFLAGS `$png_config --cppflags --I_opts | tr '\n\r' '  '`"
1652                 # The extra flags are unneeded for latest libpng-config, but some versions are so broken...
1653                 if [ "$enable_static" != "0" ]; then
1654                         if [ "$os" = "OSX" ]; then
1655                                 LIBS="$LIBS `$png_config --prefix`/lib/libpng.a"
1656                         else
1657                                 LIBS="$LIBS `$png_config --static --ldflags | tr '\n\r' '  '`"
1658                         fi
1659                 else
1660                         LIBS="$LIBS `$png_config --ldflags | tr '\n\r' '  '`"
1661                 fi
1662         fi
1664         if [ -n "$fontconfig_config" ]; then
1665                 CFLAGS="$CFLAGS -DWITH_FONTCONFIG"
1666                 CFLAGS="$CFLAGS `$fontconfig_config --cflags | tr '\n\r' '  '`"
1668                 if [ "$enable_static" != "0" ]; then
1669                         if [ "$os" = "OSX" ]; then
1670                                 # fontconfig_config goes via pkg-config on all systems, which doesn't know --prefix
1671                                 # Also, despite the reason we link to the .a file ourself (because we can't use -static), we do need to ask pkg-config about possible other deps
1672                                 LIBS="$LIBS `$fontconfig_config --variable=prefix`/lib/libfontconfig.a `$fontconfig_config --libs --static | sed s@-lfontconfig@@`"
1673                         else
1674                                 LIBS="$LIBS `$fontconfig_config --libs --static | tr '\n\r' '  '`"
1675                         fi
1676                 else
1677                         LIBS="$LIBS `$fontconfig_config --libs | tr '\n\r' '  '`"
1678                 fi
1679         fi
1681         if [ -n "$freetype_config" ]; then
1682                 CFLAGS="$CFLAGS -DWITH_FREETYPE"
1683                 CFLAGS="$CFLAGS `$freetype_config --cflags | tr '\n\r' '  '`"
1685                 if [ "$enable_static" != "0" ]; then
1686                         if [ "$os" = "OSX" ]; then
1687                                 LIBS="$LIBS `$freetype_config --prefix`/lib/libfreetype.a"
1688                         else
1689                                 # Is it possible to do static with freetype, if so: how?
1690                                 LIBS="$LIBS `$freetype_config --libs | tr '\n\r' '  '`"
1691                         fi
1692                 else
1693                         LIBS="$LIBS `$freetype_config --libs | tr '\n\r' '  '`"
1694                 fi
1695         fi
1697         if [ -n "$icu_config" ]; then
1698                 CFLAGS="$CFLAGS -DWITH_ICU"
1699                 CFLAGS="$CFLAGS `$icu_config --cppflags | tr '\n\r' '  '`"
1701                 # Some icu-configs have the 'feature' of not adding a space where others do add the space
1702                 if [ "$static_icu" != "0" ]; then
1703                         LIBS="$LIBS `$icu_config --ldflags-searchpath` `$icu_config --ldflags-libsonly | tr '\n\r' '  ' | sed s/licu/lsicu/g`"
1704                 else
1705                         LIBS="$LIBS `$icu_config --ldflags-searchpath` `$icu_config --ldflags-libsonly | tr '\n\r' '  '`"
1706                 fi
1707         fi
1710         if [ "$with_direct_music" != "0" ]; then
1711                 CFLAGS="$CFLAGS -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT"
1712                 # GCC 4.0+ doesn't like the DirectX includes (gives tons of
1713                 #  warnings on it we won't be able to fix). For now just
1714                 #  suppress those warnings.
1715                 if [ $cc_version -ge 40 ]; then
1716                         CFLAGS="$CFLAGS -Wno-non-virtual-dtor"
1717                 fi
1718         fi
1720         if [ -n "$libtimidity" ]; then
1721                 if [ "$enable_static" != "0" ]; then
1722                         LIBS="$LIBS $libtimidity"
1723                 else
1724                         LIBS="$LIBS -ltimidity"
1725                 fi
1726                 CFLAGS="$CFLAGS -DLIBTIMIDITY"
1727         fi
1729         if [ "$with_iconv" != "0" ]; then
1730                 CFLAGS="$CFLAGS -DWITH_ICONV"
1731                 if [ "$link_to_iconv" = "yes" ]; then
1732                         LIBS="$LIBS -liconv"
1733                         if [ "$with_iconv" != "2" ]; then
1734                                 CFLAGS="$CFLAGS -I$with_iconv/include"
1735                                 LIBS="$LIBS -L$with_iconv/lib"
1736                         fi
1737                 fi
1739                 if [ "$have_non_const_iconv" != "no" ]; then
1740                         CFLAGS="$CFLAGS -DHAVE_NON_CONST_ICONV"
1741                 fi
1742         fi
1744         if [ -n "$with_midi" ]; then
1745                 CFLAGS="$CFLAGS -DEXTERNAL_PLAYER=\\\\\"$with_midi\\\\\""
1746         fi
1747         if [ -n "$with_midi_arg" ]; then
1748                 CFLAGS="$CFLAGS -DMIDI_ARG=\\\\\"$with_midi_arg\\\\\""
1749         fi
1751         if [ "$enable_dedicated" != "0" ]; then
1752                 CFLAGS="$CFLAGS -DDEDICATED"
1753         fi
1755         if [ "$enable_unicode" != "0" ]; then
1756                 CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"
1757         fi
1759         if [ "$enable_network" != "0" ]; then
1760                 CFLAGS="$CFLAGS -DENABLE_NETWORK"
1762                 if [ "$os" = "BEOS" ]; then
1763                         LDFLAGS="$LDFLAGS -lbind -lsocket"
1764                 fi
1766                 if [ "$os" = "HAIKU" ]; then
1767                         LDFLAGS="$LDFLAGS -lnetwork"
1768                 fi
1770                 if [ "$os" = "SUNOS" ]; then
1771                         LDFLAGS="$LDFLAGS -lnsl -lsocket"
1772                 fi
1773         fi
1775         if [ "$enable_static" != "0" ]; then
1776                 # OSX can't handle -static in LDFLAGS
1777                 if [ "$os" != "OSX" ]; then
1778                         LDFLAGS="$LDFLAGS -static"
1779                 fi
1780         fi
1782         if [ "$enable_assert" = "0" ]; then
1783                 CFLAGS="$CFLAGS -DNDEBUG"
1784                 CFLAGS_BUILD="$CFLAGS_BUILD -DNDEBUG"
1785         fi
1787         if [ "$enable_desync_debug" != "0" ]; then
1788                 CFLAGS="$CFLAGS -DRANDOM_DEBUG"
1789         fi
1791         if [ "$enable_osx_g5" != "0" ]; then
1792                 CFLAGS="$CFLAGS -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
1793         fi
1795         if [ -n "$personal_dir" ]; then
1796                 CFLAGS="$CFLAGS -DWITH_PERSONAL_DIR -DPERSONAL_DIR=\\\\\"$personal_dir\\\\\""
1797         fi
1799         if [ -n "$shared_dir" ]; then
1800                 CFLAGS="$CFLAGS -DWITH_SHARED_DIR -DSHARED_DIR=\\\\\"$shared_dir\\\\\""
1801         fi
1803         CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\""
1805         if [ "$enable_lto" != "0" ]; then
1806                 lto_build=`echo "$FEATURES_BUILD" | grep "lto"`
1807                 lto_host=`echo "$FEATURES" | grep "lto"`
1808                 if [ -z "$lto_build$lto_host" ]; then
1809                         log 1 "WARNING: you enabled LTO/IPO, but neither build nor host compiler supports it"
1810                         log 1 "WARNING: LTO/IPO has been disabled"
1811                 fi
1812                 if [ -n "$lto_build" ]; then
1813                         LDFLAGS_BUILD="$LDFLAGS_BUILD $CFLAGS_BUILD $CXXFLAGS_BUILD"
1814                 fi
1815                 if [ -n "$lto_host" ]; then
1816                         LDFLAGS="$LDFLAGS $CFLAGS $CXXFLAGS"
1817                 fi
1818         fi
1820         log 1 "using CFLAGS_BUILD... $CFLAGS_BUILD"
1821         log 1 "using CXXFLAGS_BUILD... $CXXFLAGS_BUILD"
1822         log 1 "using LDFLAGS_BUILD... $LDFLAGS_BUILD"
1823         log 1 "using CFLAGS... $CFLAGS"
1824         log 1 "using CXXFLAGS... $CXXFLAGS"
1825         log 1 "using LDFLAGS... $LIBS $LDFLAGS"
1827         # Makedepend doesn't like something like: -isysroot /OSX/blabla
1828         #  so convert it to: -isysroot -OSX/blabla. makedepend just ignores
1829         #  any - command it doesn't know, so we are pretty save.
1830         # Lovely hackish, not?
1831         # Btw, this almost always comes from outside the configure, so it is
1832         #  not something we can control.
1833         # Also make makedepend aware of compiler's built-in defines.
1834         if [ "$with_makedepend" != "0" ] || [ "$enable_builtin_depend" != "0" ]; then
1835                 # Append CXXFLAGS possibly containing -std=c++0x
1836                 cflags_makedep="`echo | $cxx_host $CXXFLAGS -E -x c++ -dM - | sed 's@.define @-D@g;s@ .*@ @g;s@(.*)@@g' | tr -d '\r\n'`"
1838                 # Please escape ALL " within ` because e.g. "" terminates the string in some sh implementations
1839                 cflags_makedep="$cflags_makedep `echo \"$CFLAGS\" \"$CXXFLAGS\" | sed 's@ /@ -@g;s@-I[ ]*[^ ]*@@g'`"
1840         else
1841                 makedepend=""
1842         fi
1844         if [ "$with_distcc" != "0" ]; then
1845                 cc_host="$distcc $cc_host"
1846                 cxx_host="$distcc $cxx_host"
1847                 log 1 ""
1848                 log 1 " NOTICE: remind yourself to use 'make -jN' to make use of distcc"
1849                 log 1 ""
1850         fi
1852         if [ "$with_ccache" != "0" ]; then
1853                 cc_host="$ccache $cc_host"
1854                 cxx_host="$ccache $cxx_host"
1855         fi
1858 check_compiler() {
1859         # Params:
1860         # $1 - Type for message (build / host)
1861         # $2 - What to fill with the found compiler
1862         # $3 - System to try
1863         # $4 - Compiler to try
1864         # $5 - Env-setting to try
1865         # $6 - GCC alike to try
1866         # $7 - CC alike to try
1867         # $8 - "0" gcc, "1" g++, "2" windres, "3" strip, "4" lipo
1868         # $9 - What the command is to check for
1870         if [ -n "$3" ]; then
1871                 # Check for system
1872                 if [ -z "$6" ]; then
1873                         compiler="$3"
1874                 else
1875                         compiler="$3-$6"
1876                 fi
1877                 machine=`eval $compiler $9 2>/dev/null`
1878                 ret=$?
1879                 eval "$2=\"$compiler\""
1881                 log 2 "executing $compiler $9"
1882                 log 2 "  returned $machine"
1883                 log 2 "  exit code $ret"
1885                 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1886                         log 1 "checking $1... $compiler not found"
1887                         log 1 "I couldn't detect any $6 binary for $3"
1888                         exit 1
1889                 fi
1891                 if [ "$machine" != "$3" ] && ( [ "$8" = "0" ] || [ "$8" = "1" ] ); then
1892                         log 1 "checking $1... expected $3, found $machine"
1893                         log 1 "the compiler suggests it doesn't build code for the machine you specified"
1894                         exit 1
1895                 fi
1896         elif [ -n "$4" ]; then
1897                 # Check for manual compiler
1898                 machine=`$4 $9 2>/dev/null`
1899                 ret=$?
1900                 eval "$2=\"$4\""
1902                 log 2 "executing $4 $9"
1903                 log 2 "  returned $machine"
1904                 log 2 "  exit code $ret"
1906                 if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1907                         log 1 "checking $1... $4 not found"
1908                         log 1 "the selected binary doesn't seem to be a $6 binary"
1909                         exit 1
1910                 fi
1911         else
1912                 # Nothing given, autodetect
1914                 if [ -n "$5" ]; then
1915                         machine=`$5 $9 2>/dev/null`
1916                         ret=$?
1917                         eval "$2=\"$5\""
1919                         log 2 "executing $5 $9"
1920                         log 2 "  returned $machine"
1921                         log 2 "  exit code $ret"
1923                         # The user defined a GCC that doesn't reply to $9.. abort
1924                         if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1925                                 log 1 "checking $1... $5 unusable"
1926                                 log 1 "the CC environment variable is set, but it doesn't seem to be a $6 binary"
1927                                 log 1 "please redefine the CC/CXX environment to a $6 binary"
1928                                 exit 1
1929                         fi
1930                 else
1931                         log 2 "checking $1... CC/CXX not set (skipping)"
1933                         # No $5, so try '$6'
1934                         machine=`$6 $9 2>/dev/null`
1935                         ret=$?
1936                         eval "$2=\"$6\""
1938                         log 2 "executing $6 $9"
1939                         log 2 "  returned $machine"
1940                         log 2 "  exit code $ret"
1942                         if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
1943                                 # Maybe '$7'?
1944                                 machine=`$7 $9 2>/dev/null`
1945                                 ret=$?
1946                                 eval "$2=\"$7\""
1948                                 log 2 "executing $7 $9"
1949                                 log 2 "  returned $machine"
1950                                 log 2 "  exit code $ret"
1952                                 # All failed, abort
1953                                 if [ -z "$machine" ]; then
1954                                         log 1 "checking $1... $6 not found"
1955                                         log 1 "I couldn't detect any $6 binary on your system"
1956                                         log 1 "please define the CC/CXX environment to where it is located"
1958                                         exit 1
1959                                 fi
1960                         fi
1961                 fi
1962         fi
1964         if [ "$8" != "0" ]; then
1965                 eval "res=\$$2"
1966                 log 1 "checking $1... $res"
1967         else
1968                 log 1 "checking $1... $machine"
1969         fi
1972 check_build() {
1973         if [ "$os" = "FREEBSD" ]; then
1974                 # FreeBSD's C compiler does not support dump machine.
1975                 # However, removing C support is not possible because PSP must be linked with the C compiler.
1976                 check_compiler "build system type" "cc_build" "$build" "$cc_build" "$CXX" "g++" "c++" "0" "-dumpmachine"
1977         else
1978                 check_compiler "build system type" "cc_build" "$build" "$cc_build" "$CC" "gcc" "cc" "0" "-dumpmachine"
1979         fi
1982 check_host() {
1983         # By default the host is the build
1984         if [ -z "$host" ]; then host="$build"; fi
1986         if [ "$os" = "FREEBSD" ]; then
1987                 # FreeBSD's C compiler does not support dump machine.
1988                 # However, removing C support is not possible because PSP must be linked with the C compiler.
1989                 check_compiler "host system type" "cc_host" "$host" "$cc_host" "$CXX" "g++" "c++" "0" "-dumpmachine"
1990         else
1991                 check_compiler "host system type" "cc_host" "$host" "$cc_host" "$CC" "gcc" "cc" "0" "-dumpmachine"
1992         fi
1995 check_cxx_build() {
1996         check_compiler "build c++" "cxx_build" "$build" "$cxx_build" "$CXX" "g++" "c++" 1 "-dumpmachine"
1999 check_cxx_host() {
2000         # By default the host is the build
2001         if [ -z "$host" ]; then host="$build"; fi
2002         check_compiler "host c++" "cxx_host" "$host" "$cxx_host" "$CXX" "g++" "c++" 1 "-dumpmachine"
2005 check_windres() {
2006         if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
2007                 check_compiler "host windres" "windres" "$host" "$windres" "$WINDRES" "windres" "windres" "2" "-V"
2008         fi
2011 check_strip() {
2012         if [ "$os" = "OS2" ]; then
2013                 # OS2 via gcc is a bit weird.. stripping HAS to be done via emxbind, which is via gcc directly
2014                 log 1 "checking host strip... using gcc -s option"
2015         elif [ "$os" = "OSX" ]; then
2016                 # Most targets have -V in strip, to see if they exists... OSX doesn't.. so execute something
2017                 echo "int main(int argc, char *argv[]) { }" > strip.test.c
2018                 $cxx_host strip.test.c -o strip.test
2019                 check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "strip.test"
2020                 rm -f strip.test.c strip.test
2021         else
2022                 check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "-V"
2023         fi
2026 check_lipo() {
2027         if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ]; then
2028                 echo "int main(int argc, char *argv[]) { }" > lipo.test.c
2029                 $cxx_host lipo.test.c -o lipo.test
2030                 check_compiler "host lipo" "lipo" "$host" "$lipo" "$LIPO" "lipo" "lipo" "4" "-info lipo.test"
2031                 rm -f lipo.test.c lipo.test
2032         fi
2035 check_osx_sdk() {
2036         local sysroot=""
2037         if [ -n "$1" ]; then
2038                 if echo "$1" | grep -q / ; then
2039                         # Seems to be a file system path
2040                         osx_sdk_path="$1"
2041                 else
2042                         osx_sdk_path="/Developer/SDKs/MacOSX$1.sdk"
2043                 fi
2044                 if [ ! -d "$osx_sdk_path" ]; then
2045                         # No directory, not present or garbage
2046                         return 1
2047                 fi
2049                 # Set minimum version to 10.4 as that's when kCGBitmapByteOrder32Host was introduced
2050                 sysroot="-isysroot $osx_sdk_path -Wl,-syslibroot,$osx_sdk_path -mmacosx-version-min=10.4"
2051         fi
2053 cat > tmp.osx.mm << EOF
2054 #include <Cocoa/Cocoa.h>
2055 int main() {
2056         kCGBitmapByteOrder32Host;
2057         return 0;
2060         execute="$cxx_host $sysroot $CFLAGS tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1"
2061         eval $execute > /dev/null
2062         ret=$?
2063         log 2 "executing $execute"
2064         log 2 "  exit code $ret"
2065         rm -f tmp.osx.mm tmp.osx
2066         return $ret
2069 check_direct_music() {
2070         echo "
2071                 #include <windows.h>
2072                 #include <dmksctrl.h>
2073                 #include <dmusici.h>
2074                 #include <dmusicc.h>
2075                 #include <dmusicf.h>
2076                 int main(int argc, char *argv[]) { }" > direct_music.test.c
2077         $cxx_host $CFLAGS direct_music.test.c -o direct_music.test 2> /dev/null
2078         res=$?
2079         rm -f direct_music.test.c direct_music.test
2081         if [ "$res" != "0" ]; then
2082                 if [ "$with_direct_music" != "1" ]; then
2083                         log 1 "configure: error: direct-music is not available on this system"
2084                         exit 1
2085                 fi
2086                 with_direct_music="0"
2088                 log 1 "checking direct-music... not found"
2089         else
2090                 log 1 "checking direct-music... found"
2091         fi
2094 check_makedepend() {
2095         if [ "$enable_builtin_depend" != "0" ]; then
2096                 with_makedepend="0"
2097         fi
2099         if [ "$with_makedepend" = "0" ]; then
2100                 log 1 "checking makedepend... disabled"
2101                 return
2102         fi
2104         if [ "$with_makedepend" = "1" ] || [ "$with_makedepend" = "2" ]; then
2105                 makedepend="makedepend"
2106         else
2107                 makedepend="$with_makedepend"
2108         fi
2110         rm -f makedepend.tmp
2111         touch makedepend.tmp
2112         res=`$makedepend -fmakedepend.tmp 2>/dev/null`
2113         res=$?
2114         log 2 "executing $makedepend -f makedepend.tmp"
2115         log 2 "  returned `cat makedepend.tmp`"
2116         log 2 "  exit code $ret"
2118         if [ ! -s makedepend.tmp ]; then
2119                 rm -f makedepend.tmp makedepend.tmp.bak
2121                 if [ "$with_makedepend" = "2" ]; then
2122                         log 1 "checking makedepend... not found"
2124                         log 1 "I couldn't detect any makedepend on your system"
2125                         log 1 "please locate it via --makedepend=[binary]"
2127                         exit 1
2128                 elif [ "$with_makedepend" != "1" ]; then
2129                         log 1 "checking makedepend... $makedepend not found"
2131                         log 1 "the selected file doesn't seem to be a valid makedepend binary"
2133                         exit 1
2134                 else
2135                         log 1 "checking makedepend... not found"
2137                         with_makedepend="0"
2138                         return
2139                 fi
2140         fi
2142         rm -f makedepend.tmp makedepend.tmp.bak
2144         log 1 "checking makedepend... $makedepend"
2147 detect_awk() {
2148         # Not all awks allow gsub(), so we test for that here! It is in fact all we need...
2150         # These awks are known to work. Test for them explicit
2151         awks="gawk mawk nawk"
2153         awk_prefix="echo \"a.c b.c c.c\" | tr ' ' \\\\n | "
2154         awk_param="' { ORS = \" \" } /\.c$/   { gsub(\".c$\",   \".o\", \$0); print \$0; }' 2>/dev/null"
2155         awk_result="a.o b.o c.o "
2156         log 2 "Detecing awk..."
2158         log 2 "Trying: $awk_prefix $awk $awk_param"
2159         res=`eval $awk_prefix $awk $awk_param`
2160         log 2 "Result: '$res'"
2161         if [ "$res" != "$awk_result" ] && [ "$awk" = "awk" ]; then
2162                 # User didn't supply his own awk, so try to detect some other known working names for an awk
2163                 for awk in $awks; do
2164                         log 2 "Trying: $awk_prefix $awk $awk_param"
2165                         res=`eval $awk_prefix $awk $awk_param`
2166                         log 2 "Result: '$res'"
2167                         if [ "$res" = "$awk_result" ]; then break; fi
2168                 done
2170                 if [ "$res" != "$awk_result" ]; then
2171                         log 1 "checking awk... not found"
2172                         log 1 "configure: error: no awk found"
2173                         log 1 "configure: error: please install one of the following: $awks"
2174                         exit 1
2175                 fi
2176         fi
2177         if [ "$res" != "$awk_result" ]; then
2178                 log 1 "checking awk... not found"
2179                 log 1 "configure: error: you supplied '$awk' but it doesn't seem a valid gawk or mawk"
2180                 exit 1
2181         fi
2183         log 1 "checking awk... $awk"
2186 detect_os() {
2187         if [ "$os" = "DETECT" ]; then
2188                 # Detect UNIX, OSX, FREEBSD, OPENBSD, NETBSD, HPUX, MORPHOS, BEOS, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP
2190                 # Try first via dumpmachine, then via uname
2191                 os=`echo "$host" | tr '[A-Z]' '[a-z]' | $awk '
2192                                         /linux/        { print "UNIX";    exit}
2193                                         /darwin/       { print "OSX";     exit}
2194                                         /freebsd/      { print "FREEBSD"; exit}
2195                                         /openbsd/      { print "OPENBSD"; exit}
2196                                         /netbsd/       { print "NETBSD";  exit}
2197                                         /hp-ux/        { print "HPUX";    exit}
2198                                         /morphos/      { print "MORPHOS"; exit}
2199                                         /beos/         { print "BEOS";    exit}
2200                                         /haiku/        { print "HAIKU";   exit}
2201                                         /sunos/        { print "SUNOS";   exit}
2202                                         /solaris/      { print "SUNOS";   exit}
2203                                         /cygwin/       { print "CYGWIN";  exit}
2204                                         /mingw/        { print "MINGW";   exit}
2205                                         /os2/          { print "OS2";     exit}
2206                                         /dos/          { print "DOS";     exit}
2207                                         /wince/        { print "WINCE";   exit}
2208                                         /psp/          { print "PSP";     exit}
2209                 '`
2211                 if [ -z "$os" ]; then
2212                         os=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | $awk '
2213                                         /linux/        { print "UNIX";    exit}
2214                                         /darwin/       { print "OSX";     exit}
2215                                         /freebsd/      { print "FREEBSD"; exit}
2216                                         /openbsd/      { print "OPENBSD"; exit}
2217                                         /netbsd/       { print "NETBSD";  exit}
2218                                         /hp-ux/        { print "HPUX";    exit}
2219                                         /morphos/      { print "MORPHOS"; exit}
2220                                         /beos/         { print "BEOS";    exit}
2221                                         /haiku/        { print "HAIKU";   exit}
2222                                         /sunos/        { print "SUNOS";   exit}
2223                                         /cygwin/       { print "CYGWIN";  exit}
2224                                         /mingw/        { print "MINGW";   exit}
2225                                         /os\/2/        { print "OS2";     exit}
2226                                         /gnu/          { print "UNIX";    exit}
2227                         '`
2228                 fi
2230                 if [ -z "$os" ]; then
2231                         log 1 "detecting OS... none detected"
2232                         log 1 "I couldn't detect your OS. Please use --os=OS to force one"
2233                         log 1 "Allowed values are: UNIX, OSX, FREEBSD, OPENBSD, NETBSD, MORPHOS, HPUX, BEOS, HAIKU, SUNOS, CYGWIN, MINGW, OS2, DOS, WINCE, and PSP"
2234                         exit 1
2235                 fi
2237                 log 1 "detecting OS... $os"
2238         else
2239                 log 1 "forcing OS... $os"
2240         fi
2243 detect_allegro() {
2244         # 0 means no, 1 is auto-detect, 2 is force
2245         if [ "$with_allegro" = "0" ]; then
2246                 log 1 "checking Allegro... disabled"
2248                 allegro_config=""
2249                 return 0
2250         fi
2252         if [ "$with_allegro" = "2" ] && [ "$with_cocoa" = "2" ]; then
2253                 log 1 "configure: error: it is impossible to compile both Allegro and COCOA"
2254                 log 1 "configure: error: please deselect one of them and try again"
2255                 exit 1
2256         fi
2258         if [ "$with_allegro" = "2" ] && [ "$enable_dedicated" != "0" ]; then
2259                 log 1 "configure: error: it is impossible to compile a dedicated with Allegro"
2260                 log 1 "configure: error: please deselect one of them and try again"
2261                 exit 1
2262         fi
2264         if [ "$enable_dedicated" != "0" ]; then
2265                 log 1 "checking Allegro... dedicated server, skipping"
2267                 allegro_config=""
2268                 return 0
2269         fi
2271         # By default on OSX we don't use SDL. The rest is auto-detect
2272         if [ "$with_allegro" = "1" ] && [ "$os" = "OSX" ] && [ "$with_cocoa" != "0" ]; then
2273                 log 1 "checking Allegro... OSX, skipping"
2275                 allegro_config=""
2276                 return 0
2277         fi
2279         if [ "$with_allegro" = "1" ] || [ "$with_allegro" = "" ] || [ "$with_allegro" = "2" ]; then
2280                 allegro_config="allegro-config"
2281         else
2282                 allegro_config="$with_allegro"
2283         fi
2285         version=`$allegro_config --version 2>/dev/null`
2286         ret=$?
2287         log 2 "executing $allegro_config --version"
2288         log 2 "  returned $version"
2289         log 2 "  exit code $ret"
2291         if [ -z "$version" ] || [ "$ret" != "0" ]; then
2292                 log 1 "checking Allegro... not found"
2294                 # It was forced, so it should be found.
2295                 if [ "$with_allegro" != "1" ]; then
2296                         log 1 "configure: error: allegro-config couldn't be found"
2297                         log 1 "configure: error: you supplied '$with_allegro', but it seems invalid"
2298                         exit 1
2299                 fi
2301                 allegro_config=""
2302                 return 0
2303         fi
2305         log 1 "checking Allegro... found"
2309 detect_sdl() {
2310         # 0 means no, 1 is auto-detect, 2 is force
2311         if [ "$with_sdl" = "0" ]; then
2312                 log 1 "checking SDL... disabled"
2314                 sdl_config=""
2315                 return 0
2316         fi
2318         if [ "$with_sdl" = "2" ] && [ "$with_cocoa" = "2" ]; then
2319                 log 1 "configure: error: it is impossible to compile both SDL and COCOA"
2320                 log 1 "configure: error: please deselect one of them and try again"
2321                 exit 1
2322         fi
2324         if [ "$with_sdl" = "2" ] && [ "$enable_dedicated" != "0" ]; then
2325                 log 1 "configure: error: it is impossible to compile a dedicated with SDL"
2326                 log 1 "configure: error: please deselect one of them and try again"
2327                 exit 1
2328         fi
2330         if [ "$enable_dedicated" != "0" ]; then
2331                 log 1 "checking SDL... dedicated server, skipping"
2333                 sdl_config=""
2334                 return 0
2335         fi
2337         # By default on OSX we don't use SDL. The rest is auto-detect
2338         if [ "$with_sdl" = "1" ] && [ "$os" = "OSX" ] && [ "$with_cocoa" != "0" ]; then
2339                 log 1 "checking SDL... OSX, skipping"
2341                 sdl_config=""
2342                 return 0
2343         fi
2345         if [ "$os" = "OSX" ]; then
2346                 log 1 "WARNING: sdl is known to fail on some versions of Mac OS X"
2347                 log 1 "WARNING: with some hardware configurations. Use at own risk!"
2348                 sleep 5
2349         fi
2351         if [ "$with_sdl" = "1" ] || [ "$with_sdl" = "" ] || [ "$with_sdl" = "2" ]; then
2352                 sdl_config="sdl-config"
2353         else
2354                 sdl_config="$with_sdl"
2355         fi
2357         version=`$sdl_config --version 2>/dev/null`
2358         ret=$?
2359         log 2 "executing $sdl_config --version"
2360         log 2 "  returned $version"
2361         log 2 "  exit code $ret"
2363         if [ -z "$version" ] || [ "$ret" != "0" ]; then
2364                 log 1 "checking SDL... not found"
2366                 # It was forced, so it should be found.
2367                 if [ "$with_sdl" != "1" ]; then
2368                         log 1 "configure: error: sdl-config couldn't be found"
2369                         log 1 "configure: error: you supplied '$with_sdl', but it seems invalid"
2370                         exit 1
2371                 fi
2373                 sdl_config=""
2374                 return 0
2375         fi
2377         log 1 "checking SDL... found"
2380 detect_osx_sdk() {
2381         # Try to find the best SDK available. For a normal build this
2382         # is currently the 10.5 SDK as this is needed to compile all
2383         # optional code. Because such an executable won't run on 10.4
2384         # or lower, also check for the 10.4u SDK when doing an universal
2385         # build.
2387         # Check for the 10.5 SDK, but try 10.6 if that fails
2388         check_osx_sdk "10.5" || check_osx_sdk "10.6" || osx_sdk_path=""
2390         if [ -z "$osx_sdk_path" ] || [ "$enable_universal" != "0" ]; then
2391                 # No better SDK or universal build enabled? Check 10.4u SDK as well
2392                 local old_sdk="$osx_sdk_path"
2393                 if check_osx_sdk "10.4u"; then
2394                         osx_sdk_104_path="$osx_sdk_path"
2395                 else
2396                         osx_sdk_104_path=""
2397                 fi
2398                 if [ -z "$old_sdk" ]; then
2399                         osx_sdk_path="$osx_sdk_104_path"
2400                 else
2401                         osx_sdk_path="$old_sdk"
2402                 fi
2403         fi
2405         if [ -z "$osx_sdk_path" ]; then
2406                 log 1 "Your system SDK is probably too old"
2407                 log 1 "Please install/upgrade your Xcode to >= 2.5"
2409                 exit 1
2410         fi
2413 detect_cocoa() {
2414         # 0 means no, 1 is auto-detect, 2 is force
2415         if [ "$with_cocoa" = "0" ]; then
2416                 log 1 "checking COCOA... disabled"
2418                 return 0
2419         fi
2421         if [ "$with_cocoa" = "2" ] && [ "$enable_dedicated" != "0" ]; then
2422                 log 1 "configure: error: it is impossible to compile a dedicated with COCOA"
2423                 log 1 "configure: error: please deselect one of them and try again"
2424                 exit 1
2425         fi
2427         if [ "$enable_dedicated" != "0" ]; then
2428                 log 1 "checking COCOA... dedicated server, skipping"
2430                 with_cocoa="0"
2431                 return 0
2432         fi
2434         # By default on OSX we use COCOA. The rest doesn't support it
2435         if [ "$with_cocoa" = "1" ] && [ "$os" != "OSX" ]; then
2436                 log 1 "checking COCOA... not OSX, skipping"
2438                 with_cocoa="0"
2439                 return 0
2440         fi
2442         if [ "$os" != "OSX" ]; then
2443                 log 1 "checking COCOA... not OSX"
2445                 log 1 "configure: error: COCOA video driver is only supported for OSX"
2446                 exit 1
2447         fi
2449         log 1 "checking COCOA... found"
2452         if [ "$enable_cocoa_quartz" != "0" ]; then
2453                 log 1 "checking whether to enable the Quartz window subdriver... yes"
2454         else
2455                 log 1 "checking whether to enable the Quartz window subdriver... no"
2456         fi
2458         detect_quickdraw
2461 detect_quickdraw() {
2462         # 0 means no, 1 is auto-detect, 2 is force
2463         if [ "$enable_cocoa_quickdraw" = "0" ]; then
2464                 log 1 "checking Quickdraw window subdriver... disabled"
2465                 return 0
2466         fi
2468         # Assume QuickDraw is available when doing an universal build
2469         if [ "$enable_universal" != "0" ]; then
2470                 log 1 "checking Quickdraw window subdriver... found"
2471                 return 0
2472         fi
2474         # 64 bits doesn't have quickdraw
2475         if [ "$cpu_type" = "64" ]; then
2476                 enable_cocoa_quickdraw="0"
2477                 log 1 "checking Quickdraw window subdriver... disabled (64 bits)"
2478                 return 0
2479         fi
2481 cat > tmp.osx.mm << EOF
2482 #include <AvailabilityMacros.h>
2483 #import <Cocoa/Cocoa.h>
2484 int main(int argc, char *argv[]) { SetEmptyRgn(NULL); return 0; }
2486         execute="$cxx_host $OSX_SYSROOT $OSX_LD_SYSROOT $CFLAGS -mmacosx-version-min=10.3 tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1"
2487         eval $execute > /dev/null
2488         ret=$?
2489         log 2 "executing $execute"
2490         log 2 "  exit code $ret"
2491         rm -f tmp.osx.mm tmp.osx
2492         if [ "$ret" != "0" ]; then
2493                 log 1 "checking Quickdraw window subdriver... not found"
2495                 # It was forced, so it should be found.
2496                 if [ "$enable_cocoa_quickdraw" != "1" ]; then
2497                         log 1 "configure: error: Quickdraw window driver could not be found"
2498                         exit 1
2499                 fi
2501                 enable_cocoa_quickdraw=0
2502                 return 0
2503         fi
2505         enable_cocoa_quickdraw=1
2506         log 1 "checking Quickdraw window subdriver... found"
2509 detect_library() {
2510         # $1 - config-param ($with_zlib value)
2511         # $2 - library name ('zlib', sets $zlib)
2512         # $3 - static library name (libz.a)
2513         # $4 - header directory ()
2514         # $5 - header name (zlib.h)
2515         # $6 - force static (if non-empty)
2517         if [ -n "$6" ]; then force_static="1"; fi
2519         # 0 means no, 1 is auto-detect, 2 is force
2520         if [ "$1" = "0" ]; then
2521                 log 1 "checking $2... disabled"
2523                 eval "$2=\"\""
2524                 return 0
2525         fi
2527         log 2 "detecting $2"
2529         if [ "$1" = "1" ] || [ "$1" = "" ] || [ "$1" = "2" ]; then
2530                 eval "$2=`ls -1 /usr/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2531                 eval "res=\$$2"
2532                 if [ -z "$res" ]; then
2533                         log 2 "  trying /usr/include/$4$5... no"
2534                         eval "$2=`ls -1 /usr/local/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2535                 fi
2536                 eval "res=\$$2"
2537                 if [ -z "$res" ]; then
2538                         log 2 "  trying /usr/local/include/$4$5... no"
2539                         eval "$2=`ls -1 /mingw/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2540                 fi
2541                 eval "res=\$$2"
2542                 if [ -z "$res" ]; then
2543                         log 2 "  trying /mingw/include/$4$5... no"
2544                         eval "$2=`ls -1 /opt/local/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2545                 fi
2546                 eval "res=\$$2"
2547                 if [ -z "$res" ]; then
2548                         log 2 "  trying /opt/local/include/$4$5... no"
2549                 fi
2550                 if [ -z "$res" ] && [ "$os" = "NETBSD" ]; then
2551                         eval "$2=`ls -1 /usr/pkg/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2552                         eval "res=\$$2"
2553                         if [ -z "$res" ]; then
2554                                 log 2 "  trying /usr/pkg/include/$4$5... no"
2555                         fi
2556                 fi
2557                 if [ -z "$res" ] && [ "$os" = "HAIKU" ]; then
2558                         eval "$2=`ls -1 /boot/common/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2559                         eval "res=\$$2"
2560                         if [ -z "$res" ]; then
2561                                 log 2 "  trying /boot/common/include/$4$5... no"
2562                         fi
2563                 fi
2565                 eval "res=\$$2"
2566                 if [ -n "$res" ] && ( [ -n "$force_static" ] || ( [ "$enable_static" != "0" ] && [ "$os" != "OSX" ] ) ); then
2567                         eval "res=\$$2"
2568                         log 2 "  trying $res... found"
2569                         # Now find the static lib, if needed
2570                         eval "$2=`ls /lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2571                         eval "res=\$$2"
2572                         if [ -z "$res" ]; then
2573                                 log 2 "  trying /lib/$3... no"
2574                                 eval "$2=`ls /usr/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2575                         fi
2576                         eval "res=\$$2"
2577                         if [ -z "$res" ]; then
2578                                 log 2 "  trying /usr/lib/$3... no"
2579                                 eval "$2=`ls /usr/local/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2580                         fi
2581                         eval "res=\$$2"
2582                         if [ -z "$res" ]; then
2583                                 log 2 "  trying /usr/local/lib/$3... no"
2584                                 eval "$2=`ls /mingw/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2585                         fi
2586                         eval "res=\$$2"
2587                         if [ -z "$res" ]; then
2588                                 log 2 "  trying /mingw/lib/$3... no"
2589                                 log 1 "configure: error: $2 couldn't be found"
2590                                 log 1 "configure: error: you requested a static link, but I can't find $3"
2592                                 exit 1
2593                         fi
2594                 fi
2595         else
2596                 # Make sure it exists
2597                 if [ -f "$1" ]; then
2598                         eval "$2=`ls $1 2>/dev/null`"
2599                 else
2600                         eval "$2=`ls $1/$3 2>/dev/null`"
2601                 fi
2602         fi
2604         eval "res=\$$2"
2605         if [ -z "$res" ]; then
2606                 log 1 "checking $2... not found"
2607                 if [ "$1" = "2" ]; then
2608                         log 1 "configure: error: $2 couldn't be found"
2610                         exit 1
2611                 elif [ "$1" != "1" ]; then
2612                         log 1 "configure: error: $2 couldn't be found"
2613                         log 1 "configure: error: you supplied '$1', but it seems invalid"
2615                         exit 1
2616                 fi
2618                 eval "with_$2=0"
2620                 return 0
2621         fi
2623         eval "res=\$$2"
2624         log 2 "  trying $res... found"
2626         log 1 "checking $2... found"
2629 detect_zlib() {
2630         detect_library "$with_zlib" "zlib" "libz.a" "" "zlib.h"
2633 detect_lzo2() {
2634         detect_library "$with_lzo2" "lzo2" "liblzo2.a" "lzo/" "lzo1x.h"
2637 detect_libtimidity() {
2638         detect_library "$with_libtimidity" "libtimidity" "libtimidity.a" "" "timidity.h"
2641 detect_lzma() {
2642         # 0 means no, 1 is auto-detect, 2 is force
2643         if [ "$with_lzma" = "0" ]; then
2644                 log 1 "checking liblzma... disabled"
2646                 lzma_config=""
2647                 return 0
2648         fi
2650         if [ "$with_lzma" = "1" ] || [ "$with_lzma" = "" ] || [ "$with_lzma" = "2" ]; then
2651                 lzma_config="pkg-config liblzma"
2652         else
2653                 lzma_config="$with_lzma"
2654         fi
2656         version=`$lzma_config --modversion 2>/dev/null`
2657         ret=$?
2658         log 2 "executing $lzma_config --modversion"
2659         log 2 "  returned $version"
2660         log 2 "  exit code $ret"
2662         if [ -z "$version" ] || [ "$ret" != "0" ]; then
2663                 log 1 "checking liblzma... not found"
2665                 # It was forced, so it should be found.
2666                 if [ "$with_lzma" != "1" ]; then
2667                         log 1 "configure: error: pkg-config liblzma couldn't be found"
2668                         log 1 "configure: error: you supplied '$with_lzma', but it seems invalid"
2669                         exit 1
2670                 fi
2672                 lzma_config=""
2673                 return 0
2674         fi
2676         log 1 "checking liblzma... found"
2679 detect_png() {
2680         # 0 means no, 1 is auto-detect, 2 is force
2681         if [ "$with_png" = "0" ]; then
2682                 log 1 "checking libpng... disabled"
2684                 png_config=""
2685                 return 0
2686         fi
2688         if [ "$with_zlib" = "0" ] || [ -z "$zlib" ]; then
2689                 if [ "$with_png" != "1" ]; then
2690                         log 1 "checking libpng... no zlib"
2691                         log 1 "ERROR: libpng was forced, but zlib was not detected / disabled."
2692                         log 1 "ERROR: libpng depends on zlib."
2694                         exit 1
2695                 fi
2697                 log 1 "checking libpng... no zlib, skipping"
2699                 png_config=""
2700                 return 0
2701         fi
2703         if [ "$with_png" = "1" ] || [ "$with_png" = "" ] || [ "$with_png" = "2" ]; then
2704                 png_config="libpng-config"
2705         else
2706                 png_config="$with_png"
2707         fi
2709         version=`$png_config --version 2>/dev/null`
2710         ret=$?
2711         log 2 "executing $png_config --version"
2712         log 2 "  returned $version"
2713         log 2 "  exit code $ret"
2715         if [ -z "$version" ] || [ "$ret" != "0" ]; then
2716                 log 1 "checking libpng... not found"
2718                 # It was forced, so it should be found.
2719                 if [ "$with_png" != "1" ]; then
2720                         log 1 "configure: error: libpng-config couldn't be found"
2721                         log 1 "configure: error: you supplied '$with_png', but it seems invalid"
2722                         exit 1
2723                 fi
2725                 png_config=""
2726                 return 0
2727         fi
2729         log 1 "checking libpng... found"
2732 detect_freetype() {
2733         # 0 means no, 1 is auto-detect, 2 is force
2734         if [ "$with_freetype" = "0" ]; then
2735                 log 1 "checking libfreetype... disabled"
2737                 freetype_config=""
2738                 return 0
2739         fi
2740         if [ "$with_freetype" = "1" ] && [ "$enable_dedicated" != "0" ]; then
2741                 log 1 "checking libfreetype... dedicated server, skipping"
2743                 freetype_config=""
2744                 return 0
2745         fi
2747         if [ "$with_zlib" = "0" ] || [ -z "$zlib" ]; then
2748                 if [ "$with_freetype" != "1" ]; then
2749                         log 1 "checking libfreetype... no zlib"
2750                         log 1 "ERROR: libfreetype was forced, but zlib was not detected / disabled."
2751                         log 1 "ERROR: libfreetype depends on zlib."
2753                         exit 1
2754                 fi
2756                 log 1 "checking libfreetype... no zlib, skipping"
2758                 freetype_config=""
2759                 return 0
2760         fi
2762         if [ "$with_freetype" = "1" ] || [ "$with_freetype" = "" ] || [ "$with_freetype" = "2" ]; then
2763                 freetype_config="freetype-config"
2764         else
2765                 freetype_config="$with_freetype"
2766         fi
2768         version=`$freetype_config --version 2>/dev/null`
2769         ret=$?
2770         log 2 "executing freetype_config --version"
2771         log 2 "  returned $version"
2772         log 2 "  exit code $ret"
2774         if [ -z "$version" ] || [ "$ret" != "0" ]; then
2775                 log 1 "checking libfreetype... not found"
2777                 # It was forced, so it should be found.
2778                 if [ "$with_freetype" != "1" ]; then
2779                         log 1 "configure: error: freetype-config couldn't be found"
2780                         log 1 "configure: error: you supplied '$with_freetype', but it seems invalid"
2781                         exit 1
2782                 fi
2784                 freetype_config=""
2785                 return 0
2786         fi
2788         log 1 "checking libfreetype... found"
2791 detect_fontconfig() {
2792         # 0 means no, 1 is auto-detect, 2 is force
2793         if [ "$with_fontconfig" = "0" ]; then
2794                 log 1 "checking libfontconfig... disabled"
2796                 fontconfig_config=""
2797                 return 0
2798         fi
2799         if [ "$with_fontconfig" = "1" ] && [ "$enable_dedicated" != "0" ]; then
2800                 log 1 "checking libfontconfig... dedicated server, skipping"
2802                 fontconfig_config=""
2803                 return 0
2804         fi
2805         if [ "$with_fontconfig" != "2" ] && [ -z "$freetype_config" ]; then
2806                 log 1 "checking libfontconfig... no freetype, skipping"
2808                 fontconfig_config=""
2809                 return 0
2810         fi
2812         if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "WINCE" ]; then
2813                 log 1 "checking libfontconfig... WIN32, skipping"
2814                 fontconfig_config=""
2815                 return 0
2816         fi
2818         if [ "$os" = "OSX" ]; then
2819                 log 1 "checking libfontconfig... OSX, skipping"
2820                 fontconfig_config=""
2821                 return 0
2822         fi
2824         if [ "$with_fontconfig" = "1" ] || [ "$with_fontconfig" = "" ] || [ "$with_fontconfig" = "2" ]; then
2825                 fontconfig_config="pkg-config fontconfig"
2826         else
2827                 fontconfig_config="$with_fontconfig"
2828         fi
2830         version=`$fontconfig_config --modversion 2>/dev/null`
2831         ret=$?
2832         shortversion=`echo $version | cut -c 1,3`
2833         log 2 "executing $fontconfig_config --modversion"
2834         log 2 "  returned $version"
2835         log 2 "  exit code $ret"
2837         if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$shortversion" -le "22" ]; then
2838                 if [ -n "$shortversion" ] && [ "$shortversion" -le "22" ]; then
2839                         log 1 "checking libfontconfig... needs at least version 2.3.0, fontconfig NOT enabled"
2840                 else
2841                         log 1 "checking libfontconfig... not found"
2842                 fi
2844                 # It was forced, so it should be found.
2845                 if [ "$with_fontconfig" != "1" ]; then
2846                         log 1 "configure: error: fontconfig-config couldn't be found"
2847                         log 1 "configure: error: you supplied '$with_fontconfig', but it seems invalid"
2848                         exit 1
2849                 fi
2851                 fontconfig_config=""
2852                 return 0
2853         fi
2855         log 1 "checking libfontconfig... found"
2858 detect_icu() {
2859         # 0 means no, 1 is auto-detect, 2 is force
2860         if [ "$with_icu" = "0" ]; then
2861                 log 1 "checking libicu... disabled"
2863                 icu_config=""
2864                 return 0
2865         fi
2866         if [ "$with_icu" = "1" ] && [ "$enable_dedicated" != "0" ]; then
2867                 log 1 "checking libicu... dedicated server, skipping"
2869                 icu_config=""
2870                 return 0
2871         fi
2873         if [ "$with_icu" = "1" ] || [ "$with_icu" = "" ] || [ "$with_icu" = "2" ]; then
2874                 icu_config="icu-config"
2875         else
2876                 icu_config="$with_icu"
2877         fi
2879         version=`$icu_config --version 2>/dev/null`
2880         ret=$?
2881         shortversion=`echo $version | cut -d\. -f1,2 | sed "s/\.//g" | cut -c1-2`
2882         log 2 "executing $icu_config --version"
2883         log 2 "  returned $version"
2884         log 2 "  exit code $ret"
2886         if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$shortversion" -lt "36" ]; then
2887                 if [ -n "$shortversion" ] && [ "$shortversion" -lt "36" ]; then
2888                         log 1 "checking libicu... needs at least version 3.6.0, icu NOT enabled"
2889                 else
2890                         log 1 "checking libicu... not found"
2891                 fi
2893                 # It was forced, so it should be found.
2894                 if [ "$with_icu" != "1" ]; then
2895                         log 1 "configure: error: icu-config couldn't be found"
2896                         log 1 "configure: error: you supplied '$with_icuconfig', but it seems invalid"
2897                         exit 1
2898                 fi
2900                 icu_config=""
2901                 return 0
2902         fi
2904         log 1 "checking libicu... found"
2907 detect_pspconfig() {
2908         # 0 means no, 1 is auto-detect, 2 is force
2909         if [ "$with_psp_config" = "0" ]; then
2910                 log 1 "checking psp-config... disabled"
2912                 psp_config=""
2913                 return 0
2914         fi
2916         if [ "$with_psp_config" = "1" ] && [ "$os" != "PSP" ]; then
2917                 log 1 "checking psp-config... not PSP, skipping"
2919                 psp_config="";
2920                 return 0
2921         fi
2923         if [ "$os" != "PSP" ]; then
2924                 log 1 "checking psp-config... not PSP"
2926                 log 1 "configure: error: psp-config is only supported for PSP"
2927                 exit 1
2928         fi
2930         if [ "$with_psp_config" = "1" ] || [ "$with_psp_config" = "" ] || [ "$with_psp_config" = "2" ]; then
2931                 psp_config="psp-config"
2932         else
2933                 psp_config="$with_psp_config"
2934         fi
2936         version=`$psp_config -p 2>/dev/null`
2937         ret=$?
2938         log 2 "executing $psp_config -p"
2939         log 2 "  returned $version"
2940         log 2 "  exit code $ret"
2942         if [ -z "$version" ] || [ "$ret" != "0" ]; then
2943                 log 1 "checking psp-config... not found"
2944                 log 1 "configure: error: psp-config couldn't be found"
2946                 # It was forced, so it should be found.
2947                 if [ "$with_psp_config" != "1" ]; then
2948                         log 1 "configure: error: you supplied '$with_psp_config', but it seems invalid"
2949                 fi
2950                 exit 1
2951         fi
2953         log 1 "checking psp-config... found"
2956 detect_iconv() {
2957         # 0 means no, 1 is auto-detect, 2 is force
2958         if [ "$with_iconv" = "0" ]; then
2959                 log 1 "checking iconv... disabled"
2961                 return 0
2962         fi
2964         if [ "$with_iconv" = "1" ] && [ "$os" != "OSX" ]; then
2965                 log 1 "checking iconv... not OSX, skipping"
2966                 with_iconv="0"
2968                 return 0
2969         fi
2971         # Try to find iconv.h, seems to only thing to detect iconv with
2973         if [ "$with_iconv" = "1" ] || [ "$with_iconv" = "" ] || [ "$with_iconv" = "2" ]; then
2974                 iconv=`ls -1 /usr/include 2>/dev/null | grep "iconv.h"`
2975                 if [ -z "$iconv" ]; then
2976                         iconv=`ls -1 /usr/local/include 2>/dev/null | grep "iconv.h"`
2977                 fi
2978         else
2979                 # Make sure it exists
2980                 iconv=`ls $with_iconv/include/iconv.h 2>/dev/null`
2981         fi
2983         if [ -z "$iconv" ]; then
2984                 log 1 "checking iconv... not found"
2985                 if [ "$with_iconv" = "2" ]; then
2986                         log 1 "configure: error: iconv couldn't be found"
2988                         exit 1
2989                 elif [ "$with_iconv" != "1" ]; then
2990                         log 1 "configure: error: iconv couldn't be found"
2991                         log 1 "configure: error: you supplied '$with_iconv', but I couldn't detect iconv in it"
2993                         exit 1
2994                 fi
2996                 return 0
2997         fi
2999         if [ "$with_iconv" = "1" ]; then
3000                 with_iconv="2"
3001         fi
3003         log 2 "found iconv in $iconv"
3005         log 1 "checking iconv... found"
3007         # There are different implementations of iconv. The older ones,
3008         # e.g. SUSv2, pass a const pointer, whereas the newer ones, e.g.
3009         # IEEE 1003.1 (2004), pass a non-const pointer.
3011         cat > tmp.iconv.cpp << EOF
3012 #include "src/stdafx.h"
3013 #include <iconv.h>
3014 int main() {
3015         static char buf[1024];
3016         iconv_t convd = 0;
3017         const char *inbuf = "";
3018         char *outbuf  = buf;
3019         size_t outlen = 1023;
3020         size_t inlen  = 0;
3021         return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
3024         execute="$cxx_host $OSX_SYSROOT $CFLAGS -c tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
3025         eval $execute > /dev/null
3026         ret=$?
3027         log 2 "executing $execute"
3028         log 2 "  exit code $ret"
3029         if [ "$ret" = "0" ]; then have_non_const_iconv="no"; else have_non_const_iconv="yes"; fi
3030         log 1 "checking if iconv has non-const inbuf... $have_non_const_iconv"
3032         cat > tmp.iconv.cpp << EOF
3033 #include "src/stdafx.h"
3034 #include <iconv.h>
3035 int main() {
3036         static char buf[1024];
3037         iconv_t convd = 0;
3038         char *inbuf = "";
3039         char *outbuf  = buf;
3040         size_t outlen = 1023;
3041         size_t inlen  = 0;
3042         return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
3045         execute="$cxx_host $OSX_SYSROOT $OSX_LD_SYSROOT $CFLAGS tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
3046         eval $execute > /dev/null
3047         ret=$?
3048         log 2 "executing $execute"
3049         log 2 "  exit code $ret"
3050         if [ "$ret" = "0" ]; then link_to_iconv="no"; else link_to_iconv="yes"; fi
3051         log 1 "checking whether to link to iconv... $link_to_iconv"
3052         rm -f tmp.iconv tmp.iconv.cpp
3055 _detect_sort() {
3056         sort_test_in="d
3061         sort_test_out="a
3066         log 2 "running echo <array> | $1"
3068         if [ "`echo \"$sort_test_in\" | $1 2>/dev/null`" = "$sort_test_out" ]; then
3069                 sort="$1"
3070                 log 2 "  result was valid"
3071         else
3072                 log 2 "  result was invalid"
3073         fi
3076 detect_sort() {
3077         if [ "$with_sort" = "0" ]; then
3078                 log 1 "checking sort... disabled"
3080                 return
3081         fi
3083         if [ "$with_sort" = "1" ] || [ "$with_sort" = "2" ]; then
3084                 _detect_sort "sort"
3085                 if [ -z "$sort" ]; then _detect_sort "/sbin/sort"; fi
3086                 if [ -z "$sort" ]; then _detect_sort "/usr/sbin/sort"; fi
3087                 if [ -z "$sort" ]; then _detect_sort "/usr/local/sbin/sort"; fi
3088                 if [ -z "$sort" ]; then _detect_sort "/bin/sort"; fi
3089                 if [ -z "$sort" ]; then _detect_sort "/usr/bin/sort"; fi
3090                 if [ -z "$sort" ]; then _detect_sort "/usr/local/bin/sort"; fi
3091         else
3092                 _detect_sort "$with_sort"
3093         fi
3095         if [ -z "$sort" ]; then
3096                 if [ "$with_sort" = "2" ]; then
3097                         log 1 "checking sort... not found"
3099                         log 1 "configure: error: couldn't detect sort on your system"
3100                         exit 1
3101                 elif [ "$with_sort" != "1" ]; then
3102                         log 1 "checking sort... $with_sort not found"
3104                         log 1 "configure: error: '$with_sort' doesn't look like a sort to me"
3105                         log 1 "configure: error: please verify its location and function and try again"
3107                         exit 1
3108                 else
3109                         log 1 "checking sort... not found"
3110                 fi
3111         else
3112                 log 1 "checking sort... $sort"
3113         fi
3116 detect_grfcodec() {
3117         # 0 means no, 1 is auto-detect, 2 is force
3118         if [ "$with_grfcodec" = "0" ]; then
3119                 log 1 "checking grfcodec... disabled"
3121                 grfcodec=""
3122                 return 0
3123         fi
3125         if [ "$with_grfcodec" = "1" ] || [ "$with_grfcodec" = "" ] || [ "$with_grfcodec" = "2" ]; then
3126                 grfcodec="grfcodec"
3127         else
3128                 grfcodec="$with_grfcodec"
3129         fi
3131         version=`$grfcodec -v 2>/dev/null | $awk '{print $3}' | sed 's/[rM]//g;s/-/0/'`
3132         ret=$?
3133         log 2 "executing grfcodec -v"
3134         log 2 "  returned $version"
3135         log 2 "  exit code $ret"
3137         if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "913" ]; then
3138                 if [ -n "$version" ] && [ "$version" -lt "913" ]; then
3139                         log 1 "checking grfcodec... needs at least version 5.1.4 (r913), disabled"
3140                 else
3141                         log 1 "checking grfcodec... not found"
3142                 fi
3144                 # It was forced, so it should be found.
3145                 if [ "$with_grfcodec" != "1" ]; then
3146                         log 1 "configure: error: grfcodec couldn't be found"
3147                         log 1 "configure: error: you supplied '$with_grfcodec', but it seems invalid"
3148                         exit 1
3149                 fi
3151                 grfcodec=""
3152                 return 0
3153         fi
3155         log 1 "checking grfcodec... found"
3158 detect_nforenum() {
3159         # 0 means no, 1 is auto-detect, 2 is force
3160         if [ "$with_nforenum" = "0" ]; then
3161                 log 1 "checking nforenum... disabled"
3163                 nforenum=""
3164                 return 0
3165         fi
3167         if [ "$with_nforenum" = "1" ] || [ "$with_nforenum" = "" ] || [ "$with_nforenum" = "2" ]; then
3168                 nforenum="nforenum"
3169         else
3170                 nforenum="$with_nforenum"
3171         fi
3173         version=`$nforenum -v 2>/dev/null | $awk '{print $3}' | sed 's/[rM]//g;s/-/0/'`
3174         ret=$?
3175         log 2 "executing nforenum -v"
3176         log 2 "  returned $version"
3177         log 2 "  exit code $ret"
3179         if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "913" ]; then
3180                 if [ -n "$version" ] && [ "$version" -lt "913" ]; then
3181                         log 1 "checking nforenum... needs at least version 5.1.4 (r913), disabled"
3182                 else
3183                         log 1 "checking nforenum... not found"
3184                 fi
3186                 # It was forced, so it should be found.
3187                 if [ "$with_nforenum" != "1" ]; then
3188                         log 1 "configure: error: nforenum couldn't be found"
3189                         log 1 "configure: error: you supplied '$with_nforenum', but it seems invalid"
3190                         exit 1
3191                 fi
3193                 nforenum=""
3194                 return 0
3195         fi
3197         log 1 "checking nforenum... found"
3200 detect_cputype() {
3201         if [ -n "$cpu_type" ] && [ "$cpu_type" != "DETECT" ]; then
3202                 log 1 "forcing cpu-type... $cpu_type bits"
3203                 return;
3204         fi
3205         echo "#define _SQ64 1" > tmp.64bit.cpp
3206         echo "#include \"src/stdafx.h\"" >> tmp.64bit.cpp
3207         echo "assert_compile(sizeof(size_t) == 8);" >> tmp.64bit.cpp
3208         echo "int main() { return 0; }" >> tmp.64bit.cpp
3209         execute="$cxx_host $CFLAGS tmp.64bit.cpp -o tmp.64bit -DTESTING 2>&1"
3210         cpu_type="`eval $execute 2>/dev/null`"
3211         ret=$?
3212         log 2 "executing $execute"
3213         log 2 "  returned $cpu_type"
3214         log 2 "  exit code $ret"
3215         if [ "$ret" = "0" ]; then cpu_type="64"; else cpu_type="32"; fi
3216         log 1 "detecting cpu-type... $cpu_type bits"
3217         rm -f tmp.64bit tmp.64bit.cpp
3220 make_sed() {
3221         T_CFLAGS="$CFLAGS"
3222         T_CXXFLAGS="$CXXFLAGS"
3223         T_LDFLAGS="$LDFLAGS"
3225         SRC_OBJS_DIR="$BASE_SRC_OBJS_DIR/$OBJS_SUBDIR"
3227         # All the data needed to compile a single target
3228         #  Make sure if you compile multiple targets to
3229         #  use multiple OBJS_DIR, because all in-between
3230         #  binaries are stored in there, and nowhere else.
3231         SRC_REPLACE="
3232                 s@!!CC_HOST!!@$cc_host@g;
3233                 s@!!CXX_HOST!!@$cxx_host@g;
3234                 s@!!CC_BUILD!!@$cc_build@g;
3235                 s@!!CXX_BUILD!!@$cxx_build@g;
3236                 s@!!WINDRES!!@$windres@g;
3237                 s@!!STRIP!!@$strip $strip_arg@g;
3238                 s@!!LIPO!!@$lipo@g;
3239                 s@!!CFLAGS!!@$T_CFLAGS@g;
3240                 s@!!CFLAGS_BUILD!!@$CFLAGS_BUILD@g;
3241                 s@!!CXXFLAGS!!@$T_CXXFLAGS@g;
3242                 s@!!CXXFLAGS_BUILD!!@$CXXFLAGS_BUILD@g;
3243                 s@!!STRGEN_FLAGS!!@$strgen_flags@g;
3244                 s@!!LIBS!!@$LIBS@g;
3245                 s@!!LDFLAGS!!@$T_LDFLAGS@g;
3246                 s@!!LDFLAGS_BUILD!!@$LDFLAGS_BUILD@g;
3247                 s@!!BIN_DIR!!@$BIN_DIR@g;
3248                 s@!!ROOT_DIR!!@$ROOT_DIR@g;
3249                 s@!!MEDIA_DIR!!@$MEDIA_DIR@g;
3250                 s@!!SOURCE_LIST!!@$SOURCE_LIST@g;
3251                 s@!!SRC_OBJS_DIR!!@$SRC_OBJS_DIR@g;
3252                 s@!!LANG_OBJS_DIR!!@$LANG_OBJS_DIR@g;
3253                 s@!!GRF_OBJS_DIR!!@$GRF_OBJS_DIR@g;
3254                 s@!!SETTING_OBJS_DIR!!@$SETTING_OBJS_DIR@g;
3255                 s@!!SRC_DIR!!@$SRC_DIR@g;
3256                 s@!!SCRIPT_SRC_DIR!!@$SCRIPT_SRC_DIR@g;
3257                 s@!!OSXAPP!!@$OSXAPP@g;
3258                 s@!!LANG_DIR!!@$LANG_DIR@g;
3259                 s@!!TTD!!@$TTD@g;
3260                 s@!!BINARY_DIR!!@$prefix_dir/$binary_dir@g;
3261                 s@!!DATA_DIR!!@$prefix_dir/$data_dir@g;
3262                 s@!!DOC_DIR!!@$prefix_dir/$doc_dir@g;
3263                 s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
3264                 s@!!ICON_DIR!!@$prefix_dir/$icon_dir@g;
3265                 s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
3266                 s@!!PERSONAL_DIR!!@$personal_dir@g;
3267                 s@!!SHARED_DIR!!@$shared_dir@g;
3268                 s@!!INSTALL_DIR!!@$install_dir@g;
3269                 s@!!BINARY_NAME!!@$binary_name@g;
3270                 s@!!STRGEN!!@$STRGEN@g;
3271                 s@!!ENDIAN_CHECK!!@$ENDIAN_CHECK@g;
3272                 s@!!DEPEND!!@$DEPEND@g;
3273                 s@!!SETTINGSGEN!!@$SETTINGSGEN@g;
3274                 s@!!ENDIAN_FORCE!!@$endian@g;
3275                 s@!!STAGE!!@$STAGE@g;
3276                 s@!!MAKEDEPEND!!@$makedepend@g;
3277                 s@!!CFLAGS_MAKEDEP!!@$cflags_makedep@g;
3278                 s@!!SORT!!@$sort@g;
3279                 s@!!CONFIG_CACHE_COMPILER!!@config.cache.compiler@g;
3280                 s@!!CONFIG_CACHE_LINKER!!@config.cache.linker@g;
3281                 s@!!CONFIG_CACHE_ENDIAN!!@config.cache.endian@g;
3282                 s@!!CONFIG_CACHE_SOURCE!!@config.cache.source@g;
3283                 s@!!CONFIG_CACHE_VERSION!!@config.cache.version@g;
3284                 s@!!CONFIG_CACHE_SOURCE_LIST!!@config.cache.source.list@g;
3285                 s@!!CONFIG_CACHE_PWD!!@config.cache.pwd@g;
3286                 s@!!LANG_SUPPRESS!!@$lang_suppress@g;
3287                 s@!!OBJS_C!!@$OBJS_C@g;
3288                 s@!!OBJS_CPP!!@$OBJS_CPP@g;
3289                 s@!!OBJS_MM!!@$OBJS_MM@g;
3290                 s@!!OBJS_RC!!@$OBJS_RC@g;
3291                 s@!!SRCS!!@$SRCS@g;
3292                 s@!!OS!!@$os@g;
3293                 s@!!CONFIGURE_FILES!!@$CONFIGURE_FILES@g;
3294                 s@!!AWK!!@$awk@g;
3295                 s@!!DISTCC!!@$distcc@g;
3296                 s@!!NFORENUM!!@$nforenum@g;
3297                 s@!!GRFCODEC!!@$grfcodec@g;
3298         "
3300         if [ "$icon_theme_dir" != "" ]; then
3301                 SRC_REPLACE="$SRC_REPLACE
3302                         s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
3303                 "
3304         else
3305                 SRC_REPLACE="$SRC_REPLACE
3306                         s@!!ICON_THEME_DIR!!@@g;
3307                 "
3308         fi
3310         if [ "$man_dir" != "" ]; then
3311                 SRC_REPLACE="$SRC_REPLACE
3312                         s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
3313                 "
3314         else
3315                 SRC_REPLACE="$SRC_REPLACE
3316                         s@!!MAN_DIR!!@@g;
3317                 "
3318         fi
3320         if [ "$menu_dir" != "" ]; then
3321                 SRC_REPLACE="$SRC_REPLACE
3322                         s@!!MENU_DIR!!@$prefix_dir/$menu_dir@g;
3323                 "
3324         else
3325                 SRC_REPLACE="$SRC_REPLACE
3326                         s@!!MENU_DIR!!@@g;
3327                 "
3328         fi
3331 generate_menu_item() {
3332         MENU_REPLACE="
3333                 s@!!TTD!!@$TTD@g;
3334                 s@!!MENU_GROUP!!@$menu_group@g;
3335                 s@!!MENU_NAME!!@$menu_name@g
3336         "
3337         log 1 "Generating menu item..."
3338         mkdir -p media
3339         < $ROOT_DIR/media/openttd.desktop.in sed "$MENU_REPLACE" > media/openttd.desktop
3342 generate_main() {
3343         STAGE="[MAIN]"
3345         make_sed
3347         # Create the main Makefile
3348         log 1 "Generating Makefile..."
3349         echo "# Auto-generated file from 'Makefile.in' -- DO NOT EDIT" > Makefile
3350         < $ROOT_DIR/Makefile.in sed "$SRC_REPLACE" >> Makefile
3351         cp $ROOT_DIR/Makefile.bundle.in Makefile.bundle
3352         echo "# Auto-generated file -- DO NOT EDIT" > Makefile.am
3353         echo >> Makefile.am
3354         # Make the copy of the source-list, so we don't trigger an unwanted recompile
3355         cp $SOURCE_LIST config.cache.source.list
3356         # Add the current directory, so we don't trigger an unwanted recompile
3357         echo "`pwd`" > config.cache.pwd
3358         # Make sure config.cache is OLDER then config.cache.source.list
3359         touch config.cache
3360         touch config.pwd
3362         if [ "$menu_dir" != "" ]; then
3363                 generate_menu_item
3364         fi
3367 generate_lang() {
3368         STAGE="[LANG]"
3370         make_sed
3372         # Create the language file
3373         mkdir -p $LANG_OBJS_DIR
3375         log 1 "Generating lang/Makefile..."
3376         echo "# Auto-generated file from 'Makefile.lang.in' -- DO NOT EDIT" > $LANG_OBJS_DIR/Makefile
3377         < $ROOT_DIR/Makefile.lang.in sed "$SRC_REPLACE" >> $LANG_OBJS_DIR/Makefile
3378         echo "DIRS += $LANG_OBJS_DIR" >> Makefile.am
3379         echo "LANG_DIRS += $LANG_OBJS_DIR" >> Makefile.am
3382 generate_settings() {
3383         STAGE="[SETTING]"
3385         make_sed
3387         # Create the language file
3388         mkdir -p $SETTING_OBJS_DIR
3390         log 1 "Generating setting/Makefile..."
3391         echo "# Auto-generated file from 'Makefile.settings.in' -- DO NOT EDIT" > $SETTING_OBJS_DIR/Makefile
3392         < $ROOT_DIR/Makefile.setting.in sed "$SRC_REPLACE" >> $SETTING_OBJS_DIR/Makefile
3393         echo "DIRS += $SETTING_OBJS_DIR" >> Makefile.am
3396 generate_grf() {
3397         STAGE="[GRF]"
3399         make_sed
3401         # Create the language file
3402         mkdir -p $GRF_OBJS_DIR
3404         log 1 "Generating grf/Makefile..."
3405         echo "# Auto-generated file from 'Makefile.grf.in' -- DO NOT EDIT" > $GRF_OBJS_DIR/Makefile
3406         < $ROOT_DIR/Makefile.grf.in sed "$SRC_REPLACE" >> $GRF_OBJS_DIR/Makefile
3407         echo "DIRS += $GRF_OBJS_DIR" >> Makefile.am
3410 generate_src_normal() {
3411         STAGE=$1
3413         make_sed
3415         # Create the source file
3416         mkdir -p $SRC_OBJS_DIR
3418         log 1 "Generating $2/Makefile..."
3419         echo "# Auto-generated file from 'Makefile.src.in' -- DO NOT EDIT" > $SRC_OBJS_DIR/Makefile
3420         < $ROOT_DIR/Makefile.src.in sed "$SRC_REPLACE" >> $SRC_OBJS_DIR/Makefile
3421         echo "DIRS += $SRC_OBJS_DIR" >> Makefile.am
3422         echo "SRC_DIRS += $SRC_OBJS_DIR" >> Makefile.am
3425 generate_src_osx() {
3426         cc_host_orig="$cc_host"
3427         cxx_host_orig="$cxx_host"
3428         CFLAGS_orig="$CFLAGS"
3429         LDFLAGS_orig="$LDFLAGS"
3431         for type in $enable_universal; do
3433                 if [ -n "$osx_sdk_104_path" ]; then
3434                         # Use 10.4 SDK for 32-bit targets
3435                         CFLAGS="-isysroot $osx_sdk_104_path $CFLAGS_orig"
3436                         LDFLAGS="-Wl,-syslibroot,$osx_sdk_104_path $LDFLAGS_orig"
3437                 fi
3439                 # We don't want to duplicate the x86_64 stuff for each target, so do it once here
3440                 if [ "$type" = "ppc64" ] || [ "$type" = "x86_64" ]; then
3441                         # 64 bits is always 10.5 or higher. Furthermore it has a non const ICONV
3442                         # and they also removed support for QuickTime/QuickDraw
3443                         if [ -n "$osx_sdk_path" ]; then
3444                                 CFLAGS="-isysroot $osx_sdk_path $CFLAGS_orig"
3445                                 LDFLAGS="-Wl,-syslibroot,$osx_sdk_path $LDFLAGS_orig"
3446                         fi
3447                         CFLAGS="$CFLAGS -D_SQ64 -DHAVE_NON_CONST_ICONV -DNO_QUICKTIME -UENABLE_COCOA_QUICKDRAW"
3448                         LIBS="`echo $LIBS | sed 's/-framework QuickTime//'`"
3449                 fi
3451                 case $type in
3452                         ppc)
3453                                 BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc"
3454                                 cc_host="$cc_host_orig -arch ppc -mmacosx-version-min=10.3"
3455                                 cxx_host="$cxx_host_orig -arch ppc -mmacosx-version-min=10.3"
3456                                 generate_src_normal "[ppc]" "objs/ppc";;
3457                         ppc970)
3458                                 BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc970"
3459                                 cc_host="$cc_host_orig -arch ppc970 -mmacosx-version-min=10.3 -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
3460                                 cxx_host="$cxx_host_orig -arch ppc970 -mmacosx-version-min=10.3 -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
3461                                 generate_src_normal "[ppc970]" "objs/ppc970";;
3462                         i386)
3463                                 BASE_SRC_OBJS_DIR="$OBJS_DIR/i386"
3464                                 cc_host="$cc_host_orig -arch i386 -mmacosx-version-min=10.4"
3465                                 cxx_host="$cxx_host_orig -arch i386 -mmacosx-version-min=10.4"
3466                                 generate_src_normal "[i386]" "objs/i386";;
3467                         ppc64)
3468                                 BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc64"
3469                                 cc_host="$cc_host_orig -arch ppc64 -mmacosx-version-min=10.5"
3470                                 cxx_host="$cxx_host_orig -arch ppc64 -mmacosx-version-min=10.5"
3471                                 generate_src_normal "[ppc64]" "objs/ppc64";;
3472                         x86_64)
3473                                 BASE_SRC_OBJS_DIR="$OBJS_DIR/x86_64"
3474                                 cc_host="$cc_host_orig -arch x86_64 -mmacosx-version-min=10.5"
3475                                 cxx_host="$cxx_host_orig -arch x86_64 -mmacosx-version-min=10.5"
3476                                 generate_src_normal "[x86_64]" "objs/x86_64";;
3477                         *) log 1 "Unknown architecture requested for universal build: $type";;
3478                 esac
3479         done
3482 generate_src() {
3483         if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ]; then
3484                 generate_src_osx
3485         else
3486                 generate_src_normal "[SRC]" "objs"
3487         fi
3490 showhelp() {
3491         echo "'configure' configures OpenTTD."
3492         echo ""
3493         echo "Usage: $0 [OPTION]... [VAR=VALUE]..."
3494         echo ""
3495         echo "To assign environment variables (e.g., CC, CFLAGS...), specify them as"
3496         echo "VAR=VALUE.  See below for descriptions of some of the useful variables."
3497         echo ""
3498         echo "Defaults for the options are specified in brackets."
3499         echo ""
3500         echo "Configuration:"
3501         echo "  -h, --help                     display this help and exit"
3502         echo ""
3503         echo "System types:"
3504         echo "  --build=BUILD                  configure for building on BUILD [guessed]"
3505         echo "  --host=HOST                    cross-compile to build programs to run"
3506         echo "                                 on HOST [BUILD]"
3507         echo "  --windres=WINDRES              the windres to use [HOST-windres]"
3508         echo "  --strip=STRIP                  the strip to use [HOST-strip]"
3509         echo "  --awk=AWK                      the awk to use in configure [awk]"
3510         echo "  --lipo=LIPO                    the lipo to use (OSX ONLY) [HOST-lipo]"
3511         echo "  --os=OS                        the OS we are compiling for [DETECT]"
3512         echo "                                 DETECT/UNIX/OSX/FREEBSD/OPENBSD/NETBSD/"
3513         echo "                                 MORPHOS/HPUX/BEOS/SUNOS/CYGWIN/MINGW/OS2/"
3514         echo "                                 DOS/WINCE/PSP/HAIKU"
3515         echo "  --endian=ENDIAN                set the endian of the HOST (AUTO/LE/BE)"
3516         echo ""
3517         echo "Paths:"
3518         echo "  --prefix-dir=dir               specifies the prefix for all installed"
3519         echo "                                 files [/usr/local]"
3520         echo "  --binary-dir=dir               location of the binary. Will be prefixed"
3521         echo "                                 with the prefix-dir [games]"
3522         echo "  --data-dir=dir                 location of data files (lang, data, gm)."
3523         echo "                                 Will be prefixed with the prefix-dir"
3524         echo "                                 [share/games/openttd]"
3525         echo "  --doc-dir=dir                  location of the doc files"
3526         echo "                                 Will be prefixed with the prefix-dir"
3527         echo "                                 [$doc_dir]"
3528         echo "  --icon-dir=dir                 location of icons. Will be prefixed"
3529         echo "                                 with the prefix-dir [share/pixmaps]"
3530         echo "  --icon-theme-dir=dir           location of icon theme."
3531         echo "                                 Will be prefixed with the prefix-dir"
3532         echo "                                 and postfixed with size-dirs [$icon_theme_dir]"
3533         echo "  --man-dir=dir                  location of the manual page (UNIX only)"
3534         echo "                                 Will be prefixed with the prefix-dir"
3535         echo "                                 [$man_dir]"
3536         echo "  --menu-dir=dir                 location of the menu item. (UNIX only, except OSX)"
3537         echo "                                 Will be prefixed with the prefix-dir"
3538         echo "                                 [share/applications]"
3539         echo "  --personal-dir=dir             location of the personal directory"
3540         echo "                                 [os-dependent default]"
3541         echo "  --shared-dir=dir               location of shared data files"
3542         echo "                                 [os-dependent default]"
3543         echo "  --install-dir=dir              specifies the root to install to."
3544         echo "                                 Useful to install into jails [/]"
3545         echo "  --binary-name                  the name used for the binary, icons,"
3546         echo "                                 desktop file, etc. when installing [openttd]"
3547         echo ""
3548         echo "Features and packages:"
3549         echo "  --enable-debug[=LVL]           enable debug-mode (LVL=[0123], 0 is release)"
3550         echo "  --enable-desync-debug=[LVL]    enable desync debug options (LVL=[012], 0 is none"
3551         echo "  --enable-profiling             enables profiling"
3552         echo "  --enable-lto                   enables GCC's Link Time Optimization (LTO)/ICC's"
3553         echo "                                 Interprocedural Optimization if available"
3554         echo "  --enable-dedicated             compile a dedicated server (without video)"
3555         echo "  --enable-static                enable static compile (doesn't work for"
3556         echo "                                 all HOSTs)"
3557         echo "  --enable-translator            enable extra output for translators"
3558         echo "  --enable-universal[=ARCH]      enable universal builds (OSX ONLY). Allowed is any combination"
3559         echo "                                 of architectures: i386 ppc ppc970 ppc64 x86_64"
3560         echo "                                 Default architectures are: i386 ppc"
3561         echo "  --enable-osx-g5                enables optimizations for ppc970 (G5) (OSX ONLY)"
3562         echo "  --disable-cocoa-quartz         disable the quartz window mode driver for Cocoa (OSX ONLY)"
3563         echo "  --disable-cocoa-quickdraw      disable the quickdraw window mode driver for Cocoa (OSX ONLY)"
3564         echo "  --disable-unicode              disable unicode support to build win9x"
3565         echo "                                 version (Win32 ONLY)"
3566         echo "  --enable-console               compile as a console application instead of as a GUI application."
3567         echo "                                 If this setting is active, debug output will appear in the same"
3568         echo "                                 console instead of opening a new window. (Win32 ONLY)"
3569         echo "  --disable-network              disable network support"
3570         echo "  --disable-assert               disable asserts (continue on errors)"
3571         echo "  --enable-strip                 enable any possible stripping"
3572         echo "  --without-osx-sysroot          disable the automatic adding of sysroot "
3573         echo "                                 (OSX ONLY)"
3574         echo "  --without-application-bundle   disable generation of application bundle"
3575         echo "                                 (OSX ONLY)"
3576         echo "  --without-menu-entry           Don't generate a menu item (Freedesktop based only)"
3577         echo "  --menu-group=group             Category in which the menu item will be placed (Freedesktop based only)"
3578         echo "  --menu-name=name               Name of the menu item when placed [OpenTTD]"
3579         echo "  --with-direct-music            enable direct music support (Win32 ONLY)"
3580         echo "  --with-sort=sort               define a non-default location for sort"
3581         echo "  --with-midi=midi               define which midi-player to use"
3582         echo "  --with-midi-arg=arg            define which args to use for the"
3583         echo "                                 midi-player"
3584         echo "  --with-libtimidity             enables libtimidity support"
3585         echo "  --with-allegro[=allegro-config]"
3586         echo "                                 enables Allegro video driver support"
3587         echo "  --with-cocoa                   enables COCOA video driver (OSX ONLY)"
3588         echo "  --with-sdl[=sdl-config]        enables SDL video driver support"
3589         echo "  --with-zlib[=zlib.a]           enables zlib support"
3590         echo "  --with-liblzma[=liblzma.a]     enables liblzma support"
3591         echo "  --with-liblzo2[=liblzo2.a]     enables liblzo2 support"
3592         echo "  --with-png[=libpng-config]     enables libpng support"
3593         echo "  --with-freetype[=freetype-config]"
3594         echo "                                 enables libfreetype support"
3595         echo "  --with-fontconfig[=pkg-config fontconfig]"
3596         echo "                                 enables fontconfig support"
3597         echo "  --with-icu[=icu-config]        enables icu (used for right-to-left support)"
3598         echo "  --static-icu                   try to link statically (libsicu instead of"
3599         echo "                                 libicu; can fail as the new name is guessed)"
3600         echo "  --with-iconv[=iconv-path]      enables iconv support"
3601         echo "  --with-psp-config[=psp-config] enables psp-config support (PSP ONLY)"
3602         echo "  --disable-builtin-depend       disable use of builtin deps finder"
3603         echo "  --with-makedepend[=makedepend] enables makedepend support"
3604         echo "  --with-ccache                  enables ccache support"
3605         echo "  --with-distcc                  enables distcc support"
3606         echo ""
3607         echo "Some influential environment variables:"
3608         echo "  CC                             C compiler command"
3609         echo "  CXX                            C++ compiler command"
3610         echo "  CFLAGS                         C compiler flags"
3611         echo "  CXXFLAGS                       C++ compiler flags"
3612         echo "  WINDRES                        windres command"
3613         echo "  LDFLAGS                        linker flags, e.g. -L<lib dir> if you"
3614         echo "                                 have libraries in a nonstandard"
3615         echo "                                 directory <lib dir>"
3616         echo ""
3617         echo "Use these variables to override the choices made by 'configure' or to help"
3618         echo "it to find libraries and programs with nonstandard names/locations."