(svn r25763) -Update from WebTranslator v3.0:
[openttd/fttd.git] / configure
blobc80fb2f234ab0fe03373811ef934a0e92c2fd2d7
1 #!/bin/sh
3 # $Id$
5 # This file is part of OpenTTD.
6 # 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.
7 # 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.
8 # 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/>.
10 check_path_characters() {
11 if [ -n "`echo $ROOT_DIR | grep '[^-_A-Za-z0-9\/\\\.:]'`" ]; then
12 echo "WARNING: The path contains a non-alphanumeric character that might cause"
13 echo " failures in subsequent build stages. Any failures with the build"
14 echo " will most likely be caused by this."
18 CONFIGURE_EXECUTABLE="$_"
19 # On *nix systems those two are equal when ./configure is done
20 if [ "$0" != "$CONFIGURE_EXECUTABLE" ]; then
21 # On some systems, when ./configure is triggered from 'make'
22 # the $_ is filled with 'make'. So if that is true, skip 'make'
23 # and use $0 (and hope that is correct ;))
24 if [ -n "`echo $CONFIGURE_EXECUTABLE | grep make`" ]; then
25 CONFIGURE_EXECUTABLE="$0"
26 else
27 CONFIGURE_EXECUTABLE="$CONFIGURE_EXECUTABLE $0"
30 # Find out where configure is (in what dir)
31 ROOT_DIR="`dirname $0`"
32 # For MSYS/MinGW we want to know the FULL path. This as that path is generated
33 # once you call an outside binary. Having the same path for the rest is needed
34 # for dependency checking.
35 # pwd -W returns said FULL path, but doesn't exist on others so fall back.
36 ROOT_DIR="`cd $ROOT_DIR && (pwd -W 2>/dev/null || pwd 2>/dev/null)`"
38 check_path_characters
40 # Same here as for the ROOT_DIR above
41 PWD="`pwd -W 2>/dev/null || pwd 2>/dev/null`"
42 PREFIX="$PWD/bin"
44 . $ROOT_DIR/config.lib
46 # Set default dirs
47 OBJS_DIR="$PWD/objs"
48 BASE_SRC_OBJS_DIR="$OBJS_DIR"
49 LANG_OBJS_DIR="$OBJS_DIR/lang"
50 GRF_OBJS_DIR="$OBJS_DIR/extra_grf"
51 SETTING_OBJS_DIR="$OBJS_DIR/setting"
52 BIN_DIR="$PREFIX"
53 SRC_DIR="$ROOT_DIR/src"
54 LANG_DIR="$SRC_DIR/lang"
55 MEDIA_DIR="$ROOT_DIR/media"
56 SOURCE_LIST="$ROOT_DIR/source.list"
58 if [ "$1" = "--reconfig" ] || [ "$1" = "--reconfigure" ]; then
59 if [ ! -f "config.cache" ]; then
60 echo "can't reconfigure, because never configured before"
61 exit 1
63 # Make sure we don't lock config.cache
64 cat config.cache | sed 's@\\ @\\\\ @g' > cache.tmp
65 sh cache.tmp
66 RET=$?
67 rm -f cache.tmp
68 exit $RET
71 set_default
72 detect_params "$@"
73 check_params
74 save_params
75 make_cflags_and_ldflags
77 EXE=""
78 if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "OS2" ] || [ "$os" = "DOS" ] || [ "$os" = "WINCE" ]; then
79 EXE=".exe"
82 TTD="openttd$EXE"
83 STRGEN="strgen$EXE"
84 ENDIAN_CHECK="endian_check$EXE"
85 DEPEND="depend$EXE"
86 SETTINGSGEN="settings_gen$EXE"
88 if [ -z "$sort" ]; then
89 PIPE_SORT="sed s@a@a@"
90 else
91 PIPE_SORT="$sort"
94 if [ ! -f "$LANG_DIR/english.txt" ]; then
95 echo "Languages not found in $LANG_DIR. Can't continue without it."
96 echo "Please make sure the dir exists and contains at least english.txt"
99 # Read the source.list and process it
100 AWKCOMMAND='
102 /^( *)#end/ { if (deep == skip) { skip -= 1; } deep -= 1; next; }
103 /^( *)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; }
104 /^( *)#if/ {
105 gsub(" ", "", $0);
106 gsub("^#if ", "", $0);
108 if (deep != skip) { deep += 1; next; }
110 deep += 1;
112 if ($0 == "ALLEGRO" && "'$allegro_config'" == "") { next; }
113 if ($0 == "SDL" && "'$sdl_config'" == "") { next; }
114 if ($0 == "PNG" && "'$png_config'" == "") { next; }
115 if ($0 == "OSX" && "'$os'" != "OSX") { next; }
116 if ($0 == "OS2" && "'$os'" != "OS2") { next; }
117 if ($0 == "PSP" && "'$os'" != "PSP") { next; }
118 if ($0 == "DEDICATED" && "'$enable_dedicated'" != "1") { next; }
119 if ($0 == "AI" && "'$enable_ai'" == "0") { next; }
120 if ($0 == "COCOA" && "'$with_cocoa'" == "0") { next; }
121 if ($0 == "DOS" && "'$os'" != "DOS") { next; }
122 if ($0 == "BEOS" && "'$os'" != "BEOS" &&
123 "'$os'" != "HAIKU") { next; }
124 if ($0 == "WIN32" && "'$os'" != "MINGW" &&
125 "'$os'" != "CYGWIN" && "'$os'" != "MSVC") { next; }
126 if ($0 == "MORPHOS" && "'$os'" != "MORPHOS") { next; }
127 if ($0 == "WINCE" && "'$os'" != "WINCE") { next; }
128 if ($0 == "MSVC" && "'$os'" != "MSVC") { next; }
129 if ($0 == "DIRECTMUSIC" && "'$with_direct_music'" == "0") { next; }
130 if ($0 == "LIBTIMIDITY" && "'$libtimidity'" == "" ) { next; }
131 if ($0 == "HAVE_THREAD" && "'$with_threads'" == "0") { next; }
133 skip += 1;
135 next;
137 /^( *)#/ { next }
138 /^$/ { next }
139 /\.h$/ { next }
140 /\.hpp$/ { next }
142 if (deep == skip) {
143 gsub(" ", "", $0);
144 print $0;
149 # Read the source.list and process it
150 # Please escape ALL " within ` because e.g. "" terminates the string in some sh implementations
151 SRCS="`< $ROOT_DIR/source.list tr '\r' '\n' | $awk \"$AWKCOMMAND\" | $PIPE_SORT`"
153 OBJS_C="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.c$/ { gsub(\".c$\", \".o\", $0); print $0; }'`"
154 OBJS_CPP="`echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.cpp$/ { gsub(\".cpp$\", \".o\", $0); print $0; }'`"
155 OBJS_MM="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.mm$/ { gsub(\".mm$\", \".o\", $0); print $0; }'`"
156 OBJS_RC="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.rc$/ { gsub(\".rc$\", \".o\", $0); print $0; }'`"
157 SRCS="` echo \"$SRCS\" | $awk ' { ORS = \" \" } { print $0; }'`"
159 # In makefiles, we always use -u for sort
160 if [ -z "$sort" ]; then
161 sort="sed s@a@a@"
162 else
163 sort="$sort -u"
166 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"
168 generate_main
169 generate_lang
170 generate_settings
171 generate_grf
172 generate_src
174 check_path_characters