1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.62)
5AC_INIT(kuklomenos, 0.4.5)
6AM_INIT_AUTOMAKE
7AC_CONFIG_SRCDIR([invaders.cc])
8
9AC_CANONICAL_HOST
10
11# Checks for programs.
12AC_PROG_CXX
13AC_PROG_CC
14AC_PROG_RANLIB
15
16# Checks for libraries.
17AC_CHECK_LIB([SDL], [SDL_Init],,AC_MSG_ERROR(Requires SDL))
18AC_CHECK_LIB([curl], [curl_global_init],,nocurl=1)
19
20AM_CONDITIONAL(HAVE_CURL, test x$nocurl != x1)
21
22# Copied from SDL_mixer's configure.in:
23AC_ARG_ENABLE([sound],
24AC_HELP_STRING([--enable-sound], [enable sound [[default=yes]]]),
25              [], [enable_sound=yes])
26AC_ARG_ENABLE(sound-ogg-tremor,
27[  --enable-sound-ogg-tremor   enable OGG sound via libtremor [[default=no]]],
28              [], enable_sound_ogg_tremor=no)
29AC_ARG_ENABLE([sound-ogg-shared],
30AC_HELP_STRING([--enable-sound-ogg-shared], [dynamically load Ogg Vorbis support [[default=yes]]]),
31              [], [enable_sound_ogg_shared=yes])
32find_lib()
33{
34    gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
35    gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
36    env_lib_path=[`echo $LIBS $LDFLAGS | sed 's/-L[ ]*//g'`]
37    for path in $gcc_bin_path $gcc_lib_path $env_lib_path /usr/lib /usr/local/lib; do
38        lib=[`ls -- $path/$1 2>/dev/null | sort -r | sed 's/.*\/\(.*\)/\1/; q'`]
39        if test x$lib != x; then
40            echo $lib
41            return
42        fi
43    done
44}
45AM_CONDITIONAL(SOUND, test x$enable_sound = xyes)
46if test x$enable_sound = xyes; then
47    if test x$enable_sound_ogg_tremor = xyes; then
48        AC_CHECK_HEADER([tremor/ivorbisfile.h], [have_tremor_hdr=yes])
49        AC_CHECK_LIB([vorbisidec], [ov_open_callbacks], [have_tremor_lib=yes])
50        if test x$have_tremor_hdr = xyes -a x$have_tremor_lib = xyes; then
51            case "$host" in
52                *-*-darwin*)
53                    ogg_lib=[`find_lib libvorbisidec*.dylib`]
54                    if test x$ogg_lib = x; then
55                        ogg_lib=[`find_lib libvorbisidec.[0-9]`]
56                    fi
57                    if test x$ogg_lib = x; then
58                        ogg_lib=[`find_lib libvorbisidec.[0-9]*`]
59                    fi
60                    ;;
61                *-*-cygwin* | *-*-mingw32*)
62                    ogg_lib=[`find_lib "vorbisidec*.dll"`]
63                    ;;
64                *)
65                    ogg_lib=[`find_lib "libvorbisidec.so.[0-9]"`]
66                    if test x$ogg_lib = x; then
67                        ogg_lib=[`find_lib "libvorbisidec.so.[0-9]*"`]
68                    fi
69                    ;;
70            esac
71            MIXER_CFLAGS="$MIXER_CFLAGS -DOGG_SOUND -DOGG_USE_TREMOR"
72            if test x$enable_sound_ogg_shared = xyes && test x$ogg_lib != x; then
73                echo "-- dynamic libvorbisidec -> $ogg_lib"
74                MIXER_CFLAGS="$MIXER_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
75            else
76                MIXER_LDFLAGS="$MIXER_LDFLAGS -lvorbisidec"
77            fi
78        fi
79    else
80        AC_CHECK_HEADER([vorbis/vorbisfile.h], [have_ogg_hdr=yes])
81        AC_CHECK_LIB([vorbisfile], [ov_open_callbacks], [have_ogg_lib=yes])
82        if test x$have_ogg_hdr = xyes -a x$have_ogg_lib = xyes; then
83            case "$host" in
84                *-*-darwin*)
85                    ogg_lib=[`find_lib libvorbisfile*.dylib`]
86                    ;;
87                *-*-cygwin* | *-*-mingw32*)
88                    ogg_lib=[`find_lib "libvorbisfile*.dll"`]
89                    ;;
90                *)
91                    ogg_lib=[`find_lib "libvorbisfile.so.[0-9]"`]
92                    if test x$ogg_lib = x; then
93                        ogg_lib=[`find_lib "libvorbisfile.so.[0-9]*"`]
94                    fi
95                    ;;
96            esac
97            MIXER_CFLAGS="$MIXER_CFLAGS -DOGG_SOUND"
98            if test x$enable_sound_ogg_shared = xyes && test x$ogg_lib != x; then
99                echo "-- dynamic libvorbisfile -> $ogg_lib"
100                MIXER_CFLAGS="$MIXER_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\""
101            else
102                MIXER_LDFLAGS="$MIXER_LDFLAGS -lvorbisfile -lvorbis -logg"
103            fi
104        fi
105    fi
106    AC_SUBST(MIXER_LDFLAGS)
107    AC_SUBST(MIXER_CFLAGS)
108fi
109# end from SDL_mixer
110
111
112# Checks for header files.
113
114# Checks for typedefs, structures, and compiler characteristics.
115AC_HEADER_STDBOOL
116
117# Checks for library functions.
118AC_CHECK_FUNCS([atexit floor pow sqrt])
119
120AC_CONFIG_HEADERS([config.h])
121AC_CONFIG_FILES([Makefile SDL_mixer/Makefile fonts/Makefile sounds/Makefile])
122AC_OUTPUT
123