configure.in
author Sam Lantinga <slouken@libsdl.org>
Sun, 30 Apr 2006 20:27:33 +0000
changeset 294 58eb208474e0
parent 289 e893c155075b
child 303 e851b5783fdf
permissions -rw-r--r--
Removed automake dependency, to allow Universal binaries on Mac OS X
     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.4
   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 [  --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 [  --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 [  --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 ],,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 [  --enable-music-mod      enable MOD music via mikmod [default=yes]],
   165 , enable_music_mod=$no_libmikmod)
   166 if test x$enable_music_mod = xyes; 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 [  --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 [  --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 [  --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 [  --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 [  --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         SOURCES="$SOURCE $srcdir/load_ogg.c $srcdir/music_ogg.c"
   233         EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC"
   234         EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis -logg"
   235     fi
   236 fi
   237 AC_ARG_ENABLE(music-mp3,
   238 [  --enable-music-mp3      enable MP3 music via smpeg [default=yes]],
   239               , enable_music_mp3=yes)
   240 if test x$enable_music_mp3 = xyes; then
   241     SMPEG_VERSION=0.4.3
   242     AM_PATH_SMPEG($SMPEG_VERSION, have_smpeg=yes, have_smpeg=no)
   243     if test x$have_smpeg = xyes; then
   244         EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC $SMPEG_CFLAGS"
   245         EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS"
   246     fi
   247 fi
   248 
   249 OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
   250 
   251 dnl Expand the sources and objects needed to build the library
   252 AC_SUBST(ac_aux_dir)
   253 AC_SUBST(SOURCES)
   254 AC_SUBST(OBJECTS)
   255 AC_SUBST(BUILD_CFLAGS)
   256 AC_SUBST(EXTRA_CFLAGS)
   257 AC_SUBST(BUILD_LDFLAGS)
   258 AC_SUBST(EXTRA_LDFLAGS)
   259 AC_SUBST(EXE)
   260 AC_SUBST(SDL_CFLAGS)
   261 AC_SUBST(SDL_LIBS)
   262 
   263 AC_OUTPUT([
   264     Makefile SDL_mixer.spec SDL_mixer.qpg
   265 ], [
   266     : >build-deps
   267     if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
   268 ])