configure.in
author Ryan C. Gordon <icculus@icculus.org>
Tue, 16 Feb 2010 15:30:47 +0000
changeset 485 e2c905c12312
parent 483 685cb4a41b92
child 488 94b190330355
permissions -rw-r--r--
Win64 fixes (cast to DWORD_PTR instead of DWORD). Patch by Ozkan Sezer.

Fixes Bugzilla #951.
     1 dnl Process this file with autoconf to produce a configure script.
     2 AC_INIT(README)
     3 AC_CONFIG_AUX_DIRS($srcdir/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=11
    18 INTERFACE_AGE=1
    19 BINARY_AGE=11
    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     *-*-cygwin* | *-*-mingw32*)
   116         VERSION_SOURCES="$srcdir/version.rc"
   117         EXE=".exe"
   118         if test "$build" != "$host"; then # cross-compiling
   119             # Default cross-compile location
   120             ac_default_prefix=/usr/local/cross-tools/i386-mingw32
   121         else
   122             # Look for the location of the tools and install there
   123             if test "$BUILD_PREFIX" != ""; then
   124                 ac_default_prefix=$BUILD_PREFIX
   125             fi
   126         fi
   127         ;;
   128     *)
   129         SOURCES=""
   130         EXE=""
   131         ;;
   132 esac
   133 
   134 # Standard C sources
   135 SOURCES="$SOURCES \
   136 $srcdir/effect_position.c \
   137 $srcdir/effect_stereoreverse.c \
   138 $srcdir/effects_internal.c \
   139 $srcdir/load_aiff.c \
   140 $srcdir/load_voc.c \
   141 $srcdir/mixer.c \
   142 $srcdir/music.c"
   143 
   144 dnl set this to use on systems that use lib64 instead of lib
   145 base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
   146 
   147 dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
   148 dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
   149 CheckVisibilityHidden()
   150 {
   151     AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
   152     have_gcc_fvisibility=no
   153 
   154     visibility_CFLAGS="-fvisibility=hidden"
   155     save_CFLAGS="$CFLAGS"
   156     CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
   157     AC_TRY_COMPILE([
   158     #if !defined(__GNUC__) || __GNUC__ < 4
   159     #error SDL only uses visibility attributes in GCC 4 or newer
   160     #endif
   161     ],[
   162     ],[
   163     have_gcc_fvisibility=yes
   164     ])
   165     AC_MSG_RESULT($have_gcc_fvisibility)
   166     CFLAGS="$save_CFLAGS"
   167 
   168     if test x$have_gcc_fvisibility = xyes; then
   169         EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
   170     fi
   171 }
   172 
   173 
   174 dnl Function to find a library in the compiler search path
   175 find_lib()
   176 {
   177     gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   178     gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   179     env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
   180     if test "$cross_compiling" = yes; then
   181         host_lib_path=""
   182     else
   183         host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
   184     fi
   185     for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
   186         lib=[`ls -- $path/$1 2>/dev/null | sort | sed 's/.*\/\(.*\)/\1/; q'`]
   187         if test x$lib != x; then
   188             echo $lib
   189             return
   190         fi
   191     done
   192 }
   193 
   194 dnl Check for SDL
   195 SDL_VERSION=1.2.10
   196 AM_PATH_SDL($SDL_VERSION,
   197             :,
   198             AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
   199 )
   200 EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
   201 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
   202 
   203 dnl Check for math library
   204 AC_CHECK_LIB(m, pow, [LIBM="-lm"])
   205 
   206 dnl Check command-line options
   207 
   208 CheckVisibilityHidden
   209 
   210 AC_ARG_ENABLE([music-cmd],
   211 AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
   212               [], [enable_music_cmd=detect])
   213 if test "x$enable_music_cmd" != xno; then
   214     AC_CHECK_FUNCS([fork vfork])
   215     if test "x$ac_cv_func_fork" = "xyes"; then
   216         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK"
   217     elif test "x$ac_cv_func_vfork" = "xyes"; then
   218         EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK"
   219     elif test "x$enable_music_cmd" = "xyes"; then
   220         AC_MSG_ERROR([external music player not available on your platform])
   221     else
   222         enable_music_cmd=no
   223     fi
   224     if test "x$enable_music_cmd" != xno; then
   225         SOURCES="$SOURCES $srcdir/music_cmd.c"
   226         EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC"
   227     fi
   228 fi
   229 
   230 AC_ARG_ENABLE([music-wave],
   231 AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
   232               [], [enable_music_wave=yes])
   233 if test x$enable_music_wave = xyes; then
   234     SOURCES="$SOURCES $srcdir/wavestream.c"
   235     EXTRA_CFLAGS="$EXTRA_CFLAGS -DWAV_MUSIC"
   236 fi
   237 
   238 AC_ARG_ENABLE([music-mod],
   239 AC_HELP_STRING([--enable-music-mod], [enable MOD music via mikmod [[default=yes]]]),
   240               [], [enable_music_mod=yes])
   241 AC_ARG_ENABLE([music-mod-shared],
   242 AC_HELP_STRING([--enable-music-mod-shared], [dynamically load MOD support [[default=yes]]]),
   243               [], [enable_music_mod_shared=yes])
   244 if test x$enable_music_mod = xyes; then
   245     have_libmikmod=no
   246     libmikmod_maj=3
   247     libmikmod_min=1
   248     libmikmod_rev=10
   249     libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
   250     AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
   251     if test "$LIBMIKMOD_CONFIG" != "no" ; then
   252         
   253         CFLAGS_SAVED="$CFLAGS"
   254         LIBS_SAVED="$LIBS"
   255         CFLAGS="$CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
   256         LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
   257         have_libmikmod=yes
   258         AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
   259         AC_TRY_RUN([
   260 #include "mikmod.h"
   261 #include "stdio.h"
   262 
   263 int main(int argc, char **argv)
   264 {
   265 long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
   266 /*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
   267 if(ver>=((maj<<16)|(min<<8)|(rev))) {
   268     printf("yes\n");
   269     return 0;
   270 }
   271 printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
   272 return 1;
   273 }
   274 ], [], have_libmikmod=no; CFLAGS="$CFLAGS_SAVED"; LIBS="$LIBS_SAVED",
   275         [echo $ac_n "cross compiling; assumed OK... $ac_c"])
   276     fi
   277 
   278     if test x$have_libmikmod = xyes; then
   279         case "$host" in
   280             *-*-darwin*)
   281                 mikmod_lib=[`find_lib libmikmod.dylib`]
   282                 ;;
   283             *-*-cygwin* | *-*-mingw32*)
   284                 mikmod_lib=[`find_lib "mikmod*.dll"`]
   285                 ;;
   286             *)
   287                 mikmod_lib=[`find_lib "libmikmod*.so.[0-9]"`]
   288                 if test x$mikmod_lib = x; then
   289                     mikmod_lib=[`find_lib "libmikmod*.so.[0-9]*"`]
   290                 fi
   291                 ;;
   292         esac
   293         SOURCES="$SOURCES $srcdir/*_mod.c"
   294         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
   295         if test x$enable_music_mod_shared = xyes && test x$mikmod_lib != x; then
   296             echo "-- dynamic libmikmod -> $mikmod_lib"
   297             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_DYNAMIC=\\\"$mikmod_lib\\\""
   298         else
   299             EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`"
   300         fi
   301     else
   302         AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.raphnet.net/)])
   303     fi
   304 fi
   305 
   306 AC_ARG_ENABLE([music-mod-modplug],
   307 AC_HELP_STRING([--enable-music-mod-modplug], [enable MOD music via modplug [[default=no]]]),
   308               [], [enable_music_mod_modplug=no])
   309 if test x$enable_music_mod_modplug = xyes; then
   310 	PKG_CHECK_MODULES([MODPLUG], [libmodplug >= 0.8.7])
   311 	EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_MUSIC  $MODPLUG_CFLAGS"
   312 	EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
   313 dnl	AC_TRY_COMPILE([
   314 dnl     #include "modplug.h"
   315 dnl    ],[
   316 dnl    ],[
   317     have_libmodplug=yes
   318     SOURCES="$SOURCES $srcdir/music_modplug.c"
   319 dnl    ])
   320 else
   321 	have_libmodplug=no
   322 fi
   323 
   324 if test x$have_libmikmod != xyes -a x$have_libmodplug != xyes ; then
   325 	AC_MSG_WARN([MOD support disabled])
   326 fi
   327 
   328 AC_ARG_ENABLE([music-midi],
   329 AC_HELP_STRING([--enable-music-midi], [enable MIDI music via timidity [[default=yes]]]),
   330               [], [enable_music_midi=yes])
   331 if test x$enable_music_midi = xyes; then
   332     EXTRA_CFLAGS="$EXTRA_CFLAGS -DMID_MUSIC"
   333     AC_ARG_ENABLE([music-timidity-midi],
   334 AC_HELP_STRING([--enable-music-timidity-midi], [enable timidity MIDI output [[default=yes]]]),
   335                   [], [enable_music_timidity_midi=yes])
   336     if test x$enable_music_timidity_midi = xyes; then
   337         EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_TIMIDITY_MIDI -I\$(srcdir)/timidity"
   338         SOURCES="$SOURCES $srcdir/timidity/*.c"
   339     fi
   340     AC_ARG_ENABLE([music-native-midi],
   341 AC_HELP_STRING([--enable-music-native-midi], [enable native MIDI music output [[default=yes]]]),
   342                   [], [enable_music_native_midi=yes])
   343     if test x$enable_music_native_midi = xyes; then
   344         use_music_native_midi=no
   345         case "$host" in
   346             *-*-cygwin* | *-*-mingw32*)
   347                 use_music_native_midi=yes
   348                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
   349                 ;;
   350             *-*-darwin*)
   351                 use_music_native_midi=yes
   352                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices"
   353                 ;;
   354         esac
   355         if test x$use_music_native_midi = xyes; then
   356             EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
   357             SOURCES="$SOURCES $srcdir/native_midi/*.c"
   358         fi
   359     fi
   360     AC_ARG_ENABLE([music-native-midi-gpl],
   361 AC_HELP_STRING([--enable-music-native-midi-gpl], [enable native MIDI on UNIX using GPL code [[default=no]]]),
   362                   [], [enable_music_native_midi_gpl=no])
   363     if test x$enable_music_native_midi_gpl = xyes; then
   364         use_music_native_midi_gpl=no
   365         case "$host" in
   366             *-*-linux* | *-*-freebsd*)
   367                 use_music_native_midi_gpl=yes
   368                 ;;
   369         esac
   370         if test x$use_music_native_midi_gpl = xyes; then
   371             EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
   372             SOURCES="$SOURCES $srcdir/native_midi_gpl/*.c"
   373         fi
   374     fi
   375 fi
   376 
   377 AC_ARG_ENABLE([music-ogg],
   378 AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
   379               [], [enable_music_ogg=yes])
   380 AC_ARG_ENABLE(music-ogg-tremor,
   381 AC_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [[default=no]]]),
   382               [], enable_music_ogg_tremor=no)
   383 AC_ARG_ENABLE([music-ogg-shared],
   384 AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis support [[default=yes]]]),
   385               [], [enable_music_ogg_shared=yes])
   386 if test x$enable_music_ogg = xyes; then
   387     if test x$enable_music_ogg_tremor = xyes; then
   388         AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
   389         AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes])
   390         if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
   391             case "$host" in
   392                 *-*-darwin*)
   393                     ogg_lib=[`find_lib libvorbisidec.dylib`]
   394                     if test x$ogg_lib = x; then
   395                         ogg_lib=[`find_lib libvorbisidec.[0-9]`]
   396                     fi
   397                     if test x$ogg_lib = x; then
   398                         ogg_lib=[`find_lib libvorbisidec.[0-9]*`]
   399                     fi
   400                     ;;
   401                 *-*-cygwin* | *-*-mingw32*)
   402                     ogg_lib=[`find_lib "vorbisidec*.dll"`]
   403                     ;;
   404                 *)
   405                     ogg_lib=[`find_lib "libvorbisidec.so.[0-9]"`]
   406                     if test x$ogg_lib = x; then
   407                         ogg_lib=[`find_lib "libvorbisidec.so.[0-9]*"`]
   408                     fi
   409                     ;;
   410             esac
   411             SOURCES="$SOURCES $srcdir/*_ogg.c"
   412             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC -DOGG_USE_TREMOR"
   413             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   414                 echo "-- dynamic libvorbisidec -> $ogg_lib"
   415                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   416             else
   417                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis -logg $LIBM"
   418             fi
   419         else
   420             AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)])
   421             AC_MSG_WARN([Ogg Vorbis support disabled])
   422         fi
   423     else
   424         AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
   425         AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes])
   426         if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
   427             case "$host" in
   428                 *-*-darwin*)
   429                     ogg_lib=[`find_lib libvorbisfile.dylib`]
   430                     ;;
   431                 *-*-cygwin* | *-*-mingw32*)
   432                     ogg_lib=[`find_lib "libvorbisfile*.dll"`]
   433                     ;;
   434                 *)
   435                     ogg_lib=[`find_lib "libvorbisfile.so.[0-9]"`]
   436                     if test x$ogg_lib = x; then
   437                         ogg_lib=[`find_lib "libvorbisfile.so.[0-9]*"`]
   438                     fi
   439                     ;;
   440             esac
   441             SOURCES="$SOURCES $srcdir/*_ogg.c"
   442             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC"
   443             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   444                 echo "-- dynamic libvorbisfile -> $ogg_lib"
   445                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   446             else
   447                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis -logg $LIBM"
   448             fi
   449         else
   450             AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)])
   451             AC_MSG_WARN([Ogg Vorbis support disabled])
   452         fi
   453     fi
   454 fi
   455 
   456 libflac_ver=8
   457 AC_ARG_ENABLE([music-flac],
   458 AC_HELP_STRING([--enable-music-flac], [enable FLAC music [[default=yes]]]),
   459               [], [enable_music_flac=yes])
   460 AC_ARG_ENABLE([music-flac-shared],
   461 AC_HELP_STRING([--enable-music-flac-shared],
   462               [dynamically load FLAC support [[default=yes]]]),
   463               [], [enable_music_flac_shared=yes])
   464 if test x$enable_music_flac = xyes; then
   465     AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes])
   466     if test x$have_flac_export = xyes; then
   467         LIBS_SAVED="$LIBS"
   468         LIBS="-lFLAC"
   469         AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver])
   470         AC_TRY_RUN([
   471 #include "FLAC/export.h"
   472 #include "stdio.h"
   473 int main( int argc, char *argv[] ) {
   474 #if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
   475     return 0;
   476 #else
   477     return 1;
   478 #endif
   479 }
   480 ], have_flac_ver=yes, have_flac_ver=no)
   481         LIBS="$LIBS_SAVED"
   482         AC_MSG_RESULT($have_flac_ver)
   483     fi
   484 
   485     if test x$have_flac_ver = xyes; then
   486         AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
   487         AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
   488         if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then    
   489             case "$host" in
   490                 *-*-darwin*)
   491                     flac_lib=[`find_lib libFLAC.dylib`]
   492                     ;;
   493                 *-*-cygwin* | *-*-mingw32*)
   494                     flac_lib=[`find_lib "libFLAC*.dll"`]
   495                     ;;
   496                 *)
   497                     flac_lib=[`find_lib "libFLAC.so.[0-9]"`]
   498                     if test x$flac_lib = x; then
   499                         flac_lib=[`find_lib "libFLAC.so.[0-9]*"`]
   500                     fi
   501                     ;;
   502             esac
   503             SOURCES="$SOURCES $srcdir/*_flac.c"
   504             EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_MUSIC"
   505             if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
   506                 echo "-- dynamic libFLAC -> $flac_lib"
   507                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
   508             else
   509                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
   510             fi
   511         fi
   512     else
   513         AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)])
   514         AC_MSG_WARN([FLAC support disabled])
   515     fi
   516 fi
   517 
   518 AC_ARG_ENABLE(music-mp3,
   519 AC_HELP_STRING([--enable-music-mp3], [enable MP3 music via smpeg [[default=yes]]]),
   520               [], enable_music_mp3=yes)
   521 AC_ARG_ENABLE([music-mp3-shared],
   522 AC_HELP_STRING([--enable-music-mp3-shared], [dynamically load MP3 support [[default=yes]]]),
   523               [], [enable_music_mp3_shared=yes])
   524 if test x$enable_music_mp3 = xyes; then
   525     SMPEG_VERSION=0.4.3
   526     AM_PATH_SMPEG($SMPEG_VERSION, have_smpeg=yes, have_smpeg=no)
   527     if test x$have_smpeg = xyes; then
   528         case "$host" in
   529             *-*-darwin*)
   530                 smpeg_lib=[`find_lib libsmpeg.dylib`]
   531                 ;;
   532             *-*-cygwin* | *-*-mingw32*)
   533                 smpeg_lib=[`find_lib "smpeg*.dll"`]
   534                 ;;
   535             *)
   536                 smpeg_lib=[`find_lib "libsmpeg*.so.[0-9]"`]
   537                 if test x$smpeg_lib = x; then
   538                     smpeg_lib=[`find_lib "libsmpeg*.so.[0-9]*"`]
   539                 fi
   540                 ;;
   541         esac
   542         SOURCES="$SOURCES $srcdir/*_mp3.c"
   543         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC $SMPEG_CFLAGS"
   544         if test x$enable_music_mp3_shared = xyes && test x$smpeg_lib != x; then
   545             echo "-- dynamic libsmpeg -> $smpeg_lib"
   546             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_DYNAMIC=\\\"$smpeg_lib\\\""
   547         else
   548             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS"
   549         fi
   550     else
   551         AC_MSG_WARN([*** Unable to find SMPEG library (http://icculus.org/smpeg/)])
   552     fi
   553 fi
   554 
   555 AC_ARG_ENABLE(music-mp3-mad-gpl,
   556 AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
   557                   [], [enable_music_mp3_mad_gpl=no])
   558 if test x$enable_music_mp3_mad_gpl = xyes; then
   559     AC_MSG_CHECKING(for libmad headers)
   560     have_libmad=no
   561     AC_TRY_COMPILE([
   562      #include "mad.h"
   563     ],[
   564     ],[
   565     have_libmad=yes
   566     ])
   567     AC_MSG_RESULT($have_libmad)
   568     if test x$have_libmad = xyes; then
   569         SOURCES="$SOURCES $srcdir/music_mad.c"
   570         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC"
   571         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
   572         SOURCES="$SOURCES $srcdir/music_modplug.c"
   573     else
   574         AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
   575     fi
   576 fi
   577 
   578 if test x$have_smpeg != xyes -a x$have_libmad != xyes; then
   579     AC_MSG_WARN([MP3 support disabled])
   580 fi
   581 
   582 
   583 OBJECTS=`echo $SOURCES`
   584 DEPENDS=`echo $SOURCES`
   585 OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   586 DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   587 $(objects)/\2.lo: \1/\2.c\\
   588 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   589 
   590 VERSION_OBJECTS=`echo $VERSION_SOURCES`
   591 VERSION_DEPENDS=`echo $VERSION_SOURCES`
   592 VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
   593 VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
   594 $(objects)/\2.o: \1/\2.rc\\
   595 	\$(WINDRES) \$< \$@,g'`
   596 
   597 PLAYWAVE_SOURCES="$srcdir/playwave.c"
   598 PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES`
   599 PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES`
   600 PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   601 PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   602 $(objects)/\2.lo: \1/\2.c\\
   603 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   604 
   605 PLAYMUS_SOURCES="$srcdir/playmus.c"
   606 PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES`
   607 PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES`
   608 PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   609 PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
   610 $(objects)/\2.lo: \1/\2.c\\
   611 	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
   612 
   613 dnl Expand the sources and objects needed to build the library
   614 AC_SUBST(ac_aux_dir)
   615 AC_SUBST(OBJECTS)
   616 AC_SUBST(DEPENDS)
   617 AC_SUBST(VERSION_OBJECTS)
   618 AC_SUBST(VERSION_DEPENDS)
   619 AC_SUBST(PLAYWAVE_OBJECTS)
   620 AC_SUBST(PLAYWAVE_DEPENDS)
   621 AC_SUBST(PLAYMUS_OBJECTS)
   622 AC_SUBST(PLAYMUS_DEPENDS)
   623 AC_SUBST(BUILD_CFLAGS)
   624 AC_SUBST(EXTRA_CFLAGS)
   625 AC_SUBST(BUILD_LDFLAGS)
   626 AC_SUBST(EXTRA_LDFLAGS)
   627 AC_SUBST(EXE)
   628 AC_SUBST(WINDRES)
   629 AC_SUBST(SDL_VERSION)
   630 AC_SUBST(SDL_CFLAGS)
   631 AC_SUBST(SDL_LIBS)
   632 
   633 AC_OUTPUT([
   634     Makefile SDL_mixer.spec SDL_mixer.qpg SDL_mixer.pc
   635 ])