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