configure.in
author Ozkan Sezer <sezeroz@gmail.com>
Wed, 03 Oct 2018 21:55:00 +0300
changeset 863 b81eb791d10d
parent 855 a7dee77dd60f
child 901 253f50984a9a
permissions -rw-r--r--
readmidi.c (groom_list): avoid integer overflow when recomputing time.

from libtimidity -- see:
https://sourceforge.net/p/libtimidity/libtimidity/ci/11be98a89eac229111420e6a3d521edbfddb0dbc/
     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=3
    18 INTERFACE_AGE=1
    19 BINARY_AGE=3
    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         EXE=""
   134         ;;
   135 esac
   136 
   137 # Standard C sources
   138 SOURCES=`ls $srcdir/*.c | fgrep -v playwave.c | fgrep -v playmus.c`
   139 
   140 dnl set this to use on systems that use lib64 instead of lib
   141 base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
   142 
   143 dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
   144 dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
   145 CheckVisibilityHidden()
   146 {
   147     AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
   148     have_gcc_fvisibility=no
   149 
   150     visibility_CFLAGS="-fvisibility=hidden"
   151     save_CFLAGS="$CFLAGS"
   152     CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
   153     AC_TRY_COMPILE([
   154     #if !defined(__GNUC__) || __GNUC__ < 4
   155     #error SDL only uses visibility attributes in GCC 4 or newer
   156     #endif
   157     ],[
   158     ],[
   159     have_gcc_fvisibility=yes
   160     ])
   161     AC_MSG_RESULT($have_gcc_fvisibility)
   162     CFLAGS="$save_CFLAGS"
   163 
   164     if test x$have_gcc_fvisibility = xyes; then
   165         EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
   166     fi
   167 }
   168 
   169 
   170 dnl Function to find a library in the compiler search path
   171 find_lib()
   172 {
   173     gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   174     gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   175     env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
   176     if test "$cross_compiling" = yes; then
   177         host_lib_path=""
   178     else
   179         host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
   180     fi
   181     for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
   182         lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`]
   183         if test x$lib != x; then
   184             echo $lib
   185             return
   186         fi
   187     done
   188 }
   189 
   190 dnl Check for SDL
   191 SDL_VERSION=2.0.7
   192 AM_PATH_SDL2($SDL_VERSION,
   193             :,
   194             AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
   195 )
   196 EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
   197 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
   198 
   199 dnl Check for math library
   200 AC_CHECK_LIB(m, pow, [LIBM="-lm"])
   201 
   202 AC_CHECK_HEADERS([signal.h], [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SIGNAL_H"])
   203 AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"])
   204 
   205 dnl Check command-line options
   206 
   207 CheckVisibilityHidden
   208 
   209 AC_ARG_ENABLE([music-cmd],
   210 AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
   211               [], [enable_music_cmd=detect])
   212 if test "x$enable_music_cmd" != xno; then
   213     AC_CHECK_FUNCS([fork vfork])
   214     if test "x$ac_cv_func_fork" = "xyes"; then
   215         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK"
   216     elif test "x$ac_cv_func_vfork" = "xyes"; then
   217         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK"
   218     elif test "x$enable_music_cmd" = "xyes"; then
   219         AC_MSG_ERROR([external music player not available on your platform])
   220     else
   221         enable_music_cmd=no
   222     fi
   223     if test "x$enable_music_cmd" != xno; then
   224         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD"
   225     fi
   226 fi
   227 
   228 AC_ARG_ENABLE([music-wave],
   229 AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
   230               [], [enable_music_wave=yes])
   231 if test x$enable_music_wave = xyes; then
   232     EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV"
   233 fi
   234 
   235 AC_ARG_ENABLE([music-mod],
   236 AC_HELP_STRING([--enable-music-mod], [enable MOD music [[default=yes]]]),
   237               [], [enable_music_mod=yes])
   238 
   239 AC_ARG_ENABLE([music-mod-modplug],
   240 AC_HELP_STRING([--enable-music-mod-modplug], [enable MOD music via modplug [[default=yes]]]),
   241               [], [enable_music_mod_modplug=yes])
   242 AC_ARG_ENABLE([music-mod-modplug-shared],
   243 AC_HELP_STRING([--enable-music-mod-modplug-shared], [dynamically load modplug library [[default=yes]]]),
   244               [], [enable_music_mod_modplug_shared=yes])
   245 if test x$enable_music_mod = xyes -a x$enable_music_mod_modplug = xyes; then
   246     PKG_CHECK_MODULES([MODPLUG], [libmodplug >= 0.8.8], [dnl
   247             have_libmodplug_hdr=yes
   248             have_libmodplug_lib=yes
   249         ], [dnl
   250             AC_CHECK_HEADER([libmodplug/modplug.h], [have_libmodplug_hdr=yes])
   251             AC_CHECK_LIB([modplug], [ModPlug_Load], [have_libmodplug_lib=yes])
   252         ])
   253 
   254     if test x$have_libmodplug_hdr = xyes -a x$have_libmodplug_lib = xyes; then
   255         have_libmodplug=yes
   256         case "$host" in
   257             *-*-darwin*)
   258                 modplug_lib=[`find_lib libmodplug.dylib`]
   259                 ;;
   260             *-*-cygwin* | *-*-mingw32*)
   261                 modplug_lib=[`find_lib "libmodplug*.dll"`]
   262                 ;;
   263             *)
   264                 modplug_lib=[`find_lib "libmodplug[0-9]*.so.*"`]
   265                 if test x$modplug_lib = x; then
   266                     modplug_lib=[`find_lib "libmodplug.so.*"`]
   267                 fi
   268                 ;;
   269         esac
   270         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MODPLUG $MODPLUG_CFLAGS"
   271         if test x$enable_music_mod_modplug_shared = xyes && test x$modplug_lib != x; then
   272             echo "-- dynamic libmodplug -> $modplug_lib"
   273             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\""
   274         else
   275             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
   276         fi
   277     else
   278         AC_MSG_WARN([*** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)])
   279     fi
   280 fi
   281 
   282 AC_ARG_ENABLE([music-mod-mikmod],
   283 AC_HELP_STRING([--enable-music-mod-mikmod], [enable MOD music via mikmod [[default=no]]]),
   284               [], [enable_music_mod_mikmod=no])
   285 AC_ARG_ENABLE([music-mod-mikmod-shared],
   286 AC_HELP_STRING([--enable-music-mod-mikmod-shared], [dynamically load mikmod library [[default=yes]]]),
   287               [], [enable_music_mod_mikmod_shared=yes])
   288 if test x$enable_music_mod = xyes -a x$enable_music_mod_mikmod = xyes; then
   289     have_libmikmod=no
   290     libmikmod_maj=3
   291     libmikmod_min=1
   292     libmikmod_rev=10
   293     libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
   294     AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
   295     if test "$LIBMIKMOD_CONFIG" != "no" ; then
   296         
   297         CFLAGS_SAVED="$CFLAGS"
   298         LIBS_SAVED="$LIBS"
   299         CFLAGS="$CFLAGS `$LIBMIKMOD_CONFIG --cflags`"
   300         LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
   301         have_libmikmod=yes
   302         AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
   303         AC_TRY_RUN([
   304 #include "mikmod.h"
   305 #include "stdio.h"
   306 
   307 int main(int argc, char **argv)
   308 {
   309 long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
   310 /*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
   311 if(ver>=((maj<<16)|(min<<8)|(rev))) {
   312     printf("yes\n");
   313     return 0;
   314 }
   315 printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
   316 return 1;
   317 }
   318 ], [], have_libmikmod=no; CFLAGS="$CFLAGS_SAVED"; LIBS="$LIBS_SAVED",
   319         [echo $ac_n "cross compiling; assumed OK... $ac_c"])
   320     fi
   321 
   322     if test x$have_libmikmod = xyes; then
   323         case "$host" in
   324             *-*-darwin*)
   325                 mikmod_lib=[`find_lib libmikmod.dylib`]
   326                 ;;
   327             *-*-cygwin* | *-*-mingw32*)
   328                 mikmod_lib=[`find_lib "libmikmod*.dll"`]
   329                 ;;
   330             *)
   331                 mikmod_lib=[`find_lib "libmikmod[0-9]*.so.*"`]
   332                 if test x$mikmod_lib = x; then
   333                     mikmod_lib=[`find_lib "libmikmod.so.*"`]
   334                 fi
   335                 ;;
   336         esac
   337         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MIKMOD `$LIBMIKMOD_CONFIG --cflags`"
   338         if test x$enable_music_mod_mikmod_shared = xyes && test x$mikmod_lib != x; then
   339             echo "-- dynamic libmikmod -> $mikmod_lib"
   340             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMIKMOD_DYNAMIC=\\\"$mikmod_lib\\\""
   341         else
   342             EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`"
   343         fi
   344     else
   345         AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.raphnet.net/)])
   346     fi
   347 fi
   348 
   349 if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes ; then
   350     AC_MSG_WARN([MOD support disabled])
   351 fi
   352 
   353 AC_ARG_ENABLE([music-midi],
   354 AC_HELP_STRING([--enable-music-midi], [enable MIDI music [[default=yes]]]),
   355               [], [enable_music_midi=yes])
   356 if test x$enable_music_midi = xyes; then
   357     EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID"
   358     AC_ARG_ENABLE([music-midi-timidity],
   359 AC_HELP_STRING([--enable-music-midi-timidity], [enable timidity MIDI output [[default=yes]]]),
   360                   [], [enable_music_midi_timidity=yes])
   361     if test x$enable_music_midi_timidity = xyes; then
   362         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/timidity"
   363         SOURCES="$SOURCES $srcdir/timidity/*.c"
   364     fi
   365     AC_ARG_ENABLE([music-midi-native],
   366 AC_HELP_STRING([--enable-music-midi-native], [enable native MIDI music output [[default=yes]]]),
   367                   [], [enable_music_midi_native=yes])
   368     if test x$enable_music_midi_native = xyes; then
   369         use_music_midi_native=no
   370         case "$host" in
   371             *mingw32ce*)
   372                 use_music_midi_native=no
   373                 ;;
   374             *-*-cygwin* | *-*-mingw32*)
   375                 use_music_midi_native=yes
   376                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
   377                 ;;
   378             *-*-darwin*)
   379                 use_music_midi_native=yes
   380                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices"
   381                 ;;
   382             *-*-haiku*)
   383                 use_music_midi_native=yes_cpp
   384                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi" 
   385                 ;;
   386         esac
   387         if test x$use_music_midi_native = xyes; then
   388             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
   389             SOURCES="$SOURCES $srcdir/native_midi/*.c"
   390         elif test x$use_music_midi_native = xyes_cpp; then
   391             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
   392             SOURCES="$SOURCES $srcdir/native_midi/*.c"
   393             SOURCES_CXX="$SOURCES_CXX $srcdir/native_midi/*.cpp"
   394         fi
   395     fi
   396     AC_ARG_ENABLE([music-midi-fluidsynth],
   397 AC_HELP_STRING([--enable-music-midi-fluidsynth], [enable FluidSynth MIDI output [[default=yes]]]),
   398                   [], [enable_music_midi_fluidsynth=yes])
   399     AC_ARG_ENABLE([music-midi-fluidsynth-shared],
   400 AC_HELP_STRING([--enable-music-midi-fluidsynth-shared], [dynamically load FluidSynth library [[default=yes]]]),
   401                   [], [enable_music_midi_fluidsynth_shared=yes])
   402     if test x$enable_music_midi_fluidsynth = xyes; then
   403         AC_CHECK_HEADER([fluidsynth.h], [have_fluidsynth_hdr=yes])
   404         AC_CHECK_LIB([fluidsynth], [fluid_player_add_mem], [have_fluidsynth_lib=yes])
   405         if test x$have_fluidsynth_hdr = xyes -a x$have_fluidsynth_lib = xyes; then
   406             have_fluidsynth=yes
   407             case "$host" in
   408                 *-*-darwin*)
   409                     fluidsynth_lib=[`find_lib libfluidsynth.dylib`]
   410                     ;;
   411                 *-*-cygwin* | *-*-mingw32*)
   412                     fluidsynth_lib=[`find_lib "fluidsynth*.dll"`]
   413                     ;;
   414                 *)
   415                     fluidsynth_lib=[`find_lib "libfluidsynth[0-9]*.so.*"`]
   416                     if test x$fluidsynth_lib = x; then
   417                         fluidsynth_lib=[`find_lib "libfluidsynth.so.*"`]
   418                     fi
   419                     ;;
   420             esac
   421             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH"
   422             if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then
   423                 echo "-- dynamic libfluidsynth -> $fluidsynth_lib"
   424                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\""
   425             else
   426                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth"
   427             fi
   428         else
   429             AC_MSG_WARN([*** Unable to find FluidSynth library (http://www.fluidsynth.org/)])
   430             AC_MSG_WARN([FluidSynth support disabled])
   431         fi
   432     fi
   433 fi
   434 
   435 if test x$enable_music_midi_timidity != xyes -a \
   436         x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \
   437         x$have_fluidsynth != xyes; then
   438     AC_MSG_WARN([MIDI support disabled])
   439 fi
   440 
   441 AC_ARG_ENABLE([music-ogg],
   442 AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
   443               [], [enable_music_ogg=yes])
   444 AC_ARG_ENABLE(music-ogg-tremor,
   445 AC_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [[default=no]]]),
   446               [], enable_music_ogg_tremor=no)
   447 AC_ARG_ENABLE([music-ogg-shared],
   448 AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis library [[default=yes]]]),
   449               [], [enable_music_ogg_shared=yes])
   450 if test x$enable_music_ogg = xyes; then
   451     if test x$enable_music_ogg_tremor = xyes; then
   452         AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
   453         AC_CHECK_LIB([vorbisidec -logg], [ov_open_callbacks], [have_tremor_lib=yes])
   454         if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
   455             case "$host" in
   456                 *-*-darwin*)
   457                     ogg_lib=[`find_lib libvorbisidec.dylib`]
   458                     ;;
   459                 *-*-cygwin* | *-*-mingw32*)
   460                     ogg_lib=[`find_lib "vorbisidec*.dll"`]
   461                     ;;
   462                 *)
   463                     ogg_lib=[`find_lib "libvorbisidec[0-9]*.so.*"`]
   464                     if test x$ogg_lib = x; then
   465                         ogg_lib=[`find_lib "libvorbisidec.so.*"`]
   466                     fi
   467                     ;;
   468             esac
   469             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR"
   470             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   471                 echo "-- dynamic libvorbisidec -> $ogg_lib"
   472                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   473             else
   474                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis"
   475             fi
   476         else
   477             AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)])
   478             AC_MSG_WARN([Ogg Vorbis support disabled])
   479         fi
   480     else
   481         AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
   482         AC_CHECK_LIB([vorbisfile -lvorbis -logg -lm], [ov_open_callbacks], [have_ogg_lib=yes])
   483         if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
   484             case "$host" in
   485                 *-*-darwin*)
   486                     ogg_lib=[`find_lib libvorbisfile.dylib`]
   487                     ;;
   488                 *-*-cygwin* | *-*-mingw32*)
   489                     ogg_lib=[`find_lib "libvorbisfile*.dll"`]
   490                     ;;
   491                 *)
   492                     ogg_lib=[`find_lib "libvorbisfile[0-9]*.so.*"`]
   493                     if test x$ogg_lib = x; then
   494                         ogg_lib=[`find_lib "libvorbisfile.so.*"`]
   495                     fi
   496                     ;;
   497             esac
   498             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG"
   499             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   500                 echo "-- dynamic libvorbisfile -> $ogg_lib"
   501                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   502             else
   503                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis"
   504             fi
   505         else
   506             AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)])
   507             AC_MSG_WARN([Ogg Vorbis support disabled])
   508         fi
   509     fi
   510 fi
   511 
   512 libflac_ver=8
   513 AC_ARG_ENABLE([music-flac],
   514 AC_HELP_STRING([--enable-music-flac], [enable FLAC music [[default=yes]]]),
   515               [], [enable_music_flac=yes])
   516 AC_ARG_ENABLE([music-flac-shared],
   517 AC_HELP_STRING([--enable-music-flac-shared],
   518               [dynamically load FLAC library [[default=yes]]]),
   519               [], [enable_music_flac_shared=yes])
   520 if test x$enable_music_flac = xyes; then
   521     AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes])
   522     if test x$have_flac_export = xyes; then
   523         LIBS_SAVED="$LIBS"
   524         LIBS="-lFLAC"
   525         AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver])
   526         AC_TRY_COMPILE([
   527 #include "FLAC/export.h"
   528 #include "stdio.h"
   529 ],[
   530 #if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
   531 #else
   532 #error "old-flac"
   533 #endif
   534 ], have_flac_ver=yes, have_flac_ver=no)
   535         LIBS="$LIBS_SAVED"
   536         AC_MSG_RESULT($have_flac_ver)
   537     fi
   538 
   539     if test x$have_flac_ver = xyes; then
   540         AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
   541         AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
   542         if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then    
   543             case "$host" in
   544                 *-*-darwin*)
   545                     flac_lib=[`find_lib libFLAC.dylib`]
   546                     ;;
   547                 *-*-cygwin* | *-*-mingw32*)
   548                     flac_lib=[`find_lib "libFLAC-*.dll"`]
   549                     ;;
   550                 *)
   551                     flac_lib=[`find_lib "libFLAC[0-9]*.so.*"`]
   552                     if test x$flac_lib = x; then
   553                         flac_lib=[`find_lib "libFLAC.so.*"`]
   554                     fi
   555                     ;;
   556             esac
   557             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC"
   558             if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
   559                 echo "-- dynamic libFLAC -> $flac_lib"
   560                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
   561             else
   562                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
   563             fi
   564         fi
   565     else
   566         AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)])
   567         AC_MSG_WARN([FLAC support disabled])
   568     fi
   569 fi
   570 
   571 AC_ARG_ENABLE(music-mp3,
   572 AC_HELP_STRING([--enable-music-mp3], [enable MP3 music [[default=yes]]]),
   573               [], enable_music_mp3=yes)
   574 
   575 AC_ARG_ENABLE(music-mp3-smpeg,
   576 AC_HELP_STRING([--enable-music-mp3-smpeg], [enable MP3 music via smpeg [[default=no]]]),
   577               [], enable_music_mp3_smpeg=no)
   578 AC_ARG_ENABLE([music-mp3-smpeg-shared],
   579 AC_HELP_STRING([--enable-music-mp3-smpeg-shared], [dynamically load smpeg library [[default=yes]]]),
   580               [], [enable_music_mp3_smpeg_shared=yes])
   581 if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_smpeg = xyes; then
   582     SMPEG_VERSION=2.0.0
   583     AM_PATH_SMPEG2($SMPEG_VERSION, have_smpeg=yes, have_smpeg=no)
   584     if test x$have_smpeg = xyes; then
   585         case "$host" in
   586             *-*-darwin*)
   587                 smpeg_lib=[`find_lib libsmpeg2.dylib`]
   588                 ;;
   589             *-*-cygwin* | *-*-mingw32*)
   590                 smpeg_lib=[`find_lib "smpeg2*.dll"`]
   591                 ;;
   592             *)
   593                 smpeg_lib=[`find_lib "libsmpeg2*.so.*"`]
   594                 ;;
   595         esac
   596         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_SMPEG $SMPEG_CFLAGS"
   597         if test x$enable_music_mp3_smpeg_shared = xyes && test x$smpeg_lib != x; then
   598             echo "-- dynamic libsmpeg -> $smpeg_lib"
   599             EXTRA_CFLAGS="$EXTRA_CFLAGS -DSMPEG_DYNAMIC=\\\"$smpeg_lib\\\""
   600         else
   601             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS"
   602         fi
   603     else
   604         AC_MSG_WARN([*** Unable to find SMPEG library (http://icculus.org/smpeg/)])
   605     fi
   606 fi
   607 
   608 AC_ARG_ENABLE(music-mp3-mad-gpl,
   609 AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
   610                   [], [enable_music_mp3_mad_gpl=no])
   611 AC_ARG_ENABLE(music-mp3-mad-gpl-dithering,
   612 AC_HELP_STRING([--enable-music-mp3-mad-gpl-dithering], [enable MP3 music via libmad GPL code [[default=yes]]]),
   613                   [], [enable_music_mp3_mad_gpl_dithering=yes])
   614 if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then
   615     AC_MSG_CHECKING(for libmad headers)
   616     have_libmad=no
   617     AC_TRY_COMPILE([
   618      #include "mad.h"
   619     ],[
   620     ],[
   621     have_libmad=yes
   622     ])
   623     AC_MSG_RESULT($have_libmad)
   624     if test x$have_libmad = xyes; then
   625         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD"
   626 		if test x$enable_music_mp3_mad_gpl_dithering = xyes; then
   627             AC_MSG_WARN([*** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL])
   628 			EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING"
   629         fi
   630         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
   631     else
   632         AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
   633     fi
   634 fi
   635 
   636 AC_ARG_ENABLE(music-mp3-mpg123,
   637 AC_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via libmpg123 [[default=yes]]]),
   638                   [], [enable_music_mp3_mpg123=yes])
   639 AC_ARG_ENABLE([music-mp3-mpg123-shared],
   640 AC_HELP_STRING([--enable-music-mp3-mpg123-shared], [dynamically load libmpg123 library [[default=yes]]]),
   641               [], [enable_music_mp3_mpg123_shared=yes])
   642 if test x$enable_music_mp3_mpg123 = xyes; then
   643     AC_CHECK_HEADER([mpg123.h], [have_mpg123_hdr=yes])
   644     AC_CHECK_LIB([mpg123], [mpg123_replace_reader_handle], [have_mpg123_lib=yes])
   645     if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then
   646         have_mpg123=yes
   647         case "$host" in
   648             *-*-darwin*)
   649                 mpg123_lib=[`find_lib libmpg123.dylib`]
   650                 ;;
   651             *-*-cygwin* | *-*-mingw32*)
   652                 mpg123_lib=[`find_lib "libmpg123*.dll"`]
   653                 ;;
   654             *)
   655 				mpg123_lib=[`find_lib "libmpg123.so.*"`]
   656                 ;;
   657         esac
   658         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123"
   659         if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then
   660             echo "-- dynamic libmpg123 -> $mpg123_lib"
   661             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\""
   662         else
   663             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
   664         fi
   665     else
   666         AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)])
   667         AC_MSG_WARN([mpg123 support disabled])
   668     fi
   669 fi
   670 
   671 if test x$have_smpeg = xyes -o x$have_libmad = xyes -o x$have_libmpg123; then
   672     :
   673 else
   674     AC_MSG_WARN([MP3 support disabled])
   675 fi
   676 
   677 AC_ARG_ENABLE([music-opus],
   678 AC_HELP_STRING([--enable-music-opus], [enable Opus music [[default=yes]]]),
   679               [], [enable_music_opus=yes])
   680 
   681 AC_ARG_ENABLE([music-opus-shared],
   682 AC_HELP_STRING([--enable-music-opus-shared], [dynamically load opusfile library [[default=yes]]]),
   683               [], [enable_music_opus_shared=yes])
   684 if test x$enable_music_opus = xyes; then
   685     PKG_CHECK_MODULES([OPUSFILE], [opusfile >= 0.2], [dnl
   686             have_opusfile_hdr=yes
   687             have_opusfile_lib=yes
   688         ], [dnl
   689             AC_CHECK_HEADER([opus/opusfile.h], [have_opusfile_hdr=yes])
   690             AC_CHECK_LIB([opusfile], [op_open_callbacks], [have_opusfile_lib=yes])
   691         ])
   692 
   693     if test x$have_opusfile_hdr = xyes -a x$have_opusfile_lib = xyes; then
   694         have_opusfile=yes
   695         case "$host" in
   696             *-*-darwin*)
   697                 opusfile_lib=[`find_lib libopusfile.dylib`]
   698                 ;;
   699             *-*-cygwin* | *-*-mingw32*)
   700                 opusfile_lib=[`find_lib "libopusfile*.dll"`]
   701                 ;;
   702             *)
   703                 opusfile_lib=[`find_lib "libopusfile[0-9]*.so.*"`]
   704                 if test x$opusfile_lib = x; then
   705                     opusfile_lib=[`find_lib "libopusfile.so.*"`]
   706                 fi
   707                 ;;
   708         esac
   709         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OPUS $OPUSFILE_CFLAGS"
   710         if test x$enable_music_opus_shared = xyes && test x$opusfile_lib != x; then
   711             echo "-- dynamic opusfile -> $opusfile_lib"
   712             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOPUS_DYNAMIC=\\\"$opusfile_lib\\\""
   713         else
   714             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $OPUSFILE_LIBS"
   715         fi
   716     else
   717         AC_MSG_WARN([*** Unable to find opusfile library (http://opus-codec.org/)])
   718     fi
   719 fi
   720 
   721 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM"
   722 
   723 OBJECTS=`echo $SOURCES`
   724 DEPENDS=`echo $SOURCES`
   725 OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   726 DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   727 $(objects)/\2.lo: \1/\2.c\\
   728 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   729 
   730 OBJECTS_CXX=`echo $SOURCES_CXX`
   731 DEPENDS_CXX=`echo $SOURCES_CXX`
   732 OBJECTS_CXX=`echo "$OBJECTS_CXX" | sed 's,[[^ ]]*/\([[^ ]]*\)\.cpp,$(objects)/\1.lo,g'`
   733 DEPENDS_CXX=`echo "$DEPENDS_CXX" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.cpp,\\
   734 $(objects)/\2.lo: \1/\2.cpp\\
   735 	\$(LIBTOOL) --mode=compile \$(CXX) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   736 OBJECTS="$OBJECTS $OBJECTS_CXX"
   737 DEPENDS="$DEPENDS $DEPENDS_CXX"
   738 DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'`
   739 
   740 VERSION_OBJECTS=`echo $VERSION_SOURCES`
   741 VERSION_DEPENDS=`echo $VERSION_SOURCES`
   742 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
   743 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
   744 $(objects)/\2.o: \1/\2.rc\\
   745 	\$(WINDRES) \$< \$@,g'`
   746 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'`
   747 
   748 PLAYWAVE_SOURCES="$srcdir/playwave.c"
   749 PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES`
   750 PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES`
   751 PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   752 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   753 $(objects)/\2.lo: \1/\2.c\\
   754 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   755 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\\$,\\\\$,g'`
   756 
   757 PLAYMUS_SOURCES="$srcdir/playmus.c"
   758 PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES`
   759 PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES`
   760 PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   761 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   762 $(objects)/\2.lo: \1/\2.c\\
   763 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   764 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'`
   765 
   766 dnl Expand the sources and objects needed to build the library
   767 AC_SUBST(ac_aux_dir)
   768 AC_SUBST(OBJECTS)
   769 AC_SUBST(VERSION_OBJECTS)
   770 AC_SUBST(PLAYWAVE_OBJECTS)
   771 AC_SUBST(PLAYMUS_OBJECTS)
   772 AC_SUBST(BUILD_CFLAGS)
   773 AC_SUBST(EXTRA_CFLAGS)
   774 AC_SUBST(BUILD_LDFLAGS)
   775 AC_SUBST(EXTRA_LDFLAGS)
   776 AC_SUBST(EXE)
   777 AC_SUBST(WINDRES)
   778 AC_SUBST(SDL_VERSION)
   779 AC_SUBST(SDL_CFLAGS)
   780 AC_SUBST(SDL_LIBS)
   781 
   782 AC_OUTPUT([
   783 ])
   784 AC_CONFIG_FILES([
   785     Makefile SDL2_mixer.spec SDL2_mixer.pc
   786 ])
   787 AC_CONFIG_COMMANDS([default],
   788                    [cat >>Makefile <<__EOF__
   789 
   790 # Build rules for objects
   791 -include \$(OBJECTS:.lo=.d)
   792 $DEPENDS
   793 $VERSION_DEPENDS
   794 
   795 -include \$(PLAYWAVE_OBJECTS:.lo=.d)
   796 $PLAYWAVE_DEPENDS
   797 
   798 -include \$(PLAYMUS_OBJECTS:.lo=.d)
   799 $PLAYMUS_DEPENDS
   800 __EOF__ 
   801 ], [
   802 DEPENDS="$DEPENDS"
   803 VERSION_DEPENDS="$VERSION_DEPENDS"
   804 PLAYWAVE_DEPENDS="$PLAYWAVE_DEPENDS"
   805 PLAYMUS_DEPENDS="$PLAYMUS_DEPENDS"
   806 ])
   807 AC_OUTPUT