configure.in
author Sam Lantinga <slouken@libsdl.org>
Fri, 12 May 2006 09:42:24 +0000
changeset 314 8c791a6ba872
parent 313 db79bfffb09b
child 332 fb7c3d64963d
permissions -rw-r--r--
Added support for dynamically loading SMPEG library
slouken@0
     1
dnl Process this file with autoconf to produce a configure script.
slouken@0
     2
AC_INIT(README)
slouken@0
     3
slouken@0
     4
dnl Set various version strings - taken gratefully from the GTk sources
slouken@0
     5
slouken@0
     6
# Making releases:
slouken@0
     7
#   MICRO_VERSION += 1;
slouken@0
     8
#   INTERFACE_AGE += 1;
slouken@0
     9
#   BINARY_AGE += 1;
slouken@0
    10
# if any functions have been added, set INTERFACE_AGE to 0.
slouken@0
    11
# if backwards compatibility has been broken,
slouken@0
    12
# set BINARY_AGE and INTERFACE_AGE to 0.
slouken@294
    13
#
slouken@0
    14
MAJOR_VERSION=1
slouken@81
    15
MINOR_VERSION=2
slouken@255
    16
MICRO_VERSION=7
slouken@255
    17
INTERFACE_AGE=5
slouken@255
    18
BINARY_AGE=7
slouken@0
    19
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
slouken@0
    20
slouken@0
    21
AC_SUBST(MAJOR_VERSION)
slouken@0
    22
AC_SUBST(MINOR_VERSION)
slouken@0
    23
AC_SUBST(MICRO_VERSION)
slouken@0
    24
AC_SUBST(INTERFACE_AGE)
slouken@0
    25
AC_SUBST(BINARY_AGE)
slouken@0
    26
AC_SUBST(VERSION)
slouken@0
    27
slouken@0
    28
# libtool versioning
slouken@0
    29
LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
slouken@0
    30
LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
slouken@0
    31
LT_REVISION=$INTERFACE_AGE
slouken@0
    32
LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
slouken@0
    33
slouken@0
    34
AC_SUBST(LT_RELEASE)
slouken@0
    35
AC_SUBST(LT_CURRENT)
slouken@0
    36
AC_SUBST(LT_REVISION)
slouken@0
    37
AC_SUBST(LT_AGE)
slouken@0
    38
slouken@289
    39
dnl Detect the canonical build and host environments
slouken@294
    40
AC_CONFIG_AUX_DIRS($srcdir/build-scripts)
slouken@289
    41
AC_CANONICAL_HOST
slouken@68
    42
slouken@294
    43
dnl Set up the compiler and linker flags
slouken@294
    44
case "$host" in
slouken@294
    45
    *-*-cygwin*)
slouken@294
    46
        # We build SDL on cygwin without the UNIX emulation layer
slouken@294
    47
        BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
slouken@294
    48
        BASE_LDFLAGS="-mno-cygwin"
slouken@294
    49
        ;;
slouken@294
    50
    *)
slouken@294
    51
        BASE_CFLAGS="-D_GNU_SOURCE=1"
slouken@294
    52
        BASE_LDFLAGS=""
slouken@294
    53
        ;;
slouken@294
    54
esac
slouken@294
    55
BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
slouken@294
    56
EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
slouken@294
    57
BUILD_LDFLAGS="$LDFLAGS"
slouken@294
    58
EXTRA_LDFLAGS="$BASE_LDFLAGS"
slouken@294
    59
for path in /usr/local; do
slouken@294
    60
    if test -d $path/include; then
slouken@294
    61
        EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
slouken@294
    62
    fi
slouken@294
    63
    if test -d $path/lib; then
slouken@294
    64
        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
slouken@294
    65
    fi
slouken@294
    66
done
slouken@294
    67
CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
slouken@294
    68
CFLAGS="$CFLAGS $EXTRA_CFLAGS"
slouken@294
    69
LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
slouken@91
    70
slouken@0
    71
dnl Check for tools
slouken@294
    72
AC_LIBTOOL_WIN32_DLL
slouken@294
    73
AC_PROG_LIBTOOL
slouken@294
    74
AC_PROG_CC
slouken@294
    75
AC_PROG_CXX
slouken@294
    76
AC_PROG_INSTALL
slouken@294
    77
AC_PROG_MAKE_SET
slouken@0
    78
slouken@294
    79
dnl Check for compiler characteristics
slouken@294
    80
AC_C_CONST
slouken@0
    81
slouken@289
    82
case "$host" in
slouken@294
    83
    *-*-cygwin* | *-*-mingw32*)
