configure.in
author Sam Lantinga <slouken@libsdl.org>
Sat, 03 Oct 2009 20:43:33 +0000
changeset 419 e27fe0bfe470
parent 411 cade1e3a4cb8
child 422 614c9a2f8279
permissions -rw-r--r--
Sam Lantinga - Sat Oct 3 13:33:36 PDT 2009
* MOD support uses libmikmod and is dynamically loaded by default
slouken@0
     1
dnl Process this file with autoconf to produce a configure script.
slouken@0
     2
AC_INIT(README)
slouken@0
     3
slouken@0
     4
dnl Set various version strings - taken gratefully from the GTk sources
slouken@0
     5
slouken@0
     6
# Making releases:
slouken@0
     7
#   MICRO_VERSION += 1;
slouken@0
     8
#   INTERFACE_AGE += 1;
slouken@0
     9
#   BINARY_AGE += 1;
slouken@0
    10
# if any functions have been added, set INTERFACE_AGE to 0.
slouken@0
    11
# if backwards compatibility has been broken,
slouken@0
    12
# set BINARY_AGE and INTERFACE_AGE to 0.
slouken@294
    13
#
slouken@0
    14
MAJOR_VERSION=1
slouken@81
    15
MINOR_VERSION=2
slouken@349
    16
MICRO_VERSION=8
slouken@349
    17
INTERFACE_AGE=6
slouken@349
    18
BINARY_AGE=8
slouken@0
    19
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
slouken@0
    20
slouken@0
    21
AC_SUBST(MAJOR_VERSION)
slouken@0
    22
AC_SUBST(MINOR_VERSION)
slouken@0
    23
AC_SUBST(MICRO_VERSION)
slouken@0
    24
AC_SUBST(INTERFACE_AGE)
slouken@0
    25
AC_SUBST(BINARY_AGE)
slouken@0
    26
AC_SUBST(VERSION)
slouken@0
    27
slouken@0
    28
# libtool versioning
slouken@0
    29
LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
slouken@0
    30
LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
slouken@0
    31
LT_REVISION=$INTERFACE_AGE
slouken@0
    32
LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
slouken@0
    33
slouken@0
    34
AC_SUBST(LT_RELEASE)
slouken@0
    35
AC_SUBST(LT_CURRENT)
slouken@0
    36
AC_SUBST(LT_REVISION)
slouken@0
    37
AC_SUBST(LT_AGE)
slouken@0
    38
slouken@289
    39
dnl Detect the canonical build and host environments
slouken@294
    40
AC_CONFIG_AUX_DIRS($srcdir/build-scripts)
slouken@289
    41
AC_CANONICAL_HOST
slouken@68
    42
slouken@406
    43
dnl Check for tools
slouken@406
    44
AC_LIBTOOL_WIN32_DLL
slouken@406
    45
AC_PROG_LIBTOOL
slouken@406
    46
AC_PROG_CC
slouken@406
    47
AC_PROG_INSTALL
slouken@406
    48
AC_PROG_MAKE_SET
slouken@406
    49
if test -z "$host_alias"; then
slouken@406
    50
    hostaliaswindres=
slouken@406
    51
else
slouken@406
    52
    hostaliaswindres="$host_alias-windres"
slouken@406
    53
fi
slouken@406
    54
AC_CHECK_PROGS(WINDRES, [windres $hostaliaswindres $host_os-windres])
slouken@406
    55
slouken@294
    56
dnl Set up the compiler and linker flags
slouken@294
    57
case "$host" in
slouken@294
    58
    *-*-cygwin*)
slouken@294
    59
        # We build SDL on cygwin without the UNIX emulation layer
slouken@294
    60
        BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
slouken@294
    61
        BASE_LDFLAGS="-mno-cygwin"
slouken@294
    62
        ;;
slouken@294
    63
    *)
slouken@294
    64
        BASE_CFLAGS="-D_GNU_SOURCE=1"
slouken@294
    65
        BASE_LDFLAGS=""
slouken@294
    66
        ;;
slouken@294
    67
esac
slouken@294
    68
BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
slouken@294
    69
EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
slouken@294
    70
