configure.in
author Patrice Mandin <patmandin@gmail.com>
Mon, 26 Oct 2009 18:08:09 +0000
changeset 464 9a6369a63488
parent 463 47c9366cede1
child 467 4b52401dda92
permissions -rw-r--r--
Do not force math library usage beforce checking its presence.
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@429
    17
MICRO_VERSION=9
slouken@429
    18
INTERFACE_AGE=7
slouken@429
    19
BINARY_AGE=9
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
slouken@451
   147
dnl Function to find a library in the compiler search path
slouken@368
   148
find_lib()
slouken@368
   149
{
slouken@372
   150
    gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
slouken@372
   151
    gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
slouken@451
   152
    env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
slouken@405
   153
    if test "$cross_compiling" = yes; then
slouken@405
   154
        host_lib_path=""
slouken@405
   155
    else
slouken@451
   156
        host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
slouken@405
   157
    fi
slouken@405
   158
    for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
slouken@451
   159
        lib=[`ls -- $path/$1 2>/dev/null | sort | sed 's/.*\/\(.*\)/\1/; q'`]
slouken@368
   160
        if test x$lib != x; then
slouken@368
   161
            echo $lib
slouken@368
   162
            return
slouken@368
   163
        fi
slouken@368
   164
    done
slouken@368
   165
}
slouken@368
   166
slouken@20
   167
dnl Check for SDL
slouken@308
   168
SDL_VERSION=1.2.10
slouken@20
   169
AM_PATH_SDL($SDL_VERSION,
slouken@20
   170
            :,
slouken@368
   171
            AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
slouken@20
   172
)
slouken@294
   173
EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
slouken@294
   174
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
slouken@0
   175
patmandin@464
   176
dnl Check for math library
patmandin@464
   177
AC_CHECK_LIB(m, pow, [LIBM="-lm"])
patmandin@464
   178
slouken@0
   179
dnl Check command-line options
slouken@91
   180
slouken@312
   181
AC_ARG_ENABLE([music-cmd],
slouken@312
   182
AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
slouken@312
   183
              [], [enable_music_cmd=yes])
slouken@0
   184
if test x$enable_music_cmd = xyes; then
slouken@294
   185
    SOURCES="$SOURCES $srcdir/music_cmd.c"
slouken@294
   186
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC"
slouken@0
   187
fi
slouken@419
   188
slouken@312
   189
AC_ARG_ENABLE([music-wave],
slouken@312
   190
AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
slouken@312
   191
              [], [enable_music_wave=yes])
slouken@0
   192
if test x$enable_music_wave = xyes; then
slouken@294
   193
    SOURCES="$SOURCES $srcdir/wavestream.c"
slouken@294
   194
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DWAV_MUSIC"
slouken@0
   195
fi
slouken@419
   196
slouken@419
   197
AC_ARG_ENABLE([music-mod],
slouken@419
   198
AC_HELP_STRING([--enable-music-mod], [enable MOD music via mikmod [[default=yes]]]),
slouken@419
   199
              [], [enable_music_mod=yes])
slouken@419
   200
AC_ARG_ENABLE([music-mod-shared],
slouken@419
   201
AC_HELP_STRING([--enable-music-mod-shared], [dynamically load MOD support [[default=yes]]]),
slouken@419
   202
              [], [enable_music_mod_shared=yes])
slouken@419
   203
if test x$enable_music_mod = xyes; then
slouken@419
   204
    have_libmikmod=no
slouken@419
   205
    libmikmod_maj=3
slouken@419
   206
    libmikmod_min=1
slouken@419
   207
    libmikmod_rev=10
slouken@419
   208
    libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
slouken@368
   209
    AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
slouken@368
   210
    if test "$LIBMIKMOD_CONFIG" != "no" ; then
slouken@419
   211
        
slouken@368
   212
        CFLAGS_SAVED="$CFLAGS"
slouken@368
   213
        LIBS_SAVED="$LIBS"
slouken@368
   214
        CFLAGS="$CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
slouken@368
   215
        LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
slouken@419
   216
        have_libmikmod=yes
slouken@368
   217
        AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
