configure.in
author Ryan C. Gordon <icculus@icculus.org>
Thu, 04 Feb 2010 05:01:02 +0000
changeset 483 685cb4a41b92
parent 482 7b0c54eed938
child 488 94b190330355
permissions -rw-r--r--
Fixed building with modplug support.
slouken@0
     1
dnl Process this file with autoconf to produce a configure script.
slouken@0
     2
AC_INIT(README)
slouken@426
     3
AC_CONFIG_AUX_DIRS($srcdir/build-scripts)
slouken@0
     4
slouken@0
     5
dnl Set various version strings - taken gratefully from the GTk sources
slouken@0
     6
slouken@0
     7
# Making releases:
slouken@0
     8
#   MICRO_VERSION += 1;
slouken@0
     9
#   INTERFACE_AGE += 1;
slouken@0
    10
#   BINARY_AGE += 1;
slouken@0
    11
# if any functions have been added, set INTERFACE_AGE to 0.
slouken@0
    12
# if backwards compatibility has been broken,
slouken@0
    13
# set BINARY_AGE and INTERFACE_AGE to 0.
slouken@294
    14
#
slouken@0
    15
MAJOR_VERSION=1
slouken@81
    16
MINOR_VERSION=2
slouken@477
    17
MICRO_VERSION=11
slouken@477
    18
INTERFACE_AGE=1
slouken@477
    19
BINARY_AGE=11
slouken@0
    20
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
slouken@0
    21
slouken@0
    22
AC_SUBST(MAJOR_VERSION)
slouken@0
    23
AC_SUBST(MINOR_VERSION)
slouken@0
    24
AC_SUBST(MICRO_VERSION)
slouken@0
    25
AC_SUBST(INTERFACE_AGE)
slouken@0
    26
AC_SUBST(BINARY_AGE)
slouken@0
    27
AC_SUBST(VERSION)
slouken@0
    28
slouken@0
    29
# libtool versioning
slouken@426
    30
LT_INIT([win32-dll])
slouken@426
    31
slouken@0
    32
LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
slouken@0
    33
LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
slouken@0
    34
LT_REVISION=$INTERFACE_AGE
slouken@0
    35
LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
slouken@435
    36
m4_pattern_allow([^LT_])
slouken@0
    37
slouken@0
    38
AC_SUBST(LT_RELEASE)
slouken@0
    39
AC_SUBST(LT_CURRENT)
slouken@0
    40
AC_SUBST(LT_REVISION)
slouken@0
    41
AC_SUBST(LT_AGE)
slouken@0
    42
slouken@289
    43
dnl Detect the canonical build and host environments
slouken@294
    44
AC_CONFIG_AUX_DIRS($srcdir/build-scripts)
slouken@435
    45
dnl AC_CANONICAL_HOST
slouken@68
    46
slouken@406
    47
dnl Check for tools
slouken@406
    48
AC_PROG_LIBTOOL
slouken@406
    49
AC_PROG_CC
slouken@406
    50
AC_PROG_INSTALL
slouken@406
    51
AC_PROG_MAKE_SET
slouken@406
    52
if test -z "$host_alias"; then
slouken@406
    53
    hostaliaswindres=
slouken@406
    54
else
slouken@406
    55
    hostaliaswindres="$host_alias-windres"
slouken@406
    56
fi
slouken@406
    57
AC_CHECK_PROGS(WINDRES, [windres $hostaliaswindres $host_os-windres])
slouken@406
    58
slouken@294
    59
dnl Set up the compiler and linker flags
slouken@294
    60
case "$host" in
slouken@294
    61
    *-*-cygwin*)
slouken@294
    62
        # We build SDL on cygwin without the UNIX emulation layer
slouken@294
    63
        BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
slouken@294
    64
        BASE_LDFLAGS="-mno-cygwin"
slouken@294
    65
        ;;
slouken@294
    66
    *)
slouken@294
    67
        BASE_CFLAGS="-D_GNU_SOURCE=1"
slouken@294
    68
        BASE_LDFLAGS=""
slouken@294
    69
        ;;
slouken@294
    70
esac
slouken@294
    71
BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
slouken@294
    72
EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
slouken@294
    73
BUILD_LDFLAGS="$LDFLAGS"
slouken@294
    74
EXTRA_LDFLAGS="$BASE_LDFLAGS"
slouken@368
    75
## These are common directories to find software packages
slouken@368
    76
#for path in /usr/freeware /usr/pkg /usr/local; do
slouken@368
    77