BUILD_LDFLAGS="$LDFLAGS"
slouken@294
    71
EXTRA_LDFLAGS="$BASE_LDFLAGS"
slouken@368
    72
## These are common directories to find software packages
slouken@368
    73
#for path in /usr/freeware /usr/pkg /usr/local; do
slouken@368
    74
#    if test -d $path/include; then
slouken@368
    75
#        EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
slouken@368
    76
#    fi
slouken@368
    77
#    if test -d $path/lib; then
slouken@368
    78
#        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
slouken@368
    79
#    fi
slouken@368
    80
#done
slouken@294
    81
CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
slouken@294
    82
CFLAGS="$CFLAGS $EXTRA_CFLAGS"
slouken@294
    83
LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
slouken@91
    84
slouken@294
    85
dnl Check for compiler characteristics
slouken@294
    86
AC_C_CONST
slouken@0
    87
slouken@289
    88
case "$host" in
slouken@294
    89
    *-*-cygwin* | *-*-mingw32*)
slouken@368
    90
        SOURCES="$srcdir/version.rc"
slouken@294
    91
        EXE=".exe"
slouken@368
    92
        if test "$build" != "$host"; then # cross-compiling
slouken@368
    93
            # Default cross-compile location
slouken@368
    94
            ac_default_prefix=/usr/local/cross-tools/i386-mingw32
slouken@368
    95
        else
slouken@368
    96
            # Look for the location of the tools and install there
slouken@368
    97
            if test "$BUILD_PREFIX" != ""; then
slouken@368
    98
                ac_default_prefix=$BUILD_PREFIX
slouken@368
    99
            fi
slouken@368
   100
        fi
slouken@6
   101
        ;;
slouken@294
   102
    *)
slouken@368
   103
        SOURCES=""
slouken@294
   104
        EXE=""
slouken@208
   105
        ;;
slouken@6
   106
esac
slouken@6
   107
slouken@294
   108
# Standard C sources
slouken@294
   109
SOURCES="$SOURCES \
slouken@294
   110
$srcdir/effect_position.c \
slouken@294
   111
$srcdir/effect_stereoreverse.c \
slouken@294
   112
$srcdir/effects_internal.c \
slouken@294
   113
$srcdir/load_aiff.c \
slouken@294
   114
$srcdir/load_voc.c \
slouken@294
   115
$srcdir/mixer.c \
slouken@294
   116
$srcdir/music.c"
slouken@294
   117
slouken@368
   118