slouken@368
   218
        AC_TRY_RUN([
slouken@249
   219
#include "mikmod.h"
slouken@249
   220
#include "stdio.h"
slouken@249
   221
slouken@249
   222
int main(int argc, char **argv)
slouken@249
   223
{
slouken@419
   224
long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
slouken@419
   225
/*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
slouken@419
   226
if(ver>=((maj<<16)|(min<<8)|(rev))) {
slouken@419
   227
    printf("yes\n");
slouken@419
   228
    return 0;
slouken@249
   229
}
slouken@419
   230
printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
slouken@419
   231
return 1;
slouken@419
   232
}
slouken@419
   233
], [], have_libmikmod=no; CFLAGS="$CFLAGS_SAVED"; LIBS="$LIBS_SAVED",
slouken@419
   234
        [echo $ac_n "cross compiling; assumed OK... $ac_c"])
slouken@368
   235
    fi
slouken@419
   236
slouken@419
   237
    if test x$have_libmikmod = xyes; then
slouken@419
   238
        case "$host" in
slouken@419
   239
            *-*-darwin*)
slouken@456
   240
                mikmod_lib=[`find_lib libmikmod.dylib`]
slouken@419
   241
                ;;
slouken@419
   242
            *-*-cygwin* | *-*-mingw32*)
slouken@419
   243
                mikmod_lib=[`find_lib "mikmod*.dll"`]
slouken@419
   244
                ;;
slouken@419
   245
            *)
slouken@419
   246
                mikmod_lib=[`find_lib "libmikmod*.so.[0-9]"`]
slouken@419
   247
                if test x$mikmod_lib = x; then
slouken@419
   248
                    mikmod_lib=[`find_lib "libmikmod*.so.[0-9]*"`]
slouken@419
   249
                fi
slouken@419
   250
                ;;
slouken@419
   251
        esac
slouken@419
   252
        SOURCES="$SOURCES $srcdir/*_mod.c"
slouken@419
   253
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
slouken@419
   254
        if test x$enable_music_mod_shared = xyes && test x$mikmod_lib != x; then
slouken@419
   255
            echo "-- dynamic libmikmod -> $mikmod_lib"
slouken@419
   256
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_DYNAMIC=\\\"$mikmod_lib\\\""
slouken@419
   257
        else
slouken@419
   258
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`"
slouken@419
   259
        fi
slouken@419
   260
    else
slouken@419
   261
        AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.raphnet.net/)])
slouken@419
   262
        AC_MSG_WARN([MOD support disabled])
slouken@419
   263
    fi
slouken@249
   264
fi
slouken@249
   265
slouken@312
   266
AC_ARG_ENABLE([music-midi],
slouken@312
   267
AC_HELP_STRING([--enable-music-midi], [enable MIDI music via timidity [[default=yes]]]),
slouken@312
   268
              [], [enable_music_midi=yes])
slouken@0
   269
if test x$enable_music_midi = xyes; then
slouken@294
   270
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DMID_MUSIC"
slouken@312
   271
    AC_ARG_ENABLE([music-timidity-midi],
slouken@312
   272
AC_HELP_STRING([--enable-music-timidity-midi], [enable timidity MIDI output [[default=yes]]]),
slouken@312
   273
                  [], [enable_music_timidity_midi=yes])
slouken@106
   274
    if test x$enable_music_timidity_midi = xyes; then
slouken@294
   275
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_TIMIDITY_MIDI -I\$(srcdir)/timidity"
slouken@294
   276
        SOURCES="$SOURCES $srcdir/timidity/*.c"
slouken@106
   277
    fi
slouken@312
   278
    AC_ARG_ENABLE([music-native-midi],
slouken@312
   279
AC_HELP_STRING([--enable-music-native-midi], [enable native MIDI music output [[default=yes]]]),
slouken@312
   280
                  [], [enable_music_native_midi=yes])
slouken@99
   281
    if test x$enable_music_native_midi = xyes; then
slouken@99
   282
        use_music_native_midi=no
slouken@289
   283
        case "$host" in
slouken@99
   284
            *-*-cygwin* | *-*-mingw32*)
slouken@99
   285
                use_music_native_midi=yes
slouken@294
   286
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
slouken@99
   287
                ;;
slouken@107
   288
            *-*-darwin*)
icculus@458
   289
                use_music_native_midi=yes
icculus@461
   290
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices"
slouken@107
   291
                ;;
slouken@99
   292
        esac
slouken@99
   293
        if test x$use_music_native_midi = xyes; then
slouken@294
   294
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
slouken@294
   295
            SOURCES="$SOURCES $srcdir/native_midi/*.c"
slouken@99
   296
        fi
slouken@99
   297
    fi
slouken@312
   298
    AC_ARG_ENABLE([music-native-midi-gpl],
slouken@312
   299
AC_HELP_STRING([--enable-music-native-midi-gpl], [enable native MIDI on UNIX using GPL code [[default=no]]]),
slouken@312
   300
                  [], [enable_music_native_midi_gpl=no])
slouken@160
   301
    if test x$enable_music_native_midi_gpl = xyes; then
slouken@160
   302
        use_music_native_midi_gpl=no
slouken@289
   303
        case "$host" in
slouken@160
   304
            *-*-linux* | *-*-freebsd*)
slouken@160
   305
                use_music_native_midi_gpl=yes
slouken@160
   306
                ;;
slouken@160
   307
        esac
slouken@160
   308
        if test x$use_music_native_midi_gpl = xyes; then
slouken@294
   309
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
slouken@294
   310
            SOURCES="$SOURCES $srcdir/native_midi_gpl/*.c"
slouken@160
   311
        fi
slouken@160
   312
    fi
slouken@0
   313
fi
slouken@419
   314
slouken@312
   315
AC_ARG_ENABLE([music-ogg],
slouken@312
   316
AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
slouken@312
   317
              [], [enable_music_ogg=yes])
slouken@353
   318
AC_ARG_ENABLE(music-ogg-tremor,
slouken@419
   319
AC_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [[default=no]]]),
slouken@368
   320
              [], enable_music_ogg_tremor=no)
slouken@368
   321
AC_ARG_ENABLE([music-ogg-shared],
slouken@368
   322
AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis support [[default=yes]]]),
slouken@368
   323
              [], [enable_music_ogg_shared=yes])
slouken@368
   324
if test x$enable_music_ogg = xyes; then
slouken@368
   325
    if test x$enable_music_ogg_tremor = xyes; then
slouken@368
   326
        AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
patmandin@464
   327
        AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes], [have_tremor_lib=no], [-lvorbis -logg $LIBM])
slouken@368
   328
        if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
slouken@368
   329
            case "$host" in
slouken@368
   330
                *-*-darwin*)
slouken@456
   331
                    ogg_lib=[`find_lib libvorbisidec.dylib`]
slouken@368
   332
                    if test x$ogg_lib = x; then
slouken@368
   333
                        ogg_lib=[`find_lib libvorbisidec.[0-9]`]
slouken@368
   334
                    fi
slouken@368
   335
                    if test x$ogg_lib = x; then
slouken@368
   336
                        ogg_lib=[`find_lib libvorbisidec.[0-9]*`]
slouken@368
   337
                    fi
slouken@368
   338
                    ;;
slouken@368
   339
                *-*-cygwin* | *-*-mingw32*)
slouken@372
   340
                    ogg_lib=[`find_lib "vorbisidec*.dll"`]
slouken@368
   341
                    ;;
slouken@368
   342
                *)
slouken@368
   343
                    ogg_lib=[`find_lib "libvorbisidec.so.[0-9]"`]
slouken@368
   344
                    if test x$ogg_lib = x; then
slouken@368
   345
                        ogg_lib=[`find_lib "libvorbisidec.so.[0-9]*"`]
slouken@368
   346
                    fi
slouken@368
   347
                    ;;
slouken@368
   348
            esac
slouken@368
   349
            SOURCES="$SOURCES $srcdir/*_ogg.c"
slouken@368
   350
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC -DOGG_USE_TREMOR"
slouken@368
   351
            if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
slouken@368
   352
                echo "-- dynamic libvorbisidec -> $ogg_lib"
slouken@368
   353
                EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
slouken@368
   354
            else
patmandin@464
   355
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis -logg $LIBM"
slouken@368
   356
            fi
slouken@419
   357
        else
slouken@419
   358
            AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)])
slouken@419
   359
            AC_MSG_WARN([Ogg Vorbis support disabled])
slouken@368
   360
        fi
slouken@368
   361
    else
slouken@368
   362
        AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
patmandin@464
   363
        AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes], [have_ogg_lib=no], [-lvorbis -logg $LIBM])
slouken@368
   364
        if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
slouken@368
   365
            case "$host" in
slouken@368
   366
                *-*-darwin*)
slouken@456
   367
                    ogg_lib=[`find_lib libvorbisfile.dylib`]
slouken@368
   368
                    ;;
slouken@368
   369
                *-*-cygwin* | *-*-mingw32*)
slouken@372
   370
                    ogg_lib=[`find_lib "libvorbisfile*.dll"`]
slouken@368
   371
                    ;;
slouken@368
   372
                *)
slouken@368
   373
                    ogg_lib=[`find_lib "libvorbisfile.so.[0-9]"`]
slouken@368
   374
                    if test x$ogg_lib = x; then
slouken@368
   375
                        ogg_lib=[`find_lib "libvorbisfile.so.[0-9]*"`]
slouken@368
   376
                    fi
slouken@368
   377
                    ;;
slouken@368
   378
            esac
slouken@368
   379
            SOURCES="$SOURCES $srcdir/*_ogg.c"
slouken@368
   380
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC"
slouken@368
   381
            if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
slouken@368
   382
                echo "-- dynamic libvorbisfile -> $ogg_lib"
slouken@368
   383
                EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
slouken@368
   384
            else
patmandin@464
   385
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis -logg $LIBM"
slouken@368
   386
            fi
slouken@419
   387
        else
slouken@419
   388
            AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)])
slouken@419
   389
            AC_MSG_WARN([Ogg Vorbis support disabled])
slouken@368
   390
        fi
slouken@353
   391
    fi
slouken@353
   392
fi
slouken@419
   393
slouken@396
   394
libflac_ver=8
slouken@382
   395
AC_ARG_ENABLE([music-flac],
slouken@382
   396
AC_HELP_STRING([--enable-music-flac], [enable FLAC music [[default=yes]]]),
slouken@382
   397
              [], [enable_music_flac=yes])
slouken@382
   398
AC_ARG_ENABLE([music-flac-shared],
slouken@382
   399
AC_HELP_STRING([--enable-music-flac-shared],
slouken@382
   400
              [dynamically load FLAC support [[default=yes]]]),
slouken@382
   401
              [], [enable_music_flac_shared=yes])
slouken@382
   402
if test x$enable_music_flac = xyes; then
slouken@452
   403
    AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes])
slouken@452
   404
    if test x$have_flac_export = xyes; then
slouken@452
   405
        LIBS_SAVED="$LIBS"
slouken@452
   406
        LIBS="-lFLAC"
slouken@452
   407
        AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver])
slouken@452
   408
        AC_TRY_RUN([
slouken@396
   409
#include "FLAC/export.h"
slouken@396
   410
#include "stdio.h"
slouken@396
   411
int main( int argc, char *argv[] ) {
slouken@396
   412
#if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
slouken@452
   413
    return 0;
slouken@396
   414
#else
slouken@452
   415
    return 1;
slouken@396
   416
#endif
slouken@396
   417
}
slouken@396
   418
], have_flac_ver=yes, have_flac_ver=no)
slouken@419
   419
        LIBS="$LIBS_SAVED"
slouken@419
   420
        AC_MSG_RESULT($have_flac_ver)
slouken@419
   421
    fi
slouken@419
   422
slouken@419
   423
    if test x$have_flac_ver = xyes; then
slouken@419
   424
        AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
slouken@419
   425
        AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
slouken@419
   426
        if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then    
slouken@419
   427
            case "$host" in
slouken@419
   428
                *-*-darwin*)
slouken@456
   429
                    flac_lib=[`find_lib libFLAC.dylib`]
slouken@419
   430
                    ;;
slouken@419
   431
                *-*-cygwin* | *-*-mingw32*)
slouken@419
   432
                    flac_lib=[`find_lib "libFLAC*.dll"`]
slouken@419
   433
                    ;;
slouken@419
   434
                *)
slouken@419
   435
                    flac_lib=[`find_lib "libFLAC.so.[0-9]"`]
slouken@419
   436
                    if test x$flac_lib = x; then
slouken@419
   437
                        flac_lib=[`find_lib "libFLAC.so.[0-9]*"`]
slouken@419
   438
                    fi
slouken@419
   439
                    ;;
slouken@419
   440
            esac
slouken@419
   441
            SOURCES="$SOURCES $srcdir/*_flac.c"
slouken@419
   442
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_MUSIC"
slouken@419
   443
            if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
slouken@419
   444
                echo "-- dynamic libFLAC -> $flac_lib"
slouken@419
   445
                EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
slouken@419
   446
            else
slouken@419
   447
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
slouken@419
   448
            fi
slouken@419
   449
        fi
slouken@419
   450
    else
slouken@419
   451
        AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)])
slouken@419
   452
        AC_MSG_WARN([FLAC support disabled])
slouken@419
   453
    fi
slouken@382
   454
fi
slouken@419
   455
slouken@0
   456
AC_ARG_ENABLE(music-mp3,
slouken@419
   457
AC_HELP_STRING([--enable-music-mp3], [enable MP3 music via smpeg [[default=yes]]]),
slouken@419
   458
              [], enable_music_mp3=yes)
slouken@419
   459
AC_ARG_ENABLE([music-mp3-shared],
slouken@419
   460
AC_HELP_STRING([--enable-music-mp3-shared], [dynamically load MP3 support [[default=yes]]]),
slouken@419
   461
              [], [enable_music_mp3_shared=yes])
slouken@0
   462
if test x$enable_music_mp3 = xyes; then
slouken@83
   463
    SMPEG_VERSION=0.4.3
slouken@83
   464
    AM_PATH_SMPEG($SMPEG_VERSION, have_smpeg=yes, have_smpeg=no)
slouken@0
   465
    if test x$have_smpeg = xyes; then
slouken@313
   466
        case "$host" in
slouken@313
   467
            *-*-darwin*)
slouken@456
   468
                smpeg_lib=[`find_lib libsmpeg.dylib`]
slouken@313
   469
                ;;
slouken@313
   470
            *-*-cygwin* | *-*-mingw32*)
slouken@372
   471
                smpeg_lib=[`find_lib "smpeg*.dll"`]
slouken@313
   472
                ;;
slouken@313
   473
            *)
slouken@374
   474
                smpeg_lib=[`find_lib "libsmpeg*.so.[0-9]"`]
slouken@368
   475
                if test x$smpeg_lib = x; then
slouken@374
   476
                    smpeg_lib=[`find_lib "libsmpeg*.so.[0-9]*"`]
slouken@368
   477
                fi
slouken@313
   478
                ;;
slouken@313
   479
        esac
slouken@314
   480
        SOURCES="$SOURCES $srcdir/*_mp3.c"
slouken@294
   481
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC $SMPEG_CFLAGS"
slouken@313
   482
        if test x$enable_music_mp3_shared = xyes && test x$smpeg_lib != x; then
slouken@313
   483
            echo "-- dynamic libsmpeg -> $smpeg_lib"
slouken@313
   484
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_DYNAMIC=\\\"$smpeg_lib\\\""
slouken@313
   485
        else
slouken@313
   486
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS"
slouken@313
   487
        fi
slouken@419
   488
    else
slouken@419
   489
        AC_MSG_WARN([*** Unable to find SMPEG library (http://icculus.org/smpeg/)])
slouken@0
   490
    fi
slouken@0
   491
fi
slouken@419
   492
slouken@357
   493
AC_ARG_ENABLE(music-mp3-mad-gpl,
slouken@357
   494
AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
slouken@357
   495
                  [], [enable_music_mp3_mad_gpl=no])
slouken@357
   496
if test x$enable_music_mp3_mad_gpl = xyes; then
slouken@357
   497
    AC_MSG_CHECKING(for libmad headers)
slouken@357
   498
    have_libmad=no
slouken@357
   499
    AC_TRY_COMPILE([
slouken@357
   500
     #include "mad.h"
slouken@357
   501
    ],[
slouken@357
   502
    ],[
slouken@357
   503
    have_libmad=yes
slouken@357
   504
    ])
slouken@357
   505
    AC_MSG_RESULT($have_libmad)
slouken@357
   506
    if test x$have_libmad = xyes; then
slouken@357
   507
        SOURCES="$SOURCES $srcdir/music_mad.c"
slouken@357
   508
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC"
slouken@357
   509
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
slouken@419
   510
    else
slouken@419
   511
        AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
slouken@357
   512
    fi
slouken@357
   513
fi
slouken@0
   514
slouken@419
   515
if test x$have_smpeg != xyes -a x$have_libmad != xyes; then
slouken@419
   516
    AC_MSG_WARN([MP3 support disabled])
slouken@419
   517
fi
slouken@419
   518
slouken@422
   519
slouken@422
   520
OBJECTS=`echo $SOURCES`
slouken@422
   521
DEPENDS=`echo $SOURCES`
slouken@422
   522
OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
slouken@422
   523
DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
slouken@422
   524
$(objects)/\2.lo: \1/\2.c\\
slouken@432
   525
	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
slouken@422
   526
slouken@422
   527
VERSION_OBJECTS=`echo $VERSION_SOURCES`
slouken@422
   528
VERSION_DEPENDS=`echo $VERSION_SOURCES`
slouken@422
   529
VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
slouken@422
   530
VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
slouken@422
   531
$(objects)/\2.o: \1/\2.rc\\
slouken@422
   532
	\$(WINDRES) \$< \$@,g'`
slouken@422
   533
slouken@422
   534
PLAYWAVE_SOURCES="$srcdir/playwave.c"
slouken@422
   535
PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES`
slouken@422
   536
PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES`
slouken@422
   537
PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
slouken@422
   538
PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
slouken@422
   539
$(objects)/\2.lo: \1/\2.c\\
slouken@432
   540
	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
slouken@422
   541
slouken@422
   542
PLAYMUS_SOURCES="$srcdir/playmus.c"
slouken@422
   543
PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES`
slouken@422
   544
PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES`
slouken@422
   545
PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
slouken@422
   546
PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
slouken@422
   547
$(objects)/\2.lo: \1/\2.c\\
slouken@432
   548
	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
slouken@1
   549
slouken@294
   550
dnl Expand the sources and objects needed to build the library
slouken@294
   551
AC_SUBST(ac_aux_dir)
slouken@294
   552
AC_SUBST(OBJECTS)
slouken@422
   553
AC_SUBST(DEPENDS)
slouken@422
   554
AC_SUBST(VERSION_OBJECTS)
slouken@422
   555
AC_SUBST(VERSION_DEPENDS)
slouken@422
   556
AC_SUBST(PLAYWAVE_OBJECTS)
slouken@422
   557
AC_SUBST(PLAYWAVE_DEPENDS)
slouken@422
   558
AC_SUBST(PLAYMUS_OBJECTS)
slouken@422
   559
AC_SUBST(PLAYMUS_DEPENDS)
slouken@294
   560
AC_SUBST(BUILD_CFLAGS)
slouken@294
   561
AC_SUBST(EXTRA_CFLAGS)
slouken@294
   562
AC_SUBST(BUILD_LDFLAGS)
slouken@294
   563
AC_SUBST(EXTRA_LDFLAGS)
slouken@294
   564
AC_SUBST(EXE)
slouken@368
   565
AC_SUBST(WINDRES)
slouken@392
   566
AC_SUBST(SDL_VERSION)
slouken@294
   567
AC_SUBST(SDL_CFLAGS)
slouken@294
   568
AC_SUBST(SDL_LIBS)
slouken@206
   569
slouken@0
   570
AC_OUTPUT([
slouken@392
   571
    Makefile SDL_mixer.spec SDL_mixer.qpg SDL_mixer.pc
slouken@0
   572
])