3
# Some things this script could/should do when finished
5
# * detect whether it's a GNU compiler or not (for compiler settings)
6
# * command line options to...
7
# - override the host settings (for cross compiles
8
# - whether to do a debug build (with -g) or an optimized build (-O3 etc.)
9
# * detect whether the chosen backend is available (e.g. call sdl-config)
13
# use environment vars if set
14
CXXFLAGS="$CXXFLAGS $CPPFLAGS"
16
# default lib behaviour yes/no/auto
21
# default option behaviour yes/no
50
X_LIBS="/usr/X11R6/lib"
54
# TODO: We should really use mktemp(1) to determine a random tmp file name.
55
# However, that tool might not be available everywhere.
56
TMPO=${_srcdir}/stella-conf
58
TMPLOG=${_srcdir}/config.log
69
cat "$TMPC" >> "$TMPLOG"
71
echo "$CXX $TMPC -o $TMPO$EXEEXT $@" >> "$TMPLOG"
73
( $CXX "$TMPC" -o "$TMPO$EXEEXT" "$@" ) >> "$TMPLOG" 2>&1
80
echo_n "Checking for $@... "
84
# Check whether the given command is a working C++ compiler
88
cat <<EOF >tmp_cxx_compiler.cpp
92
int main(int argc, char **argv)
100
if test -n "$_host"; then
101
# In cross-compiling mode, we cannot run the result
102
eval "$1 -o tmp_cxx_compiler$EXEEXT tmp_cxx_compiler.cpp 2> /dev/null" && rm -f tmp_cxx_compiler$EXEEXT tmp_cxx_compiler.cpp
104
eval "$1 -o tmp_cxx_compiler$EXEEXT tmp_cxx_compiler.cpp 2> /dev/null" && eval "./tmp_cxx_compiler 2> /dev/null" && rm -f tmp_cxx_compiler$EXEEXT tmp_cxx_compiler.cpp
109
# Determine sdl-config
111
# TODO: small bit of code to test sdl useability
114
echo_n "Looking for sdl-config... "
115
sdlconfigs="$_sdlconfig:sdl-config:sdl11-config:sdl12-config"
118
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="$SEPARATOR"
120
for path_dir in $_sdlpath; do
121
#reset separator to parse sdlconfigs
123
for sdlconfig in $sdlconfigs; do
124
if test -x "$path_dir/$sdlconfig" ; then
125
_sdlconfig="$path_dir/$sdlconfig"
130
if test $done -eq 1 ; then
138
if test -z "$_sdlconfig"; then
145
# Function to provide echo -n for bourne shells that don't have it
156
echo "Running Stella configure..."
157
echo "Configure run on" `date` > $TMPLOG
160
# Check any parameters we received
163
# * Change --disable-mad / --enable-mad to the way it's done in autoconf:
164
# That is, --without-mad / --with-mad=/prefix/to/mad. Useful for people
165
# who have Mad/Vorbis/ALSA installed in a non-standard locations.
168
for parm in "$@" ; do
169
if test "$parm" = "--help" || test "$parm" = "-help" || test "$parm" = "-h" ; then
172
Usage: $0 [OPTIONS]...
175
-h, --help display this help and exit
177
Installation directories:
178
--prefix=DIR use this prefix for installing stella [/usr/local]
179
--bindir=DIR directory to install the stella binary [PREFIX/bin]
180
--docdir=DIR directory to install documentation [PREFIX/share/doc/stella]
181
--datadir=DIR directory to install icons/data files [PREFIX/share]
184
--enable-gl enable/disable OpenGL rendering support [enabled]
186
--enable-windowed enable/disable windowed rendering modes [enabled]
188
--enable-sound enable/disable sound support [enabled]
190
--enable-debugger enable/disable all debugger options [enabled]
192
--enable-joystick enable/disable joystick support [enabled]
194
--enable-cheats enable/disable cheatcode support [enabled]
196
--enable-shared build shared binary [enabled]
197
--enable-static build static binary (if possible) [disabled]
199
--enable-profile build binary with profiling info [disabled]
201
--force-builtin-libpng force use of built-in libpng library [auto]
202
--force-builtin-zlib force use of built-in zlib library [auto]
205
--with-sdl-prefix=DIR Prefix where the sdl-config script is installed (optional)
206
--with-libpng-prefix=DIR Prefix where libpng is installed (optional)
207
--with-zlib-prefix=DIR Prefix where zlib is installed (optional)
208
--x-libraries Path to X11 libraries [${X_LIBS}]
210
Some influential environment variables:
211
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
212
nonstandard directory <lib dir>
213
CXX C++ compiler command
214
CXXFLAGS C++ compiler flags
215
CPPFLAGS C++ preprocessor flags, e.g. -I<include dir> if you have
216
headers in a nonstandard directory <include dir>
221
done # for parm in ...
223
for ac_option in $@; do
225
--enable-gl) _build_gl=yes ;;
226
--disable-gl) _build_gl=no ;;
227
--enable-windowed) _build_windowed=yes ;;
228
--disable-windowed) _build_windowed=no ;;
229
--enable-sound) _build_sound=yes ;;
230
--disable-sound) _build_sound=no ;;
231
--enable-debugger) _build_debugger=yes ;;
232
--disable-debugger) _build_debugger=no ;;
233
--enable-joystick) _build_joystick=yes ;;
234
--disable-joystick) _build_joystick=no ;;
235
--enable-cheats) _build_cheats=yes ;;
236
--disable-cheats) _build_cheats=no ;;
237
--enable-thumb) _build_thumb=yes ;;
238
--disable-thumb) _build_thumb=no ;;
239
--enable-shared) _build_static=no ;;
240
--enable-static) _build_static=yes ;;
241
--disable-static) _build_static=no ;;
242
--enable-profile) _build_profile=yes ;;
243
--disable-profile) _build_profile=no ;;
244
--force-builtin-libpng) _libpng=no ;;
245
--force-builtin-zlib) _zlib=no ;;
247
arg=`echo $ac_option | cut -d '=' -f 2`
248
_sdlpath="$arg:$arg/bin"
250
--with-libpng-prefix=*)
251
_prefix=`echo $ac_option | cut -d '=' -f 2`
252
LIBPNG_CFLAGS="-I$_prefix/include"
253
LIBPNG_LIBS="-L$_prefix/lib"
255
--with-zlib-prefix=*)
256
_prefix=`echo $ac_option | cut -d '=' -f 2`
257
ZLIB_CFLAGS="-I$_prefix/include"
258
ZLIB_LIBS="-L$_prefix/lib"
261
arg=`echo $ac_option | cut -d '=' -f 2`
265
_host=`echo $ac_option | cut -d '=' -f 2`
268
_prefix=`echo $ac_option | cut -d '=' -f 2`
271
_bindir=`echo $ac_option | cut -d '=' -f 2`
274
_docdir=`echo $ac_option | cut -d '=' -f 2`
277
_datadir=`echo $ac_option | cut -d '=' -f 2`
280
echo "warning: unrecognised option: $ac_option"
285
CXXFLAGS="$CXXFLAGS $DEBFLAGS"
303
_host_prefix=arm-open2x-linux
308
_host_prefix=i386-mingw32msvc
311
guessed_host=`$_srcdir/config.guess`
312
_host_cpu=`echo $guessed_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
313
_host_os=`echo $guessed_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
314
_host_vendor=`echo $guessed_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
319
# Determine extension used for executables
322
mingw* | cygwin* |os2-emx*)
340
# Determine separator used for $PATH
353
# Determine the C++ compiler
355
echo_n "Looking for C++ compiler... "
356
if test -n "$_host"; then
357
compilers="$CXX $_host_prefix-g++ $_host_prefix-c++ $_host_cpu-$_host_os-g++ $_host_cpu-$_host_os-c++"
359
compilers="$CXX g++ c++"
362
for compiler in $compilers; do
363
if test_compiler $compiler; then
369
if test -z $CXX; then
375
# Determine the compiler version
377
echocheck "compiler version"
379
cxx_name=`( $cc -v ) 2>&1 | tail -n 1 | cut -d ' ' -f 1`
380
cxx_version=`( $CXX -dumpversion ) 2>&1`
381
if test "$?" -gt 0; then
382
cxx_version="not found"
386
2.95.[2-9]|2.95.[2-9][-.]*|3.[0-9]|3.[0-9].[0-9]|3.[0-9].[0-9][-.]*|4.[0-9].[0-9]|4.[0-9].[0-9][-.]*)
387
_cxx_major=`echo $cxx_version | cut -d '.' -f 1`
388
_cxx_minor=`echo $cxx_version | cut -d '.' -f 2`
389
cxx_version="$cxx_version, ok"
392
# whacky beos version strings
393
2.9-beos-991026*|2.9-beos-000224*)
396
cxx_version="$cxx_version, ok"
407
cxx_version="$cxx_version, bad"
414
if test "$cxx_verc_fail" = yes ; then
416
echo "The version of your compiler is not supported at this time"
417
echo "Please ensure you are using GCC 2.95.x or GCC 3.x"
422
# Do CXXFLAGS now we know the compiler version
425
if test "$_cxx_major" -ge "3" ; then
427
_make_def_HAVE_GCC3='HAVE_GCC3 = 1'
430
if test -n "$_host"; then
431
# Cross-compiling mode - add your target here if needed
433
# linupy|arm-riscos-aof)
434
# echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
435
# DEFINES="$DEFINES -DUNIX"
436
# _def_endianness='#define SCUMM_LITTLE_ENDIAN'
437
# _def_align='#define SCUMM_NEED_ALIGNMENT'
438
# _def_linupy="#define DLINUPY"
440
# type_2_byte='short'
444
# echo "Cross-compiling to $_host, forcing endianness, alignment and type sizes"
445
# _def_endianness='#define SCUMM_BIG_ENDIAN'
446
# _def_align='#define SCUMM_NEED_ALIGNMENT'
448
# type_2_byte='short'
450
# CXXFLAGS="$CFLAGS -newlib -mstrict-align -mcpu=750 -mtune=7400"
451
# LDFLAGS="$LDFLAGS -newlib"
454
echo "Cross-compiling to $_host, forcing static build, and disabling OpenGL."
460
echo "Cross-compiling for Win32 using MinGW."
461
DEFINES="$DEFINES -DWIN32"
465
echo "Cross-compiling to unknown target, please add your target to configure."
472
# Determine build settings
474
# TODO - also add an command line option to override this?!?
475
echo_n "Checking hosttype... "
478
linux* | openbsd* | freebsd* | kfreebsd* | netbsd* | bsd* | gnu0.3 | sunos* | hpux* | beos*)
479
DEFINES="$DEFINES -DUNIX"
483
DEFINES="$DEFINES -DUNIX"
488
DEFINES="$DEFINES -DWIN32"
492
DEFINES="$DEFINES -mno-cygwin -DWIN32"
493
LIBS="$LIBS -mno-cygwin -lmingw32 -lwinmm"
497
DEFINES="$DEFINES -DUNIX -DOS2"
500
# given this is a shell script assume some type of unix
502
echo "WARNING: could not establish system type, assuming unix like"
503
DEFINES="$DEFINES -DUNIX"
508
# Cross-compilers use their own commands for the following functions
509
if test -n "$_host_prefix"; then
510
_strip="$_host_prefix-$_strip"
511
_windres="$_host_prefix-$_windres"
518
if test "$_libpng" = auto ; then
523
int main(void) { return printf("%s\n", PNG_HEADER_VERSION_STRING); }
525
cc_check $LDFLAGS $CXXFLAGS $LIBPNG_CFLAGS $LIBPNG_LIBS -lpng && _libpng=yes
527
if test "$_libpng" = yes ; then
530
echo "none found, using built-in version"
537
if test "$_zlib" = auto ; then
542
int main(void) { return strcmp(ZLIB_VERSION, zlibVersion()); }
544
cc_check $LDFLAGS $CXXFLAGS $ZLIB_CFLAGS $ZLIB_LIBS -lz && _zlib=yes
546
if test "$_zlib" = yes ; then
549
echo "none found, using built-in version"
556
if test "$_opengl" = auto ; then
562
int main(void) { return 0; }
564
cc_check $LDFLAGS $CXXFLAGS && _opengl=yes
569
# figure out installation directories
571
test -z "$_bindir" && _bindir="$_prefix/bin"
572
test -z "$_docdir" && _docdir="$_prefix/share/doc/stella"
573
test -z "$_datadir" && _datadir="$_prefix/share"
579
if test "$_build_gl" = "yes" ; then
580
if test "$_opengl" = "yes" ; then
581
echo_n " OpenGL rendering enabled"
584
echo_n " OpenGL rendering disabled (missing OpenGL headers)"
589
echo_n " OpenGL rendering disabled"
593
if test "$_build_windowed" = "yes" ; then
594
echo_n " Windowed rendering modes enabled"
597
echo_n " Windowed rendering modes disabled"
601
if test "$_build_sound" = "yes" ; then
602
echo_n " Sound support enabled"
605
echo_n " Sound support disabled"
609
if test "$_build_debugger" = "yes" ; then
610
echo_n " Debugger support enabled"
613
echo_n " Debugger support disabled"
617
if test "$_build_snapshot" = "yes" ; then
618
echo_n " Snapshot support enabled"
621
echo_n " Snapshot support disabled"
625
if test "$_build_joystick" = yes ; then
626
echo_n " Joystick support enabled"
629
echo_n " Joystick support disabled"
633
if test "$_build_cheats" = yes ; then
634
echo_n " Cheatcode support enabled"
637
echo_n " Cheatcode support disabled"
641
if test "$_build_thumb" = yes ; then
642
echo_n " Thumb ARM emulation support enabled"
645
echo_n " Thumb ARM emulation support disabled"
649
if test "$_build_static" = yes ; then
650
echo_n " Static binary enabled"
653
echo_n " Static binary disabled"
657
if test "$_build_profile" = yes ; then
658
echo_n " Profiling enabled"
661
echo_n " Profiling disabled"
667
# Now, add the appropriate defines/libraries/headers
677
DBGGUI="$SRC/debugger/gui"
683
INCLUDES="-I$CORE -I$COMMON -I$GUI"
685
INCLUDES="$INCLUDES `$_sdlconfig --cflags`"
686
if test "$_build_static" = yes ; then
687
_sdl_conf_libs="--static-libs"
688
LDFLAGS="-static $LDFLAGS"
690
_sdl_conf_libs="--libs"
693
LIBS="$LIBS `$_sdlconfig $_sdl_conf_libs`"
697
DEFINES="$DEFINES -DBSPF_UNIX -DHAVE_GETTIMEOFDAY -DHAVE_INTTYPES"
698
MODULES="$MODULES $SRC/unix"
699
INCLUDES="$INCLUDES -I$SRC/unix"
706
#include <X11/Xutil.h>
707
int main(void) { return 0; }
709
cc_check $LDFLAGS $CXXFLAGS -lX11 && _x11=yes
710
if test "$_x11" = yes ; then
711
DEFINES="$DEFINES -DHAVE_X11"
716
DEFINES="$DEFINES -DBSPF_WIN32 -DHAVE_GETTIMEOFDAY -DHAVE_INTTYPES"
717
MODULES="$MODULES $SRC/win32"
718
INCLUDES="$INCLUDES -I$SRC/win32"
719
LIBS="$LIBS -lmingw32 -lwinmm"
722
# -O3 hangs the GP2X, do not use.
723
CXXFLAGS="-O2 -finline-functions -mtune=arm920t"
724
DEFINES="$DEFINES -DBSPF_GP2X -DGP2X -DHAVE_GETTIMEOFDAY -DHAVE_INTTYPES"
725
MODULES="$MODULES $SRC/gp2x"
726
INCLUDES="$INCLUDES -I$SRC/gp2x $ZLIB_CFLAGS"
728
_ranlib="arm-linux-ranlib"
729
_ar="arm-linux-ar cru"
732
echo "WARNING: host system not currenty supported"
737
if test "$_libpng" = yes ; then
740
MODULES="$MODULES $LIBPNG"
741
INCLUDES="$INCLUDES -I$LIBPNG"
744
if test "$_zlib" = yes ; then
747
MODULES="$MODULES $ZLIB"
748
INCLUDES="$INCLUDES -I$ZLIB"
751
if test "$_build_gl" = yes ; then
752
DEFINES="$DEFINES -DDISPLAY_OPENGL"
755
if test "$_build_windowed" = yes ; then
756
DEFINES="$DEFINES -DWINDOWED_SUPPORT"
759
if test "$_build_sound" = yes ; then
760
DEFINES="$DEFINES -DSOUND_SUPPORT"
763
if test "$_build_debugger" = yes ; then
764
DEFINES="$DEFINES -DDEBUGGER_SUPPORT"
765
MODULES="$MODULES $DBG $DBGGUI $YACC"
766
INCLUDES="$INCLUDES -I$DBG -I$DBGGUI -I$YACC"
769
if test "$_build_snapshot" = yes ; then
770
DEFINES="$DEFINES -DSNAPSHOT_SUPPORT"
773
if test "$_build_joystick" = yes ; then
774
DEFINES="$DEFINES -DJOYSTICK_SUPPORT"
777
if test "$_build_cheats" = yes ; then
778
DEFINES="$DEFINES -DCHEATCODE_SUPPORT"
779
MODULES="$MODULES $CHEAT"
780
INCLUDES="$INCLUDES -I$CHEAT"
783
if test "$_build_thumb" = yes ; then
784
DEFINES="$DEFINES -DTHUMB_SUPPORT"
787
if test "$_build_profile" = no ; then
792
echo "Creating config.mak"
793
cat > config.mak << EOF
794
# -------- Generated by configure -----------
797
CXXFLAGS := $CXXFLAGS
810
WIN32PATH=$_win32path
815
MODULE_DIRS += $MODULE_DIRS
822
PROFILE := $_build_profile
826
INCLUDES += $INCLUDES
832
# This should be taken care of elsewhere, but I'm not sure where