find_lib()
slouken@368
   119
{
slouken@372
   120
    gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
slouken@372
   121
    gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
slouken@368
   122
    env_lib_path=[`echo $LIBS $LDFLAGS | sed 's/-L[ ]*//g'`]
slouken@405
   123
    if test "$cross_compiling" = yes; then
slouken@405
   124
        host_lib_path=""
slouken@405
   125
    else
slouken@405
   126
        host_lib_path="/usr/lib /usr/local/lib"
slouken@405
   127
    fi
slouken@405
   128
    for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
slouken@368
   129
        lib=[`ls -- $path/$1 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
slouken@368
   130
        if test x$lib != x; then
slouken@368
   131
            echo $lib
slouken@368
   132
            return
slouken@368
   133
        fi
slouken@368
   134
    done
slouken@368
   135
}
slouken@368
   136
slouken@20
   137
dnl Check for SDL
slouken@308
   138
SDL_VERSION=1.2.10
slouken@20
   139
AM_PATH_SDL($SDL_VERSION,
slouken@20
   140
            :,
slouken@368
   141
            AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
slouken@20
   142
)
slouken@294
   143
EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
slouken@294
   144
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
slouken@0
   145
slouken@0
   146
dnl Check command-line options
slouken@91
   147
slouken@312
   148
AC_ARG_ENABLE([music-cmd],
slouken@312
   149
AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
slouken@312
   150
              [], [enable_music_cmd=yes])
slouken@0
   151
if test x$enable_music_cmd = xyes; then
slouken@294
   152
    SOURCES="$SOURCES $srcdir/music_cmd.c"
slouken@294
   153
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC"
slouken@0
   154
fi
slouken@419
   155
slouken@312
   156
AC_ARG_ENABLE([music-wave],
slouken@312
   157
AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
slouken@312
   158
              [], [enable_music_wave=yes])
slouken@0
   159
if test x$enable_music_wave = xyes; then
slouken@294
   160
    SOURCES="$SOURCES $srcdir/wavestream.c"
slouken@294
   161
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DWAV_MUSIC"
slouken@0
   162
fi
slouken@419
   163
slouken@419
   164
AC_ARG_ENABLE([music-mod],
slouken@419
   165
AC_HELP_STRING([--enable-music-mod], [enable MOD music via mikmod [[default=yes]]]),
slouken@419
   166
              [], [enable_music_mod=yes])
slouken@419
   167
AC_ARG_ENABLE([music-mod-shared],
slouken@419
   168
AC_HELP_STRING([--enable-music-mod-shared], [dynamically load MOD support [[default=yes]]]),
slouken@419
   169
              [], [enable_music_mod_shared=yes])
slouken@419
   170
if test x$enable_music_mod = xyes; then
slouken@419
   171
    have_libmikmod=no
slouken@419
   172
    libmikmod_maj=3
slouken@419
   173
    libmikmod_min=1
slouken@419
   174
    libmikmod_rev=10
slouken@419
   175
    libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
slouken@368
   176
    AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
slouken@368
   177
    if test "$LIBMIKMOD_CONFIG" != "no" ; then
slouken@419
   178
        
slouken@368
   179
        CFLAGS_SAVED="$CFLAGS"
slouken@368
   180
        LIBS_SAVED="$LIBS"
slouken@368
   181
        CFLAGS="$CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
slouken@368
   182
        LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
slouken@419
   183
        have_libmikmod=yes
slouken@368
   184
        AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
slouken@368
   185
        AC_TRY_RUN([
slouken@249
   186
#include "mikmod.h"
slouken@249
   187
#include "stdio.h"
slouken@249
   188
slouken@249
   189
int main(int argc, char **argv)
slouken@249
   190
{
slouken@419
   191
long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
slouken@419
   192
/*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
slouken@419
   193
if(ver>=((maj<<16)|(min<<8)|(rev))) {
slouken@419
   194
    printf("yes\n");
slouken@419
   195
    return 0;
slouken@249
   196
}
slouken@419
   197
printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
slouken@419
   198
return 1;
slouken@419
   199
}
slouken@419
   200
], [], have_libmikmod=no; CFLAGS="$CFLAGS_SAVED"; LIBS="$LIBS_SAVED",
slouken@419
   201
        [echo $ac_n "cross compiling; assumed OK... $ac_c"])
slouken@368
   202
    fi
slouken@419
   203
slouken@419
   204
    if test x$have_libmikmod = xyes; then
slouken@419
   205
        case "$host" in
slouken@419
   206
            *-*-darwin*)
slouken@419
   207
                mikmod_lib=[`find_lib libmikmod*.dylib`]
slouken@419
   208
                ;;
slouken@419
   209
            *-*-cygwin* | *-*-mingw32*)
slouken@419
   210
                mikmod_lib=[`find_lib "mikmod*.dll"`]
slouken@419
   211
                ;;
slouken@419
   212
            *)
slouken@419
   213
                mikmod_lib=[`find_lib "libmikmod*.so.[0-9]"`]
slouken@419
   214
                if test x$mikmod_lib = x; then
slouken@419
   215
                    mikmod_lib=[`find_lib "libmikmod*.so.[0-9]*"`]
slouken@419
   216
                fi
slouken@419
   217
                ;;
slouken@419
   218
        esac
slouken@419
   219
        SOURCES="$SOURCES $srcdir/*_mod.c"
slouken@419
   220
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
slouken@419
   221
        if test x$enable_music_mod_shared = xyes && test x$mikmod_lib != x; then
slouken@419
   222
            echo "-- dynamic libmikmod -> $mikmod_lib"
slouken@419
   223
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_DYNAMIC=\\\"$mikmod_lib\\\""
slouken@419
   224
        else
slouken@419
   225
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`"
slouken@419
   226
        fi
slouken@419
   227
    else
slouken@419
   228
        AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.raphnet.net/)])
