2 # Configuration script for Tennix
3 # 2013-07-27 Thomas Perl <m@thp.io>
8 DEFAULT_CFLAGS
="-I. -Wno-char-subscripts -Wno-maybe-uninitialized"
14 if [ -z "$CXX" ]; then
18 if [ -z "$CFLAGS" ]; then
22 if [ -z "$LDFLAGS" ]; then
26 CFLAGS
="$DEFAULT_CFLAGS $CFLAGS"
30 GENERATED_HEADER
="Generated: $(date)"
31 CONFIG_H
="/* $GENERATED_HEADER */"
32 CONFIG_MK
="# $GENERATED_HEADER"
43 CONFIG_MK
="$CONFIG_MK$NL$1 := $2"
47 CONFIG_H
="$CONFIG_H$NL#define $1"
51 CONFIG_H
="$CONFIG_H$NL#undef $1"
56 set_make_variable
$1 1
61 set_make_variable
$1 0
73 echo "int main() { return 0; }" |
$CC $CFLAGS -x c
-c -o /dev
/null
- 2>/dev
/null
77 echo "class A { public: A() {} }; int main() { A a; }" |
$CXX $CFLAGS -x c
++ -c -o /dev
/null
-
81 echo "int main() { return 0; }" |
$CC $CFLAGS $LDFLAGS -l$1 -x c
-o /dev
/null
- 2>/dev
/null
85 echo "#include <$1>" |
$CC $CFLAGS -c -x c
-o /dev
/null
-c - 2>/dev
/null
102 if ! which sdl-config
>/dev
/null
2>&1; then
106 CFLAGS
="$(sdl-config --cflags) $CFLAGS"
107 LDFLAGS
="$(sdl-config --libs) $LDFLAGS"
112 echo -n "Detecting operating system ... "
125 fail
"Unknown platform: $UNAME"
131 message_wrapper
"Testing working C compiler ($CC)" check_cc || fail
"C compiler ($CC) not working"
132 message_wrapper
"Testing working C++ compiler ($CXX)" check_cxx || fail
"C++ compiler ($CXX) not working"
136 message_wrapper
"Checking for SDL 1.2" check_sdl_lib
137 cond_definition $? HAVE_SDL
141 check_sdl || fail
"SDL not found"
144 check_voice_files
() {
145 message_wrapper
"Checking for voice files" [ -f voice
/deuce.ogg
]
146 cond_definition $? HAVE_VOICE_FILES
150 if ! which python-config
>/dev
/null
2>&1; then
154 CFLAGS
="$(python-config --cflags) $CFLAGS"
155 LDFLAGS
="$(python-config --libs) $LDFLAGS"
163 if ! which $COMMAND >/dev
/null
2>&1; then
167 if [ "$VARIABLE" != "" ]; then
168 set_make_variable
$VARIABLE $
(which $COMMAND 2>/dev
/null
)
173 message_wrapper
"Checking for $1" check_tool_path $
*
177 check_tool $
* || fail
"Required command '$1' not found"
181 message_wrapper
"Checking for libpython" check_python_lib
182 cond_definition $? HAVE_PYTHON
186 message_wrapper
"Checking for $1" check_header_cc
$1
190 message_wrapper
"Checking for -l$1" check_linker_cc
$1
197 check_linker
$LIBRARY
201 if [ $HAVE_LINKER -eq 0 -a $HAVE_HEADER -eq 0 ]; then
202 add_definition
$DEFINE
203 LDFLAGS
="-l$LIBRARY $LDFLAGS"
205 no_definition
$DEFINE
212 check_library $
* || fail
"Library $1 ($2) not found"
215 generate_dependencies
() {
216 echo "Generating dependencies.mk"
217 rm -f dependencies.mk
219 echo "# $GENERATED_HEADER"
220 for filename
in src
/*.cc
; do $CXX -MM $filename $CFLAGS -o -; done
225 echo "Writing config.h"
229 echo "#define VERSION \"$V\""
230 echo "#define PREFIX \"$PREFIX\""
233 echo "Writing config.mk"
238 echo "SILENT = $SILENT"
239 echo "PREFIX = $PREFIX"
240 echo "PLATFORM = $PLATFORM"
243 echo "CFLAGS = $CFLAGS"
244 echo "CXXFLAGS = $CFLAGS"
245 echo "LDFLAGS = $LDFLAGS"
255 --prefix PREFIX Install into PREFIX (default: $PREFIX)
256 --help | -h Show this help message
257 --with-debug Enable additional debugging output
258 --enable-update-rect Visualize screen updates
259 --enable-nonfree-locations Additional tennis courts on world map
260 --enable-fps-limit Limit frame rate
261 --disable-silent Disable silent make output
267 while [ $# -gt 0 ]; do
270 [ $# -gt 1 ] || fail
"Not enough arguments."
278 --enable-update-rect)
279 define_macro DRAW_UPDATE_RECTANGLE
281 --enable-nonfree-locations)
282 define_macro NONFREE_LOCATIONS
285 define_macro ENABLE_FPS_LIMIT
296 fail
"Unknown argument: $1"
303 # Parse command-line arguments
306 # Check for compatible OS and working compiler
310 # Check for command-line tools needed for build
313 # Check for command-line tools required in makefile
315 require_tool
install INSTALL
318 # Check for SDL 1.2 and libpython
322 # Check for mandatory and optional libraries
323 require_library SDL_image SDL_image.h HAVE_SDL_IMAGE
324 require_library SDL_ttf SDL_ttf.h HAVE_SDL_TTF
325 check_library SDL_net SDL_net.h HAVE_SDL_NET
326 require_library SDL_mixer SDL_mixer.h HAVE_SDL_MIXER
328 # Check for optional game content
331 # Save configuration results and generate dependency file
333 generate_dependencies