configure.in
author Sam Lantinga <slouken@libsdl.org>
Fri, 04 Jan 2019 22:02:19 -0800
changeset 926 d6c9518fb5ee
parent 915 2e274cefe1db
permissions -rw-r--r--
Updated copyright for 2019
     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"
    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;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)/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     LIBS_SAVED="$LIBS"
   452     if test x$enable_music_ogg_tremor = xyes; then
   453         AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
   454         AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes], [], [-logg])
   455         if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
   456             case "$host" in
   457                 *-*-darwin*)
   458                     ogg_lib=[`find_lib libvorbisidec.dylib`]
   459                     ;;
   460                 *-*-cygwin* | *-*-mingw32*)
   461                     ogg_lib=[`find_lib "vorbisidec*.dll"`]
   462                     ;;
   463                 *)
   464                     ogg_lib=[`find_lib "libvorbisidec[0-9]*.so.*"`]
   465                     if test x$ogg_lib = x; then
   466                         ogg_lib=[`find_lib "libvorbisidec.so.*"`]
   467                     fi
   468                     ;;
   469             esac
   470             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR"
   471             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   472                 echo "-- dynamic libvorbisidec -> $ogg_lib"
   473                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   474             else
   475                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis"
   476             fi
   477         else
   478             AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)])
   479             AC_MSG_WARN([Ogg Vorbis support disabled])
   480         fi
   481     else
   482         AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
   483         AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes], [], [-lvorbis -logg -lm])
   484         if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
   485             case "$host" in
   486                 *-*-darwin*)
   487                     ogg_lib=[`find_lib libvorbisfile.dylib`]
   488                     ;;
   489                 *-*-cygwin* | *-*-mingw32*)
   490                     ogg_lib=[`find_lib "libvorbisfile*.dll"`]
   491                     ;;
   492                 *)
   493                     ogg_lib=[`find_lib "libvorbisfile[0-9]*.so.*"`]
   494                     if test x$ogg_lib = x; then
   495                         ogg_lib=[`find_lib "libvorbisfile.so.*"`]
   496                     fi
   497                     ;;
   498             esac
   499             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG"
   500             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   501                 echo "-- dynamic libvorbisfile -> $ogg_lib"
   502                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   503             else
   504                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis"
   505             fi
   506         else
   507             AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)])
   508             AC_MSG_WARN([Ogg Vorbis support disabled])
   509         fi
   510     fi
   511     LIBS="$LIBS_SAVED"
   512 fi
   513 
   514 libflac_ver=8
   515 AC_ARG_ENABLE([music-flac],
   516 AC_HELP_STRING([--enable-music-flac], [enable FLAC music [[default=yes]]]),
   517               [], [enable_music_flac=yes])
   518 AC_ARG_ENABLE([music-flac-shared],
   519 AC_HELP_STRING([--enable-music-flac-shared],
   520               [dynamically load FLAC library [[default=yes]]]),
   521               [], [enable_music_flac_shared=yes])
   522 if test x$enable_music_flac = xyes; then
   523     AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes])
   524     if test x$have_flac_export = xyes; then
   525         LIBS_SAVED="$LIBS"
   526         LIBS="-lFLAC"
   527         AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver])
   528         AC_TRY_COMPILE([
   529 #include "FLAC/export.h"
   530 #include "stdio.h"
   531 ],[
   532 #if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
   533 #else
   534 #error "old-flac"
   535 #endif
   536 ], have_flac_ver=yes, have_flac_ver=no)
   537         LIBS="$LIBS_SAVED"
   538         AC_MSG_RESULT($have_flac_ver)
   539     fi
   540 
   541     if test x$have_flac_ver = xyes; then
   542         AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
   543         AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
   544         if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then    
   545             case "$host" in
   546                 *-*-darwin*)
   547                     flac_lib=[`find_lib libFLAC.dylib`]
   548                     ;;
   549                 *-*-cygwin* | *-*-mingw32*)
   550                     flac_lib=[`find_lib "libFLAC-*.dll"`]
   551                     ;;
   552                 *)
   553                     flac_lib=[`find_lib "libFLAC[0-9]*.so.*"`]
   554                     if test x$flac_lib = x; then
   555                         flac_lib=[`find_lib "libFLAC.so.*"`]
   556                     fi
   557                     ;;
   558             esac
   559             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC"
   560             if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
   561                 echo "-- dynamic libFLAC -> $flac_lib"
   562                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
   563             else
   564                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
   565             fi
   566         fi
   567     else
   568         AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)])
   569         AC_MSG_WARN([FLAC support disabled])
   570     fi
   571 fi
   572 
   573 AC_ARG_ENABLE(music-mp3,
   574 AC_HELP_STRING([--enable-music-mp3], [enable MP3 music [[default=yes]]]),
   575               [], enable_music_mp3=yes)
   576 
   577 AC_ARG_ENABLE(music-mp3-mad-gpl,
   578 AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
   579                   [], [enable_music_mp3_mad_gpl=no])
   580 AC_ARG_ENABLE(music-mp3-mad-gpl-dithering,
   581 AC_HELP_STRING([--enable-music-mp3-mad-gpl-dithering], [enable MP3 music via libmad GPL code [[default=yes]]]),
   582                   [], [enable_music_mp3_mad_gpl_dithering=yes])
   583 if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then
   584     AC_MSG_CHECKING(for libmad headers)
   585     have_libmad=no
   586     AC_TRY_COMPILE([
   587      #include "mad.h"
   588     ],[
   589     ],[
   590     have_libmad=yes
   591     ])
   592     AC_MSG_RESULT($have_libmad)
   593     if test x$have_libmad = xyes; then
   594         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD"
   595         if test x$enable_music_mp3_mad_gpl_dithering = xyes; then
   596             AC_MSG_WARN([*** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL])
   597             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING"
   598         fi
   599         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
   600     else
   601         AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
   602     fi
   603 fi
   604 
   605 AC_ARG_ENABLE(music-mp3-mpg123,
   606 AC_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via libmpg123 [[default=yes]]]),
   607                   [], [enable_music_mp3_mpg123=yes])
   608 AC_ARG_ENABLE([music-mp3-mpg123-shared],
   609 AC_HELP_STRING([--enable-music-mp3-mpg123-shared], [dynamically load libmpg123 library [[default=yes]]]),
   610               [], [enable_music_mp3_mpg123_shared=yes])
   611 if test x$enable_music_mp3_mpg123 = xyes; then
   612     AC_CHECK_HEADER([mpg123.h], [have_mpg123_hdr=yes])
   613     AC_CHECK_LIB([mpg123], [mpg123_replace_reader_handle], [have_mpg123_lib=yes])
   614     if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then
   615         have_libmpg123=yes
   616         case "$host" in
   617             *-*-darwin*)
   618                 mpg123_lib=[`find_lib libmpg123.dylib`]
   619                 ;;
   620             *-*-cygwin* | *-*-mingw32*)
   621                 mpg123_lib=[`find_lib "libmpg123*.dll"`]
   622                 ;;
   623             *)
   624                 mpg123_lib=[`find_lib "libmpg123.so.*"`]
   625                 ;;
   626         esac
   627         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123"
   628         if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then
   629             echo "-- dynamic libmpg123 -> $mpg123_lib"
   630             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\""
   631         else
   632             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
   633         fi
   634     else
   635         AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)])
   636         AC_MSG_WARN([mpg123 support disabled])
   637     fi
   638 fi
   639 
   640 if test x$have_libmad = xyes -o x$have_libmpg123 = xyes; then
   641     :
   642 else
   643     AC_MSG_WARN([MP3 support disabled])
   644 fi
   645 
   646 AC_ARG_ENABLE([music-opus],
   647 AC_HELP_STRING([--enable-music-opus], [enable Opus music [[default=yes]]]),
   648               [], [enable_music_opus=yes])
   649 
   650 AC_ARG_ENABLE([music-opus-shared],
   651 AC_HELP_STRING([--enable-music-opus-shared], [dynamically load opusfile library [[default=yes]]]),
   652               [], [enable_music_opus_shared=yes])
   653 if test x$enable_music_opus = xyes; then
   654     LIBS_SAVED="$LIBS"
   655     PKG_CHECK_MODULES([OPUSFILE], [opusfile >= 0.2], [dnl
   656             have_opusfile_hdr=yes
   657             have_opusfile_lib=yes
   658         ], [dnl
   659             AC_CHECK_HEADER([opus/opusfile.h], [have_opusfile_hdr=yes])
   660             AC_CHECK_LIB([opusfile], [op_open_callbacks], [have_opusfile_lib=yes;OPUSFILE_LIBS="-lopusfile -lopus"], [], [-lopus -logg -lm])
   661         ])
   662     LIBS="$LIBS_SAVED"
   663 
   664     if test x$have_opusfile_hdr = xyes -a x$have_opusfile_lib = xyes; then
   665         have_opusfile=yes
   666         case "$host" in
   667             *-*-darwin*)
   668                 opusfile_lib=[`find_lib libopusfile.dylib`]
   669                 ;;
   670             *-*-cygwin* | *-*-mingw32*)
   671                 opusfile_lib=[`find_lib "libopusfile*.dll"`]
   672                 ;;
   673             *)
   674                 opusfile_lib=[`find_lib "libopusfile[0-9]*.so.*"`]
   675                 if test x$opusfile_lib = x; then
   676                     opusfile_lib=[`find_lib "libopusfile.so.*"`]
   677                 fi
   678                 ;;
   679         esac
   680         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OPUS $OPUSFILE_CFLAGS"
   681         if test x$enable_music_opus_shared = xyes && test x$opusfile_lib != x; then
   682             echo "-- dynamic opusfile -> $opusfile_lib"
   683             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOPUS_DYNAMIC=\\\"$opusfile_lib\\\""
   684         else
   685             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $OPUSFILE_LIBS"
   686         fi
   687     else
   688         AC_MSG_WARN([*** Unable to find opusfile library (http://opus-codec.org/)])
   689     fi
   690 fi
   691 
   692 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM"
   693 
   694 OBJECTS=`echo $SOURCES`
   695 DEPENDS=`echo $SOURCES`
   696 OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   697 DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   698 $(objects)/\2.lo: \1/\2.c\\
   699 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   700 
   701 OBJECTS_CXX=`echo $SOURCES_CXX`
   702 DEPENDS_CXX=`echo $SOURCES_CXX`
   703 OBJECTS_CXX=`echo "$OBJECTS_CXX" | sed 's,[[^ ]]*/\([[^ ]]*\)\.cpp,$(objects)/\1.lo,g'`
   704 DEPENDS_CXX=`echo "$DEPENDS_CXX" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.cpp,\\
   705 $(objects)/\2.lo: \1/\2.cpp\\
   706 	\$(LIBTOOL) --mode=compile \$(CXX) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   707 OBJECTS="$OBJECTS $OBJECTS_CXX"
   708 DEPENDS="$DEPENDS $DEPENDS_CXX"
   709 DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'`
   710 
   711 VERSION_OBJECTS=`echo $VERSION_SOURCES`
   712 VERSION_DEPENDS=`echo $VERSION_SOURCES`
   713 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
   714 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
   715 $(objects)/\2.o: \1/\2.rc\\
   716 	\$(WINDRES) \$< \$@,g'`
   717 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'`
   718 
   719 PLAYWAVE_SOURCES="$srcdir/playwave.c"
   720 PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES`
   721 PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES`
   722 PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   723 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   724 $(objects)/\2.lo: \1/\2.c\\
   725 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   726 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\\$,\\\\$,g'`
   727 
   728 PLAYMUS_SOURCES="$srcdir/playmus.c"
   729 PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES`
   730 PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES`
   731 PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   732 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   733 $(objects)/\2.lo: \1/\2.c\\
   734 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   735 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'`
   736 
   737 dnl Expand the sources and objects needed to build the library
   738 AC_SUBST(ac_aux_dir)
   739 AC_SUBST(OBJECTS)
   740 AC_SUBST(VERSION_OBJECTS)
   741 AC_SUBST(PLAYWAVE_OBJECTS)
   742 AC_SUBST(PLAYMUS_OBJECTS)
   743 AC_SUBST(BUILD_CFLAGS)
   744 AC_SUBST(EXTRA_CFLAGS)
   745 AC_SUBST(BUILD_LDFLAGS)
   746 AC_SUBST(EXTRA_LDFLAGS)
   747 AC_SUBST(EXE)
   748 AC_SUBST(WINDRES)
   749 AC_SUBST(SDL_VERSION)
   750 AC_SUBST(SDL_CFLAGS)
   751 AC_SUBST(SDL_LIBS)
   752 
   753 AC_OUTPUT([
   754 ])
   755 AC_CONFIG_FILES([
   756     Makefile SDL2_mixer.spec SDL2_mixer.pc
   757 ])
   758 AC_CONFIG_COMMANDS([default],
   759                    [cat >>Makefile <<__EOF__
   760 
   761 # Build rules for objects
   762 -include \$(OBJECTS:.lo=.d)
   763 $DEPENDS
   764 $VERSION_DEPENDS
   765 
   766 -include \$(PLAYWAVE_OBJECTS:.lo=.d)
   767 $PLAYWAVE_DEPENDS
   768 
   769 -include \$(PLAYMUS_OBJECTS:.lo=.d)
   770 $PLAYMUS_DEPENDS
   771 __EOF__ 
   772 ], [
   773 DEPENDS="$DEPENDS"
   774 VERSION_DEPENDS="$VERSION_DEPENDS"
   775 PLAYWAVE_DEPENDS="$PLAYWAVE_DEPENDS"
   776 PLAYMUS_DEPENDS="$PLAYMUS_DEPENDS"
   777 ])
   778 AC_OUTPUT