#    if test -d $path/include; then
slouken@368
    78
#        EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
slouken@368
    79
#    fi
slouken@368
    80
#    if test -d $path/lib; then
slouken@368
    81
#        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
slouken@368
    82
#    fi
slouken@368
    83
#done
slouken@294
    84
CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
slouken@294
    85
CFLAGS="$CFLAGS $EXTRA_CFLAGS"
slouken@294
    86
LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
slouken@91
    87
slouken@294
    88
dnl Check for compiler characteristics
slouken@294
    89
AC_C_CONST
slouken@0
    90
slouken@432
    91
dnl See whether we can use gcc style dependency tracking
slouken@432
    92
AC_ARG_ENABLE(dependency-tracking,
slouken@432
    93
AC_HELP_STRING([--enable-dependency-tracking],
slouken@432
    94
               [Use gcc -MMD -MT dependency tracking [[default=yes]]]),
slouken@432
    95
              , enable_dependency_tracking=yes)
slouken@432
    96
if test x$enable_dependency_tracking = xyes; then
slouken@432
    97
    have_gcc_mmd_mt=no
slouken@432
    98
    AC_MSG_CHECKING(for GCC -MMD -MT option)
slouken@432
    99
    AC_TRY_COMPILE([
slouken@432
   100
    #if !defined(__GNUC__) || __GNUC__ < 3
slouken@432
   101
    #error Dependency tracking requires GCC 3.0 or newer
slouken@432
   102
    #endif
slouken@432
   103
    ],[
slouken@432
   104
    ],[
slouken@432
   105
    have_gcc_mmd_mt=yes
slouken@432
   106
    ])
slouken@432
   107
    AC_MSG_RESULT($have_gcc_mmd_mt)
slouken@432
   108
slouken@432
   109
    if test x$have_gcc_mmd_mt = xyes; then
slouken@432
   110
        DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
slouken@432
   111
    fi
slouken@432
   112
fi
slouken@432
   113
    
slouken@289
   114
case "$host" in
slouken@294
   115
    *-*-cygwin* | *-*-mingw32*)
slouken@422
   116
        VERSION_SOURCES="$srcdir/version.rc"
slouken@294
   117
        EXE=".exe"
slouken@368
   118
        if test "$build" != "$host"; then # cross-compiling
slouken@368
   119
            # Default cross-compile location
slouken@368
   120
            ac_default_prefix=/usr/local/cross-tools/i386-mingw32
slouken@368
   121
        else
slouken@368
   122
            # Look for the location of the tools and install there
slouken@368
   123
            if test "$BUILD_PREFIX" != ""; then
slouken@368
   124
                ac_default_prefix=$BUILD_PREFIX
slouken@368
   125
            fi
slouken@368
   126
        fi
slouken@6
   127
        ;;
slouken@294
   128
    *)
slouken@368
   129
        SOURCES=""
slouken@294
   130
        EXE=""
slouken@208
   131
        ;;
slouken@6
   132
esac
slouken@6
   133
slouken@294
   134
# Standard C sources
slouken@294
   135
SOURCES="$SOURCES \
slouken@294
   136
$srcdir/effect_position.c \
slouken@294
   137
$srcdir/effect_stereoreverse.c \
slouken@294
   138
$srcdir/effects_internal.c \
slouken@294
   139
$srcdir/load_aiff.c \
slouken@294
   140
$srcdir/load_voc.c \
slouken@294
   141
$srcdir/mixer.c \
slouken@294
   142
$srcdir/music.c"
slouken@294
   143
slouken@451
   144
dnl set this to use on systems that use lib64 instead of lib
slouken@451
   145
base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
slouken@451
   146
icculus@482
   147
dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
icculus@482
   148
dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
icculus@482
   149
CheckVisibilityHidden()
icculus@482
   150
{
icculus@482
   151
    AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
icculus@482
   152
    have_gcc_fvisibility=no
icculus@482
   153
icculus@482
   154
    visibility_CFLAGS="-fvisibility=hidden"
icculus@482
   155
    save_CFLAGS="$CFLAGS"
icculus@482
   156
    CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
icculus@482
   157
    AC_TRY_COMPILE([
icculus@482
   158
    #if !defined(__GNUC__) || __GNUC__ < 4
icculus@482
   159
    #error SDL only uses visibility attributes in GCC 4 or newer
icculus@482
   160
    #endif
icculus@482
   161
    ],[
icculus@482
   162
    ],[
icculus@482
   163
    have_gcc_fvisibility=yes
icculus@482
   164
    ])
icculus@482
   165
    AC_MSG_RESULT($have_gcc_fvisibility)
icculus@482
   166
    CFLAGS="$save_CFLAGS"
icculus@482
   167
icculus@482
   168
    if test x$have_gcc_fvisibility = xyes; then
icculus@482
   169
        EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
icculus@482
   170
    fi
icculus@482
   171
}
icculus@482
   172
