2 # Configuration script for Tennix
3 # 2013-07-27 Thomas Perl <m@thp.io>
9 DEFAULT_CFLAGS
="-I. -Wall"
15 if [ -z "$CXX" ]; then
19 if [ -z "$CFLAGS" ]; then
23 if [ -z "$LDFLAGS" ]; then
27 CFLAGS
="$DEFAULT_CFLAGS $CFLAGS"
31 GENERATED_HEADER
="Generated: $(date)"
32 CONFIG_H
="/* $GENERATED_HEADER */"
33 CONFIG_MK
="# $GENERATED_HEADER"
44 CONFIG_MK
="$CONFIG_MK$NL$1 := $2"
48 CONFIG_H
="$CONFIG_H$NL#define $1"
52 CONFIG_H
="$CONFIG_H$NL#undef $1"
57 set_make_variable
$1 1
62 set_make_variable
$1 0
74 echo "int main() { return 0; }" |
$CC $CFLAGS -x c
-c -o /dev
/null
- 2>/dev
/null
78 echo "class A { public: A() {} }; int main() { A a; }" |
$CXX $CFLAGS -x c
++ -c -o /dev
/null
-
82 echo "int main() { return 0; }" |
$CC $CFLAGS $LDFLAGS -l$1 -x c
-o /dev
/null
- 2>/dev
/null
86 echo "#include <$1>" |
$CC $CFLAGS -c -x c
-o /dev
/null
-c - 2>/dev
/null
103 if ! which sdl-config
>/dev
/null
2>&1; then
107 CFLAGS
="$(sdl-config --cflags) $CFLAGS"
108 LDFLAGS
="$(sdl-config --libs) $LDFLAGS"
113 printf "Detecting operating system ... "
126 fail
"Unknown platform: $UNAME"
132 message_wrapper
"Testing working C compiler ($CC)" check_cc || fail
"C compiler ($CC) not working"
133 message_wrapper
"Testing working C++ compiler ($CXX)" check_cxx || fail
"C++ compiler ($CXX) not working"
137 message_wrapper
"Checking for SDL 1.2" check_sdl_lib
138 cond_definition $? HAVE_SDL
142 check_sdl || fail
"SDL not found"
145 check_voice_files
() {
146 message_wrapper
"Checking for voice files" [ -f voice
/deuce.ogg
]
147 cond_definition $? HAVE_VOICE_FILES
151 if ! which python-config
>/dev
/null
2>&1; then
155 CFLAGS
="$(python-config --cflags) $CFLAGS"
156 LDFLAGS
="$(python-config --libs) $LDFLAGS"
164 if ! which $COMMAND >/dev
/null
2>&1; then
168 if [ "$VARIABLE" != "" ]; then
169 set_make_variable
$VARIABLE $
(which $COMMAND 2>/dev
/null
)
174 message_wrapper
"Checking for $1" check_tool_path $
*
178 check_tool $
* || fail
"Required command '$1' not found"
182 message_wrapper
"Checking for libpython" check_python_lib
183 cond_definition $? HAVE_PYTHON
187 message_wrapper
"Checking for $1" check_header_cc
$1
191 message_wrapper
"Checking for -l$1" check_linker_cc
$1
198 check_linker
$LIBRARY
202 if [ $HAVE_LINKER -eq 0 -a $HAVE_HEADER -eq 0 ]; then
203 add_definition
$DEFINE
204 LDFLAGS
="-l$LIBRARY $LDFLAGS"
206 no_definition
$DEFINE
213 check_library $
* || fail
"Library $1 ($2) not found"
216 generate_dependencies
() {
217 echo "Generating dependencies.mk"
218 rm -f dependencies.mk
220 echo "# $GENERATED_HEADER"
221 for filename
in src
/*.cc
; do $CXX -MM $filename $CFLAGS -o -; done
226 echo "Writing config.h"
230 echo "#define VERSION \"$V\""
231 echo "#define PREFIX \"$PREFIX\""
234 echo "Writing config.mk"
239 echo "SILENT = $SILENT"
240 echo "PREFIX = $PREFIX"
241 echo "PLATFORM = $PLATFORM"
244 echo "CFLAGS = $CFLAGS"
245 echo "CXXFLAGS = $CFLAGS"
246 echo "LDFLAGS = $LDFLAGS"
256 --prefix PREFIX Install into PREFIX (default: $PREFIX)
257 --help | -h Show this help message
258 --with-debug Enable additional debugging output
259 --enable-update-rect Visualize screen updates
260 --enable-nonfree-locations Additional tennis courts on world map
261 --enable-fps-limit Limit frame rate
262 --disable-silent Disable silent make output
263 --disable-python Disable checking for Python
269 while [ $# -gt 0 ]; do
272 [ $# -gt 1 ] || fail
"Not enough arguments."
280 --enable-update-rect)
281 define_macro DRAW_UPDATE_RECTANGLE
283 --enable-nonfree-locations)
284 define_macro NONFREE_LOCATIONS
287 define_macro ENABLE_FPS_LIMIT
301 fail
"Unknown argument: $1"
308 # Parse command-line arguments
311 # Check for compatible OS and working compiler
315 # Check for command-line tools needed for build
318 # Check for command-line tools required in makefile
320 require_tool
install INSTALL
323 # Check for SDL 1.2 and libpython
325 [ "$PYTHON" != "0" ] && check_python
327 # Check for mandatory and optional libraries
328 require_library SDL_image SDL_image.h HAVE_SDL_IMAGE
329 require_library SDL_ttf SDL_ttf.h HAVE_SDL_TTF
330 check_library SDL_net SDL_net.h HAVE_SDL_NET
331 require_library SDL_mixer SDL_mixer.h HAVE_SDL_MIXER
333 # Check for optional game content
336 # Save configuration results and generate dependency file
338 generate_dependencies