2009-08-21 20:21:05 +00:00
# This file is part of OpenTTD.
# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
2007-01-02 19:19:48 +00:00
log() {
2011-02-07 09:55:09 +00:00
if [ $1 = "1" ]; then
shift
echo "$@"
else
shift
fi
echo "$@" >> $config_log
2007-01-02 19:19:48 +00:00
}
set_default() {
ignore_extra_parameters="0"
# We set all kinds of defaults for params. Later on the user can override
# most of them; but if they don't, this default is used.
build=""
host=""
cc_build=""
cc_host=""
2007-01-10 18:56:51 +00:00
cxx_build=""
2007-01-02 19:19:48 +00:00
cxx_host=""
windres=""
strip=""
lipo=""
2007-02-19 19:59:19 +00:00
awk="awk"
2015-08-08 08:52:21 +00:00
pkg_config="pkg-config"
2007-01-02 19:19:48 +00:00
os="DETECT"
2007-06-17 20:36:14 +00:00
cpu_type="DETECT"
2007-01-02 19:19:48 +00:00
config_log="config.log"
prefix_dir="/usr/local"
binary_dir="games"
data_dir="share/games/openttd"
2008-07-23 15:37:20 +00:00
doc_dir="1"
2007-01-02 19:19:48 +00:00
icon_dir="share/pixmaps"
2008-07-23 15:37:20 +00:00
icon_theme_dir="1"
2007-06-17 15:48:57 +00:00
personal_dir="1"
2008-01-13 17:45:29 +00:00
shared_dir="1"
2007-01-02 19:19:48 +00:00
install_dir="/"
2008-07-23 15:37:20 +00:00
man_dir="1"
menu_dir="1"
2008-07-22 17:18:53 +00:00
menu_group="Game;"
2008-10-16 11:33:17 +00:00
menu_name="OpenTTD"
2008-10-16 11:12:18 +00:00
binary_name="openttd"
2007-01-02 19:19:48 +00:00
enable_debug="0"
2007-12-15 22:42:12 +00:00
enable_desync_debug="0"
2007-01-02 19:19:48 +00:00
enable_profiling="0"
2009-12-01 20:53:13 +00:00
enable_lto="0"
2007-01-02 19:19:48 +00:00
enable_dedicated="0"
enable_static="1"
enable_translator="0"
2008-01-10 18:59:16 +00:00
enable_unicode="1"
2010-11-14 20:47:45 +00:00
enable_console="1";
2007-01-02 19:19:48 +00:00
enable_assert="1"
2008-03-29 21:50:14 +00:00
enable_strip="0"
2010-11-14 22:57:32 +00:00
enable_universal="0"
2007-01-02 19:19:48 +00:00
enable_osx_g5="0"
2007-12-17 07:47:21 +00:00
enable_cocoa_quartz="1"
2007-01-02 19:19:48 +00:00
with_osx_sysroot="1"
with_application_bundle="1"
2008-07-23 15:37:20 +00:00
with_menu_entry="1"
2008-11-25 19:32:12 +00:00
with_allegro="1"
2007-01-02 19:19:48 +00:00
with_sdl="1"
with_cocoa="1"
with_zlib="1"
2010-10-27 16:42:20 +00:00
with_lzma="1"
2010-01-10 13:12:34 +00:00
with_lzo2="1"
2013-11-13 19:32:37 +00:00
with_xdg_basedir="1"
2019-10-09 19:57:28 +00:00
with_fcitx="1"
2007-01-02 19:19:48 +00:00
with_png="1"
2009-05-14 21:59:24 +00:00
enable_builtin_depend="1"
with_makedepend="0"
2007-01-02 19:19:48 +00:00
with_direct_music="1"
2018-04-09 22:18:45 +00:00
with_xaudio2="1"
2007-01-02 19:19:48 +00:00
with_sort="1"
with_iconv="1"
with_midi=""
with_midi_arg=""
2018-09-11 23:06:31 +00:00
with_fluidsynth="1"
2007-01-10 10:39:45 +00:00
with_freetype="1"
2007-01-02 19:19:48 +00:00
with_fontconfig="1"
2015-08-09 13:54:17 +00:00
with_icu_layout="1"
with_icu_sort="1"
2009-11-17 18:01:05 +00:00
static_icu="0"
2018-06-25 17:39:59 +00:00
with_uniscribe="1"
2007-07-20 18:34:21 +00:00
with_threads="1"
2008-01-10 18:59:16 +00:00
with_distcc="1"
with_ccache="1"
2011-12-05 20:11:42 +00:00
with_nforenum="1"
with_grfcodec="1"
2014-01-02 08:35:45 +00:00
with_sse="1"
2015-09-09 19:19:26 +00:00
with_libbfd="1"
with_bfd_extra_debug="1"
2016-06-10 18:55:28 +00:00
with_self_gdb_debug="1"
2019-04-18 17:30:09 +00:00
with_self_lldb_debug="1"
2019-11-05 17:59:11 +00:00
with_sigaltstack="1"
2007-01-02 19:19:48 +00:00
2008-01-13 13:53:53 +00:00
save_params_array="
build
host
cc_build
cc_host
cxx_build
cxx_host
windres
strip
lipo
awk
2015-08-08 08:52:21 +00:00
pkg_config
2008-01-13 13:53:53 +00:00
os
cpu_type
config_log
prefix_dir
binary_dir
data_dir
2008-07-23 15:37:20 +00:00
doc_dir
2008-01-13 13:53:53 +00:00
icon_dir
2008-07-23 15:37:20 +00:00
icon_theme_dir
man_dir
2008-07-22 17:18:53 +00:00
menu_dir
2008-01-13 13:53:53 +00:00
personal_dir
2008-01-13 17:45:29 +00:00
shared_dir
2008-01-13 13:53:53 +00:00
install_dir
2008-07-22 17:18:53 +00:00
menu_group
2008-10-16 11:33:17 +00:00
menu_name
2008-10-16 11:12:18 +00:00
binary_name
2008-01-13 13:53:53 +00:00
enable_debug
enable_desync_debug
enable_profiling
2009-12-01 20:53:13 +00:00
enable_lto
2008-01-13 13:53:53 +00:00
enable_dedicated
enable_static
enable_translator
enable_unicode
2010-11-14 20:47:45 +00:00
enable_console
2008-01-13 13:53:53 +00:00
enable_assert
enable_strip
enable_universal
enable_osx_g5
enable_cocoa_quartz
with_osx_sysroot
with_application_bundle
2008-11-25 19:32:12 +00:00
with_allegro
2008-01-13 13:53:53 +00:00
with_sdl
with_cocoa
with_zlib
2010-10-27 16:42:20 +00:00
with_lzma
2010-01-10 13:12:34 +00:00
with_lzo2
2013-11-13 19:32:37 +00:00
with_xdg_basedir
2019-10-09 19:57:28 +00:00
with_fcitx
2008-01-13 13:53:53 +00:00
with_png
2009-05-14 21:59:24 +00:00
enable_builtin_depend
2008-01-13 13:53:53 +00:00
with_makedepend
with_direct_music
2018-04-09 22:18:45 +00:00
with_xaudio2
2008-01-13 13:53:53 +00:00
with_sort
with_iconv
with_midi
with_midi_arg
2018-09-11 23:06:31 +00:00
with_fluidsynth
2008-01-13 13:53:53 +00:00
with_freetype
with_fontconfig
2015-08-09 13:54:17 +00:00
with_icu_layout
with_icu_sort
2009-11-17 18:01:05 +00:00
static_icu
2018-06-25 17:39:59 +00:00
with_uniscribe
2008-01-13 13:53:53 +00:00
with_threads
with_distcc
with_ccache
2011-12-05 20:11:42 +00:00
with_grfcodec
with_nforenum
2014-01-02 08:35:45 +00:00
with_sse
2015-09-09 19:19:26 +00:00
with_libbfd
with_bfd_extra_debug
2016-06-10 18:55:28 +00:00
with_self_gdb_debug
2019-04-18 17:30:09 +00:00
with_self_lldb_debug
2019-11-05 17:59:11 +00:00
with_sigaltstack
2017-08-27 16:07:24 +00:00
CC CXX CFLAGS CXXFLAGS LDFLAGS CFLAGS_BUILD CXXFLAGS_BUILD LDFLAGS_BUILD PKG_CONFIG_PATH PKG_CONFIG_LIBDIR"
2007-01-02 19:19:48 +00:00
}
detect_params() {
# Walk over all params from the user and override any default settings if
# needed. This also handles any invalid option.
2007-01-07 09:48:10 +00:00
for p in "$@"; do
if [ -n "$prev_p" ]; then
2007-01-02 19:19:48 +00:00
eval "$prev_p=\$p"
prev_p=
continue
fi
optarg=`expr "x$p" : 'x[^=]*=\(.*\)'`
case "$p" in
2008-12-07 12:41:20 +00:00
--help | -h | -\?) showhelp; exit 0;;
2007-01-02 19:19:48 +00:00
2007-01-05 17:29:08 +00:00
--config-log) prev_p="config_log";;
--config-log=*) config_log="$optarg";;
2007-01-02 19:19:48 +00:00
2007-01-05 17:29:08 +00:00
--build) prev_p="build";;
--build=*) build="$optarg";;
2007-01-02 19:19:48 +00:00
2007-01-05 17:29:08 +00:00
--host) prev_p="host";;
--host=*) host="$optarg";;
2007-01-02 19:19:48 +00:00
2007-01-05 17:29:08 +00:00
--os) prev_p="os";;
--os=*) os="$optarg";;
2007-01-02 19:19:48 +00:00
2007-06-17 20:36:14 +00:00
--cpu-type) prev_p="cpu_type";;
--cpu-type=*) cpu_type="$optarg";;
2012-08-14 15:51:28 +00:00
--cc-build) prev_p="cc_build";;
2007-01-05 17:29:08 +00:00
--cc-build=*) cc_build="$optarg";;
2012-08-14 15:51:28 +00:00
--cc-host) prev_p="cc_host";;
2007-01-05 17:29:08 +00:00
--cc-host=*) cc_host="$optarg";;
2012-08-14 15:51:28 +00:00
--cxx-build) prev_p="cxx_build";;
2007-01-10 18:56:51 +00:00
--cxx-build=*) cxx_build="$optarg";;
2012-08-14 15:51:28 +00:00
--cxx-host) prev_p="cxx_host";;
2007-01-05 17:29:08 +00:00
--cxx-host=*) cxx_host="$optarg";;
2012-08-14 15:51:28 +00:00
--windres) prev_p="windres";;
2007-01-05 17:29:08 +00:00
--windres=*) windres="$optarg";;
2012-08-14 15:51:28 +00:00
--awk) prev_p="awk";;
2007-02-19 19:59:19 +00:00
--awk=*) awk="$optarg";;
2015-08-08 08:52:21 +00:00
--pkg-config) prev_p="pkg_config";;
--pkg-config=*) pkg_config="$optarg";;
2012-08-14 15:51:28 +00:00
--strip) prev_p="strip";;
2007-01-05 17:29:08 +00:00
--strip=*) strip="$optarg";;
2012-08-14 15:51:28 +00:00
--lipo) prev_p="lipo";;
2007-01-05 17:29:08 +00:00
--lipo=*) lipo="$optarg";;
2007-01-02 19:19:48 +00:00
2012-08-14 15:47:44 +00:00
# Alias --prefix with --prefix-dir, for compatibility with GNU autotools
2012-08-14 15:51:28 +00:00
--prefix-dir | --prefix) prev_p="prefix_dir";;
2012-08-14 15:47:44 +00:00
--prefix-dir=* | --prefix=*) prefix_dir="$optarg";;
2007-01-02 19:19:48 +00:00
2012-08-14 15:51:28 +00:00
--binary-dir) prev_p="binary_dir";;
2007-01-05 17:29:08 +00:00
--binary-dir=*) binary_dir="$optarg";;
2007-01-02 19:19:48 +00:00
2012-08-14 15:51:28 +00:00
--data-dir) prev_p="data_dir";;
2007-01-05 17:29:08 +00:00
--data-dir=*) data_dir="$optarg";;
2007-01-02 19:19:48 +00:00
2012-08-14 15:51:28 +00:00
--doc-dir) prev_p="doc_dir";;
2008-07-23 15:37:20 +00:00
--doc-dir=*) doc_dir="$optarg";;
2012-08-14 15:51:28 +00:00
--icon-dir) prev_p="icon_dir";;
2007-01-05 17:29:08 +00:00
--icon-dir=*) icon_dir="$optarg";;
2007-01-02 19:19:48 +00:00
2012-08-14 15:51:28 +00:00
--icon-theme-dir) prev_p="icon_theme_dir";;
2008-07-23 15:37:20 +00:00
--icon-theme-dir=*) icon_theme_dir="$optarg";;
--without-icon-theme) icon_theme_dir="";;
2012-08-14 15:51:28 +00:00
--menu-dir) prev_p="menu_dir";;
2008-07-22 17:18:53 +00:00
--menu-dir=*) menu_dir="$optarg";;
2008-07-23 15:37:20 +00:00
--without-menu-entry) menu_dir="";;
2012-08-14 15:51:28 +00:00
--menu-name) prev_p="menu_name";;
2008-10-16 11:33:17 +00:00
--menu-name=*) menu_name="$optarg";;
2012-08-14 15:51:28 +00:00
--binary-name) prev_p="binary_name";;
2008-10-16 11:12:18 +00:00
--binary-name=*) binary_name="$optarg";;
2012-08-14 15:51:28 +00:00
--man-dir) prev_p="man_dir";;
2008-07-24 20:29:40 +00:00
--man-dir=*) man_dir="$optarg";;
2008-07-22 17:18:53 +00:00
2012-08-14 15:51:28 +00:00
--personal-dir) prev_p="personal_dir";;
2007-01-05 17:29:08 +00:00
--personal-dir=*) personal_dir="$optarg";;
2007-06-17 15:48:57 +00:00
--without-personal-dir) personal_dir="";;
2007-01-02 19:19:48 +00:00
2012-08-14 15:51:28 +00:00
--shared-dir) prev_p="shared_dir";;
2008-01-13 17:45:29 +00:00
--shared-dir=*) shared_dir="$optarg";;
--without-shared-dir) shared_dir="";;
2012-08-14 15:51:28 +00:00
--install-dir) prev_p="install_dir";;
2007-01-05 17:29:08 +00:00
--install-dir=*) install_dir="$optarg";;
2007-01-02 19:19:48 +00:00
2012-08-14 15:51:28 +00:00
--menu-group) prev_p="menu_group";;
2008-07-22 18:53:52 +00:00
--menu-group=*) menu_group="$optarg";;
2008-07-22 17:18:53 +00:00
2007-01-05 17:29:08 +00:00
--enable-debug) enable_debug="1";;
--enable-debug=*) enable_debug="$optarg";;
2007-12-15 22:42:12 +00:00
--enable-desync-debug) enable_desync_debug="1";;
--enable-desync-debug=*) enable_desync_debug="$optarg";;
2007-01-05 17:29:08 +00:00
--enable-profiling) enable_profiling="1";;
--enable-profiling=*) enable_profiling="$optarg";;
2009-12-01 20:53:13 +00:00
--enable-lto) enable_lto="1";;
--enable-lto=*) enable_lto="$optarg";;
--enable-ipo) enable_lto="1";;
--enable-ipo=*) enable_lto="$optarg";;
2007-01-05 17:29:08 +00:00
--enable-dedicated) enable_dedicated="1";;
--enable-dedicated=*) enable_dedicated="$optarg";;
--disable-static) enable_static="0";;
--enable-static) enable_static="2";;
--enable-static=*) enable_static="$optarg";;
--disable-translator) enable_translator="0";;
--enable-translator) enable_translator="2";;
--enable-translator=*) enable_translator="$optarg";;
--disable-assert) enable_assert="0";;
--enable-assert) enable_assert="2";;
--enable-assert=*) enable_assert="$optarg";;
--disable-strip) enable_strip="0";;
--enable-strip) enable_strip="2";;
--enable-strip=*) enable_strip="$optarg";;
--disable-universal) enable_universal="0";;
2010-11-14 22:57:32 +00:00
--enable-universal) enable_universal="i386 ppc";;
2007-01-05 17:29:08 +00:00
--enable-universal=*) enable_universal="$optarg";;
--disable-osx-g5) enable_osx_g5="0";;
--enable-osx-g5) enable_osx_g5="2";;
--enable-osx-g5=*) enable_osx_g5="$optarg";;
2007-03-06 19:14:15 +00:00
--disable-unicode) enable_unicode="0";;
--enable-unicode) enable_unicode="2";;
--enable-unicode=*) enable_unicode="$optarg";;
2010-11-14 20:47:45 +00:00
--disable-console) enable_console="0";;
--enable-console) enable_console="2";;
--enable-console=*) enable_console="$optarg";;
2007-01-05 17:29:08 +00:00
2007-12-17 07:47:21 +00:00
--disable-cocoa-quartz) enable_cocoa_quartz="0";;
--enable-cocoa-quartz) enable_cocoa_quartz="2";;
--enable-cocoa-quartz=*) enable_cocoa_quartz="$optarg";;
2008-11-25 19:32:12 +00:00
--with-allegro) with_allegro="2";;
--without-allegro) with_allegro="0";;
--with-allegro=*) with_allegro="$optarg";;
2007-01-05 17:29:08 +00:00
--with-sdl) with_sdl="2";;
--without-sdl) with_sdl="0";;
--with-sdl=*) with_sdl="$optarg";;
--with-cocoa) with_cocoa="2";;
--without-cocoa) with_cocoa="0";;
--with-cocoa=*) with_cocoa="$optarg";;
--with-zlib) with_zlib="2";;
--without-zlib) with_zlib="0";;
--with-zlib=*) with_zlib="$optarg";;
2010-10-27 16:42:20 +00:00
--with-lzma) with_lzma="2";;
--without-lzma) with_lzma="0";;
--with-lzma=*) with_lzma="$optarg";;
--with-liblzma) with_lzma="2";;
--without-liblzma) with_lzma="0";;
--with-liblzma=*) with_lzma="$optarg";;
2010-01-10 13:12:34 +00:00
--with-lzo2) with_lzo2="2";;
--without-lzo2) with_lzo2="0";;
--with-lzo2=*) with_lzo2="$optarg";;
--with-liblzo2) with_lzo2="2";;
--without-liblzo2) with_lzo2="0";;
--with-liblzo2=*) with_lzo2="$optarg";;
2013-11-13 19:32:37 +00:00
--with-xdg-basedir) with_xdg_basedir="2";;
--without-xdg-basedir) with_xdg_basedir="0";;
--with-xdg-basedir=*) with_xdg_basedir="$optarg";;
--with-libxdg-basedir) with_xdg_basedir="2";;
--without-libxdg-basedir) with_xdg_basedir="0";;
--with-libxdg-basedir=*) with_xdg_basedir="$optarg";;
2019-10-09 19:57:28 +00:00
--with-fcitx) with_fcitx="2";;
--without-fcitx) with_fcitx="0";;
--with-fcitx=*) with_fcitx="$optarg";;
2007-01-05 17:29:08 +00:00
--with-png) with_png="2";;
--without-png) with_png="0";;
--with-png=*) with_png="$optarg";;
--with-libpng) with_png="2";;
--without-libpng) with_png="0";;
--with-libpng=*) with_png="$optarg";;
2018-09-11 23:06:31 +00:00
--with-fluidsynth) with_fluidsynth="2";;
--without-fluidsynth) with_fluidsynth="0";;
2019-01-15 01:21:48 +00:00
--with-fluidsynth=*) with_fluidsynth="$optarg";;
2018-09-11 23:06:31 +00:00
2007-01-05 17:29:08 +00:00
--with-freetype) with_freetype="2";;
--without-freetype) with_freetype="0";;
--with-freetype=*) with_freetype="$optarg";;
--with-libfreetype) with_freetype="2";;
--without-libfreetype) with_freetype="0";;
--with-libfreetype=*) with_freetype="$optarg";;
--with-fontconfig) with_fontconfig="2";;
--without-fontconfig) with_fontconfig="0";;
--with-fontconfig=*) with_fontconfig="$optarg";;
--with-libfontconfig) with_fontconfig="2";;
--without-libfontconfig) with_fontconfig="0";;
--with-libfontconfig=*) with_fontconfig="$optarg";;
2015-08-09 13:54:17 +00:00
--with-icu) with_icu_layout="2";with_icu_sort="2";;
--without-icu) with_icu_layout="0";with_icu_sort="0";;
--with-icu=*) with_icu_layout="$optarg";with_icu_sort="$optarg";;
--with-libicu) with_icu_layout="2";with_icu_sort="2";;
--without-libicu) with_icu_layout="0";with_icu_sort="0";;
--with-libicu=*) with_icu_layout="$optarg";with_icu_sort="$optarg";;
--with-icu-layout) with_icu_layout="2";;
--without-icu-layout) with_icu_layout="0";;
--with-icu-layout=*) with_icu_layout="$optarg";;
--with-icu-sort) with_icu_sort="2";;
--without-icu-sort) with_icu_sort="0";;
--with-icu-sort=*) with_icu_sort="$optarg";;
2009-11-17 18:01:05 +00:00
--static-icu) static_icu="1";;
--static-icu=*) static_icu="$optarg";;
--static-libicu) static_icu="1";;
--static-libicu=*) static_icu="$optarg";;
2008-10-17 17:14:09 +00:00
2018-06-25 17:39:59 +00:00
--with-uniscribe) with_uniscribe="2";;
--without-uniscribe) with_uniscribe="0";;
--with-uniscribe=*) with_uniscribe="$optarg";;
2009-05-14 21:59:24 +00:00
--disable-builtin-depend) enable_builtin_depend="0";;
--enable-builtin-depend) enable_builtin_depend="2";;
--enable-builtin-depend=*) enable_builtin_depend="$optarg";;
2007-01-05 17:29:08 +00:00
--with-makedepend) with_makedepend="2";;
--without-makedepend) with_makedepend="0";;
--with-makedepend=*) with_makedepend="$optarg";;
--with-direct-music) with_direct_music="2";;
--without-direct-music) with_direct_music="0";;
--with-direct-music=*) with_direct_music="$optarg";;
2018-04-09 22:18:45 +00:00
--with-xaudio2) with_xaudio2="2";;
--without-xaudio2) with_xaudio2="0";;
--with-xaudio2=*) with_xaudio2="$optarg";;
2007-01-05 17:29:08 +00:00
--with-sort) with_sort="2";;
--without-sort) with_sort="0";;
--with-sort=*) with_sort="$optarg";;
--with-iconv) with_iconv="2";;
--without-iconv) with_iconv="0";;
--with-iconv=*) with_iconv="$optarg";;
--with-midi=*) with_midi="$optarg";;
--with-midi-arg=*) with_midi_arg="$optarg";;
2007-06-11 10:01:03 +00:00
--without-distcc) with_distcc="0";;
--with-distcc) with_distcc="2";;
--with-distcc=*) with_distcc="$optarg";;
2007-06-16 21:57:30 +00:00
--without-ccache) with_ccache="0";;
--with-ccache) with_ccache="2";;
--with-ccache=*) with_ccache="$optarg";;
2011-12-05 20:11:42 +00:00
--without-nforenum) with_nforenum="0";;
--with-nforenum) with_nforenum="2";;
--with-nforenum=*) with_nforenum="$optarg";;
--without-grfcodec) with_grfcodec="0";;
--with-grfcodec) with_grfcodec="2";;
--with-grfcodec=*) with_grfcodec="$optarg";;
2007-01-05 17:29:08 +00:00
--without-osx-sysroot) with_osx_sysroot="0";;
--with-osx-sysroot) with_osx_sysroot="2";;
--with-osx-sysroot=*) with_osx_sysroot="$optarg";;
2007-04-20 19:41:19 +00:00
--without-application-bundle) with_application_bundle="0";;
--with-application-bundle) with_application_bundle="1";;
--with-application-bundle=*) with_application_bundle="$optarg";;
2007-01-05 17:29:08 +00:00
2007-07-20 18:34:21 +00:00
--without-threads) with_threads="0";;
--with-threads) with_threads="1";;
--with-threads=*) with_threads="$optarg";;
2014-01-02 08:35:45 +00:00
--without-sse) with_sse="0";;
--with-sse) with_sse="1";;
--with-sse=*) with_sse="$optarg";;
2015-09-09 19:19:26 +00:00
--without-libbfd) with_libbfd="0";;
--with-libbfd) with_libbfd="1";;
--with-libbfd=*) with_libbfd="$optarg";;
--without-bfd-extra-debug) with_bfd_extra_debug="0";;
--with-bfd-extra-debug) with_bfd_extra_debug="1";;
--with-bfd-extra-debug=*) with_bfd_extra_debug="$optarg";;
2016-06-10 18:55:28 +00:00
--without-self-gdb-debug) with_self_gdb_debug="0";;
--with-self-gdb-debug) with_self_gdb_debug="1";;
--with-self-gdb-debug=*) with_self_gdb_debug="$optarg";;
2016-03-10 00:08:34 +00:00
2019-04-18 17:30:09 +00:00
--without-self-lldb-debug) with_self_lldb_debug="0";;
--with-self-lldb-debug) with_self_lldb_debug="1";;
--with-self-lldb-debug=*) with_self_lldb_debug="$optarg";;
2019-11-05 17:59:11 +00:00
--without-sigaltstack) with_sigaltstack="0";;
--with-sigaltstack) with_sigaltstack="1";;
--with-sigaltstack=*) with_sigaltstack="$optarg";;
2007-01-05 17:29:08 +00:00
CC=* | --CC=*) CC="$optarg";;
CXX=* | --CXX=*) CXX="$optarg";;
CFLAGS=* | --CFLAGS=*) CFLAGS="$optarg";;
2009-09-07 21:01:24 +00:00
CXXFLAGS=* | --CXXFLAGS=*) CXXFLAGS="$optarg";;
2007-01-05 17:29:08 +00:00
LDFLAGS=* | --LDFLAGS=*) LDFLAGS="$optarg";;
2012-10-17 18:48:12 +00:00
CFLAGS_BUILD=* | --CFLAGS_BUILD=* | --CFLAGS-BUILD=*) CFLAGS_BUILD="$optarg";;
CXXFLAGS_BUILD=* | --CXXFLAGS_BUILD=* | --CXXFLAGS-BUILD=*) CXXFLAGS_BUILD="$optarg";;
LDFLAGS_BUILD=* | --LDFLAGS_BUILD=* | --LDFLAGS-BUILD=*) LDFLAGS_BUILD="$optarg";;
2017-08-27 16:07:24 +00:00
PKG_CONFIG_PATH=* | --PKG_CONFIG_PATH=* | --PKG-CONFIG-PATH=*) PKG_CONFIG_PATH="$optarg";;
PKG_CONFIG_LIBDIR=* | --PKG_CONFIG_LIBDIR=* | --PKG-CONFIG-LIBDIR=*) PKG_CONFIG_LIBDIR="$optarg";;
2007-01-05 17:29:08 +00:00
--ignore-extra-parameters) ignore_extra_parameters="1";;
2007-01-02 19:19:48 +00:00
2008-12-07 12:41:20 +00:00
--* | -*)
2007-01-07 09:48:10 +00:00
if [ "$ignore_extra_parameters" = "0" ]; then
2008-12-17 23:08:11 +00:00
log 1 "Unknown option $p"
2007-01-02 19:19:48 +00:00
exit 1
else
2008-12-17 23:08:11 +00:00
log 1 "Unknown option $p ignored"
2007-01-02 19:19:48 +00:00
fi
;;
esac
done
2007-01-07 09:48:10 +00:00
if [ -n "$prev_p" ]; then
2008-12-17 23:08:11 +00:00
log 1 "configure: error: missing argument to --$prev_p"
2007-01-02 19:19:48 +00:00
exit 1
fi
# Clean the logfile
echo "" > $config_log
2011-02-07 09:55:09 +00:00
log 2 "Invocation: $0 $*"
2016-06-10 18:57:51 +00:00
if [ "$ignore_extra_parameters" = "0" -o ! -f config.invocation ]; then
echo "$0 $*" > config.invocation
CONFIGURE_INVOCATION="$0 $*"
else
CONFIGURE_INVOCATION="`cat config.invocation`"
fi
2007-01-02 19:19:48 +00:00
}
save_params() {
# Here we save all params, so we can later on do an exact redo of this
# configuration, without having the user to re-input stuff
echo "Running configure with following options:" >> $config_log
echo "" >> $config_log
2007-03-06 23:42:30 +00:00
configure="$CONFIGURE_EXECUTABLE --ignore-extra-parameters"
2007-01-07 09:48:10 +00:00
for p in $save_params_array; do
2007-01-07 13:13:01 +00:00
eval "v=\"\$$p\""
2009-05-16 12:36:33 +00:00
p=`echo "$p" | sed 's@_@-@g;s@\n@@g;s@ @\\ @g'`
2007-01-02 19:19:48 +00:00
# Only save those params that aren't empty
2007-01-07 13:13:01 +00:00
configure="$configure --$p=\"$v\""
2007-01-02 19:19:48 +00:00
done
echo "$configure" >> $config_log
echo "$configure" > config.cache
echo "" >> $config_log
}
2017-08-27 16:07:24 +00:00
# Export a variable so tools like pkg-config can see it when invoked.
# If the variable contains an empty string then unset it.
# $1 - name of the variable to export or unset
export_or_unset() {
eval local value=\$$1
if [ -n "$value" ]; then
export $1;
log 2 "using $1=$value";
else
unset $1;
log 2 "not using $1";
fi
}
2007-01-02 19:19:48 +00:00
check_params() {
# Some params want to be in full uppercase, else they might not work as
# expected.. fix that here
2007-02-19 16:24:10 +00:00
os=`echo $os | tr '[a-z]' '[A-Z]'`
2007-06-17 20:36:14 +00:00
cpu_type=`echo $cpu_type | tr '[a-z]' '[A-Z]'`
2007-01-02 19:19:48 +00:00
2017-08-27 16:07:24 +00:00
# Export some variables to be used by pkg-config
#
2019-09-29 20:27:32 +00:00
# PKG_CONFIG_LIBDIR variable mustn't be set if we are not willing to
# override the default pkg-config search path, it mustn't be an empty
2017-08-27 16:07:24 +00:00
# string. If the variable is empty (e.g. when an empty string comes
# from config.cache) then unset it. This way the "don't override" state
# will be properly preserved when (re)configuring.
export_or_unset PKG_CONFIG_PATH
export_or_unset PKG_CONFIG_LIBDIR
2007-01-02 19:19:48 +00:00
# Check if all params have valid values
Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.
Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.
Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.
By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.
Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 21:23:09 +00:00
# OS only allows DETECT, UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, HAIKU, SUNOS, CYGWIN, MINGW, and OS2
if [ -z "`echo $os | egrep '^(DETECT|UNIX|OSX|FREEBSD|DRAGONFLY|OPENBSD|NETBSD|HPUX|HAIKU|SUNOS|CYGWIN|MINGW|OS2)$'`" ]; then
2008-12-17 23:08:11 +00:00
log 1 "configure: error: invalid option --os=$os"
Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.
Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.
Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.
By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.
Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 21:23:09 +00:00
log 1 " Available options are: --os=[DETECT|UNIX|OSX|FREEBSD|DRAGONFLY|OPENBSD|NETBSD|HPUX|HAIKU|SUNOS|CYGWIN|MINGW|OS2]"
2007-01-02 19:19:48 +00:00
exit 1
fi
2007-06-17 20:36:14 +00:00
# cpu_type can be either 32 or 64
2007-06-20 19:17:22 +00:00
if [ -z "`echo $cpu_type | egrep '^(32|64|DETECT)$'`" ]; then
2008-12-17 23:08:11 +00:00
log 1 "configure: error: invalid option --cpu-type=$cpu_type"
log 1 " Available options are: --cpu-type[=DETECT|32|64]"
2007-06-17 20:36:14 +00:00
exit 1
fi
2007-01-02 19:19:48 +00:00
# enable_debug should be between 0 and 4
2007-06-20 19:17:22 +00:00
if [ -z "`echo $enable_debug | egrep '^[0123]$'`" ]; then
2008-12-17 23:08:11 +00:00
log 1 "configure: error: invalid option --enable-debug=$enable_debug"
log 1 " Available options are: --enable-debug[=0123]"
2007-01-02 19:19:48 +00:00
exit 1
fi
2007-12-15 22:42:12 +00:00
# enable_desync_debug should be between 0 and 3
if [ -z "`echo $enable_desync_debug | egrep '^[012]$'`" ]; then
2008-12-17 23:08:11 +00:00
log 1 "configure: error: invalid option --enable-desync-debug=$enable_desync_debug"
log 1 " Available options are: --enable-desync-debug[=012]"
2007-12-15 22:42:12 +00:00
exit 1
fi
2007-02-19 19:59:19 +00:00
detect_awk
2008-04-24 20:07:12 +00:00
detect_os
2007-01-02 19:19:48 +00:00
check_build
check_host
2011-02-07 09:55:09 +00:00
# Check for universal builds; they only make sense for OSX, so fail if enabled for another OS
2007-01-07 09:48:10 +00:00
if [ "$enable_universal" = "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking universal build... no"
else
2010-11-14 22:57:32 +00:00
if [ "$os" != "OSX" ]; then
log 1 "configure: error: --enable-universal only works on OSX"
exit 1
2009-05-03 15:46:36 +00:00
fi
2010-11-14 22:57:32 +00:00
log 1 "checking universal build... yes, for: $enable_universal"
2007-01-02 19:19:48 +00:00
fi
# Already detected by check_build
2007-02-11 17:36:46 +00:00
log 1 "checking build cc... $cc_build"
log 1 "checking host cc... $cc_host"
2007-01-02 19:19:48 +00:00
2007-01-10 18:56:51 +00:00
check_cxx_build
check_cxx_host
2007-01-02 19:19:48 +00:00
check_windres
2007-02-19 20:10:46 +00:00
if [ "$enable_strip" != "0" ]; then
check_strip
else
log 1 "checking strip... disabled"
fi
2007-01-02 19:19:48 +00:00
check_lipo
2009-05-14 21:59:24 +00:00
if [ "$enable_builtin_depend" != "0" ]; then
log 1 "checking builtin depend... yes"
makedepend="\$(SRC_OBJS_DIR)/\$(DEPEND)"
else
log 1 "checking builtin depend... no"
fi
2007-01-02 19:19:48 +00:00
check_makedepend
2007-06-17 20:36:14 +00:00
detect_cputype
2014-01-02 08:35:45 +00:00
detect_sse_capable_architecture
2007-01-02 19:19:48 +00:00
2007-01-07 09:48:10 +00:00
if [ "$enable_static" = "1" ]; then
Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.
Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.
Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.
By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.
Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 21:23:09 +00:00
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
2007-01-02 19:19:48 +00:00
enable_static="2"
else
enable_static="0"
fi
fi
2007-01-07 09:48:10 +00:00
if [ "$enable_static" != "0" ]; then
2007-02-11 17:36:46 +00:00
log 1 "checking static... yes"
2007-01-02 19:19:48 +00:00
Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.
Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.
Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.
By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.
Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 21:23:09 +00:00
if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ] && [ "$os" != "OSX" ]; then
log 1 "WARNING: static is only known to work on Windows, and MacOSX"
2007-01-02 19:19:48 +00:00
log 1 "WARNING: use static at your own risk on this platform"
sleep 5
fi
else
2007-02-11 17:36:46 +00:00
log 1 "checking static... no"
2007-01-02 19:19:48 +00:00
fi
2007-03-06 19:14:15 +00:00
if [ "$enable_unicode" = "1" ]; then
Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.
Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.
Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.
By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.
Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 21:23:09 +00:00
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
2007-03-06 19:14:15 +00:00
enable_unicode="2"
else
enable_unicode="0"
fi
fi
if [ "$enable_unicode" != "0" ]; then
log 1 "checking unicode... yes"
else
log 1 "checking unicode... no"
fi
2007-01-02 19:19:48 +00:00
# Show what we configured
2007-01-07 09:48:10 +00:00
if [ "$enable_debug" = "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "using debug level... no"
2007-01-07 09:48:10 +00:00
elif [ "$enable_profiling" != "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "using debug level... profiling (debug level $enable_debug)"
else
log 1 "using debug level... level $enable_debug"
fi
2007-12-15 22:42:12 +00:00
if [ "$enable_desync_debug" = "0" ]; then
log 1 "using desync debug level... no"
else
log 1 "using desync debug level... level $enable_desync_debug"
log 1 "WARNING: desync debug functions slow down the game considerably."
log 1 "WARNING: use only when you are instructed to do so"
log 1 " or when you know what you are doing."
sleep 5
fi
2009-12-01 20:53:13 +00:00
if [ "$enable_lto" != "0" ]; then
2010-12-08 14:39:31 +00:00
# GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
has_lto=`($cxx_build -dumpspecs 2>&1 | grep '\%{flto') || ($cxx_build -help ipo 2>&1 | grep '\-ipo')`
2009-12-01 20:53:13 +00:00
if [ -n "$has_lto" ]; then
log 1 "using link time optimization... yes"
else
enable_lto="0"
log 1 "using link time optimization... no"
log 1 "WARNING: you selected link time optimization but it is not found."
sleep 5
fi
else
log 1 "using link time optimization... no"
fi
2009-10-04 20:53:26 +00:00
if [ "$os" != "OSX" ] && [ "$with_osx_sysroot" != "0" ]; then
if [ "$with_osx_sysroot" = "1" ]; then
with_osx_sysroot="0"
log 1 "checking OSX sysroot... not OSX, skipping"
else
log 1 "configure: error: --with-osx-sysroot only works if OSX is the target"
exit 1
fi
fi
if [ "$with_osx_sysroot" != "0" ]; then
if [ "$enable_universal" = "0" ] && [ "$with_osx_sysroot" != "1" ] && [ "$with_osx_sysroot" != "2" ]; then
# Sysroot manually specified? Check for usability
log 1 "checking OSX sysroot... $with_osx_sysroot"
if ! check_osx_sdk "$with_osx_sysroot"; then
log 1 "Passed sysroot not found/not functional"
exit 1
fi
else
# If autodetect and no universal, use system default
if [ "$with_osx_sysroot" = "1" ] && [ "$enable_universal" = "0" ]; then
log 1 "checking OSX sysroot... no (use system default)"
else
log 1 "checking OSX sysroot... automatically"
detect_osx_sdk
fi
fi
if [ -n "$osx_sdk_path" ]; then
if [ "$enable_universal" != "0" ]; then
if [ -z "$osx_sdk_104_path" ]; then
log 1 "WARNING: Could not find a usable 10.4u SDK, the resulting"
log 1 "WARNING: binary will only run on OSX 10.5 or later"
osx_sdk_104_path="$osx_sdk_path"
fi
OSX_SYSROOT="-isysroot $osx_sdk_104_path"
OSX_LD_SYSROOT="-Wl,-syslibroot,$osx_sdk_104_path"
else
OSX_SYSROOT="-isysroot $osx_sdk_path"
OSX_LD_SYSROOT="-Wl,-syslibroot,$osx_sdk_path"
fi
fi
else
if [ "$os" = "OSX" ]; then
log 1 "checking OSX sysroot... no (use system default)"
fi
fi
2008-11-25 19:32:12 +00:00
detect_allegro
2007-01-02 19:19:48 +00:00
detect_sdl
detect_cocoa
2007-01-07 09:48:10 +00:00
if [ "$enable_dedicated" != "0" ]; then
2008-10-19 20:53:13 +00:00
log 1 "checking GDI video driver... dedicated server, skipping"
2007-01-02 19:19:48 +00:00
log 1 "checking dedicated... found"
else
2018-04-29 12:21:31 +00:00
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking GDI video driver... found"
else
log 1 "checking GDI video driver... not Windows, skipping"
fi
2019-09-19 15:18:50 +00:00
if [ -z "$allegro_config" ] && [ -z "$sdl2_config" ] && [ -z "$sdl_config" ] && [ "$with_cocoa" = 0 ] && [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
2008-12-18 12:23:08 +00:00
log 1 "configure: error: no video driver development files found"
log 1 " If you want a dedicated server use --enable-dedicated as parameter"
exit 1
2007-01-02 19:19:48 +00:00
else
log 1 "checking dedicated... not selected"
fi
fi
2010-11-14 20:47:45 +00:00
if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
log 1 "checking console application... not Windows, skipping"
elif [ "$enable_console" = "1" ] && [ "$enable_dedicated" != "0" ]; then
log 1 "checking console application... dedicated server, enabled"
enable_console="2"
elif [ "$enable_console" = "1" ]; then
log 1 "checking console application... disabled (only used when forced)"
enable_console="0"
elif [ "$enable_console" = "0" ]; then
log 1 "checking console application... disabled"
else
log 1 "checking console application... enabled"
fi
2011-12-01 12:03:34 +00:00
log 1 "checking squirrel... found"
SCRIPT_SRC_DIR="$ROOT_DIR/src/3rdparty/squirrel/include"
2010-02-10 16:24:05 +00:00
2007-01-07 09:48:10 +00:00
if [ "$enable_translator" != "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking translator... debug"
# -t shows TODO items, normally they are muted
strgen_flags="-t"
2007-01-02 21:30:33 +00:00
else
log 1 "checking translator... no"
strgen_flags=""
2007-01-02 19:19:48 +00:00
fi
2007-01-07 09:48:10 +00:00
if [ "$enable_assert" != "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking assert... enabled"
else
log 1 "checking assert... disabled"
fi
2008-12-18 12:23:08 +00:00
pre_detect_with_zlib=$with_zlib
2007-01-02 19:19:48 +00:00
detect_zlib
2008-10-19 21:29:12 +00:00
2019-03-03 16:54:04 +00:00
if [ "$with_zlib" = "0" ] || [ -z "$zlib_config" ]; then
2008-10-19 21:29:12 +00:00
log 1 "WARNING: zlib was not detected or disabled"
2010-10-27 16:42:20 +00:00
log 1 "WARNING: OpenTTD doesn't require zlib, but it does mean that many features"
log 1 "WARNING: (like loading most old savegames/scenarios, loading heightmaps,"
log 1 "WARNING: using PNG, or using fonts, ...) will be disabled."
2008-12-18 12:23:08 +00:00
if [ "$pre_detect_with_zlib" = "0" ]; then
log 1 "WARNING: We strongly suggest you to install zlib."
else
log 1 "configure: error: no zlib detected"
log 1 " If you want to compile without zlib use --without-zlib as parameter"
exit
fi
2008-10-19 21:29:12 +00:00
fi
2010-10-27 16:42:20 +00:00
pre_detect_with_lzma=$with_lzma
detect_lzma
if [ "$with_lzma" = "0" ] || [ -z "$lzma_config" ]; then
log 1 "WARNING: lzma was not detected or disabled"
log 1 "WARNING: OpenTTD doesn't require lzma, but it does mean that many features"
log 1 "WARNING: (like loading most savegames/scenarios and joining most servers)"
log 1 "WARNING: will be disabled."
if [ "$pre_detect_with_lzma" = "0" ]; then
log 1 "WARNING: We strongly suggest you to install liblzma."
log 1 "configure: error: no liblzma detected"
else
log 1 " If you want to compile without lzma use --without-lzma as parameter"
exit
fi
fi
2010-01-10 13:12:34 +00:00
pre_detect_with_lzo2=$with_lzo2
detect_lzo2
if [ "$with_lzo2" = "0" ] || [ -z "$lzo2" ]; then
log 1 "WARNING: liblzo2 was not detected or disabled"
log 1 "WARNING: OpenTTD doesn't require liblzo2, but it does mean that"
log 1 "WARNING: loading old savegames/scenarios will be disabled."
if [ "$pre_detect_with_lzo2" = "0" ]; then
log 1 "WARNING: We strongly suggest you to install liblzo2."
else
log 1 "configure: error: no liblzo2 detected"
log 1 " If you want to compile without liblzo2 use --without-liblzo2 as parameter"
exit
fi
fi
2018-06-25 17:39:59 +00:00
if [ "$with_uniscribe" != "0" ]; then
if [ "$os" != "MINGW" ]; then
if [ "$with_uniscribe" != "1" ]; then
log 1 "configure: error: Uniscribe is only supported on native Win32 targets"
exit 1
fi
with_uniscribe="0"
log 1 "checking Uniscribe text layout... not Windows, skipping"
else
log 1 "checking Uniscribe text layout... found"
# Don't use ICU unless forced.
if [ "$with_icu_layout" = "1" ]; then
with_icu_layout="0"
fi
if [ "$with_icu_sort" = "1" ]; then
with_icu_sort="0"
fi
fi
fi
2013-11-13 19:32:37 +00:00
detect_xdg_basedir
2019-10-09 19:57:28 +00:00
detect_fcitx
2007-01-02 19:19:48 +00:00
detect_png
detect_freetype
detect_fontconfig
2015-08-09 13:54:17 +00:00
detect_icu_layout
detect_icu_sort
2018-09-11 23:06:31 +00:00
detect_fluidsynth
2007-01-02 19:19:48 +00:00
2008-11-29 22:40:54 +00:00
if [ "$with_direct_music" != "0" ]; then
2007-01-07 09:48:10 +00:00
if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
2008-11-29 22:40:54 +00:00
if [ "$with_direct_music" != "1" ]; then
2007-01-02 19:19:48 +00:00
log 1 "configure: error: direct-music is only supported on Win32 targets"
exit 1
fi
with_direct_music="0"
log 1 "checking direct-music... not Windows, skipping"
else
check_direct_music
fi
fi
2018-04-09 22:18:45 +00:00
if [ "$with_xaudio2" != "0" ]; then
if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
if [ "$with_xaudio2" != "1" ]; then
log 1 "configure: error: xaudio2 is only supported on Win32 targets"
exit 1
fi
with_xaudio2="0"
log 1 "checking xaudio2... not Windows, skipping"
else
check_xaudio2
fi
fi
2007-01-02 19:19:48 +00:00
detect_sort
# Suppress language errors when there is a version defined, indicating a release
# It just isn't pretty if any release produces warnings in the languages.
2007-01-07 09:48:10 +00:00
if [ -f "$ROOT_DIR/version" ]; then
2007-01-02 19:19:48 +00:00
lang_suppress="yes"
log 1 "suppress language errors... yes"
else
lang_suppress=""
log 1 "suppress language errors... no"
fi
2007-01-07 09:48:10 +00:00
if [ "$enable_debug" = "0" ] && [ "$enable_profiling" = "0" ] && [ "$enable_strip" != "0" ]; then
2019-03-04 18:21:13 +00:00
if [ "$os" = "OSX" ]; then
2007-01-02 19:19:48 +00:00
strip_arg=""
2007-01-07 13:00:56 +00:00
elif [ "$os" = "OS2" ]; then
strip_arg=""
# OS2 uses strip via gcc, because it needs to be feed to emxbind
LDFLAGS="$LDFLAGS -s"
2007-03-06 20:37:46 +00:00
elif [ "$os" = "SUNOS" ]; then
# The GNU strip does know -s, the non-GNU doesn't
# So try to detect it (in a bit of an ugly way)
strip_arg="`$strip -s strip.test 2>/dev/null && echo \"-s\"`"
2007-01-02 19:19:48 +00:00
else
strip_arg="-s"
fi
log 1 "checking stripping... $strip $strip_arg"
else
strip=""
log 1 "checking stripping... skipped"
fi
2007-06-11 10:01:03 +00:00
if [ "$with_distcc" = "0" ]; then
log 1 "checking distcc... no"
elif [ "$with_distcc" = "1" ]; then
with_distcc="0"
log 1 "checking distcc... no (only used when forced)"
elif [ "$with_distcc" = "2" ]; then
distcc="distcc"
else
distcc="$with_distcc"
fi
if [ "$with_distcc" != "0" ]; then
2008-01-24 23:56:43 +00:00
res="`$distcc --version 2>/dev/null | head -n 1 | cut -b 1-6`"
2007-06-11 10:01:03 +00:00
if [ "$res" != "distcc" ]; then
2007-06-11 10:29:07 +00:00
distcc=""
2007-06-11 10:01:03 +00:00
log 1 "checking distcc... no"
if [ "$with_distcc" = "2" ]; then
log 1 "configure: error: no distcc detected, but was forced to be used"
exit 1
fi
if [ "$with_distcc" != "1" ]; then
log 1 "configure: error: '$with_distcc' doesn't seem a distcc to me"
exit 1
fi
fi
log 1 "checking distcc... $distcc"
fi
2007-06-16 21:57:30 +00:00
if [ "$with_ccache" = "0" ]; then
log 1 "checking ccache... no"
elif [ "$with_ccache" = "1" ]; then
with_ccache="0"
log 1 "checking ccache... no (only used when forced)"
elif [ "$with_ccache" = "2" ]; then
ccache="ccache"
else
ccache="$with_ccache"
fi
if [ "$with_ccache" != "0" ]; then
2008-01-24 23:56:43 +00:00
res="`$ccache --version 2>/dev/null | head -n 1 | cut -b 1-6`"
2007-06-16 21:57:30 +00:00
if [ "$res" != "ccache" ]; then
ccache=""
log 1 "checking ccache... no"
if [ "$with_ccache" = "2" ]; then
log 1 "configure: error: no ccache detected, but was forced to be used"
exit 1
fi
if [ "$with_ccache" != "1" ]; then
log 1 "configure: error: '$with_ccache' doesn't seem a ccache to me"
exit 1
fi
fi
log 1 "checking ccache... $ccache"
fi
2011-12-05 20:11:42 +00:00
detect_grfcodec
detect_nforenum
if [ -z "$grfcodec" ] && [ -n "$nforenum" ]; then
log 1 "checking nforenum/grfcodec... nforenum needs grfcodec enabled, disabling nforenum"
nforenum=""
fi
if [ -z "$nforenum" ] && [ -n "$grfcodec" ]; then
log 1 "checking nforenum/grfcodec... grfcodec needs nforenum enabled, disabling grfcodec"
grfcodec=""
fi
2007-01-07 09:48:10 +00:00
if [ "$os" != "OSX" ] && [ "$with_application_bundle" != "0" ]; then
if [ "$with_application_bundle" = "1" ]; then
2007-01-02 19:19:48 +00:00
with_application_bundle="0"
log 1 "checking OSX application bundle... not OSX, skipping"
else
log 1 "configure: error: --with-application-bundle only works if OSX is the target"
exit 1
fi
fi
2007-01-07 09:48:10 +00:00
if [ "$os" = "OSX" ] && [ "$with_application_bundle" = "1" ]; then
2007-01-02 19:19:48 +00:00
OSXAPP="OpenTTD.app"
else
OSXAPP=""
fi
2007-01-07 09:48:10 +00:00
if [ "$os" = "OSX" ]; then
2010-11-14 22:57:32 +00:00
# Test on ppc970 (G5) - we can optimize there
2007-01-02 19:19:48 +00:00
2007-01-07 09:48:10 +00:00
if [ "$enable_osx_g5" != "0" ]; then
2010-11-14 22:57:32 +00:00
log 1 "detecting ppc970 (G5)... yes (forced)"
2007-01-02 19:19:48 +00:00
else
# First, are we a real OSX system, else we can't detect it
2007-02-19 16:24:10 +00:00
native=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | grep darwin`
2007-01-02 19:19:48 +00:00
# If $host doesn't match $build , we are cross-compiling
2008-07-22 17:18:53 +00:00
if [ -n "$native" ] && [ "$build" = "$host" ]; then
2007-03-15 23:26:47 +00:00
$cxx_build $SRC_DIR/os/macosx/G5_detector.cpp -o G5_detector
2007-01-02 19:19:48 +00:00
res=`./G5_detector`
rm -f G5_detector
2007-01-07 09:48:10 +00:00
if [ -n "$res" ]; then
2007-01-02 19:19:48 +00:00
# This is G5, add flags for it
enable_osx_g5="2"
2010-11-14 22:57:32 +00:00
log 1 "detecting ppc970 (G5)... yes"
2007-01-02 19:19:48 +00:00
else
enable_osx_g5="0"
2010-11-14 22:57:32 +00:00
log 1 "detecting ppc970 (G5)... no"
2007-01-02 19:19:48 +00:00
fi
else
enable_osx_g5="0"
2010-11-14 22:57:32 +00:00
log 1 "detecting ppc970 (G5)... no (cross-compiling)"
2007-01-02 19:19:48 +00:00
fi
fi
else
2007-01-07 09:48:10 +00:00
if [ "$enable_osx_g5" != "0" ]; then
2010-11-14 22:57:32 +00:00
log 1 "configure: error: ppc970 (OSX G5) selected, but not compiling for OSX"
log 1 "configure: error: either select OSX as OS, or deselect ppc970"
2007-01-02 19:19:48 +00:00
exit 1
fi
fi
2007-06-07 00:15:00 +00:00
2019-08-28 21:45:36 +00:00
if { [ -d "$ROOT_DIR/.git" ] || [ -f "$ROOT_DIR/.git" ]; } && [ -n "`git help 2>/dev/null`" ]; then
2015-12-09 23:54:58 +00:00
log 1 "checking revision... git detection"
elif [ -f "$ROOT_DIR/.ottdrev-vc" ]; then
log 1 "checking revision... source release version"
2010-11-29 13:09:35 +00:00
elif [ -f "$ROOT_DIR/.ottdrev" ]; then
log 1 "checking revision... source tarball"
2007-06-07 00:15:00 +00:00
else
2010-11-29 13:09:35 +00:00
log 1 "checking revision... no detection"
log 1 "WARNING: there is no means to determine the version."
log 1 "WARNING: please use a subversion, mercurial, or git checkout of OpenTTD."
log 1 "WARNING: you can only join game servers that have been compiled without"
log 1 "WARNING: version detection."
log 1 "WARNING: there is a great chance you desync."
log 1 "WARNING: USE WITH CAUTION!"
2007-06-07 00:15:00 +00:00
2010-11-29 13:09:35 +00:00
sleep 5
2007-06-07 00:15:00 +00:00
fi
2007-06-17 15:48:57 +00:00
2008-07-23 15:37:20 +00:00
if [ "$doc_dir" = "1" ]; then
2015-04-11 10:25:36 +00:00
if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
2008-07-23 15:37:20 +00:00
doc_dir="share/doc/openttd"
else
doc_dir="$data_dir/docs"
fi
2008-10-05 11:52:24 +00:00
else
2009-05-16 12:36:33 +00:00
doc_dir="`echo $doc_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
2008-07-23 15:37:20 +00:00
fi
if [ "$icon_theme_dir" = "1" ]; then
2015-04-11 10:25:36 +00:00
if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
2008-07-23 15:37:20 +00:00
icon_theme_dir="share/icons/hicolor"
else
icon_theme_dir=""
fi
2008-10-05 11:52:24 +00:00
else
2009-05-16 12:36:33 +00:00
icon_theme_dir="`echo $icon_theme_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
2008-07-23 15:37:20 +00:00
fi
2007-06-17 15:55:52 +00:00
if [ "$personal_dir" = "1" ]; then
Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.
Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.
Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.
By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.
Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 21:23:09 +00:00
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "HAIKU" ]; then
2007-06-17 15:48:57 +00:00
personal_dir="OpenTTD"
elif [ "$os" = "OSX" ]; then
personal_dir="Documents/OpenTTD"
else
personal_dir=".openttd"
fi
2008-10-05 11:52:24 +00:00
else
2009-05-16 12:36:33 +00:00
personal_dir="`echo $personal_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
2007-06-17 15:48:57 +00:00
fi
2008-01-13 17:45:29 +00:00
if [ "$shared_dir" = "1" ]; then
# we are using default values
if [ "$os" = "OSX" ]; then
2008-01-14 20:30:05 +00:00
shared_dir="/Library/Application\\\\ Support/OpenTTD"
2008-01-13 17:45:29 +00:00
else
shared_dir=""
fi
2008-10-05 11:52:24 +00:00
else
2009-05-16 12:36:33 +00:00
shared_dir="`echo $shared_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
2008-01-13 17:45:29 +00:00
fi
2008-07-23 15:37:20 +00:00
if [ "$man_dir" = "1" ]; then
# add manpage on UNIX systems
2015-04-11 10:25:36 +00:00
if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OSX" ]; then
2008-07-23 15:37:20 +00:00
man_dir="share/man/man6"
else
man_dir=""
fi
2008-10-05 11:52:24 +00:00
else
2009-05-16 12:36:33 +00:00
man_dir="`echo $man_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
2008-07-23 15:37:20 +00:00
fi
if [ "$menu_dir" = "1" ]; then
2008-07-22 23:11:40 +00:00
# add a freedesktop menu item only for some UNIX systems
2015-04-11 10:25:36 +00:00
if [ "$os" = "UNIX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ]; then
2008-07-22 23:11:40 +00:00
menu_dir="share/applications"
else
2008-07-23 15:37:20 +00:00
menu_dir=""
2008-07-22 23:11:40 +00:00
fi
2008-10-05 11:52:24 +00:00
else
2009-05-16 12:36:33 +00:00
menu_dir="`echo $menu_dir | sed 's@\([^\]\)\\\\ @\1\\\\\\\\ @g;s@\([^\]\) @\1\\\\\\\\ @g'`"
2008-07-22 23:11:40 +00:00
fi
2008-07-27 20:43:21 +00:00
detect_iconv
2007-06-17 15:48:57 +00:00
if [ -n "$personal_dir" ]
then
log 1 "personal home directory... $personal_dir"
else
log 1 "personal home directory... none"
fi
2008-01-13 17:45:29 +00:00
if [ -n "$shared_dir" ]
then
log 1 "shared data directory... $shared_dir"
else
log 1 "shared data directory... none"
fi
2007-06-17 15:48:57 +00:00
if [ -n "$install_dir" ]
then
log 1 "installation directory... $install_dir"
else
log 1 "installation directory... none"
fi
2008-07-22 22:36:07 +00:00
2008-07-23 15:37:20 +00:00
if [ -n "$icon_theme_dir" ]
then
log 1 "icon theme directory... $icon_theme_dir"
else
log 1 "icon theme directory... none"
fi
if [ -n "$man_dir" ]
then
2008-07-23 15:52:53 +00:00
log 1 "manual page directory... $man_dir"
2008-07-23 15:37:20 +00:00
else
log 1 "manual page directory... none"
fi
2008-07-22 23:11:40 +00:00
if [ -n "$menu_dir" ]
then
log 1 "menu item directory... $menu_dir"
else
log 1 "menu item directory... none"
2008-07-22 22:36:07 +00:00
fi
2007-01-02 19:19:48 +00:00
}
2009-06-22 20:38:10 +00:00
make_compiler_cflags() {
# Params:
# $1 - compiler
2010-09-03 14:14:06 +00:00
# $2 - name of the cflags variable
# $3 - name of the cxxflags variable
# $4 - name of the ldflags variable
# $5 - name of the features variable
2018-04-15 21:07:17 +00:00
# Get the compiler to tell us who it is
2018-05-10 00:05:40 +00:00
version_line="`$1 --version | head -n1`"
2018-04-11 11:35:25 +00:00
2010-09-03 14:14:06 +00:00
eval eval "flags=\\\$$2"
eval eval "cxxflags=\\\$$3"
eval eval "ldflags=\\\$$4"
eval eval "features=\\\$$5"
2009-06-22 20:38:10 +00:00
2019-01-13 23:23:36 +00:00
cppstd="-std=c++11"
2018-05-10 00:05:40 +00:00
if [ `echo "$version_line" | cut -d' ' -f1` = "icc" ]; then
2009-06-22 20:38:10 +00:00
# Enable some things only for certain ICC versions
2009-09-07 17:23:17 +00:00
cc_version=`$1 -dumpversion | cut -c 1-4 | sed s@\\\.@@g`
2009-06-22 20:38:10 +00:00
2009-09-07 12:14:45 +00:00
flags="$flags -rdynamic"
ldflags="$ldflags -rdynamic"
2009-06-22 20:38:10 +00:00
2010-11-21 16:34:18 +00:00
if [ -z "$first_time_icc_check" ]; then
first_time_icc_check=no
if [ $cc_version -lt 90 ]; then
2012-02-12 21:17:32 +00:00
log 1 "WARNING: you seem to be using a very old version of ICC"
2010-11-21 16:34:18 +00:00
log 1 "WARNING: OpenTTD hasn't been tested with this version"
sleep 5
elif [ $cc_version -lt 120 ]; then
2012-02-12 21:17:32 +00:00
log 1 "WARNING: you seem to be using an unsupported ICC version"
2010-11-21 16:34:18 +00:00
log 1 "WARNING: ICC older than 12.0 is known to fail to compile OpenTTD"
sleep 5
fi
2009-06-22 20:38:10 +00:00
fi
2010-11-21 16:34:18 +00:00
flags="$flags -Wall"
# remark #111: statement is unreachable
flags="$flags -wd111"
# remark #181: argument is incompatible with corresponding format string conversion
# ICC is very picky about signedness of operands, warnings provided by GCC are enough
flags="$flags -wd181"
# remark #271: trailing comma is nonstandard
flags="$flags -wd271"
# remark #280: selector expression is constant
flags="$flags -wd280"
# remark #304: access control not specified ("public" by default)
flags="$flags -wd304"
# remark #383: value copied to temporary, reference to temporary used
flags="$flags -wd383"
# remark #444: destructor for base class ... is not virtual
flags="$flags -wd444"
# remark #593: variable ... was set but never used
flags="$flags -wd593"
# warning #654: overloaded virtual function ... is only partially overridden in class ...
flags="$flags -wd654"
# remark #810: conversion from ... to ... may lose significant bits
flags="$flags -wd810"
# remark #869: parameter ... was never referenced
flags="$flags -wd869"
# warning #873: function ... ::operator new ... has no corresponding operator delete ...
flags="$flags -wd873"
# remark #981: operands are evaluated in unspecified order
flags="$flags -wd981"
# remark #1418: external function definition with no prior declaration
flags="$flags -wd1418"
# remark #1419: external declaration in primary source file
flags="$flags -wd1419"
# remark #1572: floating-point equality and inequality
flags="$flags -wd1572"
# remark #1599: declaration hides variable/parameter ...
flags="$flags -wd1599"
# remark #1720: function ... ::operator new ... has no corresponding member operator delete ...
flags="$flags -wd1720"
if [ $cc_version -lt 110 ]; then
# warns about system headers with recent glibc:
# warning #1292: attribute "__nonnull__" ignored
flags="$flags -wd1292"
fi
if [ $cc_version -ge 100 ]; then
# warning #1899: multicharacter character literal (potential portability problem)
flags="$flags -wd1899"
2009-06-22 20:38:10 +00:00
# vec report defaults to telling where it did loop vectorisation, which is not very important
2010-11-21 16:34:18 +00:00
flags="$flags -vec-report=0 "
fi
2009-09-07 21:01:24 +00:00
2010-11-21 16:34:18 +00:00
if [ $cc_version -ge 110 ]; then
# remark #2259: non-pointer conversion from ... to ... may lose significant bits
flags="$flags -wd2259"
2016-09-05 00:38:35 +00:00
fi
if [ $cc_version -lt 140 ]; then
log 1 "configure: error: ICC version is too old: `$1 -dumpversion`, minumum: 14.0"
exit 1
2009-06-22 20:38:10 +00:00
fi
2009-12-01 20:53:13 +00:00
2010-09-03 13:23:29 +00:00
if [ "$enable_lto" != "0" ]; then
has_ipo=`$1 -help ipo | grep '\-ipo'`
if [ -n "$has_ipo" ]; then
# Use IPO (only if we see IPO exists and is requested)
flags="$flags -ipo"
features="$features lto"
fi
2009-12-01 20:53:13 +00:00
fi
2018-05-10 00:05:40 +00:00
elif echo "$version_line" | grep -q "clang"; then
2012-02-12 21:17:32 +00:00
# Enable some things only for certain clang versions
2018-09-24 21:18:58 +00:00
# Need to try really hard to get the version line, because OSX clang likes to hide its true version
2019-01-13 22:55:51 +00:00
cc_version="`$1 -v 2>&1 | grep -i version | head -n 1 | sed s@[^0-9.]@@g | $awk -F . '{printf "%d%02d\n", $1, $2}'`"
2012-02-12 21:17:32 +00:00
# aliasing rules are not held in openttd code
flags="$flags -fno-strict-aliasing"
# -W alone doesn't enable all warnings enabled by -Wall; on the other hand,
# -Weverything enables too many useless warnings that can't be disabled (as of 3.0)
2016-09-05 19:11:01 +00:00
flags="$flags -Wall -W -Wextra"
2012-02-12 21:17:32 +00:00
# warning: unused parameter '...'
flags="$flags -Wno-unused-parameter"
# warning: expression result unused
flags="$flags -Wno-unused-value"
# warning: multi-character character constant
flags="$flags -Wno-multichar"
# warning: explicitly assigning a variable of type '...' to itself
# it happens when using the FOR_ALL_WINDOWS_FROM_BACK_FROM macro
flags="$flags -Wno-self-assign"
2019-03-24 12:35:19 +00:00
# warning: <something> is a C++11 extension
flags="$flags -Wno-c++11-extensions"
2019-01-13 22:55:51 +00:00
if [ "$cc_version" -lt "300" ]; then
2012-02-12 21:17:32 +00:00
# warning: equality comparison with extraneous parentheses
flags="$flags -Wno-parentheses"
# warning: operands of ? are integers of different signs: 'unsigned int' and 'int'
flags="$flags -Wno-sign-compare"
fi
2019-01-13 22:55:51 +00:00
if [ "$cc_version" -ge "300" ]; then
2012-02-12 21:17:32 +00:00
# warning: equality comparison with extraneous parentheses
# this warning could be useful, but it warns about code in squirrel
flags="$flags -Wno-parentheses-equality"
fi
if [ "$with_ccache" != "0" -o "$with_distcc" != "0" ]; then
# ccache and distcc run separate preprocess and compile passes,
# both are fed with the same CFLAGS. Unfortunately, clang
# complains about -I when compiling preprocessed files:
# "clang: warning: argument unused during compilation: '-I /usr/include'"
flags="$flags -Qunused-arguments"
fi
if [ "$enable_assert" -eq "0" ]; then
# do not warn about unused variables when building without asserts
flags="$flags -Wno-unused-variable"
fi
2019-10-11 18:13:04 +00:00
if [ "$cc_version" -lt "303" ]; then
2019-01-13 22:55:51 +00:00
log 1 "configure: error: clang version is too old: `$1 -v 2>&1 | grep -i version | head -n 1`, minumum: 3.3"
2016-09-05 00:38:35 +00:00
exit 1
2016-09-05 19:11:01 +00:00
fi
2012-02-12 21:17:32 +00:00
# rdynamic is used to get useful stack traces from crash reports.
ldflags="$ldflags -rdynamic"
2018-04-15 21:07:17 +00:00
# Assume gcc, since it just uses argv[0] in its --version output
2009-06-22 20:38:10 +00:00
else
# Enable some things only for certain GCC versions
2016-07-17 11:10:21 +00:00
# cc_version = major_version * 100 + minor_version
# For example: "3.3" -> 303, "4.9.2" -> 409, "6" -> 600, "23.5" -> 2305
cc_version=`$1 -dumpversion | $awk -F . '{printf "%d%02d", $1, $2}'`
2009-06-22 20:38:10 +00:00
2016-07-17 11:10:21 +00:00
if [ $cc_version -lt 303 ]; then
2010-02-12 18:45:34 +00:00
log 1 "configure: error: gcc older than 3.3 can't compile OpenTTD because of its poor template support"
2009-06-22 20:38:10 +00:00
exit 1
fi
flags="$flags -Wall -Wno-multichar -Wsign-compare -Wundef"
flags="$flags -Wwrite-strings -Wpointer-arith"
2012-07-22 05:33:09 +00:00
flags="$flags -W -Wno-unused-parameter -Wredundant-decls"
2012-07-22 18:55:12 +00:00
flags="$flags -Wformat=2 -Wformat-security"
2019-01-13 23:23:36 +00:00
cppstd="-std=gnu++11"
2009-06-22 20:38:10 +00:00
if [ $enable_assert -eq 0 ]; then
# Do not warn about unused variables when building without asserts
flags="$flags -Wno-unused-variable"
2016-07-17 11:10:21 +00:00
if [ $cc_version -ge 406 ]; then
2010-05-13 05:29:25 +00:00
# GCC 4.6 gives more warnings, disable them too
flags="$flags -Wno-unused-but-set-variable"
flags="$flags -Wno-unused-but-set-parameter"
fi
2009-06-22 20:38:10 +00:00
fi
2016-07-17 11:10:21 +00:00
if [ $cc_version -ge 304 ]; then
2010-10-31 14:25:57 +00:00
# Warn when a variable is used to initialise itself:
# int a = a;
flags="$flags -Winit-self"
fi
2016-07-17 11:10:21 +00:00
if [ $cc_version -ge 400 ]; then
2009-06-22 20:38:10 +00:00
# GCC 4.0+ complains about that we break strict-aliasing.
# On most places we don't see how to fix it, and it doesn't
# break anything. So disable strict-aliasing to make the
# compiler all happy.
flags="$flags -fno-strict-aliasing"
# Warn about casting-out 'const' with regular C-style cast.
# The preferred way is const_cast<>() which doesn't warn.
flags="$flags -Wcast-qual"
fi
2016-07-17 11:10:21 +00:00
if [ $cc_version -ge 402 ]; then
2009-06-22 20:38:10 +00:00
# GCC 4.2+ automatically assumes that signed overflows do
2019-09-29 20:27:32 +00:00
# not occur in signed arithmetic, whereas we are not
2009-06-22 20:38:10 +00:00
# sure that they will not happen. It furthermore complains
2010-04-12 14:12:47 +00:00
# about its own optimized code in some places.
2009-06-22 20:38:10 +00:00
flags="$flags -fno-strict-overflow"
2011-02-24 16:39:04 +00:00
# GCC 4.2 no longer includes -Wnon-virtual-dtor in -Wall.
# Enable it in order to be consistent with older GCC versions.
flags="$flags -Wnon-virtual-dtor"
2009-06-22 20:38:10 +00:00
fi
2009-09-07 12:14:45 +00:00
2016-07-17 11:10:21 +00:00
if [ $cc_version -eq 405 ]; then
2012-11-11 17:39:54 +00:00
# Prevent optimisation supposing enums are in a range specified by the standard
# For details, see http://gcc.gnu.org/PR43680
flags="$flags -fno-tree-vrp"
fi
2016-12-22 12:59:46 +00:00
if [ $cc_version -eq 407 ]; then
2011-08-07 11:18:33 +00:00
# Disable -Wnarrowing which gives many warnings, such as:
# warning: narrowing conversion of '...' from 'unsigned int' to 'int' inside { } [-Wnarrowing]
# They are valid according to the C++ standard, but useless.
cxxflags="$cxxflags -Wno-narrowing"
2016-12-25 13:26:15 +00:00
fi
if [ $cc_version -ge 407 ]; then
2011-08-24 18:21:54 +00:00
# Disable bogus 'attempt to free a non-heap object' warning
flags="$flags -Wno-free-nonheap-object"
2016-09-05 00:38:35 +00:00
else
log 1 "configure: error: GCC version is too old: `$1 -dumpversion`, minumum: 4.7"
exit 1
2011-08-07 11:18:33 +00:00
fi
2016-07-17 11:10:21 +00:00
if [ $cc_version -ge 600 ]; then
2016-05-31 19:33:33 +00:00
# -flifetime-dse=2 (default since GCC 6) doesn't play
# well with our custom pool item allocator
2018-11-25 11:27:08 +00:00
cxxflags="$cxxflags -flifetime-dse=1"
2016-05-31 19:33:33 +00:00
fi
2010-09-03 13:23:29 +00:00
if [ "$enable_lto" != "0" ]; then
2010-12-08 14:39:31 +00:00
# GCC 4.5 outputs '%{flto}', GCC 4.6 outputs '%{flto*}'
has_lto=`$1 -dumpspecs | grep '\%{flto'`
2010-09-03 13:23:29 +00:00
if [ -n "$has_lto" ]; then
2009-12-01 20:53:13 +00:00
# Use LTO only if we see LTO exists and is requested
2016-07-17 11:10:21 +00:00
if [ $cc_version -lt 406 ]; then
2010-12-29 20:46:35 +00:00
flags="$flags -flto"
else
flags="$flags -flto=jobserver"
fi
2010-12-29 20:20:41 +00:00
ldflags="$ldflags -fwhole-program"
2010-09-03 13:23:29 +00:00
features="$features lto"
2009-12-01 20:53:13 +00:00
fi
fi
2009-09-07 12:14:45 +00:00
has_rdynamic=`$1 -dumpspecs | grep rdynamic`
if [ -n "$has_rdynamic" ]; then
# rdynamic is used to get useful stack traces from crash reports.
flags="$flags -rdynamic"
ldflags="$ldflags -rdynamic"
fi
2009-06-22 20:38:10 +00:00
fi
2010-09-03 14:14:06 +00:00
eval "$2=\"$flags\""
2019-01-13 23:23:36 +00:00
eval "$3=\"$cxxflags $cppstd\""
2010-09-03 14:14:06 +00:00
eval "$4=\"$ldflags\""
eval "$5=\"$features\""
2009-06-22 20:38:10 +00:00
}
2015-09-14 22:00:45 +00:00
test_compile_libbfd() {
2018-05-06 11:02:11 +00:00
log 2 "executing $cc_host $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV -o tmp.config.bfd -x c++ - $1"
"$cc_host" $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV -o tmp.config.bfd -x c++ - $1 2> /dev/null << EOL
2015-09-14 22:00:45 +00:00
#define PACKAGE 1
#define PACKAGE_VERSION 1
#include <bfd.h>
#include <unistd.h>
int main() {
bfd_init();
bfd *abfd = bfd_openr("test", "test");
bfd_check_format(abfd, bfd_object);
bfd_get_file_flags(abfd);
bfd_map_over_sections(abfd, (void (*)(bfd*, asection*, void*)) 0, (void *) 0);
asymbol *syms = 0;
long symcount = bfd_read_minisymbols(abfd, false, (void**) &syms, (unsigned int *) 0);
bfd_get_section_flags(abfd, (asection*) 0);
bfd_get_section_vma(abfd, (asection*) 0);
bfd_section_size(abfd, (asection*) 0);
bfd_find_nearest_line(abfd, (asection*) 0, (asymbol **) 0, (bfd_vma) 0, (const char **) 0, (const char **) 0, (unsigned int *) 0);
return (int) symcount;
}
EOL
ret=$?
rm -f tmp.config.bfd
log 2 " exit code $ret"
return $ret
}
2007-01-02 19:19:48 +00:00
make_cflags_and_ldflags() {
# General CFlags for BUILD
2018-04-14 18:11:49 +00:00
CFLAGS_BUILD_ENV="$CFLAGS_BUILD"
CFLAGS_BUILD=""
2009-09-07 21:01:24 +00:00
# Special CXXFlags for BUILD
2018-04-14 18:11:49 +00:00
CXXFLAGS_BUILD_ENV="$CXXFLAGS_BUILD"
CXXFLAGS_BUILD=""
2009-09-07 21:01:24 +00:00
# LDFLAGS for BUILD
2018-04-14 18:11:49 +00:00
LDFLAGS_BUILD_ENV="$LDFLAGS_BUILD"
LDFLAGS_BUILD=""
2010-09-03 13:23:29 +00:00
# FEATURES for BUILD (lto)
FEATURES_BUILD=""
2007-01-02 19:19:48 +00:00
# General CFlags for HOST
2018-04-14 18:11:49 +00:00
CFLAGS_ENV="$CFLAGS"
CFLAGS=""
2009-09-07 21:01:24 +00:00
# Special CXXFlags for HOST
2018-04-14 18:11:49 +00:00
CXXFLAGS_ENV="$CXXFLAGS"
CXXFLAGS=""
2007-01-02 19:19:48 +00:00
# Libs to compile. In fact this is just LDFLAGS
2019-01-16 19:28:52 +00:00
LIBS=""
2007-01-02 19:19:48 +00:00
# LDFLAGS used for HOST
2018-04-14 18:11:49 +00:00
LDFLAGS_ENV="$LDFLAGS"
LDFLAGS=""
2010-09-03 13:23:29 +00:00
# FEATURES for HOST (lto)
FEATURES=""
2007-01-02 19:19:48 +00:00
2010-09-03 14:14:06 +00:00
make_compiler_cflags "$cc_build" "CFLAGS_BUILD" "CXXFLAGS_BUILD" "LDFLAGS_BUILD" "FEATURES_BUILD"
make_compiler_cflags "$cc_host" "CFLAGS" "CXXFLAGS" "LDFLAGS" "FEATURES"
2009-12-01 20:53:13 +00:00
CFLAGS="$CFLAGS -D$os"
2014-09-19 09:28:23 +00:00
CFLAGS_BUILD="$CFLAGS_BUILD -D$os"
2009-12-01 20:53:13 +00:00
2015-12-23 00:45:37 +00:00
if [ "$enable_static" != "0" ]; then
STATIC_FLAGS="--static"
else
STATIC_FLAGS=""
fi
2010-09-03 13:23:29 +00:00
if [ "$enable_debug" = "0" ]; then
2007-01-02 19:19:48 +00:00
# No debug, add default stuff
2007-01-06 22:58:01 +00:00
OBJS_SUBDIR="release"
2010-11-11 22:37:45 +00:00
2014-08-16 10:31:24 +00:00
if [ "$enable_profiling" = "0" ]; then
2014-08-16 10:17:18 +00:00
# -fomit-frame-pointer and -pg do not go well together (gcc errors they are incompatible)
CFLAGS="-fomit-frame-pointer $CFLAGS"
fi
CFLAGS="-O2 $CFLAGS"
2007-01-06 22:58:01 +00:00
else
OBJS_SUBDIR="debug"
2007-01-02 19:19:48 +00:00
2008-08-29 09:46:29 +00:00
# Each debug level reduces the optimization by a bit
2007-01-07 09:48:10 +00:00
if [ $enable_debug -ge 1 ]; then
2010-09-03 13:09:56 +00:00
CFLAGS="$CFLAGS -g -D_DEBUG"
2007-01-02 19:19:48 +00:00
fi
2007-01-07 09:48:10 +00:00
if [ $enable_debug -ge 2 ]; then
2007-01-06 22:58:01 +00:00
CFLAGS="$CFLAGS -fno-inline"
2007-01-02 19:19:48 +00:00
fi
2007-01-07 09:48:10 +00:00
if [ $enable_debug -ge 3 ]; then
2007-01-06 22:58:01 +00:00
CFLAGS="$CFLAGS -O0"
else
CFLAGS="$CFLAGS -O2"
fi
fi
2012-07-22 05:33:09 +00:00
if [ $enable_debug -le 2 ]; then
2016-05-11 18:38:44 +00:00
cc_host_is_gcc=`basename "$cc_host" | grep "gcc" 2>/dev/null`
2013-11-09 07:15:01 +00:00
if [ -n "$cc_host_is_gcc" ]; then
2012-07-22 05:33:09 +00:00
# Define only when compiling with GCC. Some GLIBC versions use GNU
# extensions in a way that breaks build with at least ICC.
# This requires -O1 or more, so debug level 3 (-O0) is excluded.
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
2019-12-14 18:08:30 +00:00
if [ "$os" = "MINGW" ]; then
# Prevent undefined references when _FORTIFY_SOURCE > 0
LDFLAGS="$LDFLAGS -fstack-protector"
fi
2013-11-09 07:15:01 +00:00
fi
2012-07-22 05:33:09 +00:00
2016-05-11 18:38:44 +00:00
cc_build_is_gcc=`basename "$cc_build" | grep "gcc" 2>/dev/null`
2013-11-09 07:15:01 +00:00
if [ -n "$cc_build_is_gcc" ]; then
2016-09-08 18:31:40 +00:00
# Add -O1 and fortify source to the tools needed for building, on gcc
2012-07-22 05:33:09 +00:00
CFLAGS_BUILD="$CFLAGS_BUILD -D_FORTIFY_SOURCE=2 -O1"
2019-12-14 18:08:30 +00:00
if [ "$os" = "MINGW" ]; then
# Prevent undefined references when _FORTIFY_SOURCE > 0
LDFLAGS_BUILD="$LDFLAGS_BUILD -fstack-protector"
fi
2016-09-08 18:31:40 +00:00
elif [ -n "`basename "$cc_build" | grep "clang" 2>/dev/null`" ]; then
# Add -O1 to the tools needed for building, on clang
CFLAGS_BUILD="$CFLAGS_BUILD -O1"
2012-07-22 05:33:09 +00:00
fi
fi
2016-07-17 11:10:21 +00:00
if [ "$os" = "OSX" ] && [ $cc_version -eq 400 ]; then
2010-11-11 22:37:45 +00:00
# Apple's GCC 4.0 has a compiler bug for x86_64 with (higher) optimization,
# wrongly optimizing ^= in loops. This disables the failing optimisation.
CFLAGS="$CFLAGS -fno-expensive-optimizations"
fi
2007-01-07 09:48:10 +00:00
if [ "$enable_profiling" != "0" ]; then
2014-08-16 10:17:18 +00:00
CFLAGS="$CFLAGS -pg"
2007-01-06 22:58:01 +00:00
LDFLAGS="$LDFLAGS -pg"
2007-01-02 19:19:48 +00:00
fi
2007-07-20 18:34:21 +00:00
if [ "$with_threads" = "0" ]; then
CFLAGS="$CFLAGS -DNO_THREADS"
fi
2014-01-02 08:35:45 +00:00
if [ "$with_sse" = "1" ]; then
CFLAGS="$CFLAGS -DWITH_SSE"
fi
2007-07-20 18:34:21 +00:00
2009-06-22 20:38:10 +00:00
if [ "`echo $1 | cut -c 1-3`" != "icc" ]; then
2007-12-30 19:32:09 +00:00
if [ "$os" = "CYGWIN" ]; then
2009-06-22 20:38:10 +00:00
flags="$flags -mwin32"
2007-12-30 19:32:09 +00:00
LDFLAGS="$LDFLAGS -mwin32"
fi
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
2016-07-17 11:10:21 +00:00
if [ $cc_version -lt 406 ]; then
2013-05-19 15:44:09 +00:00
flags="$flags -mno-cygwin"
LDFLAGS="$LDFLAGS -mno-cygwin"
fi
2010-11-14 20:47:45 +00:00
if [ "$enable_console" != "0" ]; then
2013-05-19 15:44:09 +00:00
LDFLAGS="$LDFLAGS -Wl,--subsystem,console"
2010-11-14 20:47:45 +00:00
else
2013-05-19 15:44:09 +00:00
LDFLAGS="$LDFLAGS -Wl,--subsystem,windows"
2010-11-14 20:47:45 +00:00
fi
2019-10-06 01:37:45 +00:00
LIBS="$LIBS -lws2_32 -lwinmm -lusp10 -lgdi32 -ldxguid -lole32 -limm32"
2009-08-21 21:21:09 +00:00
2016-07-24 09:13:51 +00:00
if [ $cc_version -ge 404 ]; then
2011-03-04 00:27:17 +00:00
LDFLAGS_BUILD="$LDFLAGS_BUILD -static-libgcc -static-libstdc++"
2009-08-21 21:21:09 +00:00
fi
2016-07-17 11:10:21 +00:00
if [ $cc_version -ge 407 ]; then
2012-10-04 15:44:09 +00:00
CFLAGS="$CFLAGS -mno-ms-bitfields"
fi
2007-12-30 19:32:09 +00:00
fi
2007-12-23 21:02:40 +00:00
fi
Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.
Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.
Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.
By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.
Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 21:23:09 +00:00
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "OPENBSD" ] && [ "$os" != "MINGW" ] && [ "$os" != "OSX" ] && [ "$os" != "OS2" ]; then
2007-01-02 19:19:48 +00:00
LIBS="$LIBS -lpthread"
fi
2015-09-07 23:49:34 +00:00
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
2018-05-06 11:02:11 +00:00
log 2 "executing $cc_host $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV -o tmp.config.libdl -x c++ - -ldl"
"$cc_host" $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV -o tmp.config.libdl -x c++ - -ldl 2> /dev/null << EOL
2015-09-07 23:49:34 +00:00
#include <dlfcn.h>
int main() {
Dl_info info;
return dladdr(0, &info);
}
EOL
2015-09-14 22:00:45 +00:00
ret=$?
rm -f tmp.config.libdl
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
2015-09-07 23:49:34 +00:00
log 1 "checking libdl... no"
else
log 1 "checking libdl... found"
LIBS="$LIBS -ldl"
CFLAGS="$CFLAGS -DWITH_DL"
fi
2016-03-10 00:08:34 +00:00
LIBBFD_LIBS=
2015-09-09 19:19:26 +00:00
if [ "$with_libbfd" = "1" ]; then
2015-09-14 22:00:45 +00:00
if test_compile_libbfd "-lbfd -lz"; then
LIBBFD_LIBS="-lbfd -lz"
elif test_compile_libbfd "-lbfd -liberty -lz"; then
LIBBFD_LIBS="-lbfd -liberty -lz"
elif test_compile_libbfd "-lbfd -liberty -lintl -lz"; then
LIBBFD_LIBS="-lbfd -liberty -lintl -lz"
fi
if [ -n "$LIBBFD_LIBS" ]; then
2015-09-09 19:19:26 +00:00
log 1 "checking libbfd... found"
2015-09-14 22:00:45 +00:00
LIBS="$LIBS $LIBBFD_LIBS"
2015-09-09 19:19:26 +00:00
CFLAGS="$CFLAGS -DWITH_BFD"
2015-09-14 22:00:45 +00:00
else
log 1 "checking libbfd... no"
2015-09-08 19:30:06 +00:00
fi
2019-11-05 17:55:13 +00:00
else
log 1 "checking libbfd... disabled"
2015-09-08 19:29:39 +00:00
fi
2016-03-10 00:08:34 +00:00
HAVE_GDB_DBG=
2016-06-10 18:55:28 +00:00
if [ "$with_self_gdb_debug" = "1" ]; then
2018-05-06 11:02:11 +00:00
log 2 "executing $cc_host $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.dbggdb -x c++ -"
"$cc_host" $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.dbggdb -x c++ - 2> /dev/null << EOL
2016-03-10 00:08:34 +00:00
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
int main() {
pid_t tid = syscall(SYS_gettid);
int status;
waitpid((pid_t) 0, &status, 0);
return WIFEXITED(status) && WEXITSTATUS(status);
}
EOL
ret=$?
rm -f tmp.config.dbggdb
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
log 1 "checking dbg gdb... no"
else
log 1 "checking dbg gdb... found"
CFLAGS="$CFLAGS -DWITH_DBG_GDB"
HAVE_GDB_DBG=1
2018-05-06 11:02:11 +00:00
log 2 "executing $cc_host $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.dbggdbprctl -x c++ -"
"$cc_host" $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.dbggdbprctl -x c++ - 2> /dev/null << EOL
2016-03-10 00:08:34 +00:00
#include <sys/prctl.h>
int main() {
return prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
}
EOL
ret=$?
rm -f tmp.config.dbggdbprctl
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
log 1 "checking dbg gdb (prctl)... no"
else
log 1 "checking dbg gdb (prctl)... found"
CFLAGS="$CFLAGS -DWITH_PRCTL_PT"
fi
fi
2019-11-05 17:55:13 +00:00
else
log 1 "checking dbg gdb... disabled"
2016-03-10 00:08:34 +00:00
fi
if [ -n "$LIBBFD_LIBS" -o -n "$HAVE_GDB_DBG" ]; then
if [ $enable_debug -lt 1 ] && [ "$with_bfd_extra_debug" = "1" ]; then
2016-09-08 18:38:13 +00:00
if [ -n "`basename "$cc_host" | grep "clang" 2>/dev/null`" ]; then
CFLAGS="$CFLAGS -gline-tables-only"
else
CFLAGS="$CFLAGS -g1"
fi
2016-03-10 00:08:34 +00:00
fi
fi
2016-06-10 18:29:43 +00:00
2018-05-06 11:02:11 +00:00
log 2 "executing $cc_host $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.sigaction -x c++ - -ldl"
"$cc_host" $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.sigaction -x c++ - -ldl 2> /dev/null << EOL
2016-06-10 18:29:43 +00:00
#include <signal.h>
void *addr;
int code;
void handler(int sig, siginfo_t *si, void *context) {
addr = si->si_addr;
code = si->si_code;
}
int main() {
struct sigaction sa;
sa.sa_flags = SA_SIGINFO;
sigemptyset(&sa.sa_mask);
sa.sa_sigaction = handler;
sigaction(SIGSEGV, &sa, 0);
return 0;
}
EOL
ret=$?
rm -f tmp.config.sigaction
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
log 1 "checking sigaction... no"
else
log 1 "checking sigaction... found"
CFLAGS="$CFLAGS -DWITH_SIGACTION"
fi
2016-06-12 18:34:06 +00:00
2018-05-06 11:02:11 +00:00
log 2 "executing $cc_host $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.ucontext -x c++ - -ldl"
"$cc_host" $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.ucontext -x c++ - -ldl 2> /dev/null << EOL
2016-06-12 18:34:06 +00:00
#include <ucontext.h>
int main() {
ucontext_t context;
#if defined(__x86_64__)
void *ptr = (void *) context.uc_mcontext.gregs[REG_RIP];
#elif defined(__i386)
void *ptr = (void *) context.uc_mcontext.gregs[REG_EIP];
#else
#error Unknown arch
#endif
return 0;
}
EOL
ret=$?
rm -f tmp.config.ucontext
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
log 1 "checking ucontext... no"
else
log 1 "checking ucontext... found"
CFLAGS="$CFLAGS -DWITH_UCONTEXT"
fi
2019-04-23 17:41:20 +00:00
2019-11-05 17:59:11 +00:00
if [ "$with_sigaltstack" = "1" ]; then
log 2 "executing $cc_host $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.sigaltstack -x c++ - -ldl"
"$cc_host" $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.sigaltstack -x c++ - -ldl 2> /dev/null << EOL
#include <signal.h>
#include <stdlib.h>
int main() {
stack_t ss;
ss.ss_sp = calloc(SIGSTKSZ, 1);
ss.ss_size = SIGSTKSZ;
ss.ss_flags = 0;
sigaltstack(&ss, nullptr);
return 0;
}
2019-04-23 17:41:20 +00:00
EOL
2019-11-05 17:59:11 +00:00
ret=$?
rm -f tmp.config.sigaltstack
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
log 1 "checking sigaltstack... no"
else
log 1 "checking sigaltstack... found"
CFLAGS="$CFLAGS -DWITH_SIGALTSTACK"
fi
2019-04-23 17:41:20 +00:00
else
2019-11-05 17:59:11 +00:00
log 1 "checking sigaltstack... disabled"
2019-04-23 17:41:20 +00:00
fi
2015-09-07 23:49:34 +00:00
fi
2007-01-02 19:19:48 +00:00
2015-09-08 23:09:07 +00:00
if [ "$os" = "MINGW" ]; then
2018-05-06 11:02:11 +00:00
log 2 "executing $cc_host $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV -o tmp.config.dbghelp -x c++ -"
"$cc_host" $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV -o tmp.config.dbghelp -x c++ - 2> /dev/null << EOL
2015-09-08 23:09:07 +00:00
#include <windows.h>
#include <dbghelp.h>
int main() {
STACKFRAME64 frame;
IMAGEHLP_SYMBOL64 *sym_info;
IMAGEHLP_MODULE64 module;
IMAGEHLP_LINE64 line;
return 0;
}
EOL
2015-09-14 22:00:45 +00:00
ret=$?
rm -f tmp.config.dbghelp
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
2015-09-08 23:09:07 +00:00
log 1 "checking dbghelp... no"
else
log 1 "checking dbghelp... found"
CFLAGS="$CFLAGS -DWITH_DBGHELP"
2015-09-09 01:14:06 +00:00
2015-09-09 19:19:26 +00:00
if [ "$with_libbfd" = "1" ]; then
2015-09-14 22:00:45 +00:00
test_compile_libbfd "-lbfd -liberty -lintl -lz"
2015-09-09 19:19:26 +00:00
if [ $? -ne 0 ]; then
log 1 "checking libbfd... no"
else
log 1 "checking libbfd... found"
2015-09-14 22:00:45 +00:00
LIBS="$LIBS -lbfd -liberty -lintl -lz"
2015-09-09 19:19:26 +00:00
CFLAGS="$CFLAGS -DWITH_BFD"
2015-09-09 01:14:06 +00:00
2015-09-09 19:19:26 +00:00
if [ $enable_debug -lt 1 ] && [ "$with_bfd_extra_debug" = "1" ]; then
CFLAGS="$CFLAGS -g1"
fi
2015-09-09 01:14:06 +00:00
fi
2019-11-05 17:55:13 +00:00
else
log 1 "checking libbfd... disabled"
2015-09-09 01:14:06 +00:00
fi
2015-09-08 23:09:07 +00:00
fi
fi
2016-09-04 17:01:38 +00:00
log 2 "executing $cc_host $CFLAGS $LDFLAGS $STATIC_FLAGS -o tmp.config.bitmath-builtins -x c++ -"
"$cc_host" $CFLAGS $LDFLAGS $STATIC_FLAGS -o tmp.config.bitmath-builtins -x c++ - 2> /dev/null << EOL
int main() {
return __builtin_popcountll(__builtin_popcountl(__builtin_popcount(__builtin_ctz(1))));
}
EOL
ret=$?
rm -f tmp.config.bitmath-builtins
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
log 1 "checking bitmath builtins... no"
else
log 1 "checking bitmath builtins... found"
CFLAGS="$CFLAGS -DWITH_BITMATH_BUILTINS"
fi
2020-04-20 20:48:04 +00:00
log 2 "executing $cc_host $CFLAGS $LDFLAGS $STATIC_FLAGS -o tmp.config.overflow-builtins -x c++ -"
"$cc_host" $CFLAGS $LDFLAGS $STATIC_FLAGS -o tmp.config.overflow-builtins -x c++ - 2> /dev/null << EOL
#include <cstdint>
int main() {
int64_t a = 0;
int64_t b = 0;
int64_t c = 0;
bool res1 = __builtin_add_overflow(a, b, &c);
bool res2 = __builtin_sub_overflow(a, b, &c);
bool res3 = __builtin_mul_overflow(a, b, &c);
return (res1 || res2 || res3) ? 1 : 0;
}
EOL
ret=$?
rm -f tmp.config.overflow-builtins
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
log 1 "checking overflow builtins... no"
else
log 1 "checking overflow builtins... found"
CFLAGS="$CFLAGS -DWITH_OVERFLOW_BUILTINS"
fi
2015-09-09 01:14:06 +00:00
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MORPHOS" ] && [ "$os" != "OSX" ] && [ "$os" != "DOS" ] && [ "$os" != "WINCE" ] && [ "$os" != "PSP" ] && [ "$os" != "OS2" ]; then
2018-05-06 11:02:11 +00:00
log 2 "executing $cc_host $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV -o tmp.config.demangle -x c++ - -lstdc++"
"$cc_host" $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV -o tmp.config.demangle -x c++ - -lstdc++ 2> /dev/null << EOL
2015-09-09 01:14:06 +00:00
#include <cxxabi.h>
int main() {
int status = -1;
char *demangled = abi::__cxa_demangle("test", 0, 0, &status);
return 0;
}
EOL
2015-09-14 22:00:45 +00:00
ret=$?
rm -f tmp.config.demangle
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
2015-09-09 01:14:06 +00:00
log 1 "checking abi::__cxa_demangle... no"
else
log 1 "checking abi::__cxa_demangle... found"
CFLAGS="$CFLAGS -DWITH_DEMANGLE"
fi
fi
Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.
Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.
Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.
By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.
Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 21:23:09 +00:00
if [ "$os" != "CYGWIN" ] && [ "$os" != "HAIKU" ] && [ "$os" != "MINGW" ]; then
2007-01-02 19:19:48 +00:00
LIBS="$LIBS -lc"
fi
2007-05-23 16:40:40 +00:00
if [ "$os" = "OPENBSD" ]; then
LIBS="$LIBS -pthread"
fi
2007-01-07 09:48:10 +00:00
if [ "$os" = "OSX" ]; then
2007-01-02 19:19:48 +00:00
LDFLAGS="$LDFLAGS -framework Cocoa"
2010-04-14 10:00:57 +00:00
# Add macports include dir which is not always set a default system dir. This avoids zillions of bogus warnings.
CFLAGS="$CFLAGS -isystem/opt/local/include"
2009-10-04 20:53:26 +00:00
if [ "$enable_universal" = "0" ]; then
# Universal builds set this elsewhere
CFLAGS="$OSX_SYSROOT $CFLAGS"
LDFLAGS="$OSX_LD_SYSROOT $LDFLAGS"
fi
2019-04-18 17:30:09 +00:00
if [ "$with_self_lldb_debug" = "0" ]; then
2019-11-05 17:55:13 +00:00
log 1 "using dbg lldb... disabled"
2019-04-18 17:30:09 +00:00
CFLAGS="$CFLAGS -DWITHOUT_DBG_LLDB"
else
log 1 "using dbg lldb... yes"
if [ $enable_debug -lt 1 ]; then
if [ -n "`"$cc_host" --version | head -n1 | grep "clang" 2>/dev/null`" ]; then
CFLAGS="$CFLAGS -gline-tables-only"
else
CFLAGS="$CFLAGS -g1"
fi
fi
fi
2019-04-23 17:04:08 +00:00
log 2 "executing $cc_host $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.ucontext -x c++ - -ldl"
"$cc_host" $CFLAGS $CFLAGS_ENV $LDFLAGS $LDFLAGS_ENV $STATIC_FLAGS -o tmp.config.ucontext -x c++ - -ldl 2> /dev/null << EOL
#include <sys/ucontext.h>
int main() {
ucontext_t context;
#if defined(__x86_64__)
void *ptr = (void *) context.uc_mcontext->__ss.__rip;
#elif defined(__i386)
void *ptr = (void *) context.uc_mcontext->__ss.__rip;
#else
#error Unknown arch
#endif
return 0;
}
EOL
ret=$?
rm -f tmp.config.ucontext
log 2 " exit code $ret"
if [ $ret -ne 0 ]; then
log 1 "checking ucontext... no"
else
log 1 "checking ucontext... found"
CFLAGS="$CFLAGS -DWITH_UCONTEXT"
fi
2019-11-05 18:02:06 +00:00
# workaround for issues with MacOS 10.15 Catalina and stack_not_16_byte_aligned_error issues
CFLAGS="$CFLAGS -fno-stack-check"
2007-01-02 19:19:48 +00:00
fi
2019-03-04 18:46:11 +00:00
if [ "$os" = "HAIKU" ]; then
2007-01-02 19:19:48 +00:00
LIBS="$LIBS -lmidi -lbe"
fi
# Most targets act like UNIX, just with some additions
2019-03-04 18:46:11 +00:00
if [ "$os" = "HAIKU" ] || [ "$os" = "OSX" ] || [ "$os" = "FREEBSD" ] || [ "$os" = "DRAGONFLY" ] || [ "$os" = "OPENBSD" ] || [ "$os" = "NETBSD" ] || [ "$os" = "HPUX" ] || [ "$os" = "SUNOS" ] || [ "$os" = "OS2" ]; then
2007-01-02 19:19:48 +00:00
CFLAGS="$CFLAGS -DUNIX"
fi
# And others like Windows
2018-04-29 12:21:31 +00:00
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
2007-01-02 19:19:48 +00:00
CFLAGS="$CFLAGS -DWIN"
fi
2008-11-25 19:32:12 +00:00
if [ -n "$allegro_config" ]; then
CFLAGS="$CFLAGS -DWITH_ALLEGRO"
CFLAGS="$CFLAGS `$allegro_config --cflags`"
2018-04-29 12:21:31 +00:00
if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
2008-11-25 19:32:12 +00:00
if [ "$enable_static" != "0" ]; then
LIBS="$LIBS `$allegro_config --static --libs`"
else
LIBS="$LIBS `$allegro_config --libs`"
fi
fi
fi
2019-09-19 15:18:50 +00:00
if [ -n "$sdl2_config" ]; then
CFLAGS="$CFLAGS -DWITH_SDL2"
# SDL must not add _GNU_SOURCE as it breaks many platforms
CFLAGS="$CFLAGS `$sdl2_config --cflags | sed 's@-D_GNU_SOURCE[^ ]*@@'`"
if [ "$enable_static" != "0" ]; then
LIBS="$LIBS `$sdl2_config --static --libs`"
else
LIBS="$LIBS `$sdl2_config --libs`"
fi
elif [ -n "$sdl_config" ]; then
2007-01-02 19:19:48 +00:00
CFLAGS="$CFLAGS -DWITH_SDL"
2009-01-25 22:51:59 +00:00
# SDL must not add _GNU_SOURCE as it breaks many platforms
2009-05-16 12:36:33 +00:00
CFLAGS="$CFLAGS `$sdl_config --cflags | sed 's@-D_GNU_SOURCE[^ ]*@@'`"
2019-03-03 16:59:36 +00:00
if [ "$enable_static" != "0" ]; then
LIBS="$LIBS `$sdl_config --static --libs`"
else
LIBS="$LIBS `$sdl_config --libs`"
2007-01-02 19:19:48 +00:00
fi
fi
2007-01-07 09:48:10 +00:00
if [ "$with_cocoa" != "0" ]; then
2007-01-02 19:19:48 +00:00
CFLAGS="$CFLAGS -DWITH_COCOA"
2020-04-10 12:23:11 +00:00
LIBS="$LIBS -F$osx_sdk_path/System/Library/Frameworks -framework Cocoa -framework AudioUnit -framework AudioToolbox"
2007-12-17 07:47:21 +00:00
if [ "$enable_cocoa_quartz" != "0" ]; then
CFLAGS="$CFLAGS -DENABLE_COCOA_QUARTZ"
fi
2007-01-02 19:19:48 +00:00
fi
2007-01-07 09:48:10 +00:00
if [ "$with_zlib" != "0" ]; then
2015-08-09 12:42:21 +00:00
CFLAGS="$CFLAGS -DWITH_ZLIB"
CFLAGS="$CFLAGS `$zlib_config --cflags | tr '\n\r' ' '`"
if [ "$enable_static" != "0" ]; then
LIBS="$LIBS `$zlib_config --libs --static | tr '\n\r' ' '`"
2007-01-02 19:19:48 +00:00
else
2015-08-09 12:42:21 +00:00
LIBS="$LIBS `$zlib_config --libs | tr '\n\r' ' '`"
2007-01-02 19:19:48 +00:00
fi
fi
2010-10-27 16:42:20 +00:00
if [ -n "$lzma_config" ]; then
2019-03-10 15:41:01 +00:00
CFLAGS="$CFLAGS -DWITH_LIBLZMA"
2010-10-27 16:42:20 +00:00
CFLAGS="$CFLAGS `$lzma_config --cflags | tr '\n\r' ' '`"
if [ "$enable_static" != "0" ]; then
CFLAGS="$CFLAGS -DLZMA_API_STATIC"
LIBS="$LIBS `$lzma_config --libs --static | tr '\n\r' ' '`"
else
LIBS="$LIBS `$lzma_config --libs | tr '\n\r' ' '`"
fi
fi
2010-01-10 13:12:34 +00:00
if [ "$with_lzo2" != "0" ]; then
if [ "$enable_static" != "0" ] && [ "$os" != "OSX" ]; then
LIBS="$LIBS $lzo2"
else
LIBS="$LIBS -llzo2"
fi
CFLAGS="$CFLAGS -DWITH_LZO"
fi
2013-11-13 19:32:37 +00:00
if [ -n "$xdg_basedir_config" ]; then
CFLAGS="$CFLAGS -DWITH_XDG_BASEDIR"
CFLAGS="$CFLAGS `$xdg_basedir_config --cflags | tr '\n\r' ' '`"
if [ "$enable_static" != "0" ]; then
LIBS="$LIBS `$xdg_basedir_config --libs --static | tr '\n\r' ' '`"
else
LIBS="$LIBS `$xdg_basedir_config --libs | tr '\n\r' ' '`"
fi
fi
2019-10-09 19:57:28 +00:00
if [ -n "$dbus_config" ]; then
CFLAGS="$CFLAGS -DWITH_DBUS"
CFLAGS="$CFLAGS `$dbus_config --cflags | tr '\n\r' ' '`"
if [ "$enable_static" != "0" ]; then
LIBS="$LIBS `$dbus_config --libs --static | tr '\n\r' ' '`"
else
LIBS="$LIBS `$dbus_config --libs | tr '\n\r' ' '`"
fi
fi
if [ -n "$x11_config" ]; then
CFLAGS="$CFLAGS -DWITH_X11"
CFLAGS="$CFLAGS `$x11_config --cflags | tr '\n\r' ' '`"
if [ "$enable_static" != "0" ]; then
LIBS="$LIBS `$x11_config --libs --static | tr '\n\r' ' '`"
else
LIBS="$LIBS `$x11_config --libs | tr '\n\r' ' '`"
fi
fi
if [ -n "$fcitx_config" ]; then
CFLAGS="$CFLAGS -DWITH_FCITX"
CFLAGS="$CFLAGS `$fcitx_config --cflags | tr '\n\r' ' '`"
if [ "$enable_static" != "0" ]; then
LIBS="$LIBS `$fcitx_config --libs --static | tr '\n\r' ' '`"
else
LIBS="$LIBS `$fcitx_config --libs | tr '\n\r' ' '`"
fi
fi
2009-01-12 17:11:45 +00:00
# 64bit machines need -D_SQ64
2009-10-04 20:53:26 +00:00
if [ "$cpu_type" = "64" ] && [ "$enable_universal" = "0" ]; then
2009-01-12 17:11:45 +00:00
CFLAGS="$CFLAGS -D_SQ64"
fi
2011-12-01 12:03:34 +00:00
CFLAGS="$CFLAGS -I$SCRIPT_SRC_DIR"
2009-01-12 17:11:45 +00:00
2007-01-07 09:48:10 +00:00
if [ -n "$png_config" ]; then
2007-01-02 19:19:48 +00:00
CFLAGS="$CFLAGS -DWITH_PNG"
2014-03-28 18:19:48 +00:00
CFLAGS="$CFLAGS `$png_config --cflags | tr '\n\r' ' '`"
2007-01-02 19:19:48 +00:00
2007-01-07 09:48:10 +00:00
if [ "$enable_static" != "0" ]; then
2015-08-09 12:37:20 +00:00
LIBS="$LIBS `$png_config --libs --static | tr '\n\r' ' '`"
2007-01-02 19:19:48 +00:00
else
2014-03-28 18:19:48 +00:00
LIBS="$LIBS `$png_config --libs | tr '\n\r' ' '`"
2007-01-02 19:19:48 +00:00
fi
fi
2007-03-06 22:40:45 +00:00
if [ -n "$fontconfig_config" ]; then
CFLAGS="$CFLAGS -DWITH_FONTCONFIG"
CFLAGS="$CFLAGS `$fontconfig_config --cflags | tr '\n\r' ' '`"
2007-01-02 19:19:48 +00:00
2007-01-07 09:48:10 +00:00
if [ "$enable_static" != "0" ]; then
2015-08-09 12:37:20 +00:00
LIBS="$LIBS `$fontconfig_config --libs --static | tr '\n\r' ' '`"
2007-01-02 19:19:48 +00:00
else
2007-03-06 22:40:45 +00:00
LIBS="$LIBS `$fontconfig_config --libs | tr '\n\r' ' '`"
2007-01-02 19:19:48 +00:00
fi
fi
2007-03-06 22:40:45 +00:00
if [ -n "$freetype_config" ]; then
CFLAGS="$CFLAGS -DWITH_FREETYPE"
CFLAGS="$CFLAGS `$freetype_config --cflags | tr '\n\r' ' '`"
2007-01-02 19:19:48 +00:00
2007-01-07 09:48:10 +00:00
if [ "$enable_static" != "0" ]; then
2018-06-18 20:22:39 +00:00
LIBS="$LIBS `$freetype_config --libs --static | tr '\n\r' ' '` -lfreetype"
2007-01-02 19:19:48 +00:00
else
2007-03-06 22:40:45 +00:00
LIBS="$LIBS `$freetype_config --libs | tr '\n\r' ' '`"
2007-01-02 19:19:48 +00:00
fi
fi
2015-08-09 13:54:17 +00:00
if [ -n "$icu_layout_config" ]; then
2019-03-10 15:43:59 +00:00
CFLAGS="$CFLAGS -DWITH_ICU_LX"
2015-08-09 13:54:17 +00:00
CFLAGS="$CFLAGS `$icu_layout_config --cflags | tr '\n\r' ' '`"
2008-10-17 17:14:09 +00:00
2009-11-17 18:01:05 +00:00
if [ "$static_icu" != "0" ]; then
2015-08-09 13:54:17 +00:00
LIBS="$LIBS `$icu_layout_config --libs --static | tr '\n\r' ' ' | sed s/-licu/-lsicu/g`"
2009-11-17 18:01:05 +00:00
else
2015-08-09 13:54:17 +00:00
LIBS="$LIBS `$icu_layout_config --libs | tr '\n\r' ' '`"
fi
fi
if [ -n "$icu_sort_config" ]; then
2019-03-10 15:46:19 +00:00
CFLAGS="$CFLAGS -DWITH_ICU_I18N"
2015-08-09 13:54:17 +00:00
CFLAGS="$CFLAGS `$icu_sort_config --cflags | tr '\n\r' ' '`"
if [ "$static_icu" != "0" ]; then
LIBS="$LIBS `$icu_sort_config --libs --static | tr '\n\r' ' ' | sed s/-licu/-lsicu/g`"
else
LIBS="$LIBS `$icu_sort_config --libs | tr '\n\r' ' '`"
2009-11-17 18:01:05 +00:00
fi
2008-10-17 17:14:09 +00:00
fi
2018-06-25 17:39:59 +00:00
if [ "$with_uniscribe" != "0" ]; then
CFLAGS="$CFLAGS -DWITH_UNISCRIBE"
LIBS="$LIBS -lusp10"
fi
2008-10-17 17:14:09 +00:00
2007-01-07 09:48:10 +00:00
if [ "$with_direct_music" != "0" ]; then
2007-01-02 19:19:48 +00:00
CFLAGS="$CFLAGS -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT"
2007-03-02 01:18:12 +00:00
# GCC 4.0+ doesn't like the DirectX includes (gives tons of
# warnings on it we won't be able to fix). For now just
# suppress those warnings.
2016-07-24 09:13:51 +00:00
if [ $cc_version -ge 400 ]; then
2007-03-02 01:18:12 +00:00
CFLAGS="$CFLAGS -Wno-non-virtual-dtor"
fi
2007-01-02 19:19:48 +00:00
fi
2018-04-09 22:18:45 +00:00
if [ "$with_xaudio2" != "0" ]; then
CFLAGS="$CFLAGS -DWITH_XAUDIO2"
fi
2018-09-11 23:06:31 +00:00
if [ -n "$fluidsynth" ]; then
LIBS="$LIBS -lfluidsynth"
CFLAGS="$CFLAGS -DFLUIDSYNTH"
fi
2007-01-07 09:48:10 +00:00
if [ "$with_iconv" != "0" ]; then
2007-01-02 19:19:48 +00:00
CFLAGS="$CFLAGS -DWITH_ICONV"
2008-10-22 20:20:08 +00:00
if [ "$link_to_iconv" = "yes" ]; then
LIBS="$LIBS -liconv"
if [ "$with_iconv" != "2" ]; then
CFLAGS="$CFLAGS -I$with_iconv/include"
LIBS="$LIBS -L$with_iconv/lib"
fi
2007-01-02 19:19:48 +00:00
fi
2007-11-07 21:35:33 +00:00
2013-06-26 21:17:09 +00:00
if [ "$os" != "OSX" ] && [ "$have_non_const_iconv" != "no" ]; then
2010-12-25 12:49:36 +00:00
CFLAGS="$CFLAGS -DHAVE_NON_CONST_ICONV"
2007-11-07 21:35:33 +00:00
fi
2007-01-02 19:19:48 +00:00
fi
2007-01-07 09:48:10 +00:00
if [ -n "$with_midi" ]; then
2007-01-06 20:39:27 +00:00
CFLAGS="$CFLAGS -DEXTERNAL_PLAYER=\\\\\"$with_midi\\\\\""
2007-01-02 19:19:48 +00:00
fi
2007-01-07 09:48:10 +00:00
if [ -n "$with_midi_arg" ]; then
2007-01-06 20:39:27 +00:00
CFLAGS="$CFLAGS -DMIDI_ARG=\\\\\"$with_midi_arg\\\\\""
2007-01-02 19:19:48 +00:00
fi
2007-01-07 09:48:10 +00:00
if [ "$enable_dedicated" != "0" ]; then
2007-01-02 19:19:48 +00:00
CFLAGS="$CFLAGS -DDEDICATED"
fi
2007-03-06 19:14:15 +00:00
if [ "$enable_unicode" != "0" ]; then
CFLAGS="$CFLAGS -DUNICODE -D_UNICODE"
fi
Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.
Additionaly, it has grown so hugely in our codebase, that it
clearly shows that the current solution was a poor one. 350+
instances of "#ifdef ENABLE_NETWORK" were in the code, of which
only ~30 in the networking code itself. The rest were all around
the code to do the right thing, from GUI to NewGRF.
A more proper solution would be to stub all the functions, and
make sure the rest of the code can simply assume network is
available. This was also partially done, and most variables were
correct if networking was disabled. Despite that, often the #ifdefs
were still used.
With the recent removal of DOS, there is also no platform anymore
which we support where networking isn't working out-of-the-box.
All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
2019-03-20 16:01:13 +00:00
if [ "$os" = "HAIKU" ]; then
LDFLAGS="$LDFLAGS -lnetwork"
fi
2009-09-21 18:36:33 +00:00
Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.
Additionaly, it has grown so hugely in our codebase, that it
clearly shows that the current solution was a poor one. 350+
instances of "#ifdef ENABLE_NETWORK" were in the code, of which
only ~30 in the networking code itself. The rest were all around
the code to do the right thing, from GUI to NewGRF.
A more proper solution would be to stub all the functions, and
make sure the rest of the code can simply assume network is
available. This was also partially done, and most variables were
correct if networking was disabled. Despite that, often the #ifdefs
were still used.
With the recent removal of DOS, there is also no platform anymore
which we support where networking isn't working out-of-the-box.
All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
2019-03-20 16:01:13 +00:00
if [ "$os" = "SUNOS" ]; then
LDFLAGS="$LDFLAGS -lnsl -lsocket"
2007-01-02 19:19:48 +00:00
fi
2007-01-07 09:48:10 +00:00
if [ "$enable_static" != "0" ]; then
2007-01-02 19:19:48 +00:00
# OSX can't handle -static in LDFLAGS
2007-01-07 09:48:10 +00:00
if [ "$os" != "OSX" ]; then
2007-01-02 19:19:48 +00:00
LDFLAGS="$LDFLAGS -static"
fi
fi
2007-01-07 09:48:10 +00:00
if [ "$enable_assert" = "0" ]; then
2007-01-02 19:19:48 +00:00
CFLAGS="$CFLAGS -DNDEBUG"
2012-07-01 08:56:57 +00:00
CFLAGS_BUILD="$CFLAGS_BUILD -DNDEBUG"
2007-01-02 19:19:48 +00:00
fi
2008-12-29 21:50:25 +00:00
if [ "$enable_desync_debug" != "0" ]; then
2007-12-15 22:42:12 +00:00
CFLAGS="$CFLAGS -DRANDOM_DEBUG"
fi
2007-01-07 09:48:10 +00:00
if [ "$enable_osx_g5" != "0" ]; then
2009-05-03 15:46:36 +00:00
CFLAGS="$CFLAGS -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
2007-01-02 19:19:48 +00:00
fi
2007-06-17 15:48:57 +00:00
if [ -n "$personal_dir" ]; then
CFLAGS="$CFLAGS -DWITH_PERSONAL_DIR -DPERSONAL_DIR=\\\\\"$personal_dir\\\\\""
2007-01-02 19:19:48 +00:00
fi
2008-01-13 17:45:29 +00:00
if [ -n "$shared_dir" ]; then
CFLAGS="$CFLAGS -DWITH_SHARED_DIR -DSHARED_DIR=\\\\\"$shared_dir\\\\\""
fi
2007-06-17 15:48:57 +00:00
CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\""
2007-01-02 19:19:48 +00:00
2010-09-03 13:23:29 +00:00
if [ "$enable_lto" != "0" ]; then
lto_build=`echo "$FEATURES_BUILD" | grep "lto"`
lto_host=`echo "$FEATURES" | grep "lto"`
if [ -z "$lto_build$lto_host" ]; then
log 1 "WARNING: you enabled LTO/IPO, but neither build nor host compiler supports it"
log 1 "WARNING: LTO/IPO has been disabled"
fi
if [ -n "$lto_build" ]; then
LDFLAGS_BUILD="$LDFLAGS_BUILD $CFLAGS_BUILD $CXXFLAGS_BUILD"
fi
if [ -n "$lto_host" ]; then
LDFLAGS="$LDFLAGS $CFLAGS $CXXFLAGS"
fi
fi
2018-04-14 18:11:49 +00:00
# All flags to be extended via the env
CFLAGS_BUILD="$CFLAGS_BUILD $CFLAGS_BUILD_ENV"
CXXFLAGS_BUILD="$CXXFLAGS_BUILD $CXXFLAGS_BUILD_ENV"
LDFLAGS_BUILD="$LDFLAGS_BUILD $LDFLAGS_BUILD_ENV"
CFLAGS="$CFLAGS $CFLAGS_ENV"
CXXFLAGS="$CXXFLAGS $CXXFLAGS_ENV"
LDFLAGS="$LDFLAGS $LDFLAGS_ENV"
2012-07-21 15:49:26 +00:00
log 1 "using CFLAGS_BUILD... $CFLAGS_BUILD"
log 1 "using CXXFLAGS_BUILD... $CXXFLAGS_BUILD"
log 1 "using LDFLAGS_BUILD... $LDFLAGS_BUILD"
2009-06-22 20:22:04 +00:00
log 1 "using CFLAGS... $CFLAGS"
2009-09-07 21:01:24 +00:00
log 1 "using CXXFLAGS... $CXXFLAGS"
2007-01-02 19:19:48 +00:00
log 1 "using LDFLAGS... $LIBS $LDFLAGS"
# Makedepend doesn't like something like: -isysroot /OSX/blabla
# so convert it to: -isysroot -OSX/blabla. makedepend just ignores
# any - command it doesn't know, so we are pretty save.
# Lovely hackish, not?
# Btw, this almost always comes from outside the configure, so it is
# not something we can control.
2009-04-26 16:03:50 +00:00
# Also make makedepend aware of compiler's built-in defines.
2009-05-14 21:59:24 +00:00
if [ "$with_makedepend" != "0" ] || [ "$enable_builtin_depend" != "0" ]; then
2009-09-07 21:01:24 +00:00
# Append CXXFLAGS possibly containing -std=c++0x
cflags_makedep="`echo | $cxx_host $CXXFLAGS -E -x c++ -dM - | sed 's@.define @-D@g;s@ .*@ @g;s@(.*)@@g' | tr -d '\r\n'`"
2009-08-01 16:57:30 +00:00
# Please escape ALL " within ` because e.g. "" terminates the string in some sh implementations
2019-01-15 01:26:54 +00:00
cflags_makedep="$cflags_makedep `echo \"$CFLAGS\" \"$CXXFLAGS\" | sed 's@ /@ -@g;s@-I[ ]*[^ ]*@@g;s@[ ]*-[^D][^ ]*@@g'`"
2007-01-02 19:19:48 +00:00
else
makedepend=""
fi
2007-06-11 10:01:03 +00:00
if [ "$with_distcc" != "0" ]; then
cc_host="$distcc $cc_host"
cxx_host="$distcc $cxx_host"
log 1 ""
log 1 " NOTICE: remind yourself to use 'make -jN' to make use of distcc"
log 1 ""
fi
2007-06-16 21:57:30 +00:00
if [ "$with_ccache" != "0" ]; then
cc_host="$ccache $cc_host"
cxx_host="$ccache $cxx_host"
fi
2007-01-02 19:19:48 +00:00
}
check_compiler() {
# Params:
# $1 - Type for message (build / host)
# $2 - What to fill with the found compiler
# $3 - System to try
# $4 - Compiler to try
# $5 - Env-setting to try
2016-09-08 22:14:02 +00:00
# $6 - GCC alike to try (array)
2007-01-02 19:19:48 +00:00
# $7 - CC alike to try
# $8 - "0" gcc, "1" g++, "2" windres, "3" strip, "4" lipo
# $9 - What the command is to check for
2018-04-14 18:12:05 +00:00
if [ -n "$4" ]; then
# Check for manual compiler
machine=`$4 $9 2>/dev/null`
ret=$?
eval "$2=\"$4\""
log 2 "executing $4 $9"
log 2 " returned $machine"
log 2 " exit code $ret"
if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
log 1 "checking $1... $4 not found"
log 1 "the selected binary doesn't seem to be a $6 binary"
exit 1
fi
elif [ -n "$3" ]; then
2007-01-02 19:19:48 +00:00
# Check for system
2016-09-08 22:14:02 +00:00
for val in $6; do
if [ -z "$6" ]; then
compiler="$3"
else
compiler="$3-$val"
fi
machine=`eval $compiler $9 2>/dev/null`
ret=$?
eval "$2=\"$compiler\""
2007-01-02 19:19:48 +00:00
2016-09-08 22:14:02 +00:00
log 2 "executing $compiler $9"
log 2 " returned $machine"
log 2 " exit code $ret"
if [ -n "$machine" ] && [ "$ret" = "0" ]; then
break
fi
done
2007-01-02 19:19:48 +00:00
2007-01-07 09:48:10 +00:00
if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
2015-08-08 08:54:49 +00:00
if [ -z "$5" ]; then
log 1 "checking $1... $compiler not found"
2016-09-08 22:14:02 +00:00
log 1 "I couldn't detect any '$6' binary for $3"
2015-08-08 08:54:49 +00:00
exit 1
else
compiler="$3-$5"
fi
machine=`eval $compiler $9 2>/dev/null`
ret=$?
eval "$2=\"$compiler\""
log 2 "executing $compiler $9"
log 2 " returned $machine"
log 2 " exit code $ret"
if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
log 1 "checking $1... $compiler not found"
log 1 "I couldn't detect any $5 binary for $3"
exit 1
fi
2007-01-02 19:19:48 +00:00
fi
2007-01-07 09:48:10 +00:00
if [ "$machine" != "$3" ] && ( [ "$8" = "0" ] || [ "$8" = "1" ] ); then
2007-01-02 19:19:48 +00:00
log 1 "checking $1... expected $3, found $machine"
log 1 "the compiler suggests it doesn't build code for the machine you specified"
exit 1
fi
else
# Nothing given, autodetect
2007-01-07 09:48:10 +00:00
if [ -n "$5" ]; then
2007-01-02 19:19:48 +00:00
machine=`$5 $9 2>/dev/null`
ret=$?
2010-02-13 00:20:19 +00:00
eval "$2=\"$5\""
2007-01-02 19:19:48 +00:00
log 2 "executing $5 $9"
log 2 " returned $machine"
log 2 " exit code $ret"
# The user defined a GCC that doesn't reply to $9.. abort
2007-01-07 09:48:10 +00:00
if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking $1... $5 unusable"
2016-09-08 22:14:02 +00:00
log 1 "the CC environment variable is set, but it doesn't seem to be a '$6' binary"
2007-01-02 19:19:48 +00:00
log 1 "please redefine the CC/CXX environment to a $6 binary"
exit 1
fi
else
log 2 "checking $1... CC/CXX not set (skipping)"
2016-09-08 22:14:02 +00:00
for val in $6; do
# No $5, so try next item in '$6'
machine=`$val $9 2>/dev/null`
ret=$?
eval "$2=\"$val\""
2007-01-02 19:19:48 +00:00
2016-09-08 22:14:02 +00:00
log 2 "executing $val $9"
log 2 " returned $machine"
log 2 " exit code $ret"
if [ -n "$machine" ] && [ "$ret" = "0" ]; then
break
fi
done
2007-01-02 19:19:48 +00:00
2007-01-07 09:48:10 +00:00
if ( [ -z "$machine" ] && [ "$8" != "3" ] ) || [ "$ret" != "0" ]; then
2007-01-02 19:19:48 +00:00
# Maybe '$7'?
machine=`$7 $9 2>/dev/null`
ret=$?
2010-02-13 00:20:19 +00:00
eval "$2=\"$7\""
2007-01-02 19:19:48 +00:00
log 2 "executing $7 $9"
log 2 " returned $machine"
log 2 " exit code $ret"
# All failed, abort
2007-01-07 09:48:10 +00:00
if [ -z "$machine" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking $1... $6 not found"
2016-09-08 22:14:02 +00:00
log 1 "I couldn't detect any '$6' binary on your system"
2007-01-02 19:19:48 +00:00
log 1 "please define the CC/CXX environment to where it is located"
exit 1
fi
fi
fi
fi
2007-01-07 09:48:10 +00:00
if [ "$8" != "0" ]; then
2007-01-02 19:19:48 +00:00
eval "res=\$$2"
log 1 "checking $1... $res"
else
log 1 "checking $1... $machine"
fi
}
check_build() {
2018-04-27 01:42:20 +00:00
check_compiler "build system type" "cc_build" "$build" "$cc_build" "$CC" "$default_cc" "cc" "0" "-dumpmachine"
2007-01-02 19:19:48 +00:00
}
check_host() {
# By default the host is the build
if [ -z "$host" ]; then host="$build"; fi
2008-04-24 20:07:12 +00:00
2018-04-27 01:42:20 +00:00
check_compiler "host system type" "cc_host" "$host" "$cc_host" "$CC" "$default_cc" "cc" "0" "-dumpmachine"
2007-01-02 19:19:48 +00:00
}
2007-01-10 18:56:51 +00:00
check_cxx_build() {
2016-09-08 22:14:02 +00:00
check_compiler "build c++" "cxx_build" "$build" "$cxx_build" "$CXX" "$default_cxx" "c++" 1 "-dumpmachine"
2007-01-10 18:56:51 +00:00
}
check_cxx_host() {
# By default the host is the build
if [ -z "$host" ]; then host="$build"; fi
2016-09-08 22:14:02 +00:00
check_compiler "host c++" "cxx_host" "$host" "$cxx_host" "$CXX" "$default_cxx" "c++" 1 "-dumpmachine"
2007-01-02 19:19:48 +00:00
}
check_windres() {
2018-04-29 12:21:31 +00:00
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
2007-01-02 19:19:48 +00:00
check_compiler "host windres" "windres" "$host" "$windres" "$WINDRES" "windres" "windres" "2" "-V"
fi
}
check_strip() {
2007-01-07 13:00:56 +00:00
if [ "$os" = "OS2" ]; then
# OS2 via gcc is a bit weird.. stripping HAS to be done via emxbind, which is via gcc directly
2008-12-17 23:08:11 +00:00
log 1 "checking host strip... using gcc -s option"
2007-01-07 13:00:56 +00:00
elif [ "$os" = "OSX" ]; then
2007-01-02 19:19:48 +00:00
# Most targets have -V in strip, to see if they exists... OSX doesn't.. so execute something
echo "int main(int argc, char *argv[]) { }" > strip.test.c
2009-07-13 23:08:03 +00:00
$cxx_host strip.test.c -o strip.test
2007-01-02 19:19:48 +00:00
check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "strip.test"
rm -f strip.test.c strip.test
else
check_compiler "host strip" "strip" "$host" "$strip" "$STRIP" "strip" "strip" "3" "-V"
fi
}
check_lipo() {
2007-01-07 09:48:10 +00:00
if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ]; then
2007-01-02 19:19:48 +00:00
echo "int main(int argc, char *argv[]) { }" > lipo.test.c
2009-07-13 23:08:03 +00:00
$cxx_host lipo.test.c -o lipo.test
2007-01-02 19:19:48 +00:00
check_compiler "host lipo" "lipo" "$host" "$lipo" "$LIPO" "lipo" "lipo" "4" "-info lipo.test"
rm -f lipo.test.c lipo.test
fi
}
2009-10-04 20:53:26 +00:00
check_osx_sdk() {
local sysroot=""
if [ -n "$1" ]; then
if echo "$1" | grep -q / ; then
# Seems to be a file system path
osx_sdk_path="$1"
else
osx_sdk_path="/Developer/SDKs/MacOSX$1.sdk"
fi
if [ ! -d "$osx_sdk_path" ]; then
# No directory, not present or garbage
return 1
fi
2008-07-27 20:43:21 +00:00
2009-10-04 20:53:26 +00:00
# Set minimum version to 10.4 as that's when kCGBitmapByteOrder32Host was introduced
sysroot="-isysroot $osx_sdk_path -Wl,-syslibroot,$osx_sdk_path -mmacosx-version-min=10.4"
2008-07-27 20:43:21 +00:00
fi
2009-07-13 23:12:34 +00:00
cat > tmp.osx.mm << EOF
#include <Cocoa/Cocoa.h>
2009-05-13 12:57:17 +00:00
int main() {
2009-07-13 23:12:34 +00:00
kCGBitmapByteOrder32Host;
2009-05-13 12:57:17 +00:00
return 0;
}
EOF
2009-10-04 20:53:26 +00:00
execute="$cxx_host $sysroot $CFLAGS tmp.osx.mm -framework Cocoa -o tmp.osx 2>&1"
2009-05-13 12:57:17 +00:00
eval $execute > /dev/null
ret=$?
log 2 "executing $execute"
log 2 " exit code $ret"
2009-07-13 23:12:34 +00:00
rm -f tmp.osx.mm tmp.osx
2009-10-04 20:53:26 +00:00
return $ret
2009-05-13 12:57:17 +00:00
}
2007-01-02 19:19:48 +00:00
check_direct_music() {
echo "
#include <windows.h>
#include <dmksctrl.h>
#include <dmusicc.h>
int main(int argc, char *argv[]) { }" > direct_music.test.c
$cxx_host $CFLAGS direct_music.test.c -o direct_music.test 2> /dev/null
res=$?
rm -f direct_music.test.c direct_music.test
2007-01-07 09:48:10 +00:00
if [ "$res" != "0" ]; then
2008-11-29 22:40:54 +00:00
if [ "$with_direct_music" != "1" ]; then
2007-01-02 19:19:48 +00:00
log 1 "configure: error: direct-music is not available on this system"
exit 1
fi
with_direct_music="0"
log 1 "checking direct-music... not found"
else
log 1 "checking direct-music... found"
fi
}
2018-04-09 22:18:45 +00:00
check_xaudio2() {
echo "
#include <windows.h>
#undef NTDDI_VERSION
#undef _WIN32_WINNT
#define NTDDI_VERSION NTDDI_WIN8
#define _WIN32_WINNT _WIN32_WINNT_WIN8
#include <xaudio2.h>
int main(int argc, char *argv[]) { }" > xaudio2.test.c
$cxx_host $CFLAGS xaudio2.test.c -o xaudio2.test 2> /dev/null
res=$?
rm -f xaudio2.test.c xaudio2.test
if [ "$res" != "0" ]; then
if [ "$with_xaudio2" != "1" ]; then
log 1 "configure: error: xaudio2 is not available on this system"
exit 1
fi
with_xaudio2="0"
log 1 "checking xaudio2... not found"
else
log 1 "checking xaudio2... found"
fi
}
2007-01-02 19:19:48 +00:00
check_makedepend() {
2009-05-14 21:59:24 +00:00
if [ "$enable_builtin_depend" != "0" ]; then
with_makedepend="0"
fi
2007-01-07 09:48:10 +00:00
if [ "$with_makedepend" = "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking makedepend... disabled"
return
fi
2007-01-07 09:48:10 +00:00
if [ "$with_makedepend" = "1" ] || [ "$with_makedepend" = "2" ]; then
2007-01-02 19:19:48 +00:00
makedepend="makedepend"
else
makedepend="$with_makedepend"
fi
rm -f makedepend.tmp
touch makedepend.tmp
res=`$makedepend -fmakedepend.tmp 2>/dev/null`
res=$?
log 2 "executing $makedepend -f makedepend.tmp"
log 2 " returned `cat makedepend.tmp`"
log 2 " exit code $ret"
2007-01-07 09:48:10 +00:00
if [ ! -s makedepend.tmp ]; then
2007-01-02 19:19:48 +00:00
rm -f makedepend.tmp makedepend.tmp.bak
2007-01-07 09:48:10 +00:00
if [ "$with_makedepend" = "2" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking makedepend... not found"
log 1 "I couldn't detect any makedepend on your system"
log 1 "please locate it via --makedepend=[binary]"
exit 1
2007-01-07 09:48:10 +00:00
elif [ "$with_makedepend" != "1" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking makedepend... $makedepend not found"
log 1 "the selected file doesn't seem to be a valid makedepend binary"
exit 1
else
log 1 "checking makedepend... not found"
with_makedepend="0"
return
fi
fi
rm -f makedepend.tmp makedepend.tmp.bak
log 1 "checking makedepend... $makedepend"
}
2012-10-17 15:23:51 +00:00
check_version() {
# $1 - requested version (major.minor)
# $2 - version we got (major.minor)
if [ -z "$2" ]; then
return 0
fi
req_major=`echo $1 | cut -d. -f1`
got_major=`echo $2 | cut -d. -f1`
if [ $got_major -lt $req_major ]; then
return 0
elif [ $got_major -gt $req_major ]; then
return 1
fi
req_minor=`echo $1 | cut -d. -f2`
got_minor=`echo $2 | cut -d. -f2`
if [ $got_minor -lt $req_minor ]; then
return 0
2019-10-14 17:51:25 +00:00
elif [ $got_minor -gt $req_minor ]; then
return 1
fi
req_micro=`echo $1 | cut -d. -f3`
got_micro=`echo $2 | cut -d. -f3`
if [ -z "$req_micro" ]; then
return 1
elif [ -z "$got_micro" ]; then
return 0
elif [ $got_micro -lt $req_micro ]; then
return 0
else
return 1
2012-10-17 15:23:51 +00:00
fi
}
2007-02-19 19:59:19 +00:00
detect_awk() {
# Not all awks allow gsub(), so we test for that here! It is in fact all we need...
# These awks are known to work. Test for them explicit
awks="gawk mawk nawk"
awk_prefix="echo \"a.c b.c c.c\" | tr ' ' \\\\n | "
awk_param="' { ORS = \" \" } /\.c$/ { gsub(\".c$\", \".o\", \$0); print \$0; }' 2>/dev/null"
awk_result="a.o b.o c.o "
log 2 "Detecing awk..."
log 2 "Trying: $awk_prefix $awk $awk_param"
res=`eval $awk_prefix $awk $awk_param`
log 2 "Result: '$res'"
if [ "$res" != "$awk_result" ] && [ "$awk" = "awk" ]; then
# User didn't supply his own awk, so try to detect some other known working names for an awk
for awk in $awks; do
log 2 "Trying: $awk_prefix $awk $awk_param"
res=`eval $awk_prefix $awk $awk_param`
log 2 "Result: '$res'"
if [ "$res" = "$awk_result" ]; then break; fi
done
if [ "$res" != "$awk_result" ]; then
log 1 "checking awk... not found"
log 1 "configure: error: no awk found"
log 1 "configure: error: please install one of the following: $awks"
exit 1
fi
fi
if [ "$res" != "$awk_result" ]; then
log 1 "checking awk... not found"
log 1 "configure: error: you supplied '$awk' but it doesn't seem a valid gawk or mawk"
exit 1
fi
log 1 "checking awk... $awk"
}
2007-01-02 19:19:48 +00:00
detect_os() {
2007-02-19 16:10:18 +00:00
if [ "$os" = "DETECT" ]; then
Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.
Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.
Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.
By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.
Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 21:23:09 +00:00
# Detect UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, HPUX, SUNOS, CYGWIN, MINGW, and OS2
2007-01-02 19:19:48 +00:00
# Try first via dumpmachine, then via uname
2007-02-19 19:59:19 +00:00
os=`echo "$host" | tr '[A-Z]' '[a-z]' | $awk '
2015-04-11 10:25:36 +00:00
/linux/ { print "UNIX"; exit}
/darwin/ { print "OSX"; exit}
/freebsd/ { print "FREEBSD"; exit}
/dragonfly/ { print "DRAGONFLY"; exit}
/openbsd/ { print "OPENBSD"; exit}
/netbsd/ { print "NETBSD"; exit}
/hp-ux/ { print "HPUX"; exit}
/haiku/ { print "HAIKU"; exit}
/sunos/ { print "SUNOS"; exit}
/solaris/ { print "SUNOS"; exit}
/cygwin/ { print "CYGWIN"; exit}
/mingw/ { print "MINGW"; exit}
/os2/ { print "OS2"; exit}
2007-01-02 19:19:48 +00:00
'`
2007-01-07 09:48:10 +00:00
if [ -z "$os" ]; then
2007-02-19 19:59:19 +00:00
os=`LC_ALL=C uname | tr '[A-Z]' '[a-z]' | $awk '
2015-04-11 10:25:36 +00:00
/linux/ { print "UNIX"; exit}
/darwin/ { print "OSX"; exit}
/freebsd/ { print "FREEBSD"; exit}
/dragonfly/ { print "DRAGONFLY"; exit}
/openbsd/ { print "OPENBSD"; exit}
/netbsd/ { print "NETBSD"; exit}
/hp-ux/ { print "HPUX"; exit}
/haiku/ { print "HAIKU"; exit}
/sunos/ { print "SUNOS"; exit}
/cygwin/ { print "CYGWIN"; exit}
/mingw/ { print "MINGW"; exit}
/os\/2/ { print "OS2"; exit}
/gnu/ { print "UNIX"; exit}
2007-01-02 19:19:48 +00:00
'`
fi
2007-01-07 09:48:10 +00:00
if [ -z "$os" ]; then
2007-01-02 19:19:48 +00:00
log 1 "detecting OS... none detected"
2007-05-23 16:40:40 +00:00
log 1 "I couldn't detect your OS. Please use --os=OS to force one"
Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.
Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.
Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.
By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.
Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 21:23:09 +00:00
log 1 "Allowed values are: UNIX, OSX, FREEBSD, DRAGONFLY, OPENBSD, NETBSD, HPUX, HAIKU, SUNOS, CYGWIN, MINGW, and OS2"
2007-01-02 19:19:48 +00:00
exit 1
fi
log 1 "detecting OS... $os"
else
log 1 "forcing OS... $os"
fi
2016-09-08 22:14:02 +00:00
if [ "$os" = "OSX" ]; then
default_cc="clang gcc"
default_cxx="clang++ g++"
else
default_cc="gcc clang"
default_cxx="g++ clang++"
fi
2007-01-02 19:19:48 +00:00
}
2008-11-25 19:32:12 +00:00
detect_allegro() {
# 0 means no, 1 is auto-detect, 2 is force
if [ "$with_allegro" = "0" ]; then
log 1 "checking Allegro... disabled"
allegro_config=""
return 0
fi
if [ "$with_allegro" = "2" ] && [ "$with_cocoa" = "2" ]; then
log 1 "configure: error: it is impossible to compile both Allegro and COCOA"
log 1 "configure: error: please deselect one of them and try again"
exit 1
fi
if [ "$with_allegro" = "2" ] && [ "$enable_dedicated" != "0" ]; then
log 1 "configure: error: it is impossible to compile a dedicated with Allegro"
log 1 "configure: error: please deselect one of them and try again"
exit 1
fi
if [ "$enable_dedicated" != "0" ]; then
log 1 "checking Allegro... dedicated server, skipping"
allegro_config=""
return 0
fi
2015-08-09 12:41:35 +00:00
# By default on OSX we don't use Allegro. The rest is auto-detect
2008-11-25 19:32:12 +00:00
if [ "$with_allegro" = "1" ] && [ "$os" = "OSX" ] && [ "$with_cocoa" != "0" ]; then
2008-11-26 13:12:45 +00:00
log 1 "checking Allegro... OSX, skipping"
2008-11-25 19:32:12 +00:00
allegro_config=""
return 0
fi
2015-08-09 12:41:35 +00:00
detect_pkg_config "$with_allegro" "allegro" "allegro_config" "4.4"
2008-11-25 19:32:12 +00:00
}
2007-01-02 19:19:48 +00:00
detect_sdl() {
# 0 means no, 1 is auto-detect, 2 is force
2007-01-07 09:48:10 +00:00
if [ "$with_sdl" = "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking SDL... disabled"
sdl_config=""
2019-10-13 09:19:38 +00:00
sdl2_config=""
2007-01-02 19:19:48 +00:00
return 0
fi
2019-10-13 09:19:38 +00:00
if [ "$with_sdl" != "1" ] && [ "$with_cocoa" = "2" ]; then
2007-01-02 19:19:48 +00:00
log 1 "configure: error: it is impossible to compile both SDL and COCOA"
log 1 "configure: error: please deselect one of them and try again"
exit 1
fi
2019-10-13 09:19:38 +00:00
if [ "$with_sdl" != "1" ] && [ "$enable_dedicated" != "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "configure: error: it is impossible to compile a dedicated with SDL"
log 1 "configure: error: please deselect one of them and try again"
exit 1
fi
2007-01-07 09:48:10 +00:00
if [ "$enable_dedicated" != "0" ]; then
2008-10-19 20:53:13 +00:00
log 1 "checking SDL... dedicated server, skipping"
2007-01-02 19:19:48 +00:00
sdl_config=""
2019-10-13 09:19:38 +00:00
sdl2_config=""
2007-01-02 19:19:48 +00:00
return 0
fi
# By default on OSX we don't use SDL. The rest is auto-detect
2007-01-07 09:48:10 +00:00
if [ "$with_sdl" = "1" ] && [ "$os" = "OSX" ] && [ "$with_cocoa" != "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking SDL... OSX, skipping"
sdl_config=""
return 0
fi
2011-02-06 21:14:57 +00:00
if [ "$os" = "OSX" ]; then
log 1 "WARNING: sdl is known to fail on some versions of Mac OS X"
log 1 "WARNING: with some hardware configurations. Use at own risk!"
sleep 5
fi
2019-09-19 15:18:50 +00:00
if [ $with_sdl = "sdl1" ]; then
detect_pkg_config "2" "sdl" "sdl_config" "1.2"
2019-10-13 09:19:38 +00:00
elif [ $with_sdl = "sdl2" ]; then
2019-11-12 18:28:54 +00:00
detect_pkg_config "2" "sdl2" "sdl2_config" "2.0"
2019-09-19 15:18:50 +00:00
else
2019-10-13 09:19:38 +00:00
sdl2_config=""
Fix: sdl2-config would always be detected as present
The presence of sdl2-config is used go determine whether to look for
sdl2 first, or just sdl1. However, when sdl2-config is *not* present,
`which` returns an empty string. Due to lack of quoting, this produces
`[ -x ]`, rather than `[ -x "" ]` and it turns out the former actually
has a succesful exit status for some reason.
This was not a problem when just running configure, because it would
then just fail to detect sdl2 and fall back to sdl1. However, when
passing `--with-sdl` (without specifying a version), this would only
attempt to detect sdl2, even when sdl2-config was not present, but sdl1
is.
Adding quotes makes the check work as intended.
2020-05-12 15:34:16 +00:00
if [ -x "`which sdl2-config`" ]; then
2019-11-12 18:28:54 +00:00
detect_pkg_config "$with_sdl" "sdl2" "sdl2_config" "2.0"
2019-10-13 09:19:38 +00:00
fi
if [ -z "$sdl2_config" ]; then
detect_pkg_config "$with_sdl" "sdl" "sdl_config" "1.2"
fi
2019-09-19 15:18:50 +00:00
fi
2007-01-02 19:19:48 +00:00
}
2009-10-04 20:53:26 +00:00
detect_osx_sdk() {
# Try to find the best SDK available. For a normal build this
# is currently the 10.5 SDK as this is needed to compile all
# optional code. Because such an executable won't run on 10.4
# or lower, also check for the 10.4u SDK when doing an universal
# build.
# Check for the 10.5 SDK, but try 10.6 if that fails
check_osx_sdk "10.5" || check_osx_sdk "10.6" || osx_sdk_path=""
if [ -z "$osx_sdk_path" ] || [ "$enable_universal" != "0" ]; then
# No better SDK or universal build enabled? Check 10.4u SDK as well
local old_sdk="$osx_sdk_path"
if check_osx_sdk "10.4u"; then
osx_sdk_104_path="$osx_sdk_path"
else
osx_sdk_104_path=""
fi
if [ -z "$old_sdk" ]; then
osx_sdk_path="$osx_sdk_104_path"
else
osx_sdk_path="$old_sdk"
fi
fi
if [ -z "$osx_sdk_path" ]; then
log 1 "Your system SDK is probably too old"
log 1 "Please install/upgrade your Xcode to >= 2.5"
exit 1
fi
}
2007-01-02 19:19:48 +00:00
detect_cocoa() {
# 0 means no, 1 is auto-detect, 2 is force
2007-01-07 09:48:10 +00:00
if [ "$with_cocoa" = "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking COCOA... disabled"
return 0
fi
2007-01-07 09:48:10 +00:00
if [ "$with_cocoa" = "2" ] && [ "$enable_dedicated" != "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "configure: error: it is impossible to compile a dedicated with COCOA"
log 1 "configure: error: please deselect one of them and try again"
exit 1
fi
2007-01-07 09:48:10 +00:00
if [ "$enable_dedicated" != "0" ]; then
2008-10-19 20:53:13 +00:00
log 1 "checking COCOA... dedicated server, skipping"
2007-01-02 19:19:48 +00:00
with_cocoa="0"
return 0
fi
# By default on OSX we use COCOA. The rest doesn't support it
2007-01-07 09:48:10 +00:00
if [ "$with_cocoa" = "1" ] && [ "$os" != "OSX" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking COCOA... not OSX, skipping"
with_cocoa="0"
return 0
fi
2007-01-07 09:48:10 +00:00
if [ "$os" != "OSX" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking COCOA... not OSX"
log 1 "configure: error: COCOA video driver is only supported for OSX"
exit 1
fi
log 1 "checking COCOA... found"
2007-12-17 07:47:21 +00:00
if [ "$enable_cocoa_quartz" != "0" ]; then
log 1 "checking whether to enable the Quartz window subdriver... yes"
else
log 1 "checking whether to enable the Quartz window subdriver... no"
fi
2007-01-02 19:19:48 +00:00
}
2007-02-16 09:50:28 +00:00
detect_library() {
# $1 - config-param ($with_zlib value)
# $2 - library name ('zlib', sets $zlib)
# $3 - static library name (libz.a)
2010-01-10 13:12:34 +00:00
# $4 - header directory ()
# $5 - header name (zlib.h)
# $6 - force static (if non-empty)
2007-06-17 20:36:14 +00:00
2010-01-10 13:12:34 +00:00
if [ -n "$6" ]; then force_static="1"; fi
2007-02-16 09:50:28 +00:00
2007-01-02 19:19:48 +00:00
# 0 means no, 1 is auto-detect, 2 is force
2007-02-16 09:50:28 +00:00
if [ "$1" = "0" ]; then
log 1 "checking $2... disabled"
2007-01-02 19:19:48 +00:00
2007-02-16 09:50:28 +00:00
eval "$2=\"\""
2007-01-02 19:19:48 +00:00
return 0
fi
2007-02-16 09:50:28 +00:00
log 2 "detecting $2"
2007-01-02 19:19:48 +00:00
2007-02-16 09:50:28 +00:00
if [ "$1" = "1" ] || [ "$1" = "" ] || [ "$1" = "2" ]; then
2010-01-10 13:12:34 +00:00
eval "$2=`ls -1 /usr/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2007-02-16 09:50:28 +00:00
eval "res=\$$2"
if [ -z "$res" ]; then
2010-01-10 13:12:34 +00:00
log 2 " trying /usr/include/$4$5... no"
eval "$2=`ls -1 /usr/local/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2007-01-02 19:19:48 +00:00
fi
2007-02-16 09:50:28 +00:00
eval "res=\$$2"
if [ -z "$res" ]; then
2010-01-10 13:12:34 +00:00
log 2 " trying /usr/local/include/$4$5... no"
2010-02-28 00:22:23 +00:00
eval "$2=`ls -1 /mingw/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
fi
eval "res=\$$2"
if [ -z "$res" ]; then
2010-02-28 15:01:57 +00:00
log 2 " trying /mingw/include/$4$5... no"
2018-06-16 23:28:08 +00:00
eval "$2=`ls -1 /mingw$cpu_type/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
fi
eval "res=\$$2"
if [ -z "$res" ]; then
log 2 " trying /mingw$cpu_type/include/$4$5... no"
2010-02-28 00:22:23 +00:00
eval "$2=`ls -1 /opt/local/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
fi
eval "res=\$$2"
if [ -z "$res" ]; then
log 2 " trying /opt/local/include/$4$5... no"
2007-01-02 19:19:48 +00:00
fi
2010-05-10 17:11:24 +00:00
if [ -z "$res" ] && [ "$os" = "NETBSD" ]; then
eval "$2=`ls -1 /usr/pkg/include/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
eval "res=\$$2"
if [ -z "$res" ]; then
log 2 " trying /usr/pkg/include/$4$5... no"
fi
fi
2010-07-25 23:13:40 +00:00
if [ -z "$res" ] && [ "$os" = "HAIKU" ]; then
2015-12-15 20:43:39 +00:00
if [ -z "$includeDir" ]; then
includeDir=`finddir B_SYSTEM_HEADERS_DIRECTORY`
fi
eval "$2=`ls -1 $includeDir/$4*.h 2>/dev/null | egrep \"\/$5\$\"`"
2010-07-25 23:13:40 +00:00
eval "res=\$$2"
if [ -z "$res" ]; then
2015-12-15 20:43:39 +00:00
log 2 " trying $includeDir/$4$5... no"
2010-07-25 23:13:40 +00:00
fi
fi
2007-01-02 19:19:48 +00:00
2007-02-16 09:50:28 +00:00
eval "res=\$$2"
2007-06-17 20:36:14 +00:00
if [ -n "$res" ] && ( [ -n "$force_static" ] || ( [ "$enable_static" != "0" ] && [ "$os" != "OSX" ] ) ); then
2007-02-16 09:50:28 +00:00
eval "res=\$$2"
log 2 " trying $res... found"
2007-01-02 19:19:48 +00:00
# Now find the static lib, if needed
2007-06-20 19:17:22 +00:00
eval "$2=`ls /lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2007-02-16 09:50:28 +00:00
eval "res=\$$2"
if [ -z "$res" ]; then
log 2 " trying /lib/$3... no"
2007-06-20 19:17:22 +00:00
eval "$2=`ls /usr/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2007-01-02 19:19:48 +00:00
fi
2007-02-16 09:50:28 +00:00
eval "res=\$$2"
if [ -z "$res" ]; then
log 2 " trying /usr/lib/$3... no"
2007-06-20 19:17:22 +00:00
eval "$2=`ls /usr/local/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
2007-01-02 19:19:48 +00:00
fi
2007-02-16 09:50:28 +00:00
eval "res=\$$2"
if [ -z "$res" ]; then
log 2 " trying /usr/local/lib/$3... no"
2010-02-28 00:22:23 +00:00
eval "$2=`ls /mingw/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
fi
eval "res=\$$2"
if [ -z "$res" ]; then
log 2 " trying /mingw/lib/$3... no"
2018-06-16 23:28:08 +00:00
eval "$2=`ls /mingw$cpu_type/lib/*.a 2>/dev/null | egrep \"\/$3\$\"`"
fi
eval "res=\$$2"
if [ -z "$res" ]; then
log 2 " trying /mingw$cpu_type/lib/$3... no"
2007-02-16 09:50:28 +00:00
log 1 "configure: error: $2 couldn't be found"
log 1 "configure: error: you requested a static link, but I can't find $3"
2007-01-02 19:19:48 +00:00
exit 1
fi
fi
else
# Make sure it exists
2007-02-16 09:50:28 +00:00
if [ -f "$1" ]; then
eval "$2=`ls $1 2>/dev/null`"
2007-01-03 16:36:36 +00:00
else
2007-02-16 09:50:28 +00:00
eval "$2=`ls $1/$3 2>/dev/null`"
2007-01-03 16:36:36 +00:00
fi
2007-01-02 19:19:48 +00:00
fi
2007-02-16 09:50:28 +00:00
eval "res=\$$2"
if [ -z "$res" ]; then
log 1 "checking $2... not found"
if [ "$1" = "2" ]; then
log 1 "configure: error: $2 couldn't be found"
2007-01-02 19:19:48 +00:00
exit 1
2007-02-16 09:50:28 +00:00
elif [ "$1" != "1" ]; then
log 1 "configure: error: $2 couldn't be found"
log 1 "configure: error: you supplied '$1', but it seems invalid"
2007-01-02 19:19:48 +00:00
exit 1
fi
2008-11-26 13:12:45 +00:00
eval "with_$2=0"
2007-01-02 19:19:48 +00:00
return 0
fi
2007-02-16 09:50:28 +00:00
eval "res=\$$2"
log 2 " trying $res... found"
log 1 "checking $2... found"
}
detect_zlib() {
2015-08-09 12:42:21 +00:00
detect_pkg_config "$with_zlib" "zlib" "zlib_config" "1.2"
2010-01-10 13:12:34 +00:00
}
detect_lzo2() {
detect_library "$with_lzo2" "lzo2" "liblzo2.a" "lzo/" "lzo1x.h"
2007-02-16 09:50:28 +00:00
}
2007-01-02 19:19:48 +00:00
2018-09-11 23:06:31 +00:00
detect_fluidsynth() {
detect_library "$with_fluidsynth" "fluidsynth" "" "" "fluidsynth.h"
}
2014-03-28 18:12:21 +00:00
detect_pkg_config() {
# $1 - config-param ($with_lzma value)
# $2 - package name ('liblzma')
# $3 - config name ('lzma_config', sets $lzma_config)
# $4 - minimum module version ('2.3')
2015-08-09 12:40:17 +00:00
# $5 - check for dedicated, 1 is "skif if dedicated"
2014-03-28 18:12:21 +00:00
2010-10-27 16:42:20 +00:00
# 0 means no, 1 is auto-detect, 2 is force
2014-03-28 18:12:21 +00:00
if [ "$1" = "0" ]; then
log 1 "checking $2... disabled"
2010-10-27 16:42:20 +00:00
2014-03-28 18:12:21 +00:00
eval "$3=\"\""
2010-10-27 16:42:20 +00:00
return 0
fi
2015-08-09 12:40:17 +00:00
if [ "$5" = "1" ] && [ "$1" = "1" ] && [ "$enable_dedicated" != "0" ]; then
log 1 "checking $2... dedicated server, skipping"
eval "$3=\"\""
return 0
fi
2014-03-28 18:12:21 +00:00
log 2 "detecting $2"
if [ "$1" = "1" ] || [ "$1" = "" ] || [ "$1" = "2" ]; then
2015-08-08 08:52:21 +00:00
pkg_config_call="$pkg_config $2"
2010-10-27 16:42:20 +00:00
else
2014-03-28 18:12:21 +00:00
pkg_config_call="$1"
2010-10-27 16:42:20 +00:00
fi
2014-03-28 18:12:21 +00:00
version=`$pkg_config_call --modversion 2>/dev/null`
2010-10-27 16:42:20 +00:00
ret=$?
2014-03-28 18:12:21 +00:00
check_version "$4" "$version"
version_ok=$?
log 2 "executing $pkg_config_call --modversion"
2010-10-27 16:42:20 +00:00
log 2 " returned $version"
log 2 " exit code $ret"
2014-03-28 18:12:21 +00:00
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version_ok" != "1" ]; then
if [ -n "$version" ] && [ "$version_ok" != "1" ]; then
log 1 "checking $2... needs at least version $4, $2 NOT enabled"
else
log 1 "checking $2... not found"
fi
2010-10-27 16:42:20 +00:00
# It was forced, so it should be found.
2014-03-28 18:12:21 +00:00
if [ "$1" != "1" ]; then
2015-08-08 08:52:21 +00:00
log 1 "configure: error: $pkg_config $2 couldn't be found"
2014-03-28 18:12:21 +00:00
log 1 "configure: error: you supplied '$1', but it seems invalid"
2010-10-27 16:42:20 +00:00
exit 1
fi
2014-03-28 18:12:21 +00:00
eval "$3=\"\""
2010-10-27 16:42:20 +00:00
return 0
fi
2014-03-28 18:12:21 +00:00
eval "$3=\"$pkg_config_call\""
log 1 "checking $2... found"
2010-10-27 16:42:20 +00:00
}
2014-03-28 18:12:21 +00:00
detect_lzma() {
detect_pkg_config "$with_lzma" "liblzma" "lzma_config" "5.0"
}
2013-11-13 19:32:37 +00:00
2014-03-28 18:12:21 +00:00
detect_xdg_basedir() {
detect_pkg_config "$with_xdg_basedir" "libxdg-basedir" "xdg_basedir_config" "1.2"
2013-11-13 19:32:37 +00:00
}
2019-10-09 19:57:28 +00:00
detect_fcitx() {
if ([ "$with_fcitx" = "1" ] && [ "$enable_dedicated" = "0" ]) || [ "$with_fcitx" = "2" ]; then
2019-10-13 09:27:12 +00:00
if [ -z "$sdl2_config" ]; then
if [ "$with_fcitx" = "2" ]; then
log 1 "configure: error: fcitx requires sdl2"
log 1 "configure: error: you supplied --with-fcitx"
exit 1
fi
log 1 "checking fcitx... no sdl2, skipping"
fcitx_config=""
dbus_config=""
x11_config=""
return 0
fi
2019-10-09 19:57:28 +00:00
detect_pkg_config "$with_fcitx" "dbus-1" "dbus_config" "1.0" "1"
detect_pkg_config "$with_fcitx" "x11" "x11_config" "1.0" "1"
if [ -z "$dbus_config" ]; then
log 1 "checking fcitx... no dbus, skipping"
fcitx_config=""
dbus_config=""
x11_config=""
return 0
elif [ -z "$x11_config" ]; then
log 1 "checking fcitx... no x11, skipping"
fcitx_config=""
dbus_config=""
x11_config=""
return 0
fi
fi
detect_pkg_config "$with_fcitx" "fcitx" "fcitx_config" "4.0" "1"
}
2007-01-02 19:19:48 +00:00
detect_png() {
2014-03-28 18:19:48 +00:00
detect_pkg_config "$with_png" "libpng" "png_config" "1.2"
2007-01-02 19:19:48 +00:00
}
detect_freetype() {
2018-11-25 01:00:42 +00:00
if [ "$with_freetype" = "1" ] && ([ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]); then
log 1 "checking freetype2... WIN32, skipping"
freetype_config=""
return 0
fi
2015-08-09 12:41:12 +00:00
detect_pkg_config "$with_freetype" "freetype2" "freetype_config" "2.2" "1"
2007-01-02 19:19:48 +00:00
}
detect_fontconfig() {
# 0 means no, 1 is auto-detect, 2 is force
2007-01-07 09:48:10 +00:00
if [ "$with_fontconfig" = "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking libfontconfig... disabled"
fontconfig_config=""
return 0
fi
2018-04-29 12:21:31 +00:00
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ]; then
2007-03-07 16:46:13 +00:00
log 1 "checking libfontconfig... WIN32, skipping"
fontconfig_config=""
return 0
fi
2009-10-17 22:36:43 +00:00
if [ "$os" = "OSX" ]; then
log 1 "checking libfontconfig... OSX, skipping"
fontconfig_config=""
return 0
fi
2015-08-09 12:40:17 +00:00
detect_pkg_config "$with_fontconfig" "fontconfig" "fontconfig_config" "2.3" "1"
2007-01-02 19:19:48 +00:00
}
2015-08-09 13:54:17 +00:00
detect_icu_layout() {
2018-10-28 22:30:49 +00:00
if [ "$with_cocoa" != "0" ] && [ "$with_icu_layout" = "1" ]; then
log 1 "checking icu-lx... OSX, skipping"
icu_layout_config=""
return 0
fi
2015-08-09 13:54:17 +00:00
detect_pkg_config "$with_icu_layout" "icu-lx" "icu_layout_config" "4.8" "1"
}
2008-10-17 17:14:09 +00:00
2015-08-09 13:54:17 +00:00
detect_icu_sort() {
2018-10-28 22:30:49 +00:00
if [ "$with_cocoa" != "0" ] && [ "$with_icu_sort" = "1" ]; then
log 1 "checking icu-i18n... OSX, skipping"
icu_sort_config=""
return 0
fi
2015-08-09 13:54:17 +00:00
detect_pkg_config "$with_icu_sort" "icu-i18n" "icu_sort_config" "4.8" "1"
2008-10-17 17:14:09 +00:00
}
2007-01-02 19:19:48 +00:00
detect_iconv() {
# 0 means no, 1 is auto-detect, 2 is force
2007-01-07 09:48:10 +00:00
if [ "$with_iconv" = "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking iconv... disabled"
return 0
fi
2007-01-07 09:48:10 +00:00
if [ "$with_iconv" = "1" ] && [ "$os" != "OSX" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking iconv... not OSX, skipping"
with_iconv="0"
return 0
fi
# Try to find iconv.h, seems to only thing to detect iconv with
2007-01-07 09:48:10 +00:00
if [ "$with_iconv" = "1" ] || [ "$with_iconv" = "" ] || [ "$with_iconv" = "2" ]; then
2018-09-24 21:17:55 +00:00
# Iterate over search paths
iconv=""
search_paths=`LC_ALL=C $cxx_host $OSX_SYSROOT $CFLAGS -E - -v </dev/null 2>&1 | \
$awk '/#include <...> search starts here:/{flag=1;next}/End of search list./{flag=0}flag'`
for path in $search_paths; do
iconv=`ls -1 $path 2>/dev/null | grep "iconv.h"`
if [ -n "$iconv" ]; then
break
fi
done
2007-01-02 19:19:48 +00:00
else
# Make sure it exists
iconv=`ls $with_iconv/include/iconv.h 2>/dev/null`
fi
2007-01-07 09:48:10 +00:00
if [ -z "$iconv" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking iconv... not found"
2007-01-07 09:48:10 +00:00
if [ "$with_iconv" = "2" ]; then
2007-01-02 19:19:48 +00:00
log 1 "configure: error: iconv couldn't be found"
exit 1
2007-01-07 09:48:10 +00:00
elif [ "$with_iconv" != "1" ]; then
2007-01-02 19:19:48 +00:00
log 1 "configure: error: iconv couldn't be found"
log 1 "configure: error: you supplied '$with_iconv', but I couldn't detect iconv in it"
exit 1
fi
return 0
fi
2007-01-07 09:48:10 +00:00
if [ "$with_iconv" = "1" ]; then
2007-01-02 19:19:48 +00:00
with_iconv="2"
fi
log 2 "found iconv in $iconv"
log 1 "checking iconv... found"
2007-11-07 21:35:33 +00:00
2010-12-25 12:49:36 +00:00
# There are different implementations of iconv. The older ones,
# e.g. SUSv2, pass a const pointer, whereas the newer ones, e.g.
# IEEE 1003.1 (2004), pass a non-const pointer.
2007-11-07 21:35:33 +00:00
cat > tmp.iconv.cpp << EOF
#include "src/stdafx.h"
#include <iconv.h>
int main() {
static char buf[1024];
iconv_t convd = 0;
const char *inbuf = "";
char *outbuf = buf;
size_t outlen = 1023;
size_t inlen = 0;
return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
}
EOF
2009-10-04 20:53:26 +00:00
execute="$cxx_host $OSX_SYSROOT $CFLAGS -c tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
2009-04-12 01:10:06 +00:00
eval $execute > /dev/null
2007-11-07 21:35:33 +00:00
ret=$?
log 2 "executing $execute"
log 2 " exit code $ret"
2010-12-25 12:49:36 +00:00
if [ "$ret" = "0" ]; then have_non_const_iconv="no"; else have_non_const_iconv="yes"; fi
log 1 "checking if iconv has non-const inbuf... $have_non_const_iconv"
2008-10-22 20:20:08 +00:00
cat > tmp.iconv.cpp << EOF
#include "src/stdafx.h"
#include <iconv.h>
int main() {
static char buf[1024];
iconv_t convd = 0;
char *inbuf = "";
char *outbuf = buf;
size_t outlen = 1023;
size_t inlen = 0;
return iconv(convd, &inbuf, &inlen, &outbuf, &outlen);
}
EOF
2009-10-04 20:53:26 +00:00
execute="$cxx_host $OSX_SYSROOT $OSX_LD_SYSROOT $CFLAGS tmp.iconv.cpp -o tmp.iconv -DTESTING 2>&1"
2009-04-12 01:10:06 +00:00
eval $execute > /dev/null
2008-10-22 20:20:08 +00:00
ret=$?
log 2 "executing $execute"
log 2 " exit code $ret"
if [ "$ret" = "0" ]; then link_to_iconv="no"; else link_to_iconv="yes"; fi
log 1 "checking whether to link to iconv... $link_to_iconv"
2007-11-07 21:35:33 +00:00
rm -f tmp.iconv tmp.iconv.cpp
2007-01-02 19:19:48 +00:00
}
_detect_sort() {
sort_test_in="d
a
c
b"
sort_test_out="a
b
c
d"
log 2 "running echo <array> | $1"
2007-01-07 09:48:10 +00:00
if [ "`echo \"$sort_test_in\" | $1 2>/dev/null`" = "$sort_test_out" ]; then
2007-01-02 19:19:48 +00:00
sort="$1"
log 2 " result was valid"
else
log 2 " result was invalid"
fi
}
detect_sort() {
2007-01-07 09:48:10 +00:00
if [ "$with_sort" = "0" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking sort... disabled"
return
fi
2007-01-07 09:48:10 +00:00
if [ "$with_sort" = "1" ] || [ "$with_sort" = "2" ]; then
2007-01-02 19:19:48 +00:00
_detect_sort "sort"
if [ -z "$sort" ]; then _detect_sort "/sbin/sort"; fi
if [ -z "$sort" ]; then _detect_sort "/usr/sbin/sort"; fi
if [ -z "$sort" ]; then _detect_sort "/usr/local/sbin/sort"; fi
if [ -z "$sort" ]; then _detect_sort "/bin/sort"; fi
if [ -z "$sort" ]; then _detect_sort "/usr/bin/sort"; fi
if [ -z "$sort" ]; then _detect_sort "/usr/local/bin/sort"; fi
else
_detect_sort "$with_sort"
fi
2007-01-07 09:48:10 +00:00
if [ -z "$sort" ]; then
if [ "$with_sort" = "2" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking sort... not found"
log 1 "configure: error: couldn't detect sort on your system"
exit 1
2007-01-07 09:48:10 +00:00
elif [ "$with_sort" != "1" ]; then
2007-01-02 19:19:48 +00:00
log 1 "checking sort... $with_sort not found"
log 1 "configure: error: '$with_sort' doesn't look like a sort to me"
log 1 "configure: error: please verify its location and function and try again"
exit 1
else
log 1 "checking sort... not found"
fi
else
log 1 "checking sort... $sort"
fi
}
2011-12-05 20:11:42 +00:00
detect_grfcodec() {
# 0 means no, 1 is auto-detect, 2 is force
if [ "$with_grfcodec" = "0" ]; then
log 1 "checking grfcodec... disabled"
grfcodec=""
return 0
fi
if [ "$with_grfcodec" = "1" ] || [ "$with_grfcodec" = "" ] || [ "$with_grfcodec" = "2" ]; then
grfcodec="grfcodec"
else
grfcodec="$with_grfcodec"
fi
2011-12-09 15:06:14 +00:00
version=`$grfcodec -v 2>/dev/null | $awk '{print $3}' | sed 's/[rM]//g;s/-/0/'`
2011-12-05 20:11:42 +00:00
ret=$?
log 2 "executing grfcodec -v"
log 2 " returned $version"
log 2 " exit code $ret"
2014-09-21 07:57:45 +00:00
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "985" ]; then
if [ -n "$version" ] && [ "$version" -lt "985" ]; then
log 1 "checking grfcodec... needs at least version 6.0.5 (r985), disabled"
2011-12-05 20:11:42 +00:00
else
log 1 "checking grfcodec... not found"
fi
# It was forced, so it should be found.
if [ "$with_grfcodec" != "1" ]; then
log 1 "configure: error: grfcodec couldn't be found"
log 1 "configure: error: you supplied '$with_grfcodec', but it seems invalid"
exit 1
fi
grfcodec=""
return 0
fi
log 1 "checking grfcodec... found"
}
detect_nforenum() {
# 0 means no, 1 is auto-detect, 2 is force
if [ "$with_nforenum" = "0" ]; then
log 1 "checking nforenum... disabled"
nforenum=""
return 0
fi
if [ "$with_nforenum" = "1" ] || [ "$with_nforenum" = "" ] || [ "$with_nforenum" = "2" ]; then
nforenum="nforenum"
else
nforenum="$with_nforenum"
fi
2011-12-09 15:06:14 +00:00
version=`$nforenum -v 2>/dev/null | $awk '{print $3}' | sed 's/[rM]//g;s/-/0/'`
2011-12-05 20:11:42 +00:00
ret=$?
log 2 "executing nforenum -v"
log 2 " returned $version"
log 2 " exit code $ret"
2014-09-21 07:57:45 +00:00
if [ -z "$version" ] || [ "$ret" != "0" ] || [ "$version" -lt "985" ]; then
if [ -n "$version" ] && [ "$version" -lt "985" ]; then
log 1 "checking nforenum... needs at least version 6.0.5 (r985), disabled"
2011-12-05 20:11:42 +00:00
else
log 1 "checking nforenum... not found"
fi
# It was forced, so it should be found.
if [ "$with_nforenum" != "1" ]; then
log 1 "configure: error: nforenum couldn't be found"
log 1 "configure: error: you supplied '$with_nforenum', but it seems invalid"
exit 1
fi
nforenum=""
return 0
fi
log 1 "checking nforenum... found"
}
2016-09-27 00:05:42 +00:00
_detect_cputype_width() {
echo "#define _SQ64 1" > $1.cpp
echo "#include \"src/stdafx.h\"" >> $1.cpp
echo "assert_compile(sizeof(size_t) == $2);" >> $1.cpp
echo "int main() { return 0; }" >> $1.cpp
execute="$cxx_host $CFLAGS -std=c++11 $1.cpp -o $1 -DTESTING 2>&1"
2007-06-17 20:36:14 +00:00
cpu_type="`eval $execute 2>/dev/null`"
ret=$?
log 2 "executing $execute"
log 2 " returned $cpu_type"
log 2 " exit code $ret"
2016-09-27 00:05:42 +00:00
rm -f $1 $1.cpp
return $ret
}
detect_cputype() {
if [ -n "$cpu_type" ] && [ "$cpu_type" != "DETECT" ]; then
log 1 "forcing cpu-type... $cpu_type bits"
return;
fi
_detect_cputype_width tmp.32bit 4
result32=$?
_detect_cputype_width tmp.64bit 8
result64=$?
if [ "$result32" = 0 ] && [ "$result64" != 0 ]; then
cpu_type="32"
elif [ "$result32" != 0 ] && [ "$result64" = 0 ]; then
cpu_type="64"
else
log 1 "configure: unable to determine cpu-type (pointer width)"
exit 1
fi
2007-06-17 20:36:14 +00:00
log 1 "detecting cpu-type... $cpu_type bits"
}
2014-01-02 08:35:45 +00:00
detect_sse_capable_architecture() {
# 0 means no, 1 is auto-detect, 2 is force
if [ "$with_sse" = "0" ]; then
log 1 "checking SSE... disabled"
return
fi
echo "#define _SQ64 1" > tmp.sse.cpp
echo "#include <xmmintrin.h>" >> tmp.sse.cpp
echo "#include <smmintrin.h>" >> tmp.sse.cpp
echo "#include <tmmintrin.h>" >> tmp.sse.cpp
echo "int main() { return 0; }" >> tmp.sse.cpp
execute="$cxx_host -msse4.1 $CFLAGS tmp.sse.cpp -o tmp.sse 2>&1"
sse="`eval $execute 2>/dev/null`"
ret=$?
log 2 "executing $execute"
log 2 " returned $sse"
log 2 " exit code $ret"
if [ "$ret" = "0" ]; then
log 1 "detecting SSE... found"
else
# It was forced, so it should be found.
if [ "$with_sse" != "1" ]; then
2019-09-29 20:27:32 +00:00
log 1 "configure: error: SSE couldn't be found"
2014-01-02 08:35:45 +00:00
log 1 "configure: error: you force enabled SSE, but it seems unavailable"
exit 1
fi
log 1 "detecting SSE... not found"
with_sse="0"
fi
2014-01-02 09:07:50 +00:00
rm -f tmp.sse tmp.exe tmp.sse.cpp
2014-01-02 08:35:45 +00:00
}
2007-01-02 19:19:48 +00:00
make_sed() {
2008-07-27 20:43:21 +00:00
T_CFLAGS="$CFLAGS"
2009-09-07 21:01:24 +00:00
T_CXXFLAGS="$CXXFLAGS"
2008-07-28 23:10:26 +00:00
T_LDFLAGS="$LDFLAGS"
2008-07-27 20:43:21 +00:00
2007-01-02 19:19:48 +00:00
SRC_OBJS_DIR="$BASE_SRC_OBJS_DIR/$OBJS_SUBDIR"
# All the data needed to compile a single target
# Make sure if you compile multiple targets to
# use multiple OBJS_DIR, because all in-between
# binaries are stored in there, and nowhere else.
SRC_REPLACE="
2009-05-16 12:36:33 +00:00
s@!!CC_HOST!!@$cc_host@g;
s@!!CXX_HOST!!@$cxx_host@g;
s@!!CC_BUILD!!@$cc_build@g;
s@!!CXX_BUILD!!@$cxx_build@g;
s@!!WINDRES!!@$windres@g;
s@!!STRIP!!@$strip $strip_arg@g;
s@!!LIPO!!@$lipo@g;
s@!!CFLAGS!!@$T_CFLAGS@g;
s@!!CFLAGS_BUILD!!@$CFLAGS_BUILD@g;
2009-09-07 21:01:24 +00:00
s@!!CXXFLAGS!!@$T_CXXFLAGS@g;
s@!!CXXFLAGS_BUILD!!@$CXXFLAGS_BUILD@g;
2009-05-16 12:36:33 +00:00
s@!!STRGEN_FLAGS!!@$strgen_flags@g;
s@!!LIBS!!@$LIBS@g;
s@!!LDFLAGS!!@$T_LDFLAGS@g;
2009-08-21 21:21:09 +00:00
s@!!LDFLAGS_BUILD!!@$LDFLAGS_BUILD@g;
2009-05-16 12:36:33 +00:00
s@!!BIN_DIR!!@$BIN_DIR@g;
s@!!ROOT_DIR!!@$ROOT_DIR@g;
s@!!MEDIA_DIR!!@$MEDIA_DIR@g;
s@!!SOURCE_LIST!!@$SOURCE_LIST@g;
s@!!SRC_OBJS_DIR!!@$SRC_OBJS_DIR@g;
s@!!LANG_OBJS_DIR!!@$LANG_OBJS_DIR@g;
2010-08-14 14:50:06 +00:00
s@!!GRF_OBJS_DIR!!@$GRF_OBJS_DIR@g;
2011-03-03 21:08:20 +00:00
s@!!SETTING_OBJS_DIR!!@$SETTING_OBJS_DIR@g;
2009-05-16 12:36:33 +00:00
s@!!SRC_DIR!!@$SRC_DIR@g;
s@!!SCRIPT_SRC_DIR!!@$SCRIPT_SRC_DIR@g;
s@!!OSXAPP!!@$OSXAPP@g;
s@!!LANG_DIR!!@$LANG_DIR@g;
s@!!TTD!!@$TTD@g;
s@!!BINARY_DIR!!@$prefix_dir/$binary_dir@g;
s@!!DATA_DIR!!@$prefix_dir/$data_dir@g;
s@!!DOC_DIR!!@$prefix_dir/$doc_dir@g;
s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
s@!!ICON_DIR!!@$prefix_dir/$icon_dir@g;
s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
s@!!PERSONAL_DIR!!@$personal_dir@g;
s@!!SHARED_DIR!!@$shared_dir@g;
s@!!INSTALL_DIR!!@$install_dir@g;
s@!!BINARY_NAME!!@$binary_name@g;
s@!!STRGEN!!@$STRGEN@g;
s@!!DEPEND!!@$DEPEND@g;
2011-03-03 21:08:20 +00:00
s@!!SETTINGSGEN!!@$SETTINGSGEN@g;
2009-05-16 12:36:33 +00:00
s@!!STAGE!!@$STAGE@g;
s@!!MAKEDEPEND!!@$makedepend@g;
s@!!CFLAGS_MAKEDEP!!@$cflags_makedep@g;
s@!!SORT!!@$sort@g;
s@!!CONFIG_CACHE_COMPILER!!@config.cache.compiler@g;
s@!!CONFIG_CACHE_LINKER!!@config.cache.linker@g;
s@!!CONFIG_CACHE_SOURCE!!@config.cache.source@g;
s@!!CONFIG_CACHE_VERSION!!@config.cache.version@g;
s@!!CONFIG_CACHE_SOURCE_LIST!!@config.cache.source.list@g;
s@!!CONFIG_CACHE_PWD!!@config.cache.pwd@g;
2016-06-10 18:57:51 +00:00
s@!!CONFIG_CACHE_INVOCATION!!@config.cache.invocation@g;
2009-05-16 12:36:33 +00:00
s@!!LANG_SUPPRESS!!@$lang_suppress@g;
s@!!OBJS_C!!@$OBJS_C@g;
s@!!OBJS_CPP!!@$OBJS_CPP@g;
s@!!OBJS_MM!!@$OBJS_MM@g;
s@!!OBJS_RC!!@$OBJS_RC@g;
s@!!SRCS!!@$SRCS@g;
s@!!OS!!@$os@g;
2015-11-17 18:56:57 +00:00
s@!!CPU_TYPE!!@$cpu_type@g;
2009-05-16 12:36:33 +00:00
s@!!CONFIGURE_FILES!!@$CONFIGURE_FILES@g;
s@!!AWK!!@$awk@g;
s@!!DISTCC!!@$distcc@g;
2011-12-05 20:11:42 +00:00
s@!!NFORENUM!!@$nforenum@g;
s@!!GRFCODEC!!@$grfcodec@g;
2019-10-14 21:17:44 +00:00
s@!!CONFIGURE_INVOCATION!!@`echo "$CONFIGURE_INVOCATION" | sed 's!@!\\\\@!g;s!"!\\\\\\\\"!g'`@g;
2007-01-02 19:19:48 +00:00
"
2008-07-22 17:18:53 +00:00
2008-07-23 15:37:20 +00:00
if [ "$icon_theme_dir" != "" ]; then
SRC_REPLACE="$SRC_REPLACE
2009-05-16 12:36:33 +00:00
s@!!ICON_THEME_DIR!!@$prefix_dir/$icon_theme_dir@g;
2008-07-23 15:37:20 +00:00
"
else
SRC_REPLACE="$SRC_REPLACE
2009-05-16 12:36:33 +00:00
s@!!ICON_THEME_DIR!!@@g;
2008-07-23 15:37:20 +00:00
"
fi
if [ "$man_dir" != "" ]; then
SRC_REPLACE="$SRC_REPLACE
2009-05-16 12:36:33 +00:00
s@!!MAN_DIR!!@$prefix_dir/$man_dir@g;
2008-07-23 15:37:20 +00:00
"
else
SRC_REPLACE="$SRC_REPLACE
2009-05-16 12:36:33 +00:00
s@!!MAN_DIR!!@@g;
2008-07-23 15:37:20 +00:00
"
fi
if [ "$menu_dir" != "" ]; then
2008-07-22 17:18:53 +00:00
SRC_REPLACE="$SRC_REPLACE
2009-05-16 12:36:33 +00:00
s@!!MENU_DIR!!@$prefix_dir/$menu_dir@g;
2008-07-22 17:18:53 +00:00
"
else
SRC_REPLACE="$SRC_REPLACE
2009-05-16 12:36:33 +00:00
s@!!MENU_DIR!!@@g;
2008-07-22 17:18:53 +00:00
"
fi
}
generate_menu_item() {
MENU_REPLACE="
2009-05-16 12:36:33 +00:00
s@!!TTD!!@$TTD@g;
s@!!MENU_GROUP!!@$menu_group@g;
s@!!MENU_NAME!!@$menu_name@g
2008-07-22 17:18:53 +00:00
"
2008-12-17 23:08:11 +00:00
log 1 "Generating menu item..."
2008-09-02 15:56:31 +00:00
mkdir -p media
2008-07-22 17:18:53 +00:00
< $ROOT_DIR/media/openttd.desktop.in sed "$MENU_REPLACE" > media/openttd.desktop
2007-01-02 19:19:48 +00:00
}
generate_main() {
STAGE="[MAIN]"
make_sed
# Create the main Makefile
2008-12-17 23:08:11 +00:00
log 1 "Generating Makefile..."
2008-09-04 19:15:52 +00:00
echo "# Auto-generated file from 'Makefile.in' -- DO NOT EDIT" > Makefile
< $ROOT_DIR/Makefile.in sed "$SRC_REPLACE" >> Makefile
2008-09-02 15:34:38 +00:00
cp $ROOT_DIR/Makefile.bundle.in Makefile.bundle
2007-01-02 19:19:48 +00:00
echo "# Auto-generated file -- DO NOT EDIT" > Makefile.am
2007-01-07 08:26:45 +00:00
echo >> Makefile.am
2007-01-02 19:19:48 +00:00
# Make the copy of the source-list, so we don't trigger an unwanted recompile
cp $SOURCE_LIST config.cache.source.list
2008-09-02 16:28:31 +00:00
# Add the current directory, so we don't trigger an unwanted recompile
echo "`pwd`" > config.cache.pwd
2007-01-02 19:19:48 +00:00
# Make sure config.cache is OLDER then config.cache.source.list
touch config.cache
2008-09-02 16:28:31 +00:00
touch config.pwd
2008-07-22 17:18:53 +00:00
2008-07-23 15:37:20 +00:00
if [ "$menu_dir" != "" ]; then
2008-07-22 17:18:53 +00:00
generate_menu_item
fi
2007-01-02 19:19:48 +00:00
}
generate_lang() {
STAGE="[LANG]"
make_sed
# Create the language file
mkdir -p $LANG_OBJS_DIR
2008-12-17 23:08:11 +00:00
log 1 "Generating lang/Makefile..."
2008-09-04 19:15:52 +00:00
echo "# Auto-generated file from 'Makefile.lang.in' -- DO NOT EDIT" > $LANG_OBJS_DIR/Makefile
< $ROOT_DIR/Makefile.lang.in sed "$SRC_REPLACE" >> $LANG_OBJS_DIR/Makefile
2007-01-02 19:19:48 +00:00
echo "DIRS += $LANG_OBJS_DIR" >> Makefile.am
echo "LANG_DIRS += $LANG_OBJS_DIR" >> Makefile.am
}
2011-03-03 21:08:20 +00:00
generate_settings() {
STAGE="[SETTING]"
make_sed
# Create the language file
mkdir -p $SETTING_OBJS_DIR
log 1 "Generating setting/Makefile..."
echo "# Auto-generated file from 'Makefile.settings.in' -- DO NOT EDIT" > $SETTING_OBJS_DIR/Makefile
< $ROOT_DIR/Makefile.setting.in sed "$SRC_REPLACE" >> $SETTING_OBJS_DIR/Makefile
echo "DIRS += $SETTING_OBJS_DIR" >> Makefile.am
}
2010-08-14 14:50:06 +00:00
generate_grf() {
2013-04-24 20:30:02 +00:00
STAGE="[BASESET]"
2010-08-14 14:50:06 +00:00
make_sed
# Create the language file
mkdir -p $GRF_OBJS_DIR
log 1 "Generating grf/Makefile..."
echo "# Auto-generated file from 'Makefile.grf.in' -- DO NOT EDIT" > $GRF_OBJS_DIR/Makefile
< $ROOT_DIR/Makefile.grf.in sed "$SRC_REPLACE" >> $GRF_OBJS_DIR/Makefile
echo "DIRS += $GRF_OBJS_DIR" >> Makefile.am
}
2007-01-02 19:19:48 +00:00
generate_src_normal() {
STAGE=$1
make_sed
# Create the source file
mkdir -p $SRC_OBJS_DIR
2008-12-17 23:08:11 +00:00
log 1 "Generating $2/Makefile..."
2008-09-04 19:15:52 +00:00
echo "# Auto-generated file from 'Makefile.src.in' -- DO NOT EDIT" > $SRC_OBJS_DIR/Makefile
< $ROOT_DIR/Makefile.src.in sed "$SRC_REPLACE" >> $SRC_OBJS_DIR/Makefile
2007-01-02 19:19:48 +00:00
echo "DIRS += $SRC_OBJS_DIR" >> Makefile.am
echo "SRC_DIRS += $SRC_OBJS_DIR" >> Makefile.am
}
generate_src_osx() {
cc_host_orig="$cc_host"
cxx_host_orig="$cxx_host"
2009-10-04 20:53:26 +00:00
CFLAGS_orig="$CFLAGS"
LDFLAGS_orig="$LDFLAGS"
2010-11-14 22:57:32 +00:00
for type in $enable_universal; do
2007-01-02 19:19:48 +00:00
2010-11-14 22:57:32 +00:00
if [ -n "$osx_sdk_104_path" ]; then
# Use 10.4 SDK for 32-bit targets
CFLAGS="-isysroot $osx_sdk_104_path $CFLAGS_orig"
LDFLAGS="-Wl,-syslibroot,$osx_sdk_104_path $LDFLAGS_orig"
2009-10-04 20:53:26 +00:00
fi
2009-05-03 15:46:36 +00:00
2010-11-14 22:57:32 +00:00
# We don't want to duplicate the x86_64 stuff for each target, so do it once here
if [ "$type" = "ppc64" ] || [ "$type" = "x86_64" ]; then
2010-12-25 12:49:36 +00:00
# 64 bits is always 10.5 or higher. Furthermore it has a non const ICONV
2010-11-14 22:57:32 +00:00
# and they also removed support for QuickTime/QuickDraw
if [ -n "$osx_sdk_path" ]; then
CFLAGS="-isysroot $osx_sdk_path $CFLAGS_orig"
LDFLAGS="-Wl,-syslibroot,$osx_sdk_path $LDFLAGS_orig"
fi
2020-04-12 15:43:08 +00:00
CFLAGS="$CFLAGS -D_SQ64"
2010-11-14 22:57:32 +00:00
fi
case $type in
ppc)
BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc"
cc_host="$cc_host_orig -arch ppc -mmacosx-version-min=10.3"
cxx_host="$cxx_host_orig -arch ppc -mmacosx-version-min=10.3"
generate_src_normal "[ppc]" "objs/ppc";;
ppc970)
BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc970"
cc_host="$cc_host_orig -arch ppc970 -mmacosx-version-min=10.3 -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
cxx_host="$cxx_host_orig -arch ppc970 -mmacosx-version-min=10.3 -mcpu=G5 -mpowerpc64 -mtune=970 -mcpu=970 -mpowerpc-gpopt"
generate_src_normal "[ppc970]" "objs/ppc970";;
i386)
BASE_SRC_OBJS_DIR="$OBJS_DIR/i386"
cc_host="$cc_host_orig -arch i386 -mmacosx-version-min=10.4"
cxx_host="$cxx_host_orig -arch i386 -mmacosx-version-min=10.4"
generate_src_normal "[i386]" "objs/i386";;
ppc64)
BASE_SRC_OBJS_DIR="$OBJS_DIR/ppc64"
cc_host="$cc_host_orig -arch ppc64 -mmacosx-version-min=10.5"
cxx_host="$cxx_host_orig -arch ppc64 -mmacosx-version-min=10.5"
generate_src_normal "[ppc64]" "objs/ppc64";;
x86_64)
BASE_SRC_OBJS_DIR="$OBJS_DIR/x86_64"
cc_host="$cc_host_orig -arch x86_64 -mmacosx-version-min=10.5"
cxx_host="$cxx_host_orig -arch x86_64 -mmacosx-version-min=10.5"
generate_src_normal "[x86_64]" "objs/x86_64";;
*) log 1 "Unknown architecture requested for universal build: $type";;
esac
done
2007-01-02 19:19:48 +00:00
}
generate_src() {
2007-01-07 09:48:10 +00:00
if [ "$os" = "OSX" ] && [ "$enable_universal" != "0" ]; then
2007-01-02 19:19:48 +00:00
generate_src_osx
else
generate_src_normal "[SRC]" "objs"
fi
}
showhelp() {
echo "'configure' configures OpenTTD."
echo ""
echo "Usage: $0 [OPTION]... [VAR=VALUE]..."
echo ""
echo "To assign environment variables (e.g., CC, CFLAGS...), specify them as"
echo "VAR=VALUE. See below for descriptions of some of the useful variables."
echo ""
echo "Defaults for the options are specified in brackets."
echo ""
echo "Configuration:"
echo " -h, --help display this help and exit"
echo ""
echo "System types:"
echo " --build=BUILD configure for building on BUILD [guessed]"
2007-01-02 22:28:15 +00:00
echo " --host=HOST cross-compile to build programs to run"
echo " on HOST [BUILD]"
2007-01-02 19:19:48 +00:00
echo " --windres=WINDRES the windres to use [HOST-windres]"
echo " --strip=STRIP the strip to use [HOST-strip]"
2007-02-19 19:59:19 +00:00
echo " --awk=AWK the awk to use in configure [awk]"
2015-08-08 08:52:21 +00:00
echo " --pkg-config=PKG-CONFIG the pkg-config to use in configure [pkg-config]"
2007-01-02 19:19:48 +00:00
echo " --lipo=LIPO the lipo to use (OSX ONLY) [HOST-lipo]"
2008-09-02 15:59:21 +00:00
echo " --os=OS the OS we are compiling for [DETECT]"
2015-04-11 10:25:36 +00:00
echo " DETECT/UNIX/OSX/FREEBSD/DRAGONFLY/OPENBSD/"
2019-03-04 18:46:11 +00:00
echo " NETBSD/HPUX/SUNOS/CYGWIN/"
Remove: DOS support
In 10 years there was no active development on DOS. Although it
turned out to still work, the FPS was very bad. There is little
interest in the current community to look into this.
Further more, we like to switch to c++11 functions for threads,
which are not implemented by DJGPP, the only current compiler
for DOS.
Additionally, DOS is the only platform which does not support
networking. It is the reason we have tons of #ifdefs to support
disabling networking.
By removing DOS support, we can both use c++11 functions for threads,
and remove all the code related to disabling network. Sadly, this
means we have to see DOS go.
Of course, if you feel up for the task, simply revert this commit,
and implement stub c++11 functions for threads and stub functions
for networking. We are more than happy to accept such Pull Request.
2019-03-19 21:23:09 +00:00
echo " MINGW/OS2/HAIKU"
2007-01-02 19:19:48 +00:00
echo ""
echo "Paths:"
2007-01-02 22:28:15 +00:00
echo " --prefix-dir=dir specifies the prefix for all installed"
2008-09-02 15:59:21 +00:00
echo " files [/usr/local]"
2007-01-02 22:28:15 +00:00
echo " --binary-dir=dir location of the binary. Will be prefixed"
2008-09-02 15:59:21 +00:00
echo " with the prefix-dir [games]"
2007-01-02 22:28:15 +00:00
echo " --data-dir=dir location of data files (lang, data, gm)."
echo " Will be prefixed with the prefix-dir"
2008-09-02 15:59:21 +00:00
echo " [share/games/openttd]"
2008-07-23 15:37:20 +00:00
echo " --doc-dir=dir location of the doc files"
echo " Will be prefixed with the prefix-dir"
echo " [$doc_dir]"
2007-01-02 22:28:15 +00:00
echo " --icon-dir=dir location of icons. Will be prefixed"
2008-09-02 15:59:21 +00:00
echo " with the prefix-dir [share/pixmaps]"
2008-07-23 15:37:20 +00:00
echo " --icon-theme-dir=dir location of icon theme."
echo " Will be prefixed with the prefix-dir"
echo " and postfixed with size-dirs [$icon_theme_dir]"
echo " --man-dir=dir location of the manual page (UNIX only)"
echo " Will be prefixed with the prefix-dir"
echo " [$man_dir]"
2008-07-22 17:18:53 +00:00
echo " --menu-dir=dir location of the menu item. (UNIX only, except OSX)"
echo " Will be prefixed with the prefix-dir"
2008-09-02 15:59:21 +00:00
echo " [share/applications]"
2008-01-13 17:45:29 +00:00
echo " --personal-dir=dir location of the personal directory"
2008-09-02 15:59:21 +00:00
echo " [os-dependent default]"
2008-01-13 17:45:29 +00:00
echo " --shared-dir=dir location of shared data files"
2008-09-02 15:59:21 +00:00
echo " [os-dependent default]"
2007-01-02 22:28:15 +00:00
echo " --install-dir=dir specifies the root to install to."
2008-09-02 15:59:21 +00:00
echo " Useful to install into jails [/]"
2008-10-16 11:12:18 +00:00
echo " --binary-name the name used for the binary, icons,"
echo " desktop file, etc. when installing [openttd]"
2007-01-02 19:19:48 +00:00
echo ""
echo "Features and packages:"
2007-01-02 22:28:15 +00:00
echo " --enable-debug[=LVL] enable debug-mode (LVL=[0123], 0 is release)"
2008-08-15 19:18:55 +00:00
echo " --enable-desync-debug=[LVL] enable desync debug options (LVL=[012], 0 is none"
2007-01-02 22:28:15 +00:00
echo " --enable-profiling enables profiling"
2009-12-01 20:53:13 +00:00
echo " --enable-lto enables GCC's Link Time Optimization (LTO)/ICC's"
echo " Interprocedural Optimization if available"
2007-01-02 22:28:15 +00:00
echo " --enable-dedicated compile a dedicated server (without video)"
echo " --enable-static enable static compile (doesn't work for"
echo " all HOSTs)"
2007-01-02 19:19:48 +00:00
echo " --enable-translator enable extra output for translators"
2010-11-14 22:57:32 +00:00
echo " --enable-universal[=ARCH] enable universal builds (OSX ONLY). Allowed is any combination"
echo " of architectures: i386 ppc ppc970 ppc64 x86_64"
echo " Default architectures are: i386 ppc"
echo " --enable-osx-g5 enables optimizations for ppc970 (G5) (OSX ONLY)"
2007-12-17 07:47:21 +00:00
echo " --disable-cocoa-quartz disable the quartz window mode driver for Cocoa (OSX ONLY)"
2007-10-06 13:20:27 +00:00
echo " --disable-unicode disable unicode support to build win9x"
echo " version (Win32 ONLY)"
2010-11-14 20:47:45 +00:00
echo " --enable-console compile as a console application instead of as a GUI application."
echo " If this setting is active, debug output will appear in the same"
echo " console instead of opening a new window. (Win32 ONLY)"
2007-01-02 22:28:15 +00:00
echo " --disable-assert disable asserts (continue on errors)"
2008-03-29 21:50:14 +00:00
echo " --enable-strip enable any possible stripping"
2007-01-02 22:28:15 +00:00
echo " --without-osx-sysroot disable the automatic adding of sysroot "
echo " (OSX ONLY)"
echo " --without-application-bundle disable generation of application bundle"
echo " (OSX ONLY)"
2008-07-22 22:21:38 +00:00
echo " --without-menu-entry Don't generate a menu item (Freedesktop based only)"
2008-08-15 19:18:55 +00:00
echo " --menu-group=group Category in which the menu item will be placed (Freedesktop based only)"
2008-10-16 12:19:24 +00:00
echo " --menu-name=name Name of the menu item when placed [OpenTTD]"
2007-01-02 19:19:48 +00:00
echo " --with-direct-music enable direct music support (Win32 ONLY)"
echo " --with-sort=sort define a non-default location for sort"
echo " --with-midi=midi define which midi-player to use"
2007-01-02 22:28:15 +00:00
echo " --with-midi-arg=arg define which args to use for the"
echo " midi-player"
2018-09-11 23:06:31 +00:00
echo " --with-fluidsynth enables fluidsynth support"
2015-08-09 12:41:35 +00:00
echo " --with-allegro[=\"pkg-config allegro\"]"
2008-11-25 19:32:12 +00:00
echo " enables Allegro video driver support"
2007-01-02 22:28:15 +00:00
echo " --with-cocoa enables COCOA video driver (OSX ONLY)"
2019-09-19 15:18:50 +00:00
echo " --with-sdl[=\"sdl1|sdl2\"] enables SDL video driver support"
2015-08-09 12:42:21 +00:00
echo " --with-zlib[=\"pkg-config zlib\"]"
echo " enables zlib support"
2013-11-16 13:16:38 +00:00
echo " --with-liblzma[=\"pkg-config liblzma\"]"
echo " enables liblzma support"
2010-01-10 13:12:34 +00:00
echo " --with-liblzo2[=liblzo2.a] enables liblzo2 support"
2015-08-09 12:42:52 +00:00
echo " --with-png[=\"pkg-config libpng\"]"
echo " enables libpng support"
2015-08-09 12:41:12 +00:00
echo " --with-freetype[=\"pkg-config freetype2\"]"
2007-01-02 19:19:48 +00:00
echo " enables libfreetype support"
2013-11-16 13:16:38 +00:00
echo " --with-fontconfig[=\"pkg-config fontconfig\"]"
2007-01-02 19:19:48 +00:00
echo " enables fontconfig support"
2013-11-16 13:16:38 +00:00
echo " --with-xdg-basedir[=\"pkg-config libxdg-basedir\"]"
2013-11-16 22:17:02 +00:00
echo " enables XDG base directory support"
2015-08-09 13:54:17 +00:00
echo " --with-icu enables icu components for layout and sorting"
echo " --with-icu-layout[=\"pkg-config icu-lx\"]"
echo " enables icu components for layouting (right-to-left support)"
echo " --with-icu-sort[=\"pkg-config icu-i18n\"]"
echo " enables icu components for locale specific string sorting"
2009-11-17 18:01:05 +00:00
echo " --static-icu try to link statically (libsicu instead of"
echo " libicu; can fail as the new name is guessed)"
2007-01-02 19:19:48 +00:00
echo " --with-iconv[=iconv-path] enables iconv support"
2009-05-14 21:59:24 +00:00
echo " --disable-builtin-depend disable use of builtin deps finder"
2007-01-02 19:19:48 +00:00
echo " --with-makedepend[=makedepend] enables makedepend support"
2010-02-13 00:00:47 +00:00
echo " --with-ccache enables ccache support"
echo " --with-distcc enables distcc support"
2013-04-26 18:39:15 +00:00
echo " --without-grfcodec disable usage of grfcodec and re-generation of base sets"
2014-01-02 08:35:45 +00:00
echo " --without-threads disable threading support"
echo " --without-sse disable SSE support (x86/x86_64 only)"
2015-09-09 19:19:26 +00:00
echo " --without-libbfd disable libbfd support, used for improved crash logs (MinGW and Unix/glibc only)"
echo " --without-bfd-extra-debug disable extra debugging information when using libbfd (MinGW and Unix/glibc only)"
2016-03-10 00:08:34 +00:00
echo " --without-self-gdb-debug disable improved crash logs using gdb (Linux only)"
2019-04-18 17:30:09 +00:00
echo " --without-self-lldb-debug disable improved crash logs using lldb (OSX only)"
2007-01-02 19:19:48 +00:00
echo ""
echo "Some influential environment variables:"
echo " CC C compiler command"
echo " CXX C++ compiler command"
echo " CFLAGS C compiler flags"
2009-09-07 21:01:24 +00:00
echo " CXXFLAGS C++ compiler flags"
2007-01-02 19:19:48 +00:00
echo " WINDRES windres command"
2007-01-02 22:28:15 +00:00
echo " LDFLAGS linker flags, e.g. -L<lib dir> if you"
echo " have libraries in a nonstandard"
echo " directory <lib dir>"
2013-02-28 06:51:45 +00:00
echo " CFLAGS_BUILD C compiler flags for build time tool generation"
echo " CXXFLAGS_BUILD C++ compiler flags for build time tool generation"
echo " LDFLAGS_BUILD linker flags for build time tool generation"
2017-08-27 16:07:24 +00:00
echo " PKG_CONFIG_PATH additional library search paths (see \"man pkg-config\")"
echo " PKG_CONFIG_LIBDIR replace the default library search path (see \"man pkg-config\")"
2007-01-02 19:19:48 +00:00
echo ""
echo "Use these variables to override the choices made by 'configure' or to help"
echo "it to find libraries and programs with nonstandard names/locations."
}