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