slouken@294
    84
        EXE=".exe"
slouken@6
    85
        ;;
slouken@294
    86
    *)
slouken@294
    87
        EXE=""
slouken@208
    88
        ;;
slouken@6
    89
esac
slouken@6
    90
slouken@294
    91
# Standard C sources
slouken@294
    92
SOURCES="$SOURCES \
slouken@294
    93
$srcdir/effect_position.c \
slouken@294
    94
$srcdir/effect_stereoreverse.c \
slouken@294
    95
$srcdir/effects_internal.c \
slouken@294
    96
$srcdir/load_aiff.c \
slouken@294
    97
$srcdir/load_voc.c \
slouken@294
    98
$srcdir/mixer.c \
slouken@294
    99
$srcdir/music.c"
slouken@294
   100
slouken@20
   101
dnl Check for SDL
slouken@308
   102
SDL_VERSION=1.2.10
slouken@20
   103
AM_PATH_SDL($SDL_VERSION,
slouken@20
   104
            :,
slouken@20
   105
	    AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
slouken@20
   106
)
slouken@294
   107
EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
slouken@294
   108
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
slouken@0
   109
slouken@0
   110
dnl Check command-line options
slouken@91
   111
slouken@312
   112
AC_ARG_ENABLE([music-cmd],
slouken@312
   113
AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
slouken@312
   114
              [], [enable_music_cmd=yes])
slouken@0
   115
if test x$enable_music_cmd = xyes; then
slouken@294
   116
    SOURCES="$SOURCES $srcdir/music_cmd.c"
slouken@294
   117
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC"
slouken@0
   118
fi
slouken@312
   119
AC_ARG_ENABLE([music-wave],
slouken@312
   120
AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
slouken@312
   121
              [], [enable_music_wave=yes])
slouken@0
   122
if test x$enable_music_wave = xyes; then
slouken@294
   123
    SOURCES="$SOURCES $srcdir/wavestream.c"
slouken@294
   124
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DWAV_MUSIC"
slouken@0
   125
fi
slouken@257
   126
no_libmikmod=yes
slouken@249
   127
libmikmod_maj=3
slouken@249
   128
libmikmod_min=1
slouken@249
   129
libmikmod_rev=10
slouken@249
   130
libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
slouken@312
   131
AC_ARG_ENABLE([music-libmikmod],
slouken@312
   132
AC_HELP_STRING([--enable-music-libmikmod], [enable MOD music via external libmikmod [[default=no]]]),
slouken@312
   133
              [], [enable_music_libmikmod=no])
slouken@249
   134
if test x$enable_music_libmikmod = xyes; then
slouken@249
   135
	AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
slouken@257
   136
	if test "$LIBMIKMOD_CONFIG" != "no" ; then
slouken@257
   137
		no_libmikmod=no
slouken@249
   138
		CFLAGS_SAVED="$CFLAGS"
slouken@249
   139
		LIBS_SAVED="$LIBS"
slouken@249
   140
		CFLAGS="$CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`"
slouken@249
   141
		LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
slouken@249
   142
		AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
