configure.in
author Sam Lantinga <slouken@libsdl.org>
Wed, 18 Jul 2007 16:58:37 +0000
changeset 368 e61c4fb262bd
parent 357 d6d0cfdbea65
child 369 5f98121182be
permissions -rw-r--r--
* Improved detection of Ogg Vorbis and Tremor libraries
* Added version.rc to the Windows build
     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_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
   121     env_lib_path=[`echo $LIBS $LDFLAGS | sed 's/-L[ ]*//g'`]
   122     for path in $gcc_lib_path $env_lib_path /usr/lib /usr/local/lib; do
   123         lib=[`ls -- $path/$1 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
   124         if test x$lib != x; then
   125             echo $lib
   126             return
   127         fi
   128     done
   129 }
   130 
   131 dnl Check for SDL
   132 SDL_VERSION=1.2.10
   133 AM_PATH_SDL($SDL_VERSION,
   134             :,
   135             AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
   136 )
   137 EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
   138 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
   139 
   140 dnl Check command-line options
   141 
   142 AC_ARG_ENABLE([music-cmd],
   143 AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
   144               [], [enable_music_cmd=yes])
   145 if test x$enable_music_cmd = xyes; then
   146     SOURCES="$SOURCES $srcdir/music_cmd.c"
   147     EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC"
   148 fi
   149 AC_ARG_ENABLE([music-wave],
   150 AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
   151               [], [enable_music_wave=yes])
   152 if test x$enable_music_wave = xyes; then
   153     SOURCES="$SOURCES $srcdir/wavestream.c"
   154     EXTRA_CFLAGS="$EXTRA_CFLAGS -DWAV_MUSIC"
   155 fi
   156 no_libmikmod=yes
   157 libmikmod_maj=3
   158 libmikmod_min=1
   159 libmikmod_rev=10
   160 libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
   161 AC_ARG_ENABLE([music-libmikmod],
   162 AC_HELP_STRING([--enable-music-libmikmod], [enable MOD music via external libmikmod [[default=no]]]),
   163               [], [enable_music_libmikmod=no])
   164 if test x$enable_music_libmikmod = xyes; then
   165     AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
   166     if test "$LIBMIKMOD_CONFIG" != "no" ; then
   167         no_libmikmod=no
   168         CFLAGS_SAVED="$CFLAGS"
   169         LIBS_SAVED="$LIBS"
   170         CFLAGS="$CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
   171         LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
   172         AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
   173         AC_TRY_RUN([
   174 #include "mikmod.h"
   175 #include "stdio.h"
   176 
   177 int main(int argc, char **argv)
   178 {
   179     long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
   180     /*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
   181     if(ver>=((maj<<16)|(min<<8)|(rev))) {
   182         printf("yes\n");
   183         return 0;
   184     }
   185     printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
   186     return 1;
   187 }
   188 ], EXTRA_CFLAGS="$EXTRA_CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`";EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`", CFLAGS="$CFLAGS_SAVED";LIBS="$LIBS_SAVED",
   189 [echo $ac_n "cross compiling; assumed OK... $ac_c"])
   190     fi
   191 fi
   192 
   193 AC_ARG_ENABLE([music-mod],
   194 AC_HELP_STRING([--enable-music-mod], [enable MOD music via mikmod [[default=yes]]]),
   195               [], [enable_music_mod=$no_libmikmod])
   196 if test x$enable_music_mod = xyes -a x$enable_music_libmikmod = xno; then
   197     EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_MUSIC -I\$(srcdir)/mikmod"
   198     SOURCES="$SOURCES $srcdir/mikmod/*.c"
   199 fi
   200 AC_ARG_ENABLE([music-midi],
   201 AC_HELP_STRING([--enable-music-midi], [enable MIDI music via timidity [[default=yes]]]),
   202               [], [enable_music_midi=yes])
   203 if test x$enable_music_midi = xyes; then
   204     EXTRA_CFLAGS="$EXTRA_CFLAGS -DMID_MUSIC"
   205     AC_ARG_ENABLE([music-timidity-midi],
   206 AC_HELP_STRING([--enable-music-timidity-midi], [enable timidity MIDI output [[default=yes]]]),
   207                   [], [enable_music_timidity_midi=yes])
   208     if test x$enable_music_timidity_midi = xyes; then
   209         EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_TIMIDITY_MIDI -I\$(srcdir)/timidity"
   210         SOURCES="$SOURCES $srcdir/timidity/*.c"
   211     fi
   212     AC_ARG_ENABLE([music-native-midi],
   213 AC_HELP_STRING([--enable-music-native-midi], [enable native MIDI music output [[default=yes]]]),
   214                   [], [enable_music_native_midi=yes])
   215     if test x$enable_music_native_midi = xyes; then
   216         use_music_native_midi=no
   217         case "$host" in
   218             *-*-cygwin* | *-*-mingw32*)
   219                 use_music_native_midi=yes
   220                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
   221                 ;;
   222             *-*-darwin*)
   223                 use_music_native_midi=yes
   224                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuickTime -Wl,-framework,CoreServices"
   225                 ;;
   226         esac
   227         if test x$use_music_native_midi = xyes; then
   228             EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
   229             SOURCES="$SOURCES $srcdir/native_midi/*.c"
   230         fi
   231     fi
   232     AC_ARG_ENABLE([music-native-midi-gpl],
   233 AC_HELP_STRING([--enable-music-native-midi-gpl], [enable native MIDI on UNIX using GPL code [[default=no]]]),
   234                   [], [enable_music_native_midi_gpl=no])
   235     if test x$enable_music_native_midi_gpl = xyes; then
   236         use_music_native_midi_gpl=no
   237         case "$host" in
   238             *-*-linux* | *-*-freebsd*)
   239                 use_music_native_midi_gpl=yes
   240                 ;;
   241         esac
   242         if test x$use_music_native_midi_gpl = xyes; then
   243             EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
   244             SOURCES="$SOURCES $srcdir/native_midi_gpl/*.c"
   245         fi
   246     fi
   247 fi
   248 AC_ARG_ENABLE([music-ogg],
   249 AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
   250               [], [enable_music_ogg=yes])
   251 AC_ARG_ENABLE(music-ogg-tremor,
   252 [  --enable-music-ogg-tremor   enable OGG music via libtremor [[default=no]]],
   253               [], enable_music_ogg_tremor=no)
   254 AC_ARG_ENABLE([music-ogg-shared],
   255 AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis support [[default=yes]]]),
   256               [], [enable_music_ogg_shared=yes])
   257 if test x$enable_music_ogg = xyes; then
   258     if test x$enable_music_ogg_tremor = xyes; then
   259         AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
   260         AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes])
   261         if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
   262             case "$host" in
   263                 *-*-darwin*)
   264                     ogg_lib=[`find_lib libvorbisidec*.dylib`]
   265                     if test x$ogg_lib = x; then
   266                         ogg_lib=[`find_lib libvorbisidec.[0-9]`]
   267                     fi
   268                     if test x$ogg_lib = x; then
   269                         ogg_lib=[`find_lib libvorbisidec.[0-9]*`]
   270                     fi
   271                     ;;
   272                 *-*-cygwin* | *-*-mingw32*)
   273                     ogg_lib=[`find_lib "vorbisidec*dll"`]
   274                     ;;
   275                 *)
   276                     ogg_lib=[`find_lib "libvorbisidec.so.[0-9]"`]
   277                     if test x$ogg_lib = x; then
   278                         ogg_lib=[`find_lib "libvorbisidec.so.[0-9]*"`]
   279                     fi
   280                     ;;
   281             esac
   282             SOURCES="$SOURCES $srcdir/*_ogg.c"
   283             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC -DOGG_USE_TREMOR"
   284             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   285                 echo "-- dynamic libvorbisidec -> $ogg_lib"
   286                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   287             else
   288                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec"
   289             fi
   290         fi
   291     else
   292         AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
   293         AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes])
   294         if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
   295             case "$host" in
   296                 *-*-darwin*)
   297                     ogg_lib=[`find_lib libvorbisfile*.dylib`]
   298                     ;;
   299                 *-*-cygwin* | *-*-mingw32*)
   300                     ogg_lib=[`find_lib "vorbisfile*dll"`]
   301                     ;;
   302                 *)
   303                     ogg_lib=[`find_lib "libvorbisfile.so.[0-9]"`]
   304                     if test x$ogg_lib = x; then
   305                         ogg_lib=[`find_lib "libvorbisfile.so.[0-9]*"`]
   306                     fi
   307                     ;;
   308             esac
   309             SOURCES="$SOURCES $srcdir/*_ogg.c"
   310             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC"
   311             if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   312                 echo "-- dynamic libvorbisfile -> $ogg_lib"
   313                 EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   314             else
   315                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis -logg"
   316             fi
   317         fi
   318     fi
   319 fi
   320 AC_ARG_ENABLE(music-mp3,
   321 [  --enable-music-mp3      enable MP3 music via smpeg [[default=yes]]],
   322               , enable_music_mp3=yes)
   323 if test x$enable_music_mp3 = xyes; then
   324     SMPEG_VERSION=0.4.3
   325     AM_PATH_SMPEG($SMPEG_VERSION, have_smpeg=yes, have_smpeg=no)
   326     if test x$have_smpeg = xyes; then
   327         AC_ARG_ENABLE([music-mp3-shared],
   328 AC_HELP_STRING([--enable-music-mp3-shared], [dynamically load MP3 support [[default=yes]]]),
   329                       [], [enable_music_mp3_shared=yes])
   330         case "$host" in
   331             *-*-darwin*)
   332                 smpeg_lib=[`find_lib libsmpeg*.dylib`]
   333                 ;;
   334             *-*-cygwin* | *-*-mingw32*)
   335                 smpeg_lib=[`find_lib "smpeg*dll"`]
   336                 ;;
   337             *)
   338                 smpeg_lib=[`find_lib "libsmpeg.so.[0-9]"`]
   339                 if test x$smpeg_lib = x; then
   340                     smpeg_lib=[`find_lib "libsmpeg.so.[0-9]*"`]
   341                 fi
   342                 ;;
   343         esac
   344         SOURCES="$SOURCES $srcdir/*_mp3.c"
   345         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC $SMPEG_CFLAGS"
   346         if test x$enable_music_mp3_shared = xyes && test x$smpeg_lib != x; then
   347             echo "-- dynamic libsmpeg -> $smpeg_lib"
   348             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_DYNAMIC=\\\"$smpeg_lib\\\""
   349         else
   350             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS"
   351         fi
   352     fi
   353 fi
   354 AC_ARG_ENABLE(music-mp3-mad-gpl,
   355 AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
   356                   [], [enable_music_mp3_mad_gpl=no])
   357 if test x$enable_music_mp3_mad_gpl = xyes; then
   358     AC_MSG_CHECKING(for libmad headers)
   359     have_libmad=no
   360     AC_TRY_COMPILE([
   361      #include "mad.h"
   362     ],[
   363     ],[
   364     have_libmad=yes
   365     ])
   366     AC_MSG_RESULT($have_libmad)
   367     if test x$have_libmad = xyes; then
   368         SOURCES="$SOURCES $srcdir/music_mad.c"
   369         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC"
   370         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
   371     fi
   372 fi
   373 
   374 OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   375 OBJECTS=`echo $OBJECTS | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
   376 
   377 dnl Expand the sources and objects needed to build the library
   378 AC_SUBST(ac_aux_dir)
   379 AC_SUBST(SOURCES)
   380 AC_SUBST(OBJECTS)
   381 AC_SUBST(BUILD_CFLAGS)
   382 AC_SUBST(EXTRA_CFLAGS)
   383 AC_SUBST(BUILD_LDFLAGS)
   384 AC_SUBST(EXTRA_LDFLAGS)
   385 AC_SUBST(EXE)
   386 AC_SUBST(WINDRES)
   387 AC_SUBST(SDL_CFLAGS)
   388 AC_SUBST(SDL_LIBS)
   389 
   390 AC_OUTPUT([
   391     Makefile SDL_mixer.spec SDL_mixer.qpg
   392 ], [
   393     : >build-deps
   394     if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
   395 ])