slouken@419
   229
        AC_MSG_WARN([MOD support disabled])
slouken@419
   230
    fi
slouken@249
   231
fi
slouken@249
   232
slouken@312
   233
AC_ARG_ENABLE([music-midi],
slouken@312
   234
AC_HELP_STRING([--enable-music-midi], [enable MIDI music via timidity [[default=yes]]]),
slouken@312
   235
              [], [enable_music_midi=yes])
slouken@0
   236
if test x$enable_music_midi = xyes; then
slouken@294
   237
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DMID_MUSIC"
slouken@312
   238
    AC_ARG_ENABLE([music-timidity-midi],
slouken@312
   239
AC_HELP_STRING([--enable-music-timidity-midi], [enable timidity MIDI output [[default=yes]]]),
slouken@312
   240
                  [], [enable_music_timidity_midi=yes])
slouken@106
   241
    if test x$enable_music_timidity_midi = xyes; then
slouken@294
   242
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_TIMIDITY_MIDI -I\$(srcdir)/timidity"
slouken@294
   243
        SOURCES="$SOURCES $srcdir/timidity/*.c"
slouken@106
   244
    fi
slouken@312
   245
    AC_ARG_ENABLE([music-native-midi],
slouken@312
   246
AC_HELP_STRING([--enable-music-native-midi], [enable native MIDI music output [[default=yes]]]),
slouken@312
   247
                  [], [enable_music_native_midi=yes])
slouken@99
   248
    if test x$enable_music_native_midi = xyes; then
slouken@99
   249
        use_music_native_midi=no
slouken@289
   250
        case "$host" in
slouken@99
   251
            *-*-cygwin* | *-*-mingw32*)
slouken@99
   252
                use_music_native_midi=yes
slouken@294
   253
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
slouken@99
   254
                ;;
slouken@107
   255
            *-*-darwin*)
slouken@402
   256
                # This doesn't work on Mac OS X 10.5+
slouken@402
   257
                # Max Horn (the original author) recommends disabling it for now.
slouken@402
   258
                #use_music_native_midi=yes
slouken@402
   259
                #EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuickTime -Wl,-framework,CoreServices"
slouken@107
   260
                ;;
slouken@99
   261
        esac
slouken@99
   262
        if test x$use_music_native_midi = xyes; then
slouken@294
   263
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
slouken@294
   264
            SOURCES="$SOURCES $srcdir/native_midi/*.c"
slouken@99
   265
        fi
slouken@99
   266
    fi
slouken@312
   267
    AC_ARG_ENABLE([music-native-midi-gpl],
slouken@312
   268
AC_HELP_STRING([--enable-music-native-midi-gpl], [enable native MIDI on UNIX using GPL code [[default=no]]]),
slouken@312
   269
                  [], [enable_music_native_midi_gpl=no])
slouken@160
   270
    if test x$enable_music_native_midi_gpl = xyes; then
slouken@160
   271
        use_music_native_midi_gpl=no
slouken@289
   272
        case "$host" in
slouken@160
   273
            *-*-linux* | *-*-freebsd*)
slouken@160
   274
                use_music_native_midi_gpl=yes
slouken@160
   275
                ;;
slouken@160
   276
        esac
slouken@160
   277
        if test x$use_music_native_midi_gpl = xyes; then
slouken@294
   278
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
slouken@294
   279
            SOURCES="$SOURCES $srcdir/native_midi_gpl/*.c"
slouken@160
   280
        fi
slouken@160
   281
    fi
slouken@0
   282
fi
slouken@419
   283
slouken@312
   284
AC_ARG_ENABLE([music-ogg],
slouken@312
   285
AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
slouken@312
   286
              [], [enable_music_ogg=yes])
slouken@353
   287
AC_ARG_ENABLE(music-ogg-tremor,
slouken@419
   288
AC_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [[default=no]]]),
slouken@368
   289
              [], enable_music_ogg_tremor=no)
slouken@368
   290
AC_ARG_ENABLE([music-ogg-shared],
slouken@368
   291
AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis support [[default=yes]]]),
slouken@368
   292
              [], [enable_music_ogg_shared=yes])
