1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(README.txt)
3AC_CONFIG_AUX_DIR(build-scripts)
4
5dnl Set various version strings - taken gratefully from the GTk sources
6
7# Making releases:
8#   MICRO_VERSION += 1;
9#   INTERFACE_AGE += 1;
10#   BINARY_AGE += 1;
11# if any functions have been added, set INTERFACE_AGE to 0.
12# if backwards compatibility has been broken,
13# set BINARY_AGE and INTERFACE_AGE to 0.
14#
15MAJOR_VERSION=2
16MINOR_VERSION=0
17MICRO_VERSION=4
18INTERFACE_AGE=2
19BINARY_AGE=4
20VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
21
22AC_SUBST(MAJOR_VERSION)
23AC_SUBST(MINOR_VERSION)
24AC_SUBST(MICRO_VERSION)
25AC_SUBST(INTERFACE_AGE)
26AC_SUBST(BINARY_AGE)
27AC_SUBST(VERSION)
28
29# libtool versioning
30LT_INIT([win32-dll])
31
32LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION
33LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE`
34LT_REVISION=$INTERFACE_AGE
35LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE`
36m4_pattern_allow([^LT_])
37
38AC_SUBST(LT_RELEASE)
39AC_SUBST(LT_CURRENT)
40AC_SUBST(LT_REVISION)
41AC_SUBST(LT_AGE)
42
43dnl Detect the canonical build and host environments
44AC_CONFIG_AUX_DIRS($srcdir/build-scripts)
45dnl AC_CANONICAL_HOST
46
47dnl Check for tools
48AC_PROG_LIBTOOL
49AC_PROG_CC
50AC_PROG_INSTALL
51AC_PROG_MAKE_SET
52if test -z "$host_alias"; then
53    hostaliaswindres=
54else
55    hostaliaswindres="$host_alias-windres"
56fi
57AC_CHECK_PROGS(WINDRES, [windres $hostaliaswindres $host_os-windres])
58
59dnl Set up the compiler and linker flags
60case "$host" in
61    *-*-cygwin*)
62        # We build SDL on cygwin without the UNIX emulation layer
63        BASE_CFLAGS="-I/usr/include/mingw -mno-cygwin"
64        BASE_LDFLAGS="-mno-cygwin"
65        ;;
66    *)
67        BASE_CFLAGS="-D_GNU_SOURCE=1"
68        BASE_LDFLAGS=""
69        ;;
70esac
71BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
72EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
73BUILD_LDFLAGS="$LDFLAGS"
74EXTRA_LDFLAGS="$BASE_LDFLAGS"
75## These are common directories to find software packages
76#for path in /usr/freeware /usr/pkg /usr/local; do
77#    if test -d $path/include; then
78#        EXTRA_CFLAGS="$EXTRA_CFLAGS -I$path/include"
79#    fi
80#    if test -d $path/lib; then
81#        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$path/lib"
82#    fi
83#done
84CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
85CFLAGS="$CFLAGS $EXTRA_CFLAGS"
86LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
87
88dnl Check for compiler characteristics
89AC_C_CONST
90
91dnl See whether we can use gcc style dependency tracking
92AC_ARG_ENABLE(dependency-tracking,
93AC_HELP_STRING([--enable-dependency-tracking],
94               [Use gcc -MMD -MT dependency tracking [[default=yes]]]),
95              , enable_dependency_tracking=yes)
96if test x$enable_dependency_tracking = xyes; then
97    have_gcc_mmd_mt=no
98    AC_MSG_CHECKING(for GCC -MMD -MT option)
99    AC_TRY_COMPILE([
100    #if !defined(__GNUC__) || __GNUC__ < 3
101    #error Dependency tracking requires GCC 3.0 or newer
102    #endif
103    ],[
104    ],[
105    have_gcc_mmd_mt=yes
106    ])
107    AC_MSG_RESULT($have_gcc_mmd_mt)
108
109    if test x$have_gcc_mmd_mt = xyes; then
110        DEPENDENCY_TRACKING_OPTIONS="-MMD -MT \$@"
111    fi
112fi
113
114case "$host" in
115    *mingw32ce*)
116        #VERSION_SOURCES="$srcdir/version.rc"
117        EXE=".exe"
118    ;;
119    *-*-cygwin* | *-*-mingw32*)
120        VERSION_SOURCES="$srcdir/version.rc"
121        EXE=".exe"
122        if test "$build" != "$host"; then # cross-compiling
123            # Default cross-compile location
124            ac_default_prefix=/usr/local/cross-tools/$host
125        else
126            # Look for the location of the tools and install there
127            if test "$BUILD_PREFIX" != ""; then
128                ac_default_prefix=$BUILD_PREFIX
129            fi
130        fi
131        ;;
132    *)
133        EXE=""
134        ;;
135esac
136
137# Standard C sources
138SOURCES=`ls $srcdir/*.c | fgrep -v playwave.c | fgrep -v playmus.c`
139
140dnl set this to use on systems that use lib64 instead of lib
141base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
142
143dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
144dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
145CheckVisibilityHidden()
146{
147    AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
148    have_gcc_fvisibility=no
149
150    visibility_CFLAGS="-fvisibility=hidden"
151    save_CFLAGS="$CFLAGS"
152    CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror"
153    AC_TRY_COMPILE([
154    #if !defined(__GNUC__) || __GNUC__ < 4
155    #error SDL only uses visibility attributes in GCC 4 or newer
156    #endif
157    ],[
158    ],[
159    have_gcc_fvisibility=yes
160    ])
161    AC_MSG_RESULT($have_gcc_fvisibility)
162    CFLAGS="$save_CFLAGS"
163
164    if test x$have_gcc_fvisibility = xyes; then
165        EXTRA_CFLAGS="$EXTRA_CFLAGS $visibility_CFLAGS"
166    fi
167}
168
169
170dnl Function to find a library in the compiler search path
171find_lib()
172{
173    gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
174    gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
175    env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
176    if test "$cross_compiling" = yes; then
177        host_lib_path=""
178    else
179        host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
180    fi
181    for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
182        lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`]
183        if test x$lib != x; then
184            echo $lib
185            return
186        fi
187    done
188}
189
190dnl Check for SDL
191SDL_VERSION=2.0.7
192AM_PATH_SDL2($SDL_VERSION,
193            :,
194            AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
195)
196EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
197EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
198
199dnl Check for math library
200AC_CHECK_LIB(m, pow, [LIBM="-lm"])
201
202AC_CHECK_HEADERS([signal.h], [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SIGNAL_H"])
203AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"])
204
205dnl Check command-line options
206
207CheckVisibilityHidden
208
209AC_ARG_ENABLE([music-cmd],
210AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
211              [], [enable_music_cmd=detect])
212if test "x$enable_music_cmd" != xno; then
213    AC_CHECK_FUNCS([fork vfork])
214    if test "x$ac_cv_func_fork" = "xyes"; then
215        EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK"
216    elif test "x$ac_cv_func_vfork" = "xyes"; then
217        EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK"
218    elif test "x$enable_music_cmd" = "xyes"; then
219        AC_MSG_ERROR([external music player not available on your platform])
220    else
221        enable_music_cmd=no
222    fi
223    if test "x$enable_music_cmd" != xno; then
224        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD"
225    fi
226fi
227
228AC_ARG_ENABLE([music-wave],
229AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]),
230              [], [enable_music_wave=yes])
231if test x$enable_music_wave = xyes; then
232    EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV"
233fi
234
235AC_ARG_ENABLE([music-mod],
236AC_HELP_STRING([--enable-music-mod], [enable MOD music [[default=yes]]]),
237              [], [enable_music_mod=yes])
238
239AC_ARG_ENABLE([music-mod-modplug],
240AC_HELP_STRING([--enable-music-mod-modplug], [enable MOD music via modplug [[default=yes]]]),
241              [], [enable_music_mod_modplug=yes])
242AC_ARG_ENABLE([music-mod-modplug-shared],
243AC_HELP_STRING([--enable-music-mod-modplug-shared], [dynamically load modplug library [[default=yes]]]),
244              [], [enable_music_mod_modplug_shared=yes])
245if test x$enable_music_mod = xyes -a x$enable_music_mod_modplug = xyes; then
246    PKG_CHECK_MODULES([MODPLUG], [libmodplug >= 0.8.8], [dnl
247            have_libmodplug_hdr=yes
248            have_libmodplug_lib=yes
249        ], [dnl
250            AC_CHECK_HEADER([libmodplug/modplug.h], [have_libmodplug_hdr=yes])
251            AC_CHECK_LIB([modplug], [ModPlug_Load], [have_libmodplug_lib=yes;MODPLUG_LIBS="-lmodplug"])
252        ])
253
254    if test x$have_libmodplug_hdr = xyes -a x$have_libmodplug_lib = xyes; then
255        have_libmodplug=yes
256        case "$host" in
257            *-*-darwin*)
258                modplug_lib=[`find_lib libmodplug.dylib`]
259                ;;
260            *-*-cygwin* | *-*-mingw32*)
261                modplug_lib=[`find_lib "libmodplug*.dll"`]
262                ;;
263            *)
264                modplug_lib=[`find_lib "libmodplug[0-9]*.so.*"`]
265                if test x$modplug_lib = x; then
266                    modplug_lib=[`find_lib "libmodplug.so.*"`]
267                fi
268                ;;
269        esac
270        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MODPLUG $MODPLUG_CFLAGS"
271        if test x$enable_music_mod_modplug_shared = xyes && test x$modplug_lib != x; then
272            echo "-- dynamic libmodplug -> $modplug_lib"
273            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\""
274        else
275            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
276        fi
277    else
278        AC_MSG_WARN([*** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)])
279    fi
280fi
281
282AC_ARG_ENABLE([music-mod-mikmod],
283AC_HELP_STRING([--enable-music-mod-mikmod], [enable MOD music via mikmod [[default=no]]]),
284              [], [enable_music_mod_mikmod=no])
285AC_ARG_ENABLE([music-mod-mikmod-shared],
286AC_HELP_STRING([--enable-music-mod-mikmod-shared], [dynamically load mikmod library [[default=yes]]]),
287              [], [enable_music_mod_mikmod_shared=yes])
288if test x$enable_music_mod = xyes -a x$enable_music_mod_mikmod = xyes; then
289    have_libmikmod=no
290    libmikmod_maj=3
291    libmikmod_min=1
292    libmikmod_rev=10
293    libmikmod_ver="$libmikmod_maj.$libmikmod_min.$libmikmod_rev"
294    CFLAGS_SAVED="$CFLAGS"
295    LIBS_SAVED="$LIBS"
296    AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no, [$PATH])
297    if test "$LIBMIKMOD_CONFIG" != "no" ; then
298        CFLAGS="$CFLAGS `$LIBMIKMOD_CONFIG --cflags`"
299        LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`"
300        have_libmikmod=yes
301        AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver])
302        AC_TRY_RUN([
303#include "mikmod.h"
304#include "stdio.h"
305
306int main(int argc, char **argv)
307{
308long maj=$libmikmod_maj,min=$libmikmod_min,rev=$libmikmod_rev,ver=MikMod_GetVersion();
309/*printf("(%d.%d.%d) ",ver>>16,(ver>>8)&0xff,ver&0xff);*/
310if(ver>=((maj<<16)|(min<<8)|(rev))) {
311    printf("yes\n");
312    return 0;
313}
314printf("no\n*** libmikmod is older than %d.%d.%d, not using.\n",maj,min,rev);
315return 1;
316}
317], [], [have_libmikmod=no], [echo $ac_n "cross compiling; assumed OK... $ac_c"])
318    fi
319
320    if test x$have_libmikmod = xyes; then
321        case "$host" in
322            *-*-darwin*)
323                mikmod_lib=[`find_lib libmikmod.dylib`]
324                ;;
325            *-*-cygwin* | *-*-mingw32*)
326                mikmod_lib=[`find_lib "libmikmod*.dll"`]
327                ;;
328            *)
329                mikmod_lib=[`find_lib "libmikmod[0-9]*.so.*"`]
330                if test x$mikmod_lib = x; then
331                    mikmod_lib=[`find_lib "libmikmod.so.*"`]
332                fi
333                ;;
334        esac
335        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MIKMOD `$LIBMIKMOD_CONFIG --cflags`"
336        if test x$enable_music_mod_mikmod_shared = xyes && test x$mikmod_lib != x; then
337            echo "-- dynamic libmikmod -> $mikmod_lib"
338            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMIKMOD_DYNAMIC=\\\"$mikmod_lib\\\""
339        else
340            EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`"
341        fi
342    else
343        AC_MSG_WARN([*** Unable to find MikMod library (http://mikmod.raphnet.net/)])
344    fi
345    LIBS="$LIBS_SAVED"
346    CFLAGS="$CFLAGS_SAVED"
347fi
348
349if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes ; then
350    AC_MSG_WARN([MOD support disabled])
351fi
352
353AC_ARG_ENABLE([music-midi],
354AC_HELP_STRING([--enable-music-midi], [enable MIDI music [[default=yes]]]),
355              [], [enable_music_midi=yes])
356if test x$enable_music_midi = xyes; then
357    EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID"
358    AC_ARG_ENABLE([music-midi-timidity],
359AC_HELP_STRING([--enable-music-midi-timidity], [enable timidity MIDI output [[default=yes]]]),
360                  [], [enable_music_midi_timidity=yes])
361    if test x$enable_music_midi_timidity = xyes; then
362        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/timidity"
363        SOURCES="$SOURCES $srcdir/timidity/*.c"
364    fi
365    AC_ARG_ENABLE([music-midi-native],
366AC_HELP_STRING([--enable-music-midi-native], [enable native MIDI music output [[default=yes]]]),
367                  [], [enable_music_midi_native=yes])
368    if test x$enable_music_midi_native = xyes; then
369        use_music_midi_native=no
370        case "$host" in
371            *mingw32ce*)
372                use_music_midi_native=no
373                ;;
374            *-*-cygwin* | *-*-mingw32*)
375                use_music_midi_native=yes
376                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
377                ;;
378            *-*-darwin*)
379                use_music_midi_native=yes
380                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,CoreServices"
381                ;;
382            *-*-haiku*)
383                use_music_midi_native=yes_cpp
384                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi"
385                ;;
386        esac
387        if test x$use_music_midi_native = xyes; then
388            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
389            SOURCES="$SOURCES $srcdir/native_midi/*.c"
390        elif test x$use_music_midi_native = xyes_cpp; then
391            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
392            SOURCES="$SOURCES $srcdir/native_midi/*.c"
393            SOURCES_CXX="$SOURCES_CXX $srcdir/native_midi/*.cpp"
394        fi
395    fi
396    AC_ARG_ENABLE([music-midi-fluidsynth],
397AC_HELP_STRING([--enable-music-midi-fluidsynth], [enable FluidSynth MIDI output [[default=yes]]]),
398                  [], [enable_music_midi_fluidsynth=yes])
399    AC_ARG_ENABLE([music-midi-fluidsynth-shared],
400AC_HELP_STRING([--enable-music-midi-fluidsynth-shared], [dynamically load FluidSynth library [[default=yes]]]),
401                  [], [enable_music_midi_fluidsynth_shared=yes])
402    if test x$enable_music_midi_fluidsynth = xyes; then
403        AC_CHECK_HEADER([fluidsynth.h], [have_fluidsynth_hdr=yes])
404        AC_CHECK_LIB([fluidsynth], [fluid_player_add_mem], [have_fluidsynth_lib=yes])
405        if test x$have_fluidsynth_hdr = xyes -a x$have_fluidsynth_lib = xyes; then
406            have_fluidsynth=yes
407            case "$host" in
408                *-*-darwin*)
409                    fluidsynth_lib=[`find_lib libfluidsynth.dylib`]
410                    ;;
411                *-*-cygwin* | *-*-mingw32*)
412                    fluidsynth_lib=[`find_lib "fluidsynth*.dll"`]
413                    ;;
414                *)
415                    fluidsynth_lib=[`find_lib "libfluidsynth[0-9]*.so.*"`]
416                    if test x$fluidsynth_lib = x; then
417                        fluidsynth_lib=[`find_lib "libfluidsynth.so.*"`]
418                    fi
419                    ;;
420            esac
421            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH"
422            if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then
423                echo "-- dynamic libfluidsynth -> $fluidsynth_lib"
424                EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\""
425            else
426                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth"
427            fi
428        else
429            AC_MSG_WARN([*** Unable to find FluidSynth library (http://www.fluidsynth.org/)])
430            AC_MSG_WARN([FluidSynth support disabled])
431        fi
432    fi
433fi
434
435if test x$enable_music_midi_timidity != xyes -a \
436        x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \
437        x$have_fluidsynth != xyes; then
438    AC_MSG_WARN([MIDI support disabled])
439fi
440
441AC_ARG_ENABLE([music-ogg],
442AC_HELP_STRING([--enable-music-ogg], [enable Ogg Vorbis music [[default=yes]]]),
443              [], [enable_music_ogg=yes])
444AC_ARG_ENABLE(music-ogg-tremor,
445AC_HELP_STRING([--enable-music-ogg-tremor], [enable OGG Vorbis music via libtremor [[default=no]]]),
446              [], enable_music_ogg_tremor=no)
447AC_ARG_ENABLE([music-ogg-shared],
448AC_HELP_STRING([--enable-music-ogg-shared], [dynamically load Ogg Vorbis library [[default=yes]]]),
449              [], [enable_music_ogg_shared=yes])
450if test x$enable_music_ogg = xyes; then
451    LIBS_SAVED="$LIBS"
452    if test x$enable_music_ogg_tremor = xyes; then
453        AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
454        AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes], [], [-logg])
455        if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
456            case "$host" in
457                *-*-darwin*)
458                    ogg_lib=[`find_lib libvorbisidec.dylib`]
459                    ;;
460                *-*-cygwin* | *-*-mingw32*)
461                    ogg_lib=[`find_lib "vorbisidec*.dll"`]
462                    ;;
463                *)
464                    ogg_lib=[`find_lib "libvorbisidec[0-9]*.so.*"`]
465                    if test x$ogg_lib = x; then
466                        ogg_lib=[`find_lib "libvorbisidec.so.*"`]
467                    fi
468                    ;;
469            esac
470            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR"
471            if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
472                echo "-- dynamic libvorbisidec -> $ogg_lib"
473                EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
474            else
475                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisidec -lvorbis"
476            fi
477        else
478            AC_MSG_WARN([*** Unable to find Ogg Vorbis Tremor library (http://www.xiph.org/)])
479            AC_MSG_WARN([Ogg Vorbis support disabled])
480        fi
481    else
482        AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
483        AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes], [], [-lvorbis -logg -lm])
484        if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
485            case "$host" in
486                *-*-darwin*)
487                    ogg_lib=[`find_lib libvorbisfile.dylib`]
488                    ;;
489                *-*-cygwin* | *-*-mingw32*)
490                    ogg_lib=[`find_lib "libvorbisfile*.dll"`]
491                    ;;
492                *)
493                    ogg_lib=[`find_lib "libvorbisfile[0-9]*.so.*"`]
494                    if test x$ogg_lib = x; then
495                        ogg_lib=[`find_lib "libvorbisfile.so.*"`]
496                    fi
497                    ;;
498            esac
499            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG"
500            if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then
501                echo "-- dynamic libvorbisfile -> $ogg_lib"
502                EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
503            else
504                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lvorbisfile -lvorbis"
505            fi
506        else
507            AC_MSG_WARN([*** Unable to find Ogg Vorbis library (http://www.xiph.org/)])
508            AC_MSG_WARN([Ogg Vorbis support disabled])
509        fi
510    fi
511    LIBS="$LIBS_SAVED"
512fi
513
514libflac_ver=8
515AC_ARG_ENABLE([music-flac],
516AC_HELP_STRING([--enable-music-flac], [enable FLAC music [[default=yes]]]),
517              [], [enable_music_flac=yes])
518AC_ARG_ENABLE([music-flac-shared],
519AC_HELP_STRING([--enable-music-flac-shared],
520              [dynamically load FLAC library [[default=yes]]]),
521              [], [enable_music_flac_shared=yes])
522if test x$enable_music_flac = xyes; then
523    AC_CHECK_HEADER([FLAC/export.h], [have_flac_export=yes])
524    if test x$have_flac_export = xyes; then
525        LIBS_SAVED="$LIBS"
526        LIBS="-lFLAC"
527        AC_MSG_CHECKING([for libflac so-name version >= $libflac_ver])
528        AC_TRY_COMPILE([
529#include "FLAC/export.h"
530#include "stdio.h"
531],[
532#if defined(FLAC_API_VERSION_CURRENT) && (FLAC_API_VERSION_CURRENT >= $libflac_ver)
533#else
534#error "old-flac"
535#endif
536], have_flac_ver=yes, have_flac_ver=no)
537        LIBS="$LIBS_SAVED"
538        AC_MSG_RESULT($have_flac_ver)
539    fi
540
541    if test x$have_flac_ver = xyes; then
542        AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
543        AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
544        if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then
545            case "$host" in
546                *-*-darwin*)
547                    flac_lib=[`find_lib libFLAC.dylib`]
548                    ;;
549                *-*-cygwin* | *-*-mingw32*)
550                    flac_lib=[`find_lib "libFLAC-*.dll"`]
551                    ;;
552                *)
553                    flac_lib=[`find_lib "libFLAC[0-9]*.so.*"`]
554                    if test x$flac_lib = x; then
555                        flac_lib=[`find_lib "libFLAC.so.*"`]
556                    fi
557                    ;;
558            esac
559            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC"
560            if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then
561                echo "-- dynamic libFLAC -> $flac_lib"
562                EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\""
563            else
564                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lFLAC"
565            fi
566        fi
567    else
568        AC_MSG_WARN([*** Unable to find FLAC library (http://flac.sourceforge.net/)])
569        AC_MSG_WARN([FLAC support disabled])
570    fi
571fi
572
573AC_ARG_ENABLE(music-mp3,
574AC_HELP_STRING([--enable-music-mp3], [enable MP3 music [[default=yes]]]),
575              [], enable_music_mp3=yes)
576
577AC_ARG_ENABLE(music-mp3-mad-gpl,
578AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]),
579                  [], [enable_music_mp3_mad_gpl=no])
580AC_ARG_ENABLE(music-mp3-mad-gpl-dithering,
581AC_HELP_STRING([--enable-music-mp3-mad-gpl-dithering], [enable MP3 music via libmad GPL code [[default=yes]]]),
582                  [], [enable_music_mp3_mad_gpl_dithering=yes])
583if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then
584    AC_MSG_CHECKING(for libmad headers)
585    have_libmad=no
586    AC_TRY_COMPILE([
587     #include "mad.h"
588    ],[
589    ],[
590    have_libmad=yes
591    ])
592    AC_MSG_RESULT($have_libmad)
593    if test x$have_libmad = xyes; then
594        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD"
595        if test x$enable_music_mp3_mad_gpl_dithering = xyes; then
596            AC_MSG_WARN([*** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL])
597            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING"
598        fi
599        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
600    else
601        AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)])
602    fi
603fi
604
605AC_ARG_ENABLE(music-mp3-mpg123,
606AC_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via libmpg123 [[default=yes]]]),
607                  [], [enable_music_mp3_mpg123=yes])
608AC_ARG_ENABLE([music-mp3-mpg123-shared],
609AC_HELP_STRING([--enable-music-mp3-mpg123-shared], [dynamically load libmpg123 library [[default=yes]]]),
610              [], [enable_music_mp3_mpg123_shared=yes])
611if test x$enable_music_mp3_mpg123 = xyes; then
612    AC_CHECK_HEADER([mpg123.h], [have_mpg123_hdr=yes])
613    AC_CHECK_LIB([mpg123], [mpg123_replace_reader_handle], [have_mpg123_lib=yes])
614    if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then
615        have_libmpg123=yes
616        case "$host" in
617            *-*-darwin*)
618                mpg123_lib=[`find_lib libmpg123.dylib`]
619                ;;
620            *-*-cygwin* | *-*-mingw32*)
621                mpg123_lib=[`find_lib "libmpg123*.dll"`]
622                ;;
623            *)
624                mpg123_lib=[`find_lib "libmpg123.so.*"`]
625                ;;
626        esac
627        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123"
628        if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then
629            echo "-- dynamic libmpg123 -> $mpg123_lib"
630            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\""
631        else
632            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123"
633        fi
634    else
635        AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)])
636        AC_MSG_WARN([mpg123 support disabled])
637    fi
638fi
639
640if test x$have_libmad = xyes -o x$have_libmpg123 = xyes; then
641    :
642else
643    AC_MSG_WARN([MP3 support disabled])
644fi
645
646AC_ARG_ENABLE([music-opus],
647AC_HELP_STRING([--enable-music-opus], [enable Opus music [[default=yes]]]),
648              [], [enable_music_opus=yes])
649
650AC_ARG_ENABLE([music-opus-shared],
651AC_HELP_STRING([--enable-music-opus-shared], [dynamically load opusfile library [[default=yes]]]),
652              [], [enable_music_opus_shared=yes])
653if test x$enable_music_opus = xyes; then
654    LIBS_SAVED="$LIBS"
655    PKG_CHECK_MODULES([OPUSFILE], [opusfile >= 0.2], [dnl
656            have_opusfile_hdr=yes
657            have_opusfile_lib=yes
658        ], [dnl
659            AC_CHECK_HEADER([opus/opusfile.h], [have_opusfile_hdr=yes])
660            AC_CHECK_LIB([opusfile], [op_open_callbacks], [have_opusfile_lib=yes;OPUSFILE_LIBS="-lopusfile -lopus"], [], [-lopus -logg -lm])
661        ])
662    LIBS="$LIBS_SAVED"
663
664    if test x$have_opusfile_hdr = xyes -a x$have_opusfile_lib = xyes; then
665        have_opusfile=yes
666        case "$host" in
667            *-*-darwin*)
668                opusfile_lib=[`find_lib libopusfile.dylib`]
669                ;;
670            *-*-cygwin* | *-*-mingw32*)
671                opusfile_lib=[`find_lib "libopusfile*.dll"`]
672                ;;
673            *)
674                opusfile_lib=[`find_lib "libopusfile[0-9]*.so.*"`]
675                if test x$opusfile_lib = x; then
676                    opusfile_lib=[`find_lib "libopusfile.so.*"`]
677                fi
678                ;;
679        esac
680        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OPUS $OPUSFILE_CFLAGS"
681        if test x$enable_music_opus_shared = xyes && test x$opusfile_lib != x; then
682            echo "-- dynamic opusfile -> $opusfile_lib"
683            EXTRA_CFLAGS="$EXTRA_CFLAGS -DOPUS_DYNAMIC=\\\"$opusfile_lib\\\""
684        else
685            EXTRA_LDFLAGS="$EXTRA_LDFLAGS $OPUSFILE_LIBS"
686        fi
687    else
688        AC_MSG_WARN([*** Unable to find opusfile library (http://opus-codec.org/)])
689    fi
690fi
691
692EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LIBM"
693
694OBJECTS=`echo $SOURCES`
695DEPENDS=`echo $SOURCES`
696OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
697DEPENDS=`echo "$DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
698$(objects)/\2.lo: \1/\2.c\\
699	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
700
701OBJECTS_CXX=`echo $SOURCES_CXX`
702DEPENDS_CXX=`echo $SOURCES_CXX`
703OBJECTS_CXX=`echo "$OBJECTS_CXX" | sed 's,[[^ ]]*/\([[^ ]]*\)\.cpp,$(objects)/\1.lo,g'`
704DEPENDS_CXX=`echo "$DEPENDS_CXX" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.cpp,\\
705$(objects)/\2.lo: \1/\2.cpp\\
706	\$(LIBTOOL) --mode=compile \$(CXX) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
707OBJECTS="$OBJECTS $OBJECTS_CXX"
708DEPENDS="$DEPENDS $DEPENDS_CXX"
709DEPENDS=`echo "$DEPENDS" | sed 's,\\$,\\\\$,g'`
710
711VERSION_OBJECTS=`echo $VERSION_SOURCES`
712VERSION_DEPENDS=`echo $VERSION_SOURCES`
713VERSION_OBJECTS=`echo "$VERSION_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.rc,$(objects)/\1.o,g'`
714VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.rc,\\
715$(objects)/\2.o: \1/\2.rc\\
716	\$(WINDRES) \$< \$@,g'`
717VERSION_DEPENDS=`echo "$VERSION_DEPENDS" | sed 's,\\$,\\\\$,g'`
718
719PLAYWAVE_SOURCES="$srcdir/playwave.c"
720PLAYWAVE_OBJECTS=`echo $PLAYWAVE_SOURCES`
721PLAYWAVE_DEPENDS=`echo $PLAYWAVE_SOURCES`
722PLAYWAVE_OBJECTS=`echo "$PLAYWAVE_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
723PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
724$(objects)/\2.lo: \1/\2.c\\
725	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
726PLAYWAVE_DEPENDS=`echo "$PLAYWAVE_DEPENDS" | sed 's,\\$,\\\\$,g'`
727
728PLAYMUS_SOURCES="$srcdir/playmus.c"
729PLAYMUS_OBJECTS=`echo $PLAYMUS_SOURCES`
730PLAYMUS_DEPENDS=`echo $PLAYMUS_SOURCES`
731PLAYMUS_OBJECTS=`echo "$PLAYMUS_OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.c,$(objects)/\1.lo,g'`
732PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\([[^ ]]*\)/\([[^ ]]*\)\.c,\\
733$(objects)/\2.lo: \1/\2.c\\
734	\$(LIBTOOL) --mode=compile \$(CC) \$(CFLAGS) \$(EXTRA_CFLAGS) '"$DEPENDENCY_TRACKING_OPTIONS"' -c \$< -o \$@,g'`
735PLAYMUS_DEPENDS=`echo "$PLAYMUS_DEPENDS" | sed 's,\\$,\\\\$,g'`
736
737dnl Expand the sources and objects needed to build the library
738AC_SUBST(ac_aux_dir)
739AC_SUBST(OBJECTS)
740AC_SUBST(VERSION_OBJECTS)
741AC_SUBST(PLAYWAVE_OBJECTS)
742AC_SUBST(PLAYMUS_OBJECTS)
743AC_SUBST(BUILD_CFLAGS)
744AC_SUBST(EXTRA_CFLAGS)
745AC_SUBST(BUILD_LDFLAGS)
746AC_SUBST(EXTRA_LDFLAGS)
747AC_SUBST(EXE)
748AC_SUBST(WINDRES)
749AC_SUBST(SDL_VERSION)
750AC_SUBST(SDL_CFLAGS)
751AC_SUBST(SDL_LIBS)
752
753AC_OUTPUT([
754])
755AC_CONFIG_FILES([
756    Makefile SDL2_mixer.spec SDL2_mixer.pc
757])
758AC_CONFIG_COMMANDS([default],
759                   [cat >>Makefile <<__EOF__
760
761# Build rules for objects
762-include \$(OBJECTS:.lo=.d)
763$DEPENDS
764$VERSION_DEPENDS
765
766-include \$(PLAYWAVE_OBJECTS:.lo=.d)
767$PLAYWAVE_DEPENDS
768
769-include \$(PLAYMUS_OBJECTS:.lo=.d)
770$PLAYMUS_DEPENDS
771__EOF__
772], [
773DEPENDS="$DEPENDS"
774VERSION_DEPENDS="$VERSION_DEPENDS"
775PLAYWAVE_DEPENDS="$PLAYWAVE_DEPENDS"
776PLAYMUS_DEPENDS="$PLAYMUS_DEPENDS"
777])
778AC_OUTPUT
779