slouken@249
   143
		AC_TRY_RUN([
slouken@249
   144
#include "mikmod.h"
slouken@249
   145
#include "stdio.h"
slouken@249
   146
slouken@249
   147
int main(int argc, char **argv)
slouken@249
   148
{
slouken@249
   149
	long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
slouken@249
   150
	/*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
slouken@249
   151
	if(ver>=((maj<<16)|(min<<8)|(rev))) {
slouken@249
   152
		printf("yes\n");
slouken@249
   153
		return 0;
slouken@249
   154
	}
slouken@249
   155
	printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
slouken@249
   156
	return 1;
slouken@249
   157
}
slouken@257
   158
],,CFLAGS="$CFLAGS_SAVED";LIBS="$LIBS_SAVED",
slouken@249
   159
[echo $ac_n "cross compiling; assumed OK... $ac_c"])
slouken@249
   160
	fi
slouken@249
   161
fi
slouken@249
   162
slouken@312
   163
AC_ARG_ENABLE([music-mod],
slouken@312
   164
AC_HELP_STRING([--enable-music-mod], [enable MOD music via mikmod [[default=yes]]]),
slouken@312
   165
              [], [enable_music_mod=$no_libmikmod])
slouken@1
   166
if test x$enable_music_mod = xyes; then
slouken@294
   167
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_MUSIC -I\$(srcdir)/mikmod"
slouken@294
   168
    SOURCES="$SOURCES $srcdir/mikmod/*.c"
slouken@1
   169
fi
slouken@312
   170
AC_ARG_ENABLE([music-midi],
slouken@312
   171
AC_HELP_STRING([--enable-music-midi], [enable MIDI music via timidity [[default=yes]]]),
slouken@312
   172
              [], [enable_music_midi=yes])
slouken@0
   173
if test x$enable_music_midi = xyes; then
slouken@294
   174
    EXTRA_CFLAGS="$EXTRA_CFLAGS -DMID_MUSIC"
slouken@312
   175
    AC_ARG_ENABLE([music-timidity-midi],
slouken@312
   176
AC_HELP_STRING([--enable-music-timidity-midi], [enable timidity MIDI output [[default=yes]]]),
slouken@312
   177
                  [], [enable_music_timidity_midi=yes])
slouken@106
   178
    if test x$enable_music_timidity_midi = xyes; then
slouken@294
   179
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_TIMIDITY_MIDI -I\$(srcdir)/timidity"
slouken@294
   180
        SOURCES="$SOURCES $srcdir/timidity/*.c"
slouken@106
   181
    fi
slouken@312
   182
    AC_ARG_ENABLE([music-native-midi],
slouken@312
   183
AC_HELP_STRING([--enable-music-native-midi], [enable native MIDI music output [[default=yes]]]),
slouken@312
   184
                  [], [enable_music_native_midi=yes])
slouken@99
   185
    if test x$enable_music_native_midi = xyes; then
slouken@99
   186
        use_music_native_midi=no
slouken@289
   187
        case "$host" in
slouken@99
   188
            *-*-cygwin* | *-*-mingw32*)
slouken@99
   189
                use_music_native_midi=yes
slouken@294
   190
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
slouken@99
   191
                ;;
slouken@107
   192
            *-*-darwin*)
slouken@107
   193
                use_music_native_midi=yes
slouken@294
   194
                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,QuickTime"
slouken@107
   195
                ;;
slouken@99
   196
        esac
slouken@99
   197
        if test x$use_music_native_midi = xyes; then
slouken@294
   198
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
slouken@294
   199
            SOURCES="$SOURCES $srcdir/native_midi/*.c"
slouken@99
   200
        fi
slouken@99
   201
    fi
slouken@312
   202
    AC_ARG_ENABLE([music-native-midi-gpl],
slouken@312
   203
AC_HELP_STRING([--enable-music-native-midi-gpl], [enable native MIDI on UNIX using GPL code [[default=no]]]),
slouken@312
   204
                  [], [enable_music_native_midi_gpl=no])
slouken@160
   205
    if test x$enable_music_native_midi_gpl = xyes; then
slouken@160
   206
        use_music_native_midi_gpl=no
slouken@289
   207
        case "$host" in
slouken@160
   208
            *-*-linux* | *-*-freebsd*)
slouken@160
   209
                use_music_native_midi_gpl=yes
slouken@160
   210
                ;;
slouken@160
   211
        esac
slouken@160
   212
        if test x$use_music_native_midi_gpl = xyes; then
slouken@294
   213
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi"
slouken@294
   214
            SOURCES="$SOURCES $srcdir/native_midi_gpl/*.c"
slouken@160
   215
        fi
slouken@160
   216
    fi
slouken@0
   217
fi
slouken@312
   218
AC_ARG_ENABLE([music-ogg],
slouken@312
   219
AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
slouken@312
   220
              [], [enable_music_ogg=yes])
slouken@63
   221
if test x$enable_music_ogg = xyes; then
slouken@63
   222
    AC_MSG_CHECKING(for Ogg Vorbis headers and libraries)
slouken@63
   223
    have_vorbis=no
slouken@63
   224
    AC_TRY_COMPILE([
slouken@63
   225
     #include <vorbis/vorbisfile.h>
slouken@63
   226
    ],[
slouken@63
   227
    ],[
slouken@63
   228
    have_vorbis=yes
slouken@63
   229
    ])
slouken@63
   230
    AC_MSG_RESULT($have_vorbis)
slouken@63
   231
    if test x$have_vorbis = xyes; then
slouken@312
   232
        AC_ARG_ENABLE([music-ogg-shared],
slouken@312
   233
AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis support [[default=yes]]]),
slouken@312
   234
                      [], [enable_music_ogg_shared=yes])
slouken@312
   235
        case "$host" in
slouken@312
   236
            *-*-darwin*) # FIXME when Mac OS X ships with Ogg Vorbis
slouken@312
   237
                ogg_lib=''
slouken@312
   238
                ;;
slouken@312
   239
            *-*-cygwin* | *-*-mingw32*)
slouken@312
   240
                ogg_lib='vorbisfile.dll'
slouken@312
   241
                ;;
slouken@312
   242
            *)
slouken@312
   243
                for path in /usr/lib /usr/local/lib; do
slouken@312
   244
                    if test x$ogg_lib = x; then
slouken@312
   245
                        ogg_lib=[`ls -- $path/libvorbisfile.so.[0-9] 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
slouken@312
   246
                    fi
slouken@312
   247
                done
slouken@312
   248
                ;;
slouken@312
   249
        esac
slouken@312
   250
        SOURCES="$SOURCES $srcdir/*_ogg.c"
slouken@294
   251
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC"
slouken@312
   252
        if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
slouken@312
   253
            echo "-- dynamic libvorbisfile -> $ogg_lib"
slouken@312
   254
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
slouken@312
   255
        else
slouken@312
   256
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis -logg"
slouken@312
   257
        fi
slouken@63
   258
    fi
slouken@63
   259
fi
slouken@0
   260
AC_ARG_ENABLE(music-mp3,
slouken@312
   261
[  --enable-music-mp3      enable MP3 music via smpeg [[default=yes]]],
slouken@0
   262
              , enable_music_mp3=yes)
slouken@0
   263
if test x$enable_music_mp3 = xyes; then
slouken@83
   264
    SMPEG_VERSION=0.4.3
slouken@83
   265
    AM_PATH_SMPEG($SMPEG_VERSION, have_smpeg=yes, have_smpeg=no)
slouken@0
   266
    if test x$have_smpeg = xyes; then
slouken@313
   267
        AC_ARG_ENABLE([music-mp3-shared],
slouken@314
   268
AC_HELP_STRING([--enable-music-mp3-shared], [dynamically load MP3 support [[default=yes]]]),
slouken@314
   269
                      [], [enable_music_mp3_shared=yes])
slouken@313
   270
        case "$host" in
slouken@313
   271
            *-*-darwin*)
slouken@313
   272
                smpeg_lib=''
slouken@313
   273
                ;;
slouken@313
   274
            *-*-cygwin* | *-*-mingw32*)
slouken@313
   275
                smpeg_lib='smpeg.dll'
slouken@313
   276
                ;;
slouken@313
   277
            *)
slouken@313
   278
                for path in /usr/lib /usr/local/lib; do
slouken@313
   279
                    if test x$smpeg_lib = x; then
slouken@313
   280
                        smpeg_lib=[`ls -- $path/libsmpeg*.so.[0-9] 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
slouken@313
   281
                    fi
slouken@313
   282
                done
slouken@313
   283
                ;;
slouken@313
   284
        esac
slouken@314
   285
        SOURCES="$SOURCES $srcdir/*_mp3.c"
slouken@294
   286
        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC $SMPEG_CFLAGS"
slouken@313
   287
        if test x$enable_music_mp3_shared = xyes && test x$smpeg_lib != x; then
slouken@313
   288
            echo "-- dynamic libsmpeg -> $smpeg_lib"
slouken@313
   289
            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_DYNAMIC=\\\"$smpeg_lib\\\""
slouken@313
   290
        else
slouken@313
   291
            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS"
slouken@313
   292
        fi
slouken@0
   293
    fi
slouken@0
   294
fi
slouken@0
   295
slouken@294
   296
OBJECTS=`echo $SOURCES | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
slouken@1
   297
slouken@294
   298
dnl Expand the sources and objects needed to build the library
slouken@294
   299
AC_SUBST(ac_aux_dir)
slouken@294
   300
AC_SUBST(SOURCES)
slouken@294
   301
AC_SUBST(OBJECTS)
slouken@294
   302
AC_SUBST(BUILD_CFLAGS)
slouken@294
   303
AC_SUBST(EXTRA_CFLAGS)
slouken@294
   304
AC_SUBST(BUILD_LDFLAGS)
slouken@294
   305
AC_SUBST(EXTRA_LDFLAGS)
slouken@294
   306
AC_SUBST(EXE)
slouken@294
   307
AC_SUBST(SDL_CFLAGS)
slouken@294
   308
AC_SUBST(SDL_LIBS)
slouken@206
   309
slouken@0
   310
AC_OUTPUT([
slouken@294
   311
    Makefile SDL_mixer.spec SDL_mixer.qpg
slouken@294
   312
], [
slouken@294
   313
    : >build-deps
slouken@294
   314
    if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
slouken@0
   315
])