(svn r27731) -Fix (r27730): Missed some sprites which also belong into orig_extra.grf
[openttd.git] / configure
blob5edbca1867a1e6ea3539131830afd128120953fa
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; }
132 if ($0 == "SSE" && "'$with_sse'" != "1") { next; }
134 skip += 1;
136 next;
138 /^( *)#/ { next }
139 /^$/ { next }
140 /\.h$/ { next }
141 /\.hpp$/ { next }
143 if (deep == skip) {
144 gsub(" ", "", $0);
145 print $0;
150 # Read the source.list and process it
151 # Please escape ALL " within ` because e.g. "" terminates the string in some sh implementations
152 SRCS="`< $ROOT_DIR/source.list tr '\r' '\n' | $awk \"$AWKCOMMAND\" | LC_ALL=C $PIPE_SORT`"
154 OBJS_C="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.c$/ { gsub(\".c$\", \".o\", $0); print $0; }'`"
155 OBJS_CPP="`echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.cpp$/ { gsub(\".cpp$\", \".o\", $0); print $0; }'`"
156 OBJS_MM="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.mm$/ { gsub(\".mm$\", \".o\", $0); print $0; }'`"
157 OBJS_RC="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.rc$/ { gsub(\".rc$\", \".o\", $0); print $0; }'`"
158 SRCS="` echo \"$SRCS\" | $awk ' { ORS = \" \" } { print $0; }'`"
160 # In makefiles, we always use -u for sort
161 if [ -z "$sort" ]; then
162 sort="sed s@a@a@"
163 else
164 sort="$sort -u"
167 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"
169 generate_main
170 generate_lang
171 generate_settings
172 generate_grf
173 generate_src
175 check_path_characters