icculus@482
   173
slouken@451
   174
dnl Function to find a library in the compiler search path
slouken@368
   175
find_lib()
slouken@368
   176
{
slouken@372
   177
    gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
slouken@372
   178
    gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
slouken@451
   179
    env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
slouken@405
   180
    if test "$cross_compiling" = yes; then
slouken@405
   181
        host_lib_path=""
slouken@405
   182
    else
slouken@451
   183
        host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
slouken@405
   184
    fi
slouken@405
   185
    for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
slouken@451
   186
        lib=[`ls -- $path/$1 2>/dev/null | sort | sed 's/.*\/\(.*\)/\1/; q'`]
slouken@368
   187
        if test x$lib != x; then
slouken@368
   188
            echo $lib
slouken@368
   189
            return
slouken@368
   190
        fi
slouken@368
   191
    done
slouken@368
   192
}
slouken@368
   193
slouken@20
   194
dnl Check for SDL
slouken@308
   195
SDL_VERSION=1.2.10
slouken@20
   196
AM_PATH_SDL($SDL_VERSION,
slouken@20
   197
            :,
slouken@368
   198
            AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
slouken@20
   199
)
slouken@294
   200
EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
slouken@294
   201
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
slouken@0
   202
patmandin@464
   203
dnl Check for math library
patmandin@464
   204
AC_CHECK_LIB(m, pow, [LIBM="-lm"])
patmandin@464
   205
slouken@0
   206
dnl Check command-line options
slouken@91
   207
icculus@482
   208
CheckVisibilityHidden
icculus@482
   209
slouken@312
   210
AC_ARG_ENABLE([music-cmd],
slouken@312
   211
AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
slouken@467
   212
              [], [enable_music_cmd=detect])
slouken@467
   213
if test "x$enable_music_cmd" != xno; then
slouken@467
   214
    AC_CHECK_FUNCS([fork vfork])
slouken@467
   215
    if test "x$ac_cv_func_fork" = "xyes"; then
slouken@467
   216
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK"
slouken@467
   217
    elif test "x$ac_cv_func_vfork" = "xyes"; then
slouken@467
   218
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK"
slouken@467
   219
    elif test "x$enable_music_cmd" = "xyes"; then
slouken@467
   220
        AC_MSG_ERROR([external music player not available on your platform])
slouken@467
   221
    else
slouken@467
   222
        enable_music_cmd=no
slouken@467
   223
    fi
slouken@467
   224
    if test "x$enable_music_cmd" != xno; then
slouken@467
   225
        SOURCES="$SOURCES $srcdir/music_cmd.c"
slouken@467
   226
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC"
slouken@467
   227
    fi
slouken@0
   228
fi
slouken@419
   229
slouken@312
   230
AC_ARG_ENABLE([music-wave],
slouken@312
   231
AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
slouken@312
   232
              [], [enable_music_wave=yes])
slouken@0
   233
if test x$enable_music_wave = xyes; then
slouken@294
   234
    SOURCES="$SOURCES $srcdir/wavestream.c"
slouken@294
   235
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DWAV_MUSIC"
slouken@0
   236
fi
slouken@419
   237
slouken@419
   238
AC_ARG_ENABLE([music-mod],
slouken@419
   239
AC_HELP_STRING([--enable-music-mod], [enable MOD music via mikmod [[default=yes]]]),
slouken@419
   240
              [], [enable_music_mod=yes])
slouken@419
   241
AC_ARG_ENABLE([music-mod-shared],
slouken@419
   242
AC_HELP_STRING([--enable-music-mod-shared], [dynamically load MOD support [[default=yes]]]),
slouken@419
   243
              [], [enable_music_mod_shared=yes])
slouken@419
   244
if test x$enable_music_mod = xyes; then
slouken@419
   245
    have_libmikmod=no
slouken@419
   246
    libmikmod_maj=3
slouken@419
   247
    libmikmod_min=1
slouken@419
   248
    libmikmod_rev=10
slouken@419
   249
    libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
slouken@368
   250
    AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
