configure.in
author Ozkan Sezer
Thu, 26 Dec 2019 17:25:50 +0300
changeset 1123 d40dacdd4ab1
parent 1086 89f446aae9b5
permissions -rw-r--r--
mp3utils.c: check for false positives if id3v1 isn't at file's end.
     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=4
    18 INTERFACE_AGE=2
    19 BINARY_AGE=4
    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 -I$srcdir/include -I$srcdir/src -I$srcdir/src/codecs"
    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/src/*.c $srcdir/src/codecs/*.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;MODPLUG_LIBS="-lmodplug"])
   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     CFLAGS_SAVED="$CFLAGS"
   295     LIBS_SAVED="$LIBS"
   296     AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
   297     if test "$LIBMIKMOD_CONFIG" != "no" ; then
   298         CFLAGS="$CFLAGS `$LIBMIKMOD_CONFIG --cflags`"
   299         LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
   300         have_libmikmod=yes
   301         AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
   302         AC_TRY_RUN([
   303 #include "mikmod.h"
   304 #include "stdio.h"
   305 
   306 int main(int argc, char **argv)
   307 {
   308 long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
   309 /*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
   310 if(ver>=((maj<<16)|(min<<8)|(rev))) {
   311     printf("yes\n");
   312     return 0;
   313 }
   314 printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
   315 return 1;
   316 }
   317 ], [], [have_libmikmod=no], [echo $ac_n "cross compiling; assumed OK... $ac_c"])
   318     fi
   319 
   320     if test x$have_libmikmod = xyes; then
   321         case "$host" in
   322             *-*-darwin*)
   323                 mikmod_lib=[`find_lib libmikmod.dylib`]
   324                 ;;
   325             *-*-cygwin* | *-*-mingw32*)
   326                 mikmod_lib=[`find_lib "libmikmod*.dll"`]
   327                 ;;
   328             *)
   329                 mikmod_lib=[`find_lib "libmikmod[0-9]*.so.*"`]
   330                 if test x$mikmod_lib = x; then
   331                     mikmod_lib=[`find_lib "libmikmod.so.*"`]
   332                 fi
   333                 ;;
   334         esac
   335         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MIKMOD `$LIBMIKMOD_CONFIG --cflags`"
   336         if test x$enable_music_mod_mikmod_shared = xyes && test x$mikmod_lib != x; then
   337             echo "-- dynamic libmikmod -> $mikmod_lib"
   338             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMIKMOD_DYNAMIC=\\\"$mikmod_lib\\\""
   339         else
   340             EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`"
   341         fi
   342     else
   343         AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.raphnet.net/)])
   344     fi
   345     LIBS="$LIBS_SAVED"
   346     CFLAGS="$CFLAGS_SAVED"
   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)/src/codecs/timidity"
   363         SOURCES="$SOURCES $srcdir/src/codecs/timidity/*.c"
   364         timidity_cfg=no
   365         AC_ARG_WITH([timidity-cfg],
   366 AC_HELP_STRING([--with-timidity-cfg=FILE], [Specify full path to timidity.cfg]), timidity_cfg="$withval", [])
   367         if test x$timidity_cfg != xyes -a x$timidity_cfg != xno; then
   368                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DTIMIDITY_CFG=\\\"$timidity_cfg\\\""
   369         fi
   370     fi
   371     AC_ARG_ENABLE([music-midi-native],
   372 AC_HELP_STRING([--enable-music-midi-native], [enable native MIDI music output [[default=yes]]]),
   373                   [], [enable_music_midi_native=yes])
   374     if test x$enable_music_midi_native = xyes; then
   375         use_music_midi_native=no
   376         case "$host" in
   377             *mingw32ce*)
   378                 use_music_midi_native=no
   379                 ;;
   380             *-*-cygwin* | *-*-mingw32*)
   381                 use_music_midi_native=yes
   382                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
   383                 ;;
   384             *-*-darwin*)
   385                 use_music_midi_native=yes
   386                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices"
   387                 ;;
   388             *-*-haiku*)
   389                 use_music_midi_native=yes_cpp
   390                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi"
   391                 ;;
   392         esac
   393         if test x$use_music_midi_native = xyes; then
   394             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi"
   395             SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c"
   396         elif test x$use_music_midi_native = xyes_cpp; then
   397             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi"
   398             SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c"
   399             SOURCES_CXX="$SOURCES_CXX $srcdir/src/codecs/native_midi/*.cpp"
   400         fi
   401     fi
   402     AC_ARG_ENABLE([music-midi-fluidsynth],
   403 AC_HELP_STRING([--enable-music-midi-fluidsynth], [enable FluidSynth MIDI output [[default=yes]]]),
   404                   [], [enable_music_midi_fluidsynth=yes])
   405     AC_ARG_ENABLE([music-midi-fluidsynth-shared],
   406 AC_HELP_STRING([--enable-music-midi-fluidsynth-shared], [dynamically load FluidSynth library [[default=yes]]]),
   407                   [], [enable_music_midi_fluidsynth_shared=yes])
   408     if test x$enable_music_midi_fluidsynth = xyes; then
   409         AC_CHECK_HEADER([fluidsynth.h], [have_fluidsynth_hdr=yes])
   410         AC_CHECK_LIB([fluidsynth], [fluid_player_add_mem], [have_fluidsynth_lib=yes])
   411         if test x$have_fluidsynth_hdr = xyes -a x$have_fluidsynth_lib = xyes; then
   412             have_fluidsynth=yes
   413             case "$host" in
   414                 *-*-darwin*)
   415                     fluidsynth_lib=[`find_lib libfluidsynth.dylib`]
   416                     ;;
   417                 *-*-cygwin* | *-*-mingw32*)
   418                     fluidsynth_lib=[`find_lib "fluidsynth*.dll"`]
   419                     ;;
   420                 *)
   421                     fluidsynth_lib=[`find_lib "libfluidsynth[0-9]*.so.*"`]
   422                     if test x$fluidsynth_lib = x; then
   423                         fluidsynth_lib=[`find_lib "libfluidsynth.so.*"`]
   424                     fi
   425                     ;;
   426             esac
   427             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH"
   428             if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then
   429                 echo "-- dynamic libfluidsynth -> $fluidsynth_lib"
   430                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\""
   431             else
   432                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth"
   433             fi
   434         else
   435             AC_MSG_WARN([*** Unable to find FluidSynth library (http://www.fluidsynth.org/)])
   436             AC_MSG_WARN([FluidSynth support disabled])
   437         fi
   438     fi
   439 fi
   440 
   441 if test x$enable_music_midi_timidity != xyes -a \
   442         x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \
   443         x$have_fluidsynth != xyes; then
   444     AC_MSG_WARN([MIDI support disabled])
   445 fi
   446 
   447 AC_ARG_ENABLE([music-ogg],
   448 AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
   449               [], [enable_music_ogg=yes])
   450 AC_ARG_ENABLE(music-ogg-tremor,
   451 AC_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [[default=no]]]),
   452               [], enable_music_ogg_tremor=no)
   453 AC_ARG_ENABLE([music-ogg-shared],
   454 AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis library [[default=yes]]]),
   455               [], [enable_music_ogg_shared=yes])
   456 if test x$enable_music_ogg = xyes; then
   457     LIBS_SAVED="$LIBS"
   458     if test x$enable_music_ogg_tremor = xyes; then
   459         AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
   460         AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes], [], [-logg])
   461         if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
   462             case "$host" in
   463                 *-*-darwin*)
   464                     ogg_lib=[`find_lib libvorbisidec.dylib`]
   465                     ;;
   466                 *-*-cygwin* | *-*-mingw32*)
   467                     ogg_lib=[`find_lib "vorbisidec*.dll"`]
   468                     ;;
   469                 *)
   470                     ogg_lib=[`find_lib "libvorbisidec[0-9]*.so.*"`]
   471                     if test x$ogg_lib = x; then
   472                         ogg_lib=[`find_lib "libvorbisidec.so.*"`]
   473                     fi
   474                     ;;
   475             esac
   476             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR"
   477             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   478                 echo "-- dynamic libvorbisidec -> $ogg_lib"
   479                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   480             else
   481                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis"
   482             fi
   483         else
   484             AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)])
   485             AC_MSG_WARN([Ogg Vorbis support disabled])
   486         fi
   487     else
   488         AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
   489         AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes], [], [-lvorbis -logg -lm])
   490         if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
   491             case "$host" in
   492                 *-*-darwin*)
   493                     ogg_lib=[`find_lib libvorbisfile.dylib`]
   494                     ;;
   495                 *-*-cygwin* | *-*-mingw32*)
   496                     ogg_lib=[`find_lib "libvorbisfile*.dll"`]
   497                     ;;
   498                 *)
   499                     ogg_lib=[`find_lib "libvorbisfile[0-9]*.so.*"`]
   500                     if test x$ogg_lib = x; then
   501                         ogg_lib=[`find_lib "libvorbisfile.so.*"`]
   502                     fi
   503                     ;;
   504             esac
   505             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG"
   506             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   507                 echo "-- dynamic libvorbisfile -> $ogg_lib"
   508                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   509             else
   510                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis"
   511             fi
   512         else
   513             AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)])
   514             AC_MSG_WARN([Ogg Vorbis support disabled])
   515         fi
   516     fi
   517     LIBS="$LIBS_SAVED"
   518 fi
   519 
   520 libflac_ver=8
   521 AC_ARG_ENABLE([music-flac],
   522 AC_HELP_STRING([--enable-music-flac], [enable FLAC music [[default=yes]]]),
   523               [], [enable_music_flac=yes])
   524 AC_ARG_ENABLE([music-flac-shared],
   525 AC_HELP_STRING([--enable-music-flac-shared],
   526               [dynamically load FLAC library [[default=yes]]]),
   527               [], [enable_music_flac_shared=yes])
   528 if test x$enable_music_flac = xyes; then
   529     AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes])
   530     if test x$have_flac_export = xyes; then
   531         LIBS_SAVED="$LIBS"
   532         LIBS="-lFLAC"
   533         AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver])
   534         AC_TRY_COMPILE([
   535 #include "FLAC/export.h"
   536 #include "stdio.h"
   537 ],[
   538 #if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
   539 #else
   540 #error "old-flac"
   541 #endif
   542 ], have_flac_ver=yes, have_flac_ver=no)
   543         LIBS="$LIBS_SAVED"
   544         AC_MSG_RESULT($have_flac_ver)
   545     fi
   546 
   547     if test x$have_flac_ver = xyes; then
   548         AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
   549         AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
   550         if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then
   551             case "$host" in
   552                 *-*-darwin*)
   553                     flac_lib=[`find_lib libFLAC.dylib`]
   554                     ;;
   555                 *-*-cygwin* | *-*-mingw32*)
   556                     flac_lib=[`find_lib "libFLAC-*.dll"`]
   557                     ;;
   558                 *)
   559                     flac_lib=[`find_lib "libFLAC[0-9]*.so.*"`]
   560                     if test x$flac_lib = x; then
   561                         flac_lib=[`find_lib "libFLAC.so.*"`]
   562                     fi
   563                     ;;
   564             esac
   565             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC"
   566             if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
   567                 echo "-- dynamic libFLAC -> $flac_lib"
   568                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
   569             else
   570                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
   571             fi
   572         fi
   573     else
   574         AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)])
   575         AC_MSG_WARN([FLAC support disabled])
   576     fi
   577 fi
   578 
   579 AC_ARG_ENABLE(music-mp3,
   580 AC_HELP_STRING([--enable-music-mp3], [enable MP3 music [[default=yes]]]),
   581               [], enable_music_mp3=yes)
   582 
   583 AC_ARG_ENABLE(music-mp3-mad-gpl,
   584 AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
   585                   [], [enable_music_mp3_mad_gpl=no])
   586 AC_ARG_ENABLE(music-mp3-mad-gpl-dithering,
   587 AC_HELP_STRING([--enable-music-mp3-mad-gpl-dithering], [enable MP3 music via libmad GPL code [[default=yes]]]),
   588                   [], [enable_music_mp3_mad_gpl_dithering=yes])
   589 if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then
   590     AC_MSG_CHECKING(for libmad headers)
   591     have_libmad=no
   592     AC_TRY_COMPILE([
   593      #include "mad.h"
   594     ],[
   595     ],[
   596     have_libmad=yes
   597     ])
   598     AC_MSG_RESULT($have_libmad)
   599     if test x$have_libmad = xyes; then
   600         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD"
   601         if test x$enable_music_mp3_mad_gpl_dithering = xyes; then
   602             AC_MSG_WARN([*** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL])
   603             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING"
   604         fi
   605         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
   606     else
   607         AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
   608     fi
   609 fi
   610 
   611 AC_ARG_ENABLE(music-mp3-mpg123,
   612 AC_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via libmpg123 [[default=yes]]]),
   613                   [], [enable_music_mp3_mpg123=yes])
   614 AC_ARG_ENABLE([music-mp3-mpg123-shared],
   615 AC_HELP_STRING([--enable-music-mp3-mpg123-shared], [dynamically load libmpg123 library [[default=yes]]]),
   616               [], [enable_music_mp3_mpg123_shared=yes])
   617 if test x$enable_music_mp3_mpg123 = xyes; then
   618     AC_CHECK_HEADER([mpg123.h], [have_mpg123_hdr=yes])
   619     AC_CHECK_LIB([mpg123], [mpg123_replace_reader_handle], [have_mpg123_lib=yes])
   620     if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then
   621         have_libmpg123=yes
   622         case "$host" in
   623             *-*-darwin*)
   624                 mpg123_lib=[`find_lib libmpg123.dylib`]
   625                 ;;
   626             *-*-cygwin* | *-*-mingw32*)
   627                 mpg123_lib=[`find_lib "libmpg123*.dll"`]
   628                 ;;
   629             *)
   630                 mpg123_lib=[`find_lib "libmpg123.so.*"`]
   631                 ;;
   632         esac
   633         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123"
   634         if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then
   635             echo "-- dynamic libmpg123 -> $mpg123_lib"
   636             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\""
   637         else
   638             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
   639         fi
   640     else
   641         AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)])
   642         AC_MSG_WARN([mpg123 support disabled])
   643     fi
   644 fi
   645 
   646 if test x$have_libmad = xyes -o x$have_libmpg123 = xyes; then
   647     :
   648 else
   649     AC_MSG_WARN([MP3 support disabled])
   650 fi
   651 
   652 AC_ARG_ENABLE([music-opus],
   653 AC_HELP_STRING([--enable-music-opus], [enable Opus music [[default=yes]]]),
   654               [], [enable_music_opus=yes])
   655 
   656 AC_ARG_ENABLE([music-opus-shared],
   657 AC_HELP_STRING([--enable-music-opus-shared], [dynamically load opusfile library [[default=yes]]]),
   658               [], [enable_music_opus_shared=yes])
   659 if test x$enable_music_opus = xyes; then
   660     LIBS_SAVED="$LIBS"
   661     PKG_CHECK_MODULES([OPUSFILE], [opusfile >= 0.2], [dnl
   662             have_opusfile_hdr=yes
   663             have_opusfile_lib=yes
   664         ], [dnl
   665             AC_CHECK_HEADER([opus/opusfile.h], [have_opusfile_hdr=yes])
   666             AC_CHECK_LIB([opusfile], [op_open_callbacks], [have_opusfile_lib=yes;OPUSFILE_LIBS="-lopusfile -lopus"], [], [-lopus -logg -lm])
   667         ])
   668     LIBS="$LIBS_SAVED"
   669 
   670     if test x$have_opusfile_hdr = xyes -a x$have_opusfile_lib = xyes; then
   671         have_opusfile=yes
   672         case "$host" in
   673             *-*-darwin*)
   674                 opusfile_lib=[`find_lib libopusfile.dylib`]
   675                 ;;
   676             *-*-cygwin* | *-*-mingw32*)
   677                 opusfile_lib=[`find_lib "libopusfile*.dll"`]
   678                 ;;
   679             *)
   680                 opusfile_lib=[`find_lib "libopusfile[0-9]*.so.*"`]
   681                 if test x$opusfile_lib = x; then
   682                     opusfile_lib=[`find_lib "libopusfile.so.*"`]
   683                 fi
   684                 ;;
   685         esac
   686         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OPUS $OPUSFILE_CFLAGS"
   687         if test x$enable_music_opus_shared = xyes && test x$opusfile_lib != x; then
   688             echo "-- dynamic opusfile -> $opusfile_lib"
   689             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOPUS_DYNAMIC=\\\"$opusfile_lib\\\""
   690         else
   691             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $OPUSFILE_LIBS"
   692         fi
   693     else
   694         AC_MSG_WARN([*** Unable to find opusfile library (http://opus-codec.org/)])
   695     fi
   696 fi
   697 
   698 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM"
   699 
   700 OBJECTS=`echo $SOURCES`
   701 DEPENDS=`echo $SOURCES`
   702 OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   703 DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   704 $(objects)/\2.lo: \1/\2.c\\
   705 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   706 
   707 OBJECTS_CXX=`echo $SOURCES_CXX`
   708 DEPENDS_CXX=`echo $SOURCES_CXX`
   709 OBJECTS_CXX=`echo "$OBJECTS_CXX" | sed 's,[[^ ]]*/\([[^ ]]*\)\.cpp,$(objects)/\1.lo,g'`
   710 DEPENDS_CXX=`echo "$DEPENDS_CXX" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.cpp,\\
   711 $(objects)/\2.lo: \1/\2.cpp\\
   712 	\$(LIBTOOL) --mode=compile \$(CXX) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   713 OBJECTS="$OBJECTS $OBJECTS_CXX"
   714 DEPENDS="$DEPENDS $DEPENDS_CXX"
   715 DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'`
   716 
   717 VERSION_OBJECTS=`echo $VERSION_SOURCES`
   718 VERSION_DEPENDS=`echo $VERSION_SOURCES`
   719 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
   720 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
   721 $(objects)/\2.o: \1/\2.rc\\
   722 	\$(WINDRES) \$< \$@,g'`
   723 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'`
   724 
   725 PLAYWAVE_SOURCES="$srcdir/playwave.c"
   726 PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES`
   727 PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES`
   728 PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   729 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   730 $(objects)/\2.lo: \1/\2.c\\
   731 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   732 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\\$,\\\\$,g'`
   733 
   734 PLAYMUS_SOURCES="$srcdir/playmus.c"
   735 PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES`
   736 PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES`
   737 PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   738 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   739 $(objects)/\2.lo: \1/\2.c\\
   740 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   741 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'`
   742 
   743 dnl Expand the sources and objects needed to build the library
   744 AC_SUBST(ac_aux_dir)
   745 AC_SUBST(OBJECTS)
   746 AC_SUBST(VERSION_OBJECTS)
   747 AC_SUBST(PLAYWAVE_OBJECTS)
   748 AC_SUBST(PLAYMUS_OBJECTS)
   749 AC_SUBST(BUILD_CFLAGS)
   750 AC_SUBST(EXTRA_CFLAGS)
   751 AC_SUBST(BUILD_LDFLAGS)
   752 AC_SUBST(EXTRA_LDFLAGS)
   753 AC_SUBST(EXE)
   754 AC_SUBST(WINDRES)
   755 AC_SUBST(SDL_VERSION)
   756 AC_SUBST(SDL_CFLAGS)
   757 AC_SUBST(SDL_LIBS)
   758 
   759 AC_OUTPUT([
   760 ])
   761 AC_CONFIG_FILES([
   762     Makefile SDL2_mixer.spec SDL2_mixer.pc
   763 ])
   764 AC_CONFIG_COMMANDS([default],
   765                    [cat >>Makefile <<__EOF__
   766 
   767 # Build rules for objects
   768 -include \$(OBJECTS:.lo=.d)
   769 $DEPENDS
   770 $VERSION_DEPENDS
   771 
   772 -include \$(PLAYWAVE_OBJECTS:.lo=.d)
   773 $PLAYWAVE_DEPENDS
   774 
   775 -include \$(PLAYMUS_OBJECTS:.lo=.d)
   776 $PLAYMUS_DEPENDS
   777 __EOF__
   778 ], [
   779 DEPENDS="$DEPENDS"
   780 VERSION_DEPENDS="$VERSION_DEPENDS"
   781 PLAYWAVE_DEPENDS="$PLAYWAVE_DEPENDS"
   782 PLAYMUS_DEPENDS="$PLAYMUS_DEPENDS"
   783 ])
   784 AC_OUTPUT