2006-03-14 19:12:39 +00:00
#!/bin/sh
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/>.
2009-05-12 20:52:12 +00:00
check_path_characters() {
if [ -n "`echo $ROOT_DIR | grep '[^-_A-Za-z0-9\/\\\.:]'`" ]; then
echo "WARNING: The path contains a non-alphanumeric character that might cause"
echo " failures in subsequent build stages. Any failures with the build"
echo " will most likely be caused by this."
fi
}
2007-03-06 23:42:30 +00:00
CONFIGURE_EXECUTABLE="$_"
# On *nix systems those two are equal when ./configure is done
if [ "$0" != "$CONFIGURE_EXECUTABLE" ]; then
2007-03-27 13:56:18 +00:00
# On some systems, when ./configure is triggered from 'make'
# the $_ is filled with 'make'. So if that is true, skip 'make'
# and use $0 (and hope that is correct ;))
if [ -n "`echo $CONFIGURE_EXECUTABLE | grep make`" ]; then
2007-03-19 18:37:23 +00:00
CONFIGURE_EXECUTABLE="$0"
else
CONFIGURE_EXECUTABLE="$CONFIGURE_EXECUTABLE $0"
fi
2007-03-06 23:42:30 +00:00
fi
2007-01-02 19:19:48 +00:00
# Find out where configure is (in what dir)
ROOT_DIR="`dirname $0`"
2009-05-24 17:34:39 +00:00
# For MSYS/MinGW we want to know the FULL path. This as that path is generated
# once you call an outside binary. Having the same path for the rest is needed
# for dependency checking.
# pwd -W returns said FULL path, but doesn't exist on others so fall back.
ROOT_DIR="`cd $ROOT_DIR && (pwd -W 2>/dev/null || pwd 2>/dev/null)`"
2006-03-14 19:12:39 +00:00
2009-05-12 20:52:12 +00:00
check_path_characters
2009-05-24 17:34:39 +00:00
# Same here as for the ROOT_DIR above
PWD="`pwd -W 2>/dev/null || pwd 2>/dev/null`"
2008-08-21 00:02:45 +00:00
PREFIX="$PWD/bin"
2006-03-14 19:12:39 +00:00
2007-01-02 19:19:48 +00:00
. $ROOT_DIR/config.lib
2006-03-14 19:12:39 +00:00
2007-01-02 19:19:48 +00:00
# Set default dirs
OBJS_DIR="$PWD/objs"
BASE_SRC_OBJS_DIR="$OBJS_DIR"
LANG_OBJS_DIR="$OBJS_DIR/lang"
2010-08-14 14:50:06 +00:00
GRF_OBJS_DIR="$OBJS_DIR/extra_grf"
2011-03-03 21:08:20 +00:00
SETTING_OBJS_DIR="$OBJS_DIR/setting"
2007-01-02 19:19:48 +00:00
BIN_DIR="$PREFIX"
SRC_DIR="$ROOT_DIR/src"
LANG_DIR="$SRC_DIR/lang"
MEDIA_DIR="$ROOT_DIR/media"
SOURCE_LIST="$ROOT_DIR/source.list"
2006-03-14 19:12:39 +00:00
2007-12-15 22:42:12 +00:00
if [ "$1" = "--reconfig" ] || [ "$1" = "--reconfigure" ]; then
2008-07-31 14:32:35 +00:00
if [ ! -f "config.cache" ]; then
2007-01-02 19:19:48 +00:00
echo "can't reconfigure, because never configured before"
exit 1
fi
# Make sure we don't lock config.cache
2009-05-16 12:36:33 +00:00
cat config.cache | sed 's@\\ @\\\\ @g' > cache.tmp
2007-01-07 13:13:01 +00:00
sh cache.tmp
2009-08-13 11:30:42 +00:00
RET=$?
2007-01-07 13:13:01 +00:00
rm -f cache.tmp
2009-08-13 11:30:42 +00:00
exit $RET
2007-01-02 19:19:48 +00:00
fi
2006-03-14 19:12:39 +00:00
2007-01-02 19:19:48 +00:00
set_default
2007-01-02 21:31:39 +00:00
detect_params "$@"
2007-01-02 19:19:48 +00:00
check_params
2007-06-07 00:15:00 +00:00
save_params
2007-01-02 19:19:48 +00:00
make_cflags_and_ldflags
2006-03-14 19:12:39 +00:00
2007-01-02 19:19:48 +00:00
EXE=""
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" = "OS2" ]; then
2007-01-02 19:19:48 +00:00
EXE=".exe"
fi
2006-03-14 19:12:39 +00:00
2007-01-02 19:19:48 +00:00
TTD="openttd$EXE"
STRGEN="strgen$EXE"
2009-05-14 21:59:24 +00:00
DEPEND="depend$EXE"
2011-03-03 21:08:20 +00:00
SETTINGSGEN="settings_gen$EXE"
2006-03-14 19:12:39 +00:00
2007-01-07 09:48:10 +00:00
if [ -z "$sort" ]; then
2009-05-16 12:36:33 +00:00
PIPE_SORT="sed s@a@a@"
2007-01-02 19:19:48 +00:00
else
PIPE_SORT="$sort"
2006-03-14 19:12:39 +00:00
fi
2008-07-31 14:32:35 +00:00
if [ ! -f "$LANG_DIR/english.txt" ]; then
2007-01-02 19:19:48 +00:00
echo "Languages not found in $LANG_DIR. Can't continue without it."
echo "Please make sure the dir exists and contains at least english.txt"
2006-03-14 21:35:15 +00:00
fi
2007-01-02 19:19:48 +00:00
# Read the source.list and process it
2009-08-01 16:57:30 +00:00
AWKCOMMAND='
2007-01-02 19:19:48 +00:00
{ }
/^( *)#end/ { if (deep == skip) { skip -= 1; } deep -= 1; next; }
/^( *)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; }
/^( *)#if/ {
gsub(" ", "", $0);
gsub("^#if ", "", $0);
if (deep != skip) { deep += 1; next; }
deep += 1;
2006-03-14 21:35:15 +00:00
2008-11-25 19:32:12 +00:00
if ($0 == "ALLEGRO" && "'$allegro_config'" == "") { next; }
2007-01-02 19:19:48 +00:00
if ($0 == "SDL" && "'$sdl_config'" == "") { next; }
2019-09-19 15:18:50 +00:00
if ($0 == "SDL2" && "'$sdl2_config'" == "") { next; }
2007-06-13 18:52:06 +00:00
if ($0 == "PNG" && "'$png_config'" == "") { next; }
2007-01-02 19:19:48 +00:00
if ($0 == "OSX" && "'$os'" != "OSX") { next; }
2007-01-10 19:13:33 +00:00
if ($0 == "OS2" && "'$os'" != "OS2") { next; }
2007-01-02 19:19:48 +00:00
if ($0 == "DEDICATED" && "'$enable_dedicated'" != "1") { next; }
2010-02-10 16:24:05 +00:00
if ($0 == "AI" && "'$enable_ai'" == "0") { next; }
2007-01-02 19:19:48 +00:00
if ($0 == "COCOA" && "'$with_cocoa'" == "0") { next; }
2019-03-04 18:46:11 +00:00
if ($0 == "HAIKU" && "'$os'" != "HAIKU") { next; }
2007-01-02 19:19:48 +00:00
if ($0 == "WIN32" && "'$os'" != "MINGW" &&
2009-09-21 18:36:33 +00:00
"'$os'" != "CYGWIN" && "'$os'" != "MSVC") { next; }
2007-01-02 19:19:48 +00:00
if ($0 == "MSVC" && "'$os'" != "MSVC") { next; }
2007-01-02 20:28:54 +00:00
if ($0 == "DIRECTMUSIC" && "'$with_direct_music'" == "0") { next; }
2018-09-11 23:06:31 +00:00
if ($0 == "FLUIDSYNTH" && "'$fluidsynth'" == "" ) { next; }
2019-03-10 15:57:42 +00:00
if ($0 == "USE_XAUDIO2" && "'$with_xaudio2'" == "0") { next; }
2019-03-10 15:33:43 +00:00
if ($0 == "USE_THREADS" && "'$with_threads'" == "0") { next; }
2019-03-10 15:36:19 +00:00
if ($0 == "USE_SSE" && "'$with_sse'" != "1") { next; }
2006-03-14 19:12:39 +00:00
2007-01-02 19:19:48 +00:00
skip += 1;
2006-03-14 19:21:49 +00:00
2007-01-02 19:19:48 +00:00
next;
}
/^( *)#/ { next }
/^$/ { next }
/\.h$/ { next }
/\.hpp$/ { next }
{
if (deep == skip) {
gsub(" ", "", $0);
print $0;
}
}
2009-08-01 16:57:30 +00:00
'
2007-01-02 19:19:48 +00:00
2009-08-01 16:57:30 +00:00
# Read the source.list and process it
# Please escape ALL " within ` because e.g. "" terminates the string in some sh implementations
2016-05-12 17:24:06 +00:00
SRCS="`< $ROOT_DIR/source.list tr '\r' '\n' | $awk \"$AWKCOMMAND\" | LC_ALL=C $PIPE_SORT`"
2009-08-01 16:57:30 +00:00
OBJS_C="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.c$/ { gsub(\".c$\", \".o\", $0); print $0; }'`"
OBJS_CPP="`echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.cpp$/ { gsub(\".cpp$\", \".o\", $0); print $0; }'`"
OBJS_MM="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.mm$/ { gsub(\".mm$\", \".o\", $0); print $0; }'`"
OBJS_RC="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.rc$/ { gsub(\".rc$\", \".o\", $0); print $0; }'`"
SRCS="` echo \"$SRCS\" | $awk ' { ORS = \" \" } { print $0; }'`"
2007-01-02 19:19:48 +00:00
# In makefiles, we always use -u for sort
2007-01-07 09:48:10 +00:00
if [ -z "$sort" ]; then
2009-05-16 12:36:33 +00:00
sort="sed s@a@a@"
2007-01-02 19:19:48 +00:00
else
sort="$sort -u"
2006-03-14 19:21:49 +00:00
fi
2011-03-03 21:08:20 +00:00
CONFIGURE_FILES="$ROOT_DIR/configure $ROOT_DIR/config.lib $ROOT_DIR/Makefile.in $ROOT_DIR/Makefile.grf.in $ROOT_DIR/Makefile.lang.in $ROOT_DIR/Makefile.src.in $ROOT_DIR/Makefile.bundle.in $ROOT_DIR/Makefile.setting.in"
2007-01-02 19:19:48 +00:00
generate_main
generate_lang
2011-03-03 21:08:20 +00:00
generate_settings
2010-08-14 14:50:06 +00:00
generate_grf
2007-01-02 19:19:48 +00:00
generate_src
2009-05-12 20:52:12 +00:00
check_path_characters