slouken@368
   251
    if test "$LIBMIKMOD_CONFIG" != "no" ; then
slouken@419
   252
        
slouken@368
   253
        CFLAGS_SAVED="$CFLAGS"
slouken@368
   254
        LIBS_SAVED="$LIBS"
slouken@368
   255
        CFLAGS="$CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
slouken@368
   256
        LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
slouken@419
   257
        have_libmikmod=yes
slouken@368
   258
        AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
slouken@368
   259
        AC_TRY_RUN([
slouken@249
   260
#include "mikmod.h"
slouken@249
   261
#include "stdio.h"
slouken@249
   262
slouken@249
   263
int main(int argc, char **argv)
slouken@249
   264
{
slouken@419
   265
long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
slouken@419
   266
/*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
slouken@419
   267
if(ver>=((maj<<16)|(min<<8)|(rev))) {
slouken@419
   268
    printf("yes\n");
slouken@419
   269
    return 0;
slouken@249
   270
}
slouken@419
   271
printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
slouken@419
   272
return 1;
slouken@419
   273
}
slouken@419
   274
], [], have_libmikmod=no; CFLAGS="$CFLAGS_SAVED"; LIBS="$LIBS_SAVED",
slouken@419
   275
        [echo $ac_n "cross compiling; assumed OK... $ac_c"])
slouken@368
   276
    fi
slouken@419
   277
slouken@419
   278
    if test x$have_libmikmod = xyes; then
slouken@419
   279
        case "$host" in
slouken@419
   280
            *-*-darwin*)
slouken@456
   281
                mikmod_lib=[`find_lib libmikmod.dylib`]
slouken@419
   282
                ;;
slouken@419
   283
            *-*-cygwin* | *-*-mingw32*)
slouken@419
   284
                mikmod_lib=[`find_lib "mikmod*.dll"`]
slouken@419
   285
                ;;
slouken@419
   286
            *)
slouken@419
   287
                mikmod_lib=[`find_lib "libmikmod*.so.[0-9]"`]
slouken@419
   288
                if test x$mikmod_lib = x; then
slouken@419
   289
                    mikmod_lib=[`find_lib "libmikmod*.so.[0-9]*"`]
slouken@419
   290
                fi
slouken@419
   291
                ;;
slouken@419
   292
        esac
slouken@419
   293
        SOURCES="$SOURCES $srcdir/*_mod.c"
slouken@419
   294
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
slouken@419
   295
        if test x$enable_music_mod_shared = xyes && test x$mikmod_lib != x; then
slouken@419
   296
            echo "-- dynamic libmikmod -> $mikmod_lib"
slouken@419
   297
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_DYNAMIC=\\\"$mikmod_lib\\\""
slouken@419
   298
        else
slouken@419
   299
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`"
slouken@419
   300
        fi
slouken@419
   301
    else
slouken@419
   302
        AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.raphnet.net/)])
slouken@419
   303
    fi
slouken@249
   304
fi
slouken@249
   305
slouken@481
   306
AC_ARG_ENABLE([music-mod-modplug],
slouken@481
   307
AC_HELP_STRING([--enable-music-mod-modplug], [enable MOD music via modplug [[default=no]]]),
slouken@481
   308
              [], [enable_music_mod_modplug=no])
slouken@481
   309
if test x$enable_music_mod_modplug = xyes; then
slouken@481
   310
	PKG_CHECK_MODULES([MODPLUG], [libmodplug >= 0.8.7])
slouken@481
   311
	EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_MUSIC  $MODPLUG_CFLAGS"
slouken@481
   312
	EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
slouken@481
   313
dnl	AC_TRY_COMPILE([
slouken@481
   314
dnl     #include "modplug.h"
slouken@481
   315
dnl    ],[
slouken@481
   316
dnl    ],[
slouken@481
   317
    have_libmodplug=yes
icculus@483
   318
    SOURCES="$SOURCES $srcdir/music_modplug.c"
slouken@481
   319
dnl    ])
slouken@481
   320
else
slouken@481
   321
	have_libmodplug=no
slouken@481
   322
fi
slouken@481
   323
slouken@481
   324
if test x$have_libmikmod != xyes -a x$have_libmodplug != xyes ; then
slouken@481
   325
	AC_MSG_WARN([MOD support disabled])
slouken@481
   326
fi
slouken@481
   327
slouken@312
   328
AC_ARG_ENABLE([music-midi],
slouken@312
   329
AC_HELP_STRING([--enable-music-midi], [enable MIDI music via timidity [[default=yes]]]),
slouken@312
   330
              [], [enable_music_midi=yes])
slouken@0
   331
if test x$enable_music_midi = xyes; then
slouken@294
   332
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DMID_MUSIC"
slouken@312
   333
    AC_ARG_ENABLE([music-timidity-midi],
slouken@312
   334
AC_HELP_STRING([--enable-music-timidity-midi], [enable timidity MIDI output [[default=yes]]]),
slouken@312
   335
                  [], [enable_music_timidity_midi=yes])
slouken@106
   336
    if test x$enable_music_timidity_midi = xyes; then
slouken@294
   337
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_TIMIDITY_MIDI -I\$(srcdir)/timidity"
slouken@294
   338
        SOURCES="$SOURCES $srcdir/timidity/*.c"
slouken@106
   339
    fi
slouken@312
   340
    AC_ARG_ENABLE([music-native-midi],
slouken@312
   341
AC_HELP_STRING([--enable-music-native-midi], [enable native MIDI music output [[default=yes]]]),
slouken@312
   342
                  [], [enable_music_native_midi=yes])
slouken@99
   343
    if test x$enable_music_native_midi = xyes; then
slouken@99
   344
        use_music_native_midi=no
slouken@289
   345
        case "$host" in
slouken@99
   346
            *-*-cygwin* | *-*-mingw32*)
slouken@99
   347
                use_music_native_midi=yes
slouken@294
   348
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
slouken@99
   349
                ;;
slouken@107
   350
            *-*-darwin*)
icculus@458
   351
                use_music_native_midi=yes
icculus@461
   352
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices"
slouken@107
   353
                ;;
slouken@99
   354
        esac
slouken@99
   355
        if test x$use_music_native_midi = xyes; then
slouken@294
   356
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
slouken@294
   357
            SOURCES="$SOURCES $srcdir/native_midi/*.c"
slouken@99
   358
        fi
slouken@99
   359
    fi
slouken@312
   360
    AC_ARG_ENABLE([music-native-midi-gpl],
slouken@312
   361
AC_HELP_STRING([--enable-music-native-midi-gpl], [enable native MIDI on UNIX using GPL code [[default=no]]]),
slouken@312
   362
                  [], [enable_music_native_midi_gpl=no])
slouken@160
   363
    if test x$enable_music_native_midi_gpl = xyes; then
slouken@160
   364
        use_music_native_midi_gpl=no
slouken@289
   365
        case "$host" in
slouken@160
   366
            *-*-linux* | *-*-freebsd*)
slouken@160
   367
                use_music_native_midi_gpl=yes
slouken@160
   368
                ;;
slouken@160
   369
        esac
slouken@160
   370
        if test x$use_music_native_midi_gpl = xyes; then
slouken@294
   371
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
slouken@294
   372
            SOURCES="$SOURCES $srcdir/native_midi_gpl/*.c"
slouken@160
   373
        fi
slouken@160
   374
    fi
slouken@0
   375
fi
slouken@419
   376
slouken@312
   377
AC_ARG_ENABLE([music-ogg],
slouken@312
   378
AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
slouken@312
   379
              [], [enable_music_ogg=yes])
slouken@353
   380
AC_ARG_ENABLE(music-ogg-tremor,
slouken@419
   381
AC_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [[default=no]]]),
slouken@368
   382
              [], enable_music_ogg_tremor=no)
slouken@368
   383
AC_ARG_ENABLE([music-ogg-shared],
slouken@368
   384
AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis support [[default=yes]]]),
slouken@368
   385
              [], [enable_music_ogg_shared=yes])
slouken@368
   386
if test x$enable_music_ogg = xyes; then
slouken@368
   387
    if test x$enable_music_ogg_tremor = xyes; then
slouken@368
   388
        AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
slouken@468
   389
        AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes])
slouken@368
   390
        if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
slouken@368
   391
            case "$host" in
slouken@368
   392
                *-*-darwin*)
slouken@456
   393
                    ogg_lib=[`find_lib libvorbisidec.dylib`]
slouken@368
   394
                    if test x$ogg_lib = x; then
slouken@368
   395
                        ogg_lib=[`find_lib libvorbisidec.[0-9]`]
slouken@368
   396
                    fi
slouken@368
   397
                    if test x$ogg_lib = x; then
slouken@368
   398
                        ogg_lib=[`find_lib libvorbisidec.[0-9]*`]
slouken@368
   399
                    fi
slouken@368
   400
                    ;;
slouken@368
   401
                *-*-cygwin* | *-*-mingw32*)
slouken@372
   402
                    ogg_lib=[`find_lib "vorbisidec*.dll"`]
slouken@368
   403
                    ;;
slouken@368
   404
                *)
slouken@368
   405
                    ogg_lib=[`find_lib "libvorbisidec.so.[0-9]"`]
slouken@368
   406
                    if test x$ogg_lib = x; then
slouken@368
   407
                        ogg_lib=[`find_lib "libvorbisidec.so.[0-9]*"`]
slouken@368
   408
                    fi
slouken@368
   409
                    ;;
slouken@368
   410
            esac
slouken@368
   411
            SOURCES="$SOURCES $srcdir/*_ogg.c"
slouken@368
   412
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC -DOGG_USE_TREMOR"
slouken@368
   413
            if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
slouken@368
   414
                echo "-- dynamic libvorbisidec -> $ogg_lib"
slouken@368
   415
                EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
slouken@368
   416
            else
patmandin@464
   417
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis -logg $LIBM"
slouken@368
   418
            fi
slouken@419
   419
        else
slouken@419
   420
            AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)])
slouken@419
   421
            AC_MSG_WARN([Ogg Vorbis support disabled])
slouken@368
   422
        fi
slouken@368
   423
    else
slouken@368
   424
        AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
slouken@468
   425
        AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes])
slouken@368
   426
        if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
slouken@368
   427
            case "$host" in
slouken@368
   428
                *-*-darwin*)
slouken@456
   429
                    ogg_lib=[`find_lib libvorbisfile.dylib`]
slouken@368
   430
                    ;;
slouken@368
   431
                *-*-cygwin* | *-*-mingw32*)
slouken@372
   432
                    ogg_lib=[`find_lib "libvorbisfile*.dll"`]
slouken@368
   433
                    ;;
slouken@368
   434
                *)
slouken@368
   435
                    ogg_lib=[`find_lib "libvorbisfile.so.[0-9]"`]
slouken@368
   436
                    if test x$ogg_lib = x; then
slouken@368
   437
                        ogg_lib=[`find_lib "libvorbisfile.so.[0-9]*"`]
slouken@368
   438
                    fi
slouken@368
   439
                    ;;
slouken@368
   440
            esac
slouken@368
   441
            SOURCES="$SOURCES $srcdir/*_ogg.c"
slouken@368
   442
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC"
slouken@368
   443
            if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
slouken@368
   444
                echo "-- dynamic libvorbisfile -> $ogg_lib"
slouken@368
   445
                EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
slouken@368
   446
            else
patmandin@464
   447
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis -logg $LIBM"
slouken@368
   448
            fi
slouken@419
   449
        else
slouken@419
   450
            AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)])
slouken@419
   451
            AC_MSG_WARN([Ogg Vorbis support disabled])
slouken@368
   452
        fi
slouken@353
   453
    fi
slouken@353
   454
fi
slouken@419
   455
slouken@396
   456
libflac_ver=8
slouken@382
   457
AC_ARG_ENABLE([music-flac],
slouken@382
   458
AC_HELP_STRING([--enable-music-flac], [enable FLAC music [[default=yes]]]),
slouken@382
   459
              [], [enable_music_flac=yes])
slouken@382
   460
AC_ARG_ENABLE([music-flac-shared],
slouken@382
   461
AC_HELP_STRING([--enable-music-flac-shared],
slouken@382
   462
              [dynamically load FLAC support [[default=yes]]]),
slouken@382
   463
              [], [enable_music_flac_shared=yes])
slouken@382
   464
if test x$enable_music_flac = xyes; then
slouken@452
   465
    AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes])
slouken@452
   466
    if test x$have_flac_export = xyes; then
slouken@452
   467
        LIBS_SAVED="$LIBS"
slouken@452
   468
        LIBS="-lFLAC"
slouken@452
   469
        AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver])
slouken@452
   470
        AC_TRY_RUN([
slouken@396
   471
#include "FLAC/export.h"
slouken@396
   472
#include "stdio.h"
slouken@396
   473
int main( int argc, char *argv[] ) {
slouken@396
   474
#if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
slouken@452
   475
    return 0;
slouken@396
   476
#else
slouken@452
   477
    return 1;
slouken@396
   478
#endif
slouken@396
   479
}
slouken@396
   480
], have_flac_ver=yes, have_flac_ver=no)
slouken@419
   481
        LIBS="$LIBS_SAVED"
slouken@419
   482
        AC_MSG_RESULT($have_flac_ver)
slouken@419
   483
    fi
slouken@419
   484
slouken@419
   485
    if test x$have_flac_ver = xyes; then
slouken@419
   486
        AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
slouken@419
   487
        AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
slouken@419
   488
        if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then    
slouken@419
   489
            case "$host" in
slouken@419
   490
                *-*-darwin*)
slouken@456
   491
                    flac_lib=[`find_lib libFLAC.dylib`]
slouken@419
   492
                    ;;
slouken@419
   493
                *-*-cygwin* | *-*-mingw32*)
slouken@419
   494
                    flac_lib=[`find_lib "libFLAC*.dll"`]
slouken@419
   495
                    ;;
slouken@419
   496
                *)
slouken@419
   497
                    flac_lib=[`find_lib "libFLAC.so.[0-9]"`]
slouken@419
   498
                    if test x$flac_lib = x; then
slouken@419
   499
                        flac_lib=[`find_lib "libFLAC.so.[0-9]*"`]
slouken@419
   500
                    fi
slouken@419
   501
                    ;;
slouken@419
   502
            esac
slouken@419
   503
            SOURCES="$SOURCES $srcdir/*_flac.c"
slouken@419
   504
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_MUSIC"
slouken@419
   505
            if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
slouken@419
   506
                echo "-- dynamic libFLAC -> $flac_lib"
slouken@419
   507
                EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
slouken@419
   508
            else
slouken@419
   509
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
slouken@419
   510
            fi
slouken@419
   511
        fi
slouken@419
   512
    else
slouken@419
   513
        AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)])
slouken@419
   514
        AC_MSG_WARN([FLAC support disabled])
slouken@419
   515
    fi
slouken@382
   516
fi
slouken@419
   517
slouken@0
   518
AC_ARG_ENABLE(music-mp3,
slouken@419
   519
AC_HELP_STRING([--enable-music-mp3], [enable MP3 music via smpeg [[default=yes]]]),
slouken@419
   520
              [], enable_music_mp3=yes)
slouken@419
   521
AC_ARG_ENABLE([music-mp3-shared],
slouken@419
   522
AC_HELP_STRING([--enable-music-mp3-shared], [dynamically load MP3 support [[default=yes]]]),
slouken@419
   523
              [], [enable_music_mp3_shared=yes])
slouken@0
   524
if test x$enable_music_mp3 = xyes; then
slouken@83
   525
    SMPEG_VERSION=0.4.3
slouken@83
   526
    AM_PATH_SMPEG($SMPEG_VERSION, have_smpeg=yes, have_smpeg=no)
slouken@0
   527
    if test x$have_smpeg = xyes; then
slouken@313
   528
        case "$host" in
slouken@313
   529
            *-*-darwin*)
slouken@456
   530
                smpeg_lib=[`find_lib libsmpeg.dylib`]
slouken@313
   531
                ;;
slouken@313
   532
            *-*-cygwin* | *-*-mingw32*)
slouken@372
   533
                smpeg_lib=[`find_lib "smpeg*.dll"`]
slouken@313
   534
                ;;
slouken@313
   535
            *)
slouken@374
   536
                smpeg_lib=[`find_lib "libsmpeg*.so.[0-9]"`]
slouken@368
   537
                if test x$smpeg_lib = x; then
slouken@374
   538
                    smpeg_lib=[`find_lib "libsmpeg*.so.[0-9]*"`]
slouken@368
   539
                fi
slouken@313
   540
                ;;
slouken@313
   541
        esac
slouken@314
   542
        SOURCES="$SOURCES $srcdir/*_mp3.c"
slouken@294
   543
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC $SMPEG_CFLAGS"
slouken@313
   544
        if test x$enable_music_mp3_shared = xyes && test x$smpeg_lib != x; then
slouken@313
   545
            echo "-- dynamic libsmpeg -> $smpeg_lib"
slouken@313
   546
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_DYNAMIC=\\\"$smpeg_lib\\\""
slouken@313
   547
        else
slouken@313
   548
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS"
slouken@313
   549
        fi
slouken@419
   550
    else
slouken@419
   551
        AC_MSG_WARN([*** Unable to find SMPEG library (http://icculus.org/smpeg/)])
slouken@0
   552
    fi
slouken@0
   553
fi
slouken@419
   554
slouken@357
   555
AC_ARG_ENABLE(music-mp3-mad-gpl,
slouken@357
   556
AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
slouken@357
   557
                  [], [enable_music_mp3_mad_gpl=no])
slouken@357
   558
if test x$enable_music_mp3_mad_gpl = xyes; then
slouken@357
   559
    AC_MSG_CHECKING(for libmad headers)
slouken@357
   560
    have_libmad=no
slouken@357
   561
    AC_TRY_COMPILE([
slouken@357
   562
     #include "mad.h"
slouken@357
   563
    ],[
slouken@357
   564
    ],[
slouken@357
   565
    have_libmad=yes
slouken@357
   566
    ])
slouken@357
   567
    AC_MSG_RESULT($have_libmad)
slouken@357
   568
    if test x$have_libmad = xyes; then
slouken@357
   569
        SOURCES="$SOURCES $srcdir/music_mad.c"
slouken@357
   570
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC"
slouken@357
   571
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
slouken@481
   572
        SOURCES="$SOURCES $srcdir/music_modplug.c"
slouken@419
   573
    else
slouken@419
   574
        AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
slouken@357
   575
    fi
slouken@357
   576
fi
slouken@0
   577
slouken@419
   578
if test x$have_smpeg != xyes -a x$have_libmad != xyes; then
slouken@419
   579
    AC_MSG_WARN([MP3 support disabled])
slouken@419
   580
fi
slouken@419
   581
slouken@422
   582
slouken@422
   583
OBJECTS=`echo $SOURCES`
slouken@422
   584
DEPENDS=`echo $SOURCES`
slouken@422
   585
OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
slouken@422
   586
DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
slouken@422
   587
$(objects)/\2.lo: \1/\2.c\\
slouken@432
   588
	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
slouken@422
   589
slouken@422
   590
VERSION_OBJECTS=`echo $VERSION_SOURCES`
slouken@422
   591
VERSION_DEPENDS=`echo $VERSION_SOURCES`
slouken@422
   592
VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
slouken@422
   593
VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
slouken@422
   594
$(objects)/\2.o: \1/\2.rc\\
slouken@422
   595
	\$(WINDRES) \$< \$@,g'`
slouken@422
   596
slouken@422
   597
PLAYWAVE_SOURCES="$srcdir/playwave.c"
slouken@422
   598
PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES`
slouken@422
   599
PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES`
slouken@422
   600
PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
slouken@422
   601
PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
slouken@422
   602
$(objects)/\2.lo: \1/\2.c\\
slouken@432
   603
	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
slouken@422
   604
slouken@422
   605
PLAYMUS_SOURCES="$srcdir/playmus.c"
slouken@422
   606
PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES`
slouken@422
   607
PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES`
slouken@422
   608
PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
slouken@422
   609
PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
slouken@422
   610
$(objects)/\2.lo: \1/\2.c\\
slouken@432
   611
	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
slouken@1
   612
slouken@294
   613
dnl Expand the sources and objects needed to build the library
slouken@294
   614
AC_SUBST(ac_aux_dir)
slouken@294
   615
AC_SUBST(OBJECTS)
slouken@422
   616
AC_SUBST(DEPENDS)
slouken@422
   617
AC_SUBST(VERSION_OBJECTS)
slouken@422
   618
AC_SUBST(VERSION_DEPENDS)
slouken@422
   619
AC_SUBST(PLAYWAVE_OBJECTS)
slouken@422
   620
AC_SUBST(PLAYWAVE_DEPENDS)
slouken@422
   621
AC_SUBST(PLAYMUS_OBJECTS)
slouken@422
   622
AC_SUBST(PLAYMUS_DEPENDS)
slouken@294
   623
AC_SUBST(BUILD_CFLAGS)
slouken@294
   624
AC_SUBST(EXTRA_CFLAGS)
slouken@294
   625
AC_SUBST(BUILD_LDFLAGS)
slouken@294
   626
AC_SUBST(EXTRA_LDFLAGS)
slouken@294
   627
AC_SUBST(EXE)
slouken@368
   628
AC_SUBST(WINDRES)
slouken@392
   629
AC_SUBST(SDL_VERSION)
slouken@294
   630
AC_SUBST(SDL_CFLAGS)
slouken@294
   631
AC_SUBST(SDL_LIBS)
slouken@206
   632
slouken@0
   633
AC_OUTPUT([
slouken@392
   634
    Makefile SDL_mixer.spec SDL_mixer.qpg SDL_mixer.pc
slouken@0
   635
])