configure.in
author Sam Lantinga <slouken@libsdl.org>
Sat, 21 Jul 2007 05:54:10 +0000
changeset 372 4bc4ba77f1a1
parent 370 56cfd885bb2a
child 374 9f79d3a5eda1
permissions -rw-r--r--
Updated Ogg Vorbis libraries for Xcode
     1 dnl Process this file with autoconf to produce a configure script.
     2 AC_INIT(README)
     3 
     4 dnl Set various version strings - taken gratefully from the GTk sources
     5 
     6 # Making releases:
     7 #   MICRO_VERSION += 1;
     8 #   INTERFACE_AGE += 1;
     9 #   BINARY_AGE += 1;
    10 # if any functions have been added, set INTERFACE_AGE to 0.
    11 # if backwards compatibility has been broken,
    12 # set BINARY_AGE and INTERFACE_AGE to 0.
    13 #
    14 MAJOR_VERSION=1
    15 MINOR_VERSION=2
    16 MICRO_VERSION=8
    17 INTERFACE_AGE=6
    18 BINARY_AGE=8
    19 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
    20 
    21 AC_SUBST(MAJOR_VERSION)
    22 AC_SUBST(MINOR_VERSION)
    23 AC_SUBST(MICRO_VERSION)
    24 AC_SUBST(INTERFACE_AGE)
    25 AC_SUBST(BINARY_AGE)
    26 AC_SUBST(VERSION)
    27 
    28 # libtool versioning
    29 LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
    30 LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
    31 LT_REVISION=$INTERFACE_AGE
    32 LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
    33 
    34 AC_SUBST(LT_RELEASE)
    35 AC_SUBST(LT_CURRENT)
    36 AC_SUBST(LT_REVISION)
    37 AC_SUBST(LT_AGE)
    38 
    39 dnl Detect the canonical build and host environments
    40 AC_CONFIG_AUX_DIRS($srcdir/build-scripts)
    41 AC_CANONICAL_HOST
    42 
    43 dnl Set up the compiler and linker flags
    44 case "$host" in
    45     *-*-cygwin*)
    46         # We build SDL on cygwin without the UNIX emulation layer
    47         BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
    48         BASE_LDFLAGS="-mno-cygwin"
    49         ;;
    50     *)
    51         BASE_CFLAGS="-D_GNU_SOURCE=1"
    52         BASE_LDFLAGS=""
    53         ;;
    54 esac
    55 BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
    56 EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
    57 BUILD_LDFLAGS="$LDFLAGS"
    58 EXTRA_LDFLAGS="$BASE_LDFLAGS"
    59 ## These are common directories to find software packages
    60 #for path in /usr/freeware /usr/pkg /usr/local; do
    61 #    if test -d $path/include; then
    62 #        EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
    63 #    fi
    64 #    if test -d $path/lib; then
    65 #        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
    66 #    fi
    67 #done
    68 CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
    69 CFLAGS="$CFLAGS $EXTRA_CFLAGS"
    70 LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
    71 
    72 dnl Check for tools
    73 AC_LIBTOOL_WIN32_DLL
    74 AC_PROG_LIBTOOL
    75 AC_PROG_CC
    76 AC_PROG_INSTALL
    77 AC_PROG_MAKE_SET
    78 if test -z "$host_alias"; then
    79     hostaliaswindres=
    80 else
    81     hostaliaswindres="$host_alias-windres"
    82 fi
    83 AC_CHECK_PROGS(WINDRES, [windres $hostaliaswindres $host_os-windres])
    84 
    85 dnl Check for compiler characteristics
    86 AC_C_CONST
    87 
    88 case "$host" in
    89     *-*-cygwin* | *-*-mingw32*)
    90         SOURCES="$srcdir/version.rc"
    91         EXE=".exe"
    92         if test "$build" != "$host"; then # cross-compiling
    93             # Default cross-compile location
    94             ac_default_prefix=/usr/local/cross-tools/i386-mingw32
    95         else
    96             # Look for the location of the tools and install there
    97             if test "$BUILD_PREFIX" != ""; then
    98                 ac_default_prefix=$BUILD_PREFIX
    99             fi
   100         fi
   101         ;;
   102     *)
   103         SOURCES=""
   104         EXE=""
   105         ;;
   106 esac
   107 
   108 # Standard C sources
   109 SOURCES="$SOURCES \
   110 $srcdir/effect_position.c \
   111 $srcdir/effect_stereoreverse.c \
   112 $srcdir/effects_internal.c \
   113 $srcdir/load_aiff.c \
   114 $srcdir/load_voc.c \
   115 $srcdir/mixer.c \
   116 $srcdir/music.c"
   117 
   118 find_lib()
   119 {
   120     gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   121     gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   122     env_lib_path=[`echo $LIBS $LDFLAGS | sed 's/-L[ ]*//g'`]
   123     for path in $gcc_bin_path $gcc_lib_path $env_lib_path /usr/lib /usr/local/lib; do
   124         lib=[`ls -- $path/$1 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
   125         if test x$lib != x; then
   126             echo $lib
   127             return
   128         fi
   129     done
   130 }
   131 
   132 dnl Check for SDL
   133 SDL_VERSION=1.2.10
   134 AM_PATH_SDL($SDL_VERSION,
   135             :,
   136             AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
   137 )
   138 EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
   139 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
   140 
   141 dnl Check command-line options
   142 
   143 AC_ARG_ENABLE([music-cmd],
   144 AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
   145               [], [enable_music_cmd=yes])
   146 if test x$enable_music_cmd = xyes; then
   147     SOURCES="$SOURCES $srcdir/music_cmd.c"
   148     EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC"
   149 fi
   150 AC_ARG_ENABLE([music-wave],
   151 AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
   152               [], [enable_music_wave=yes])
   153 if test x$enable_music_wave = xyes; then
   154     SOURCES="$SOURCES $srcdir/wavestream.c"
   155     EXTRA_CFLAGS="$EXTRA_CFLAGS -DWAV_MUSIC"
   156 fi
   157 no_libmikmod=yes
   158 libmikmod_maj=3
   159 libmikmod_min=1
   160 libmikmod_rev=10
   161 libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
   162 AC_ARG_ENABLE([music-libmikmod],
   163 AC_HELP_STRING([--enable-music-libmikmod], [enable MOD music via external libmikmod [[default=no]]]),
   164               [], [enable_music_libmikmod=no])
   165 if test x$enable_music_libmikmod = xyes; then
   166     AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
   167     if test "$LIBMIKMOD_CONFIG" != "no" ; then
   168         no_libmikmod=no
   169         CFLAGS_SAVED="$CFLAGS"
   170         LIBS_SAVED="$LIBS"
   171         CFLAGS="$CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
   172         LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
   173         AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
   174         AC_TRY_RUN([
   175 #include "mikmod.h"
   176 #include "stdio.h"
   177 
   178 int main(int argc, char **argv)
   179 {
   180     long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
   181     /*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
   182     if(ver>=((maj<<16)|(min<<8)|(rev))) {
   183         printf("yes\n");
   184         return 0;
   185     }
   186     printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
   187     return 1;
   188 }
   189 ], EXTRA_CFLAGS="$EXTRA_CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`";EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`", CFLAGS="$CFLAGS_SAVED";LIBS="$LIBS_SAVED",
   190 [echo $ac_n "cross compiling; assumed OK... $ac_c"])
   191     fi
   192 fi
   193 
   194 AC_ARG_ENABLE([music-mod],
   195 AC_HELP_STRING([--enable-music-mod], [enable MOD music via mikmod [[default=yes]]]),
   196               [], [enable_music_mod=$no_libmikmod])
   197 if test x$enable_music_mod = xyes -a x$enable_music_libmikmod = xno; then
   198     EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_MUSIC -I\$(srcdir)/mikmod"
   199     SOURCES="$SOURCES $srcdir/mikmod/*.c"
   200 fi
   201 AC_ARG_ENABLE([music-midi],
   202 AC_HELP_STRING([--enable-music-midi], [enable MIDI music via timidity [[default=yes]]]),
   203               [], [enable_music_midi=yes])
   204 if test x$enable_music_midi = xyes; then
   205     EXTRA_CFLAGS="$EXTRA_CFLAGS -DMID_MUSIC"
   206     AC_ARG_ENABLE([music-timidity-midi],
   207 AC_HELP_STRING([--enable-music-timidity-midi], [enable timidity MIDI output [[default=yes]]]),
   208                   [], [enable_music_timidity_midi=yes])
   209     if test x$enable_music_timidity_midi = xyes; then
   210         EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_TIMIDITY_MIDI -I\$(srcdir)/timidity"
   211         SOURCES="$SOURCES $srcdir/timidity/*.c"
   212     fi
   213     AC_ARG_ENABLE([music-native-midi],
   214 AC_HELP_STRING([--enable-music-native-midi], [enable native MIDI music output [[default=yes]]]),
   215                   [], [enable_music_native_midi=yes])
   216     if test x$enable_music_native_midi = xyes; then
   217         use_music_native_midi=no
   218         case "$host" in
   219             *-*-cygwin* | *-*-mingw32*)
   220                 use_music_native_midi=yes
   221                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
   222                 ;;
   223             *-*-darwin*)
   224                 use_music_native_midi=yes
   225                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuickTime -Wl,-framework,CoreServices"
   226                 ;;
   227         esac
   228         if test x$use_music_native_midi = xyes; then
   229             EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
   230             SOURCES="$SOURCES $srcdir/native_midi/*.c"
   231         fi
   232     fi
   233     AC_ARG_ENABLE([music-native-midi-gpl],
   234 AC_HELP_STRING([--enable-music-native-midi-gpl], [enable native MIDI on UNIX using GPL code [[default=no]]]),
   235                   [], [enable_music_native_midi_gpl=no])
   236     if test x$enable_music_native_midi_gpl = xyes; then
   237         use_music_native_midi_gpl=no
   238         case "$host" in
   239             *-*-linux* | *-*-freebsd*)
   240                 use_music_native_midi_gpl=yes
   241                 ;;
   242         esac
   243         if test x$use_music_native_midi_gpl = xyes; then
   244             EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
   245             SOURCES="$SOURCES $srcdir/native_midi_gpl/*.c"
   246         fi
   247     fi
   248 fi
   249 AC_ARG_ENABLE([music-ogg],
   250 AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
   251               [], [enable_music_ogg=yes])
   252 AC_ARG_ENABLE(music-ogg-tremor,
   253 [  --enable-music-ogg-tremor   enable OGG music via libtremor [[default=no]]],
   254               [], enable_music_ogg_tremor=no)
   255 AC_ARG_ENABLE([music-ogg-shared],
   256 AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis support [[default=yes]]]),
   257               [], [enable_music_ogg_shared=yes])
   258 if test x$enable_music_ogg = xyes; then
   259     if test x$enable_music_ogg_tremor = xyes; then
   260         AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
   261         AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes])
   262         if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
   263             case "$host" in
   264                 *-*-darwin*)
   265                     ogg_lib=[`find_lib libvorbisidec*.dylib`]
   266                     if test x$ogg_lib = x; then
   267                         ogg_lib=[`find_lib libvorbisidec.[0-9]`]
   268                     fi
   269                     if test x$ogg_lib = x; then
   270                         ogg_lib=[`find_lib libvorbisidec.[0-9]*`]
   271                     fi
   272                     ;;
   273                 *-*-cygwin* | *-*-mingw32*)
   274                     ogg_lib=[`find_lib "vorbisidec*.dll"`]
   275                     ;;
   276                 *)
   277                     ogg_lib=[`find_lib "libvorbisidec.so.[0-9]"`]
   278                     if test x$ogg_lib = x; then
   279                         ogg_lib=[`find_lib "libvorbisidec.so.[0-9]*"`]
   280                     fi
   281                     ;;
   282             esac
   283             SOURCES="$SOURCES $srcdir/*_ogg.c"
   284             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC -DOGG_USE_TREMOR"
   285             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   286                 echo "-- dynamic libvorbisidec -> $ogg_lib"
   287                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   288             else
   289                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec"
   290             fi
   291         fi
   292     else
   293         AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
   294         AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes])
   295         if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
   296             case "$host" in
   297                 *-*-darwin*)
   298                     ogg_lib=[`find_lib libvorbisfile*.dylib`]
   299                     ;;
   300                 *-*-cygwin* | *-*-mingw32*)
   301                     ogg_lib=[`find_lib "libvorbisfile*.dll"`]
   302                     ;;
   303                 *)
   304                     ogg_lib=[`find_lib "libvorbisfile.so.[0-9]"`]
   305                     if test x$ogg_lib = x; then
   306                         ogg_lib=[`find_lib "libvorbisfile.so.[0-9]*"`]
   307                     fi
   308                     ;;
   309             esac
   310             SOURCES="$SOURCES $srcdir/*_ogg.c"
   311             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC"
   312             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   313                 echo "-- dynamic libvorbisfile -> $ogg_lib"
   314                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   315             else
   316                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis -logg"
   317             fi
   318         fi
   319     fi
   320 fi
   321 AC_ARG_ENABLE(music-mp3,
   322 [  --enable-music-mp3      enable MP3 music via smpeg [[default=yes]]],
   323               , enable_music_mp3=yes)
   324 if test x$enable_music_mp3 = xyes; then
   325     SMPEG_VERSION=0.4.3
   326     AM_PATH_SMPEG($SMPEG_VERSION, have_smpeg=yes, have_smpeg=no)
   327     if test x$have_smpeg = xyes; then
   328         AC_ARG_ENABLE([music-mp3-shared],
   329 AC_HELP_STRING([--enable-music-mp3-shared], [dynamically load MP3 support [[default=yes]]]),
   330                       [], [enable_music_mp3_shared=yes])
   331         case "$host" in
   332             *-*-darwin*)
   333                 smpeg_lib=[`find_lib libsmpeg*.dylib`]
   334                 ;;
   335             *-*-cygwin* | *-*-mingw32*)
   336                 smpeg_lib=[`find_lib "smpeg*.dll"`]
   337                 ;;
   338             *)
   339                 smpeg_lib=[`find_lib "libsmpeg.so.[0-9]"`]
   340                 if test x$smpeg_lib = x; then
   341                     smpeg_lib=[`find_lib "libsmpeg.so.[0-9]*"`]
   342                 fi
   343                 ;;
   344         esac
   345         SOURCES="$SOURCES $srcdir/*_mp3.c"
   346         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC $SMPEG_CFLAGS"
   347         if test x$enable_music_mp3_shared = xyes && test x$smpeg_lib != x; then
   348             echo "-- dynamic libsmpeg -> $smpeg_lib"
   349             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_DYNAMIC=\\\"$smpeg_lib\\\""
   350         else
   351             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS"
   352         fi
   353     fi
   354 fi
   355 AC_ARG_ENABLE(music-mp3-mad-gpl,
   356 AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
   357                   [], [enable_music_mp3_mad_gpl=no])
   358 if test x$enable_music_mp3_mad_gpl = xyes; then
   359     AC_MSG_CHECKING(for libmad headers)
   360     have_libmad=no
   361     AC_TRY_COMPILE([
   362      #include "mad.h"
   363     ],[
   364     ],[
   365     have_libmad=yes
   366     ])
   367     AC_MSG_RESULT($have_libmad)
   368     if test x$have_libmad = xyes; then
   369         SOURCES="$SOURCES $srcdir/music_mad.c"
   370         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC"
   371         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
   372     fi
   373 fi
   374 
   375 OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   376 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
   377 
   378 dnl Expand the sources and objects needed to build the library
   379 AC_SUBST(ac_aux_dir)
   380 AC_SUBST(SOURCES)
   381 AC_SUBST(OBJECTS)
   382 AC_SUBST(BUILD_CFLAGS)
   383 AC_SUBST(EXTRA_CFLAGS)
   384 AC_SUBST(BUILD_LDFLAGS)
   385 AC_SUBST(EXTRA_LDFLAGS)
   386 AC_SUBST(EXE)
   387 AC_SUBST(WINDRES)
   388 AC_SUBST(SDL_CFLAGS)
   389 AC_SUBST(SDL_LIBS)
   390 
   391 AC_OUTPUT([
   392     Makefile SDL_mixer.spec SDL_mixer.qpg
   393 ], [
   394     : >build-deps
   395     if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
   396 ])