configure.in
author Sam Lantinga <slouken@libsdl.org>
Wed, 17 Jun 2015 00:11:41 -0700
changeset 705 fe757163b8f7
parent 697 b28b41b93ba7
child 710 1aca2b6d570f
permissions -rw-r--r--
Fixed bug 3018 - Loading MIDI music using FluidSynth leaks memory.

Philipp Wiesemann

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