slouken@368
   293
if test x$enable_music_ogg = xyes; then
slouken@368
   294
    if test x$enable_music_ogg_tremor = xyes; then
slouken@368
   295
        AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
slouken@368
   296
        AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes])
slouken@368
   297
        if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
slouken@368
   298
            case "$host" in
slouken@368
   299
                *-*-darwin*)
slouken@368
   300
                    ogg_lib=[`find_lib libvorbisidec*.dylib`]
slouken@368
   301
                    if test x$ogg_lib = x; then
slouken@368
   302
                        ogg_lib=[`find_lib libvorbisidec.[0-9]`]
slouken@368
   303
                    fi
slouken@368
   304
                    if test x$ogg_lib = x; then
slouken@368
   305
                        ogg_lib=[`find_lib libvorbisidec.[0-9]*`]
slouken@368
   306
                    fi
slouken@368
   307
                    ;;
slouken@368
   308
                *-*-cygwin* | *-*-mingw32*)
slouken@372
   309
                    ogg_lib=[`find_lib "vorbisidec*.dll"`]
slouken@368
   310
                    ;;
slouken@368
   311
                *)
slouken@368
   312
                    ogg_lib=[`find_lib "libvorbisidec.so.[0-9]"`]
slouken@368
   313
                    if test x$ogg_lib = x; then
slouken@368
   314
                        ogg_lib=[`find_lib "libvorbisidec.so.[0-9]*"`]
slouken@368
   315
                    fi
slouken@368
   316
                    ;;
slouken@368
   317
            esac
slouken@368
   318
            SOURCES="$SOURCES $srcdir/*_ogg.c"
slouken@368
   319
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC -DOGG_USE_TREMOR"
slouken@368
   320
            if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
slouken@368
   321
                echo "-- dynamic libvorbisidec -> $ogg_lib"
slouken@368
   322
                EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
slouken@368
   323
            else
slouken@368
   324
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec"
slouken@368
   325
            fi
slouken@419
   326
        else
slouken@419
   327
            AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)])
slouken@419
   328
            AC_MSG_WARN([Ogg Vorbis support disabled])
slouken@368
   329
        fi
slouken@368
   330
    else
slouken@368
   331
        AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
slouken@368
   332
        AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes])
slouken@368
   333
        if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
slouken@368
   334
            case "$host" in
slouken@368
   335
                *-*-darwin*)
slouken@368
   336
                    ogg_lib=[`find_lib libvorbisfile*.dylib`]
slouken@368
   337
                    ;;
slouken@368
   338
                *-*-cygwin* | *-*-mingw32*)
slouken@372
   339
                    ogg_lib=[`find_lib "libvorbisfile*.dll"`]
slouken@368
   340
                    ;;
slouken@368
   341
                *)
slouken@368
   342
                    ogg_lib=[`find_lib "libvorbisfile.so.[0-9]"`]
slouken@368
   343
                    if test x$ogg_lib = x; then
slouken@368
   344
                        ogg_lib=[`find_lib "libvorbisfile.so.[0-9]*"`]
slouken@368
   345
                    fi
slouken@368
   346
                    ;;
slouken@368
   347
            esac
slouken@368
   348
            SOURCES="$SOURCES $srcdir/*_ogg.c"
slouken@368
   349
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC"
slouken@368
   350
            if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
slouken@368
   351
                echo "-- dynamic libvorbisfile -> $ogg_lib"
slouken@368
   352
                EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
slouken@368
   353
            else
slouken@368
   354
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis -logg"
slouken@368
   355
            fi
slouken@419
   356
        else
slouken@419
   357
            AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)])
slouken@419
   358
            AC_MSG_WARN([Ogg Vorbis support disabled])
slouken@368
   359
        fi
slouken@353
   360
    fi
slouken@353
   361
fi
slouken@419
   362
slouken@396
   363
libflac_ver=8
slouken@382
   364
AC_ARG_ENABLE([music-flac],
slouken@382
   365
AC_HELP_STRING([--enable-music-flac], [enable FLAC music [[default=yes]]]),
slouken@382
   366
              [], [enable_music_flac=yes])
