1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
#!/bin/sh
# This 'configure' script is a very easy wrapper around 'make updateconf'
# It allows cross-compilers to do their job much more easy.
function showhelp() {
echo "Configure for OpenTTD"
echo ""
echo "Usage:"
echo " $0 --your_options"
echo ""
echo "Params:"
echo " --debug Create debug-release [no]"
echo " --profile Create profile-release [no]"
echo " --dedicated Make a dedicated build [no]"
echo " --revision Set the revision of the compilation [detected]"
echo " --target-cc Sets the target-compiler [\$CC]"
echo " --target-cxx Sets the C++ target-compiler []"
echo " --host-cc Sets the host-compiler [\$CC]"
echo " --os Sets the OS. Listens to: [detected]"
echo " UNIX, OSX, FREEBSD, MORPHOS"
echo " BEOS, SUNOS, CYGWIN, MINGW"
echo " --windres Sets the windres (Windows) [windres]"
echo " --force-le Force LE platform [no]"
echo " --force-be Force BE platform [no]"
echo ""
echo "Params that can be used with --with or --without"
echo " (e.g.: --without-static disables static (default))"
echo " static Do you want a static build? [no]"
echo " directmusic Do you want direct-music? [no]"
echo " zlib Do you want zlib-support? [yes]"
echo " sdl Do you want SDL-support? [yes]"
echo " png Do you want PNG-support? [yes]"
echo " iconv Do you want iconv-support? [no]"
echo " cocoa Do you want cocoa-support? (MacOSX) [no]"
echo ""
echo "Params used to configure external libs:"
echo " --static-zlib-path Set the path to your static zlib []"
echo " --sdl-config Where is your sdl-config [sdl-config]"
echo " --libpng-config Where is your libpng-config [libpng-config]"
echo " --with-iconv Set the path to your iconv headers []"
echo " "
}
function handle() {
PARAM="$PARAM \"$1=`awk 'BEGIN { FS="="; $0="'"$2"'"; print $2;}'`\""
}
# The things you can use inside this case:
# handle NAME VALUE - Sets the value to give the 'make upgradeconf'
# Value is in form: tag=REAL_VALUE
# ITEM="NAME" - Will set the value as above, only with the next param
# SITEM="NAME" - Will set the var $NAME to the next param
for n in "$@"
do
case "$n" in
--help | -h)
showhelp
exit 0
;;
--debug)
DEBUG_SET=1
ITEM="DEBUG"
;;
--debug=*)
handle "DEBUG" "$n"
;;
--profile)
PARAM="$PARAM PROFILE=1"
;;
--dedicated)
PARAM="$PARAM DEDICATED=1"
;;
--revision=*)
RELEASE=`awk 'BEGIN { FS="="; $0="'"$n"'"; print $2;}'`
;;
--revision)
SITEM="RELEASE"
;;
--target-cc=*)
handle "CC_TARGET" "$n"
;;
--target-cc)
ITEM="CC_TARGET"
;;
--target-cxx=*)
TARGET_CXX=`awk 'BEGIN { FS="="; $0="'"$n"'"; print $2;}'`
;;
--target-cxx)
SITEM="TARGET_CXX"
;;
--host-cc=*)
handle CC_HOST "$n"
;;
--host-cc)
ITEM="CC_HOST"
;;
--host-cflags=*)
handle CFLAGS_HOST "$n"
;;
--host-cflags)
ITEM="CFLAGS_HOST"
;;
--os=*)
TARGET_OS=`awk 'BEGIN { FS="="; $0="'"$n"'"; print $2;}'`
;;
--os)
SITEM="TARGET_OS"
;;
--windres=*)
handle WINDRES "$n"
;;
--windres)
ITEM="WINDRES"
;;
--force-le)
PARAM="$PARAM ENDIAN_FORCE=LE"
;;
--force-be)
PARAM="$PARAM ENDIAN_FORCE=BE"
;;
--with-static)
PARAM="$PARAM STATIC=1"
;;
--without-static)
PARAM="$PARAM STATIC="
;;
--with-directmusic)
PARAM="$PARAM WITH_DIRECTMUSIC=1"
;;
--without-directmusic)
PARAM="$PARAM WITH_DIRECTMUSIC="
;;
--with-zlib)
PARAM="$PARAM WITH_ZLIB=1"
;;
--without-zlib)
PARAM="$PARAM WITH_ZLIB="
;;
--with-sdl)
PARAM="$PARAM WITH_SDL=1"
;;
--without-sdl)
PARAM="$PARAM WITH_SDL="
;;
--with-png)
PARAM="$PARAM WITH_PNG=1"
;;
--without-png)
PARAM="$PARAM WITH_PNG="
;;
--with-iconv)
PARAM="$PARAM WITH_ICONV=1"
;;
--with-iconv=*)
PARAM="$PARAM WITH_ICONV=1"
handle WITH_ICONV_PATH "$n"
;;
--without-iconv)
PARAM="$PARAM WITH_ICONV="
;;
--with-cocoa)
PARAM="$PARAM WITH_COCOA=1"
;;
--without-cocoa)
PARAM="$PARAM WITH_COCOA="
;;
--static-zlib-path=*)
handle STATIC_ZLIB_PATH "$n"
;;
--static-zlib-path)
ITEM="STATIC_ZLIB_PATH"
;;
--sdl-config=*)
handle SDL_CONFIG "$n"
;;
--sdl-config)
ITEM="SDL_CONFIG"
;;
--libpng-config=*)
handle LIBPNG_CONFIG "$n"
;;
--lib-png-config)
ITEM="LIBPNG_CONFIG"
;;
--*=*)
echo -n "Unknown switch "
echo `awk 'BEGIN { FS="="; $0="'"$n"'"; print $1;}'`
exit 1
;;
-*)
echo "Unknown switch $n"
exit 1
;;
*)
if ! test -z "$ITEM"
then
PARAM="$PARAM $ITEM=\"$n\""
ITEM="";
elif ! test -z "$SITEM"
then
export $SITEM="$n"
SITEM=""
else
echo "Unknown switch $n"
exit 1
fi
;;
esac
done
if ! test -z "$TARGET_OS"
then
TARGET_OS=`echo $TARGET_OS | tr '[:lower:]' '[:upper:]'`
case "$TARGET_OS" in
WIN32)
PARAM="$PARAM WIN32=1"
;;
UNIX)
PARAM="$PARAM UNIX=1"
;;
OSX)
PARAM="$PARAM OSX=1 UNIX=1"
;;
FREEBSD)
PARAM="$PARAM FREEBSD=1"
;;
MORPHOS)
PARAM="$PARAM MORPHOS=1 UNIX=1"
;;
BEOS)
PARAM="$PARAM BEOS=1 UNIX=1"
;;
SUNOS)
PARAM="$PARAM SUNOS=1 UNIX=1"
;;
CYGWIN)
PARAM="$PARAM CYGWIN=1 WIN32=1"
;;
MINGW)
PARAM="$PARAM MINGW=1 WIN32=1"
;;
*)
echo "Unknown OS: $TARGET_OS"
exit 1
;;
esac
PARAM="$PARAM BYPASS_OS_DETECT=1"
fi
if ! test -z "$DEBUG_SET"
then
if test -z "`echo $PARAM | grep "DEBUG="`"
then
# Someone did --debug, without assigning a value, assume 1
PARAM="$PARAM DEBUG=1"
fi
fi
# First remove the Makefile.config, else you can have double entries
rm -f Makefile.config
echo "make upgradeconf $PARAM" > Makefile.run
. Makefile.run
rm -f Makefile.run
# Makefile.config currently doesn't support custom CXX, so, we add the line
# ourself!
if ! test -z "$TARGET_CXX"
then
echo "CXX=$TARGET_CXX" >> Makefile.config
fi
# Same for RELEASE (read: REVISION)
if ! test -z "$RELEASE"
then
echo "RELEASE=$RELEASE" >> Makefile.config
fi
|