configure.in
author Ryan C. Gordon <icculus@icculus.org>
Tue, 13 Feb 2007 02:12:08 +0000
changeset 340 d85cb3c11238
parent 332 fb7c3d64963d
child 344 c7447a9dbf73
permissions -rw-r--r--
Let Mac OS X handle dynamic loading of Ogg Vorbis and SMPEG at runtime.

Fixes Bugzilla #277.
     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=7
    17 INTERFACE_AGE=5
    18 BINARY_AGE=7
    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 for path in /usr/local; do
    60     if test -d $path/include; then
    61         EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
    62     fi
    63     if test -d $path/lib; then
    64         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
    65     fi
    66 done
    67 CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
    68 CFLAGS="$CFLAGS $EXTRA_CFLAGS"
    69 LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
    70 
    71 dnl Check for tools
    72 AC_LIBTOOL_WIN32_DLL
    73 AC_PROG_LIBTOOL
    74 AC_PROG_CC
    75 AC_PROG_CXX
    76 AC_PROG_INSTALL
    77 AC_PROG_MAKE_SET
    78 
    79 dnl Check for compiler characteristics
    80 AC_C_CONST
    81 
    82 case "$host" in
    83     *-*-cygwin* | *-*-mingw32*)
    84         EXE=".exe"
    85         ;;
    86     *)
    87         EXE=""
    88         ;;
    89 esac
    90 
    91 # Standard C sources
    92 SOURCES="$SOURCES \
    93 $srcdir/effect_position.c \
    94 $srcdir/effect_stereoreverse.c \
    95 $srcdir/effects_internal.c \
    96 $srcdir/load_aiff.c \
    97 $srcdir/load_voc.c \
    98 $srcdir/mixer.c \
    99 $srcdir/music.c"
   100 
   101 dnl Check for SDL
   102 SDL_VERSION=1.2.10
   103 AM_PATH_SDL($SDL_VERSION,
   104             :,
   105 	    AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
   106 )
   107 EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
   108 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
   109 
   110 dnl Check command-line options
   111 
   112 AC_ARG_ENABLE([music-cmd],
   113 AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
   114               [], [enable_music_cmd=yes])
   115 if test x$enable_music_cmd = xyes; then
   116     SOURCES="$SOURCES $srcdir/music_cmd.c"
   117     EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC"
   118 fi
   119 AC_ARG_ENABLE([music-wave],
   120 AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
   121               [], [enable_music_wave=yes])
   122 if test x$enable_music_wave = xyes; then
   123     SOURCES="$SOURCES $srcdir/wavestream.c"
   124     EXTRA_CFLAGS="$EXTRA_CFLAGS -DWAV_MUSIC"
   125 fi
   126 no_libmikmod=yes
   127 libmikmod_maj=3
   128 libmikmod_min=1
   129 libmikmod_rev=10
   130 libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
   131 AC_ARG_ENABLE([music-libmikmod],
   132 AC_HELP_STRING([--enable-music-libmikmod], [enable MOD music via external libmikmod [[default=no]]]),
   133               [], [enable_music_libmikmod=no])
   134 if test x$enable_music_libmikmod = xyes; then
   135 	AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
   136 	if test "$LIBMIKMOD_CONFIG" != "no" ; then
   137 		no_libmikmod=no
   138 		CFLAGS_SAVED="$CFLAGS"
   139 		LIBS_SAVED="$LIBS"
   140 		CFLAGS="$CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
   141 		LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
   142 		AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
   143 		AC_TRY_RUN([
   144 #include "mikmod.h"
   145 #include "stdio.h"
   146 
   147 int main(int argc, char **argv)
   148 {
   149 	long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
   150 	/*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
   151 	if(ver>=((maj<<16)|(min<<8)|(rev))) {
   152 		printf("yes\n");
   153 		return 0;
   154 	}
   155 	printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
   156 	return 1;
   157 }
   158 ], EXTRA_CFLAGS="$EXTRA_CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`";EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`", CFLAGS="$CFLAGS_SAVED";LIBS="$LIBS_SAVED",
   159 [echo $ac_n "cross compiling; assumed OK... $ac_c"])
   160 	fi
   161 fi
   162 
   163 AC_ARG_ENABLE([music-mod],
   164 AC_HELP_STRING([--enable-music-mod], [enable MOD music via mikmod [[default=yes]]]),
   165               [], [enable_music_mod=$no_libmikmod])
   166 if test x$enable_music_mod = xyes -a x$enable_music_libmikmod = xno; then
   167     EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_MUSIC -I\$(srcdir)/mikmod"
   168     SOURCES="$SOURCES $srcdir/mikmod/*.c"
   169 fi
   170 AC_ARG_ENABLE([music-midi],
   171 AC_HELP_STRING([--enable-music-midi], [enable MIDI music via timidity [[default=yes]]]),
   172               [], [enable_music_midi=yes])
   173 if test x$enable_music_midi = xyes; then
   174     EXTRA_CFLAGS="$EXTRA_CFLAGS -DMID_MUSIC"
   175     AC_ARG_ENABLE([music-timidity-midi],
   176 AC_HELP_STRING([--enable-music-timidity-midi], [enable timidity MIDI output [[default=yes]]]),
   177                   [], [enable_music_timidity_midi=yes])
   178     if test x$enable_music_timidity_midi = xyes; then
   179         EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_TIMIDITY_MIDI -I\$(srcdir)/timidity"
   180         SOURCES="$SOURCES $srcdir/timidity/*.c"
   181     fi
   182     AC_ARG_ENABLE([music-native-midi],
   183 AC_HELP_STRING([--enable-music-native-midi], [enable native MIDI music output [[default=yes]]]),
   184                   [], [enable_music_native_midi=yes])
   185     if test x$enable_music_native_midi = xyes; then
   186         use_music_native_midi=no
   187         case "$host" in
   188             *-*-cygwin* | *-*-mingw32*)
   189                 use_music_native_midi=yes
   190                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
   191                 ;;
   192             *-*-darwin*)
   193                 use_music_native_midi=yes
   194                 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuickTime"
   195                 ;;
   196         esac
   197         if test x$use_music_native_midi = xyes; then
   198             EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
   199             SOURCES="$SOURCES $srcdir/native_midi/*.c"
   200         fi
   201     fi
   202     AC_ARG_ENABLE([music-native-midi-gpl],
   203 AC_HELP_STRING([--enable-music-native-midi-gpl], [enable native MIDI on UNIX using GPL code [[default=no]]]),
   204                   [], [enable_music_native_midi_gpl=no])
   205     if test x$enable_music_native_midi_gpl = xyes; then
   206         use_music_native_midi_gpl=no
   207         case "$host" in
   208             *-*-linux* | *-*-freebsd*)
   209                 use_music_native_midi_gpl=yes
   210                 ;;
   211         esac
   212         if test x$use_music_native_midi_gpl = xyes; then
   213             EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
   214             SOURCES="$SOURCES $srcdir/native_midi_gpl/*.c"
   215         fi
   216     fi
   217 fi
   218 AC_ARG_ENABLE([music-ogg],
   219 AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
   220               [], [enable_music_ogg=yes])
   221 if test x$enable_music_ogg = xyes; then
   222     AC_MSG_CHECKING(for Ogg Vorbis headers and libraries)
   223     have_vorbis=no
   224     AC_TRY_COMPILE([
   225      #include <vorbis/vorbisfile.h>
   226     ],[
   227     ],[
   228     have_vorbis=yes
   229     ])
   230     AC_MSG_RESULT($have_vorbis)
   231     if test x$have_vorbis = xyes; then
   232         AC_ARG_ENABLE([music-ogg-shared],
   233 AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis support [[default=yes]]]),
   234                       [], [enable_music_ogg_shared=yes])
   235         case "$host" in
   236             *-*-darwin*)
   237                 for path in /usr/lib /usr/local/lib; do
   238                     if test x$ogg_lib = x; then
   239                         ogg_lib=[`ls -- $path/libvorbisfile.[0-9].dylib 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
   240                     fi
   241                 done
   242                 ;;
   243             *-*-cygwin* | *-*-mingw32*)
   244                 ogg_lib='vorbisfile.dll'
   245                 ;;
   246             *)
   247                 for path in /usr/lib /usr/local/lib; do
   248                     if test x$ogg_lib = x; then
   249                         ogg_lib=[`ls -- $path/libvorbisfile.so.[0-9] 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
   250                     fi
   251                 done
   252                 ;;
   253         esac
   254         SOURCES="$SOURCES $srcdir/*_ogg.c"
   255         EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC"
   256         if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
   257             echo "-- dynamic libvorbisfile -> $ogg_lib"
   258             EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
   259         else
   260             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis -logg"
   261         fi
   262     fi
   263 fi
   264 AC_ARG_ENABLE(music-mp3,
   265 [  --enable-music-mp3      enable MP3 music via smpeg [[default=yes]]],
   266               , enable_music_mp3=yes)
   267 if test x$enable_music_mp3 = xyes; then
   268     SMPEG_VERSION=0.4.3
   269     AM_PATH_SMPEG($SMPEG_VERSION, have_smpeg=yes, have_smpeg=no)
   270     if test x$have_smpeg = xyes; then
   271         AC_ARG_ENABLE([music-mp3-shared],
   272 AC_HELP_STRING([--enable-music-mp3-shared], [dynamically load MP3 support [[default=yes]]]),
   273                       [], [enable_music_mp3_shared=yes])
   274         case "$host" in
   275             *-*-darwin*)
   276                 for path in /usr/lib /usr/local/lib; do
   277                     if test x$smpeg_lib = x; then
   278                         smpeg_lib=[`ls -- $path/libsmpeg*.[0-9].dylib 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
   279                     fi
   280                 done
   281                 ;;
   282             *-*-cygwin* | *-*-mingw32*)
   283                 smpeg_lib='smpeg.dll'
   284                 ;;
   285             *)
   286                 for path in /usr/lib /usr/local/lib; do
   287                     if test x$smpeg_lib = x; then
   288                         smpeg_lib=[`ls -- $path/libsmpeg*.so.[0-9] 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
   289                     fi
   290                 done
   291                 ;;
   292         esac
   293         SOURCES="$SOURCES $srcdir/*_mp3.c"
   294         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC $SMPEG_CFLAGS"
   295         if test x$enable_music_mp3_shared = xyes && test x$smpeg_lib != x; then
   296             echo "-- dynamic libsmpeg -> $smpeg_lib"
   297             EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_DYNAMIC=\\\"$smpeg_lib\\\""
   298         else
   299             EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS"
   300         fi
   301     fi
   302 fi
   303 
   304 OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   305 
   306 dnl Expand the sources and objects needed to build the library
   307 AC_SUBST(ac_aux_dir)
   308 AC_SUBST(SOURCES)
   309 AC_SUBST(OBJECTS)
   310 AC_SUBST(BUILD_CFLAGS)
   311 AC_SUBST(EXTRA_CFLAGS)
   312 AC_SUBST(BUILD_LDFLAGS)
   313 AC_SUBST(EXTRA_LDFLAGS)
   314 AC_SUBST(EXE)
   315 AC_SUBST(SDL_CFLAGS)
   316 AC_SUBST(SDL_LIBS)
   317 
   318 AC_OUTPUT([
   319     Makefile SDL_mixer.spec SDL_mixer.qpg
   320 ], [
   321     : >build-deps
   322     if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
   323 ])