slouken@382
   367
AC_ARG_ENABLE([music-flac-shared],
slouken@382
   368
AC_HELP_STRING([--enable-music-flac-shared],
slouken@382
   369
              [dynamically load FLAC support [[default=yes]]]),
slouken@382
   370
              [], [enable_music_flac_shared=yes])
slouken@382
   371
if test x$enable_music_flac = xyes; then
slouken@396
   372
	AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes])
slouken@396
   373
	if test x$have_flac_export = xyes; then
slouken@396
   374
		LIBS_SAVED="$LIBS"
slouken@396
   375
		LIBS="-lFLAC"
slouken@396
   376
	    AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver])
slouken@396
   377
	    AC_TRY_RUN([
slouken@396
   378
#include "FLAC/export.h"
slouken@396
   379
#include "stdio.h"
slouken@396
   380
int main( int argc, char *argv[] ) {
slouken@396
   381
#if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
slouken@396
   382
	return 0;
slouken@396
   383
#else
slouken@396
   384
	return 1;
slouken@396
   385
#endif
slouken@396
   386
}
slouken@396
   387
], have_flac_ver=yes, have_flac_ver=no)
slouken@419
   388
        LIBS="$LIBS_SAVED"
slouken@419
   389
        AC_MSG_RESULT($have_flac_ver)
slouken@419
   390
    fi
slouken@419
   391
slouken@419
   392
    if test x$have_flac_ver = xyes; then
slouken@419
   393
        AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
slouken@419
   394
        AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
slouken@419
   395
        if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then    
slouken@419
   396
            case "$host" in
slouken@419
   397
                *-*-darwin*)
slouken@419
   398
                    flac_lib=[`find_lib libFLAC*.dylib`]
slouken@419
   399
                    ;;
slouken@419
   400
                *-*-cygwin* | *-*-mingw32*)
slouken@419
   401
                    flac_lib=[`find_lib "libFLAC*.dll"`]
slouken@419
   402
                    ;;
slouken@419
   403
                *)
slouken@419
   404
                    flac_lib=[`find_lib "libFLAC.so.[0-9]"`]
slouken@419
   405
                    if test x$flac_lib = x; then
slouken@419
   406
                        flac_lib=[`find_lib "libFLAC.so.[0-9]*"`]
slouken@419
   407
                    fi
slouken@419
   408
                    ;;
slouken@419
   409
            esac
slouken@419
   410
            SOURCES="$SOURCES $srcdir/*_flac.c"
slouken@419
   411
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_MUSIC"
slouken@419
   412
            if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
slouken@419
   413
                echo "-- dynamic libFLAC -> $flac_lib"
slouken@419
   414
                EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
slouken@419
   415
            else
slouken@419
   416
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
slouken@419
   417
            fi
slouken@419
   418
        fi
slouken@419
   419
    else
slouken@419
   420
        AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)])
slouken@419
   421
        AC_MSG_WARN([FLAC support disabled])
slouken@419
   422
    fi
slouken@382
   423
fi
slouken@419
   424
slouken@0
   425
AC_ARG_ENABLE(music-mp3,
slouken@419
   426
AC_HELP_STRING([--enable-music-mp3], [enable MP3 music via smpeg [[default=yes]]]),
slouken@419
   427
              [], enable_music_mp3=yes)
slouken@419
   428
AC_ARG_ENABLE([music-mp3-shared],
slouken@419
   429
AC_HELP_STRING([--enable-music-mp3-shared], [dynamically load MP3 support [[default=yes]]]),
slouken@419
   430
              [], [enable_music_mp3_shared=yes])
slouken@0
   431
if test x$enable_music_mp3 = xyes; then
slouken@83
   432
    SMPEG_VERSION=0.4.3
slouken@83
   433
    AM_PATH_SMPEG($SMPEG_VERSION, have_smpeg=yes, have_smpeg=no)
slouken@0
   434
    if test x$have_smpeg = xyes; then
slouken@313
   435
        case "$host" in
slouken@313
   436
            *-*-darwin*)
slouken@368
   437
                smpeg_lib=[`find_lib libsmpeg*.dylib`]
