configure.in
author Ozkan Sezer <sezeroz@gmail.com>
Sat, 13 Oct 2018 23:02:04 +0300
branchSDL-1.2
changeset 908 6b860486ce24
parent 907 f4c576887ec3
child 909 d37b598f128d
permissions -rw-r--r--
Mix_InitMP3: unload dll if mpg123_init() fails.
     1 dnl Process this file with autoconf to produce a configure script.
     2 AC_INIT(README)
     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=1
    16 MINOR_VERSION=2
    17 MICRO_VERSION=13
    18 INTERFACE_AGE=1
    19 BINARY_AGE=13
    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/i386-mingw32
   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 dnl Function to find a library in the compiler search path
   178 find_lib()
   179 {
   180     gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   181     gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   182     env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
   183     if test "$cross_compiling" = yes; then
   184         host_lib_path=""
   185     else
   186         host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
   187     fi
   188     for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
   189         lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`]
   190         if test x$lib != x; then
   191             echo $lib
   192             return
   193         fi
   194     done
   195 }
   196 
   197 dnl Check for SDL
   198 SDL_VERSION=1.2.10
   199 AM_PATH_SDL($SDL_VERSION,
   200             :,
   201             AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
   202 )
   203 EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
   204 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
   205 
   206 dnl Check for math library
   207 AC_CHECK_LIB(m, pow, [LIBM="-lm"])
   208 
   209 dnl Check command-line options
   210 
   211 CheckVisibilityHidden
   212 
   213 AC_ARG_ENABLE([music-cmd],
   214 AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
   215               [], [enable_music_cmd=detect])
   216 if test "x$enable_music_cmd" != xno; then
   217     AC_CHECK_FUNCS([fork vfork])
   218     if test "x$ac_cv_func_fork" = "xyes"; then
   219         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK"
   220     elif test "x$ac_cv_func_vfork" = "xyes"; then
   221         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK"
   222     elif test "x$enable_music_cmd" = "xyes"; then
   223         AC_MSG_ERROR([external music player not available on your platform])
   224     else
   225         enable_music_cmd=no
   226     fi
   227     if test "x$enable_music_cmd" != xno; then
   228         SOURCES="$SOURCES $srcdir/music_cmd.c"
   229         EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC"
   230     fi
   231 fi
   232 
   233 AC_ARG_ENABLE([music-wave],
   234 AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
   235               [], [enable_music_wave=yes])
   236 if test x$enable_music_wave = xyes; then
   237     SOURCES="$SOURCES $srcdir/wavestream.c"
   238     EXTRA_CFLAGS="$EXTRA_CFLAGS -DWAV_MUSIC"
   239 fi
   240 
   241 AC_ARG_ENABLE([music-mod],
   242 AC_HELP_STRING([--enable-music-mod], [enable MOD music via mikmod [[default=yes]]]),
   243               [], [enable_music_mod=yes])
   244 AC_ARG_ENABLE([music-mod-shared],
   245 AC_HELP_STRING([--enable-music-mod-shared], [dynamically load MOD support [[default=yes]]]),
   246               [], [enable_music_mod_shared=yes])
   247 if test x$enable_music_mod = xyes; then
   248     have_libmikmod=no
   249     libmikmod_maj=3
   250     libmikmod_min=1
   251     libmikmod_rev=10
   252     libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
   253     AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
   254     if test "$LIBMIKMOD_CONFIG" != "no" ; then
   255         CFLAGS_SAVED="$CFLAGS"
   256         LIBS_SAVED="$LIBS"
   257         CFLAGS="$CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
   258         LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
   259         have_libmikmod=yes
   260         AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
   261         AC_TRY_RUN([
   262 #include "mikmod.h"
   263 #include "stdio.h"
   264 
   265 int main(int argc, char **argv)
   266 {
   267 long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
   268 /*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
   269 if(ver>=((maj<<16)|(min<<8)|(rev))) {
   270     printf("yes\n");
   271     return 0;
   272 }
   273 printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
   274 return 1;
   275 }
   276 ], [], have_libmikmod=no; CFLAGS="$CFLAGS_SAVED"; LIBS="$LIBS_SAVED",
   277         [echo $ac_n "cross compiling; assumed OK... $ac_c"])
   278     fi
   279 
   280     if test x$have_libmikmod = xyes; then
   281         case "$host" in
   282             *-*-darwin*)
   283                 mikmod_lib=[`find_lib libmikmod.dylib`]
   284                 ;;
   285             *-*-cygwin* | *-*-mingw32*)
   286                 mikmod_lib=[`find_lib "libmikmod*.dll"`]
   287                 ;;
   288             *)
   289                 mikmod_lib=[`find_lib "libmikmod[0-9]*.so.*"`]
   290                 if test x$mikmod_lib = x; then
   291                     mikmod_lib=[`find_lib "libmikmod.so.*"`]
   292                 fi
   293                 ;;
   294         esac
   295         SOURCES="$SOURCES $srcdir/*_mod.c"
   296         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
   297         if test x$enable_music_mod_shared = xyes && test x$mikmod_lib != x; then
   298             echo "-- dynamic libmikmod -> $mikmod_lib"
   299             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_DYNAMIC=\\\"$mikmod_lib\\\""
   300         else
   301             EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`"
   302         fi
   303     else
   304         AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.raphnet.net/)])
   305     fi
   306 fi
   307 
   308 AC_ARG_ENABLE([music-mod-modplug],
   309 AC_HELP_STRING([--enable-music-mod-modplug], [enable MOD music via modplug [[default=no]]]),
   310               [], [enable_music_mod_modplug=no])
   311 if test x$enable_music_mod_modplug = xyes; then
   312     PKG_CHECK_MODULES([MODPLUG], [libmodplug >= 0.8.7], [dnl
   313             have_libmodplug_hdr=yes
   314             have_libmodplug_lib=yes
   315         ], [dnl
   316             AC_CHECK_HEADER([libmodplug/modplug.h], [have_libmodplug_hdr=yes])
   317             AC_CHECK_LIB([modplug], [ModPlug_Load], [have_libmodplug_lib=yes])
   318         ])
   319 
   320     if test x$have_libmodplug_hdr = xyes -a x$have_libmodplug_lib = xyes; then
   321         have_libmodplug=yes
   322         SOURCES="$SOURCES $srcdir/music_modplug.c"
   323         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_MUSIC $MODPLUG_CFLAGS"
   324         EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
   325     else
   326         AC_MSG_WARN([*** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)])
   327     fi
   328 fi
   329 
   330 if test x$have_libmikmod != xyes -a x$have_libmodplug != xyes ; then
   331 	AC_MSG_WARN([MOD support disabled])
   332 fi
   333 
   334 AC_ARG_ENABLE([music-midi],
   335 AC_HELP_STRING([--enable-music-midi], [enable MIDI music via timidity [[default=yes]]]),
   336               [], [enable_music_midi=yes])
   337 if test x$enable_music_midi = xyes; then
   338     EXTRA_CFLAGS="$EXTRA_CFLAGS -DMID_MUSIC"
   339     AC_ARG_ENABLE([music-timidity-midi],
   340 AC_HELP_STRING([--enable-music-timidity-midi], [enable timidity MIDI output [[default=yes]]]),
   341                   [], [enable_music_timidity_midi=yes])
   342     if test x$enable_music_timidity_midi = xyes; then
   343         EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_TIMIDITY_MIDI -I\$(srcdir)/timidity"
   344         SOURCES="$SOURCES $srcdir/timidity/*.c"
   345     fi
   346     AC_ARG_ENABLE([music-native-midi],
   347 AC_HELP_STRING([--enable-music-native-midi], [enable native MIDI music output [[default=yes]]]),
   348                   [], [enable_music_native_midi=yes])
   349     if test x$enable_music_native_midi = xyes; then
   350         use_music_native_midi=no
   351         case "$host" in
   352             *mingw32ce*)
   353                 use_music_native_midi=no
   354                 ;;
   355             *-*-cygwin* | *-*-mingw32*)
   356                 use_music_native_midi=yes
   357                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
   358                 ;;
   359             *-*-darwin*)
   360                 use_music_native_midi=yes
   361                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices"
   362                 ;;
   363             *-*-haiku*)
   364                 use_music_native_midi=yes_cpp
   365                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi" 
   366                 ;;
   367         esac
   368         if test x$use_music_native_midi = xyes; then
   369             EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
   370             SOURCES="$SOURCES $srcdir/native_midi/*.c"
   371         elif test x$use_music_native_midi = xyes_cpp; then
   372             EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
   373             SOURCES="$SOURCES $srcdir/native_midi/*.c"
   374             SOURCES_CXX="$SOURCES_CXX $srcdir/native_midi/*.cpp"
   375         fi
   376     fi
   377     AC_ARG_ENABLE([music-fluidsynth-midi],
   378 AC_HELP_STRING([--enable-music-fluidsynth-midi], [enable FluidSynth MIDI output [[default=yes]]]),
   379                   [], [enable_music_fluidsynth_midi=yes])
   380     AC_ARG_ENABLE([music-fluidsynth-shared],
   381 AC_HELP_STRING([--enable-music-fluidsynth-shared], [dynamically load FluidSynth support [[default=yes]]]),
   382                   [], [enable_music_fluidsynth_shared=yes])
   383     if test x$enable_music_fluidsynth_midi = xyes; then
   384         AC_CHECK_HEADER([fluidsynth.h], [have_fluidsynth_hdr=yes])
   385         AC_CHECK_LIB([fluidsynth], [fluid_player_add_mem], [have_fluidsynth_lib=yes])
   386         if test x$have_fluidsynth_hdr = xyes -a x$have_fluidsynth_lib = xyes; then
   387             case "$host" in
   388                 *-*-darwin*)
   389                     fluidsynth_lib=[`find_lib libfluidsynth.dylib`]
   390                     ;;
   391                 *-*-cygwin* | *-*-mingw32*)
   392                     fluidsynth_lib=[`find_lib "fluidsynth*.dll"`]
   393                     ;;
   394                 *)
   395                     fluidsynth_lib=[`find_lib "libfluidsynth[0-9]*.so.*"`]
   396                     if test x$fluidsynth_lib = x; then
   397                         fluidsynth_lib=[`find_lib "libfluidsynth.so.*"`]
   398                     fi
   399                     ;;
   400             esac
   401             SOURCES="$SOURCES $srcdir/dynamic_fluidsynth.c $srcdir/fluidsynth.c"
   402             EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_FLUIDSYNTH_MIDI"
   403             if test x$enable_music_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then
   404                 echo "-- dynamic libfluidsyth -> $fluidsynth_lib"
   405                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\""
   406             else
   407                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth"
   408             fi
   409         else
   410             AC_MSG_WARN([*** Unable to find FluidSynth library (http://www.fluidsynth.org/)])
   411             AC_MSG_WARN([FluidSynth support disabled])
   412         fi
   413     fi
   414 fi
   415 
   416 AC_ARG_ENABLE([music-ogg],
   417 AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
   418               [], [enable_music_ogg=yes])
   419 AC_ARG_ENABLE(music-ogg-tremor,
   420 AC_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [[default=no]]]),
   421               [], enable_music_ogg_tremor=no)
   422 AC_ARG_ENABLE([music-ogg-shared],
   423 AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis support [[default=yes]]]),
   424               [], [enable_music_ogg_shared=yes])
   425 if test x$enable_music_ogg = xyes; then
   426     if test x$enable_music_ogg_tremor = xyes; then
   427         AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
   428         AC_CHECK_LIB([vorbisidec -logg], [ov_open_callbacks], [have_tremor_lib=yes])
   429         if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
   430             case "$host" in
   431                 *-*-darwin*)
   432                     ogg_lib=[`find_lib libvorbisidec.dylib`]
   433                     ;;
   434                 *-*-cygwin* | *-*-mingw32*)
   435                     ogg_lib=[`find_lib "vorbisidec*.dll"`]
   436                     ;;
   437                 *)
   438                     ogg_lib=[`find_lib "libvorbisidec[0-9]*.so.*"`]
   439                     if test x$ogg_lib = x; then
   440                         ogg_lib=[`find_lib "libvorbisidec.so.*"`]
   441                     fi
   442                     ;;
   443             esac
   444             SOURCES="$SOURCES $srcdir/*_ogg.c"
   445             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC -DOGG_USE_TREMOR"
   446             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   447                 echo "-- dynamic libvorbisidec -> $ogg_lib"
   448                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   449             else
   450                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis"
   451             fi
   452         else
   453             AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)])
   454             AC_MSG_WARN([Ogg Vorbis support disabled])
   455         fi
   456     else
   457         AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
   458         AC_CHECK_LIB([vorbisfile -lvorbis -logg -lm], [ov_open_callbacks], [have_ogg_lib=yes])
   459         if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
   460             case "$host" in
   461                 *-*-darwin*)
   462                     ogg_lib=[`find_lib libvorbisfile.dylib`]
   463                     ;;
   464                 *-*-cygwin* | *-*-mingw32*)
   465                     ogg_lib=[`find_lib "libvorbisfile*.dll"`]
   466                     ;;
   467                 *)
   468                     ogg_lib=[`find_lib "libvorbisfile[0-9]*.so.*"`]
   469                     if test x$ogg_lib = x; then
   470                         ogg_lib=[`find_lib "libvorbisfile.so.*"`]
   471                     fi
   472                     ;;
   473             esac
   474             SOURCES="$SOURCES $srcdir/*_ogg.c"
   475             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC"
   476             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   477                 echo "-- dynamic libvorbisfile -> $ogg_lib"
   478                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   479             else
   480                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis -logg -lm"
   481             fi
   482         else
   483             AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)])
   484             AC_MSG_WARN([Ogg Vorbis support disabled])
   485         fi
   486     fi
   487 fi
   488 
   489 libflac_ver=8
   490 AC_ARG_ENABLE([music-flac],
   491 AC_HELP_STRING([--enable-music-flac], [enable FLAC music [[default=yes]]]),
   492               [], [enable_music_flac=yes])
   493 AC_ARG_ENABLE([music-flac-shared],
   494 AC_HELP_STRING([--enable-music-flac-shared],
   495               [dynamically load FLAC support [[default=yes]]]),
   496               [], [enable_music_flac_shared=yes])
   497 if test x$enable_music_flac = xyes; then
   498     AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes])
   499     if test x$have_flac_export = xyes; then
   500         LIBS_SAVED="$LIBS"
   501         LIBS="-lFLAC"
   502         AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver])
   503         AC_TRY_COMPILE([
   504 #include "FLAC/export.h"
   505 #include "stdio.h"
   506 ],[
   507 #if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
   508 #else
   509 #error "old-flac"
   510 #endif
   511 ], have_flac_ver=yes, have_flac_ver=no)
   512         LIBS="$LIBS_SAVED"
   513         AC_MSG_RESULT($have_flac_ver)
   514     fi
   515 
   516     if test x$have_flac_ver = xyes; then
   517         AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
   518         AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
   519         if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then    
   520             case "$host" in
   521                 *-*-darwin*)
   522                     flac_lib=[`find_lib libFLAC.dylib`]
   523                     ;;
   524                 *-*-cygwin* | *-*-mingw32*)
   525                     flac_lib=[`find_lib "libFLAC-*.dll"`]
   526                     ;;
   527                 *)
   528                     flac_lib=[`find_lib "libFLAC[0-9]*.so.*"`]
   529                     if test x$flac_lib = x; then
   530                         flac_lib=[`find_lib "libFLAC.so.*"`]
   531                     fi
   532                     ;;
   533             esac
   534             SOURCES="$SOURCES $srcdir/*_flac.c"
   535             EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_MUSIC"
   536             if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
   537                 echo "-- dynamic libFLAC -> $flac_lib"
   538                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
   539             else
   540                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
   541             fi
   542         fi
   543     else
   544         AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)])
   545         AC_MSG_WARN([FLAC support disabled])
   546     fi
   547 fi
   548 
   549 AC_CHECK_HEADERS([signal.h], [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SIGNAL_H"])
   550 AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"])
   551 
   552 AC_ARG_ENABLE(music-mp3,
   553 AC_HELP_STRING([--enable-music-mp3], [enable MP3 music via libmpg123 [[default=yes]]]),
   554               [], enable_music_mp3=yes)
   555 AC_ARG_ENABLE([music-mp3-shared],
   556 AC_HELP_STRING([--enable-music-mp3-shared], [dynamically load MP3 support [[default=yes]]]),
   557               [], [enable_music_mp3_shared=yes])
   558 if test x$enable_music_mp3 = xyes; then
   559     AC_CHECK_HEADER([mpg123.h], [have_mpg123_hdr=yes])
   560     AC_CHECK_LIB([mpg123], [mpg123_replace_reader_handle], [have_mpg123_lib=yes])
   561     if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then
   562         have_mpg123=yes
   563         case "$host" in
   564             *-*-darwin*)
   565                 mpg123_lib=[`find_lib libmpg123.dylib`]
   566                 ;;
   567             *-*-cygwin* | *-*-mingw32*)
   568                 mpg123_lib=[`find_lib "libmpg123*.dll"`]
   569                 ;;
   570             *)
   571                 mpg123_lib=[`find_lib "libmpg123.so.*"`]
   572                 ;;
   573         esac
   574         SOURCES="$SOURCES $srcdir/*_mp3.c $srcdir/*_mpg.c"
   575         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC"
   576         if test x$enable_music_mp3_shared = xyes && test x$mpg123_lib != x; then
   577             echo "-- dynamic libmpg123 -> $mpg123_lib"
   578             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\""
   579         else
   580             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
   581         fi
   582     else
   583         AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)])
   584     fi
   585 fi
   586 
   587 AC_ARG_ENABLE(music-mp3-mad-gpl,
   588 AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
   589                   [], [enable_music_mp3_mad_gpl=no])
   590 if test x$enable_music_mp3_mad_gpl = xyes; then
   591     AC_MSG_CHECKING(for libmad headers)
   592     have_libmad=no
   593     AC_TRY_COMPILE([
   594      #include "mad.h"
   595     ],[
   596     ],[
   597     have_libmad=yes
   598     ])
   599     AC_MSG_RESULT($have_libmad)
   600     if test x$have_libmad = xyes; then
   601         SOURCES="$SOURCES $srcdir/music_mad.c"
   602         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC"
   603         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
   604     else
   605         AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
   606     fi
   607 fi
   608 
   609 if test x$have_mpg123 != xyes -a x$have_libmad != xyes; then
   610     AC_MSG_WARN([MP3 support disabled])
   611 fi
   612 
   613 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM"
   614 
   615 OBJECTS=`echo $SOURCES`
   616 DEPENDS=`echo $SOURCES`
   617 OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   618 DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   619 $(objects)/\2.lo: \1/\2.c\\
   620 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   621 
   622 OBJECTS_CXX=`echo $SOURCES_CXX`
   623 DEPENDS_CXX=`echo $SOURCES_CXX`
   624 OBJECTS_CXX=`echo "$OBJECTS_CXX" | sed 's,[[^ ]]*/\([[^ ]]*\)\.cpp,$(objects)/\1.lo,g'`
   625 DEPENDS_CXX=`echo "$DEPENDS_CXX" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.cpp,\\
   626 $(objects)/\2.lo: \1/\2.cpp\\
   627 	\$(LIBTOOL) --mode=compile \$(CXX) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   628 OBJECTS="$OBJECTS $OBJECTS_CXX"
   629 DEPENDS="$DEPENDS $DEPENDS_CXX"
   630 DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'`
   631 
   632 VERSION_OBJECTS=`echo $VERSION_SOURCES`
   633 VERSION_DEPENDS=`echo $VERSION_SOURCES`
   634 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
   635 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
   636 $(objects)/\2.o: \1/\2.rc\\
   637 	\$(WINDRES) \$< \$@,g'`
   638 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'`
   639 
   640 PLAYWAVE_SOURCES="$srcdir/playwave.c"
   641 PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES`
   642 PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES`
   643 PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   644 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   645 $(objects)/\2.lo: \1/\2.c\\
   646 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   647 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\\$,\\\\$,g'`
   648 
   649 PLAYMUS_SOURCES="$srcdir/playmus.c"
   650 PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES`
   651 PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES`
   652 PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   653 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   654 $(objects)/\2.lo: \1/\2.c\\
   655 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   656 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'`
   657 
   658 dnl Expand the sources and objects needed to build the library
   659 AC_SUBST(ac_aux_dir)
   660 AC_SUBST(OBJECTS)
   661 AC_SUBST(VERSION_OBJECTS)
   662 AC_SUBST(PLAYWAVE_OBJECTS)
   663 AC_SUBST(PLAYMUS_OBJECTS)
   664 AC_SUBST(BUILD_CFLAGS)
   665 AC_SUBST(EXTRA_CFLAGS)
   666 AC_SUBST(BUILD_LDFLAGS)
   667 AC_SUBST(EXTRA_LDFLAGS)
   668 AC_SUBST(EXE)
   669 AC_SUBST(WINDRES)
   670 AC_SUBST(SDL_VERSION)
   671 AC_SUBST(SDL_CFLAGS)
   672 AC_SUBST(SDL_LIBS)
   673 
   674 AC_OUTPUT([
   675 ])
   676 AC_CONFIG_FILES([
   677     Makefile SDL_mixer.spec SDL_mixer.qpg SDL_mixer.pc
   678 ])
   679 AC_CONFIG_COMMANDS([default],
   680                    [cat >>Makefile <<__EOF__
   681 
   682 # Build rules for objects
   683 -include \$(OBJECTS:.lo=.d)
   684 $DEPENDS
   685 $VERSION_DEPENDS
   686 
   687 -include \$(PLAYWAVE_OBJECTS:.lo=.d)
   688 $PLAYWAVE_DEPENDS
   689 
   690 -include \$(PLAYMUS_OBJECTS:.lo=.d)
   691 $PLAYMUS_DEPENDS
   692 __EOF__ 
   693 ], [
   694 DEPENDS="$DEPENDS"
   695 VERSION_DEPENDS="$VERSION_DEPENDS"
   696 PLAYWAVE_DEPENDS="$PLAYWAVE_DEPENDS"
   697 PLAYMUS_DEPENDS="$PLAYMUS_DEPENDS"
   698 ])
   699 AC_OUTPUT