slouken@313
   438
                ;;
slouken@313
   439
            *-*-cygwin* | *-*-mingw32*)
slouken@372
   440
                smpeg_lib=[`find_lib "smpeg*.dll"`]
slouken@313
   441
                ;;
slouken@313
   442
            *)
slouken@374
   443
                smpeg_lib=[`find_lib "libsmpeg*.so.[0-9]"`]
slouken@368
   444
                if test x$smpeg_lib = x; then
slouken@374
   445
                    smpeg_lib=[`find_lib "libsmpeg*.so.[0-9]*"`]
slouken@368
   446
                fi
slouken@313
   447
                ;;
slouken@313
   448
        esac
slouken@314
   449
        SOURCES="$SOURCES $srcdir/*_mp3.c"
slouken@294
   450
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC $SMPEG_CFLAGS"
slouken@313
   451
        if test x$enable_music_mp3_shared = xyes && test x$smpeg_lib != x; then
slouken@313
   452
            echo "-- dynamic libsmpeg -> $smpeg_lib"
slouken@313
   453
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_DYNAMIC=\\\"$smpeg_lib\\\""
slouken@313
   454
        else
slouken@313
   455
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS"
slouken@313
   456
        fi
slouken@419
   457
    else
slouken@419
   458
        AC_MSG_WARN([*** Unable to find SMPEG library (http://icculus.org/smpeg/)])
slouken@0
   459
    fi
slouken@0
   460
fi
slouken@419
   461
slouken@357
   462
AC_ARG_ENABLE(music-mp3-mad-gpl,
slouken@357
   463
AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
slouken@357
   464
                  [], [enable_music_mp3_mad_gpl=no])
slouken@357
   465
if test x$enable_music_mp3_mad_gpl = xyes; then
slouken@357
   466
    AC_MSG_CHECKING(for libmad headers)
slouken@357
   467
    have_libmad=no
slouken@357
   468
    AC_TRY_COMPILE([
slouken@357
   469
     #include "mad.h"
slouken@357
   470
    ],[
slouken@357
   471
    ],[
slouken@357
   472
    have_libmad=yes
slouken@357
   473
    ])
slouken@357
   474
    AC_MSG_RESULT($have_libmad)
slouken@357
   475
    if test x$have_libmad = xyes; then
slouken@357
   476
        SOURCES="$SOURCES $srcdir/music_mad.c"
slouken@357
   477
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC"
slouken@357
   478
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
slouken@419
   479
    else
slouken@419
   480
        AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
slouken@357
   481
    fi
slouken@357
   482
fi
slouken@0
   483
slouken@419
   484
if test x$have_smpeg != xyes -a x$have_libmad != xyes; then
slouken@419
   485
    AC_MSG_WARN([MP3 support disabled])
slouken@419
   486
fi
slouken@419
   487
slouken@294
   488
OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
slouken@368
   489
OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
slouken@1
   490
slouken@294
   491
dnl Expand the sources and objects needed to build the library
slouken@294
   492
AC_SUBST(ac_aux_dir)
slouken@294
   493
AC_SUBST(SOURCES)
slouken@294
   494
AC_SUBST(OBJECTS)
slouken@294
   495
AC_SUBST(BUILD_CFLAGS)
slouken@294
   496
AC_SUBST(EXTRA_CFLAGS)
slouken@294
   497
AC_SUBST(BUILD_LDFLAGS)
slouken@294
   498
AC_SUBST(EXTRA_LDFLAGS)
slouken@294
   499
AC_SUBST(EXE)
slouken@368
   500
AC_SUBST(WINDRES)
slouken@392
   501
AC_SUBST(SDL_VERSION)
slouken@294
   502
AC_SUBST(SDL_CFLAGS)
slouken@294
   503
AC_SUBST(SDL_LIBS)
slouken@206
   504
slouken@0
   505
AC_OUTPUT([
slouken@392
   506
    Makefile SDL_mixer.spec SDL_mixer.qpg SDL_mixer.pc
slouken@294
   507
], [
slouken@294
   508
    : >build-deps
slouken@294
   509
    if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
slouken@0
   510
])