dnl autoconf file shameless ripped off from mixer-1.0.1

AC_INIT(doc/openal.texi)
AC_CONFIG_HEADER(config.h)

# Well, this seems goofy
chmod 755 config.guess >/dev/null 2>&1
chmod 755 config.sub   >/dev/null 2>&1

# Making releases:
#   MICRO_VERSION += 1;
#   INTERFACE_AGE += 1;
#   BINARY_AGE += 1;
# if any functions have been added, set INTERFACE_AGE to 0.
# if backwards compatibility has been broken,
# set BINARY_AGE and INTERFACE_AGE to 0.

MAJOR_VERSION=0
MINOR_VERSION=0
MICRO_VERSION=6
INTERFACE_AGE=0
BINARY_AGE=0
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
REDUNDANT_DECLS_WARN=yes       # warnings about redudant decls
SHOULD_ENFORCE_ANSI=yes        # whether we should use -ansi
SHADOW_WARN=yes                # warn about shadow variables
BROKEN_PTHREAD_FLAG=no         # BSD use -pthread, not -lpthread
NO_PTHREAD_FLAG=no
SHOULD_USE_FPIC=yes            # use -fPIC to compile position independent objs
SHOULD_USE_WERROR=yes          # turn warnings into errors
SHARED_LIBRARY_EXT=so	       # shared library extension
SHOULD_USE_RDYNAMIC=yes        # doesn't work on irix

# warns
WFLAGS="-Wall -Wpointer-arith -W -Wbad-function-cast -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wimplicit-function-declaration -Waggregate-return -Winline -Wpointer-arith -Wstrict-prototypes -Wcast-align -Wcast-qual"

AC_SUBST(MAJOR_VERSION)
AC_SUBST(MINOR_VERSION)
AC_SUBST(MICRO_VERSION)
AC_SUBST(INTERFACE_AGE)
AC_SUBST(BINARY_AGE)
AC_SUBST(VERSION)

dnl profile stuff
AC_ARG_ENABLE(profile,
[  --enable-profile          enable profile               [default=no]],
              , enable_profile=no)
if test x$enable_profile = xyes; then

dnl prepend to CFLAGS variable
CFLAGS="-O2 -fexpensive-optimizations -ffast-math -funroll-loops -funroll-all-loops -g -pg $CFLAGS"
LDFLAGS="-g -pg"
fi

AC_CANONICAL_SYSTEM

dnl pity the poor fools with broken headers
AC_DEFINE(_NO_STRING_INLINES)
AC_DEFINE(__NO_STRING_INLINES)

dnl optimization stuff

dnl check for misspell
if test x$enable_optimizations = xyes; then

enable_optimization=yes

fi

AC_ARG_ENABLE(optimization,
[  --enable-optimization     enable optimization          [default=no]],
              , enable_optimization=no)
if test x$enable_optimization = xyes; then

enable_paranoid_locks=no
enable_empty_locks=no

CFLAGS="-O6 -fexpensive-optimizations -funroll-all-loops -funroll-loops -fomit-frame-pointer -finline-functions -ffast-math $CFLAGS"

dnl add -march
case "$target" in 
    *i386*)
    CFLAGS="$CFLAGS -march=i386" ;;
    *i486*)
    CFLAGS="$CFLAGS -march=i486" ;;
    *i586*)
    CFLAGS="$CFLAGS -march=i586" ;;
    *i686*)
    CFLAGS="$CFLAGS -march=i686" ;;
    mips*)
    CFLAGS="$CFLAGS -march=mips" ;;
    *)
    echo "Unknown target $target" ;;
esac

fi

dnl keep CFLAGS variable if set, otherwise set it to just debug
if test "x$CFLAGS" = x; then
	CFLAGS="-g -O2"
fi

dnl optimization stuff
AC_ARG_ENABLE(paranoid-locks,
[  --enable-paranoid-locks   enable paranoid locks        [default=no]],
              , enable_paranoid_locks=no)
if test x$enable_paranoid_locks = xyes; then
	AC_DEFINE(PARANOID_LOCKS)
fi

dnl no mutex locking for sync. driver
AC_ARG_ENABLE(empty-locks,
[  --enable-empty-locks      enable empty locks           [default=no]],
              , enable_empty_locks=no)
if test x$enable_empty_locks = xyes; then
	AC_DEFINE(EMPTY_LOCKS)
fi

dnl debug stuff
AC_ARG_ENABLE(debug,
[  --enable-debug            enable debug                 [default=no]],
              , enable_debug=no)
if test x$enable_debug = xyes; then
	AC_DEFINE(DEBUG)
fi

AC_ARG_WITH(gcc,
[  --with-gcc                with custom gcc              [default=unset]],
              ,   with_gcc=unset)
if test x$with_gcc != xunset; then
	CC=$with_gcc
fi

AC_PROG_CC
AC_PROG_CPP
AC_C_BIGENDIAN

dnl I'm afraid we need libm
case "$target" in 
    *darwin*)
    AC_CHECK_LIB(m, sin, LIBS="$LIBS -lm", echo "don't need libm...") ;;
    *)
    AC_CHECK_LIB(m, sin, LIBS="$LIBS -lm", echo "I'm afraid you'll need libm."; exit 1) ;;
esac

dnl Should be allow dlopen of extensions?
AC_CHECK_LIB(dl, dlopen, LIBS="$LIBS -ldl", AC_DEFINE(NODLOPEN) echo "Can't dlopen extensions." )

dnl Special OS objs for target systems
case "$target" in
    *linux*)
    dnl subtest for mips/linux systems with broken libio headers
    case "$target" in 
    	*mips* )
	AC_DEFINE(BROKEN_LIBIO) ;;
	*) ;;
    esac
    WFLAGS="$WFLAGS -ansi"
    AC_DEFINE(LINUX_TARGET)
    OS_OBJS="\$(LIN_OBJS)" ;;
    *bsd*)
    BROKEN_PTHREAD_FLAG=yes
    AC_DEFINE(BSD_TARGET)
    OS_OBJS="\$(BSD_OBJS)" ;;
    *solaris*)
    AC_DEFINE(SOLARIS_TARGET)
    OS_OBJS="\$(SOLARIS_OBJS)" 
    REDUNDANT_DECLS_WARN=no 
    SHOULD_ENFORCE_ANSI=no ;;
    *irix*)
    AC_DEFINE(IRIX_TARGET)
    OS_OBJS="\$(IRIS_OBJS)"
    SHOULD_USE_RDYNAMIC=no
    REDUNDANT_DECLS_WARN=no
    SHOULD_ENFORCE_ANSI=no ;;
    *cygwin*)
    AC_DEFINE(WINDOWS_TARGET)
    OS_OBJS="\$(WINDOWS_OBJS)" 
    LIBS="$LIBS -lwinmm"         # need that mm library for waveOutOpen etc
    SHARED_LIBRARY_EXT=dll       # shared library extension
    SHOULD_USE_FPIC=no      # all code is position independant, causes error
    SHADOW_WARN=no
    REDUNDANT_DECLS_WARN=no 
    SHOULD_ENFORCE_ANSI=no ;;
    *darwin*)
    BROKEN_PTHREAD_FLAG=yes
    NO_PTHREAD_FLAG=yes
    LIBS="$LIBS -I/System/Library/Frameworks/CoreAudio.framework/Headers/ -framework CoreAudio"
    AC_DEFINE(DARWIN_TARGET)
    SHOULD_ENFORCE_ANSI=no
    SHOULD_USE_WERROR=no
    OS_OBJS="\$(DARWIN_OBJS)" ;;
    *)
    OS_OBJS="\$(LIN_OBJS)" ;;
esac

dnl Special objs for architectures
case "$target" in 
    *i386* | *i486* | *i586* | *i686* )
    ARCH_OBJS="\$(i386_OBJS)" ;;
    *)
    ARCH_OBJS="\$(PORTABLE_OBJS)" ;;
esac

dnl Check for headers/libs required for native backends
dnl Special OS objs for target systems
case "$target" in
    *linux*)
    # No extra libs needed
    ;;
    *bsd*)
    # No extra libs needed
    ;;
    *solaris*)
    # No extra libs needed
    ;;
    *irix*)
    # need dmedia
    AC_DEFINE(IRIS_SUPPORT)
    LIBS="$LIBS -laudio"
    ;;
    *cygwin*)
    # No extra libs needed
    ;;
    *)
    # No extra libs needed
    ;;
esac

dnl check for sizeof
AC_CHECK_SIZEOF(void *)

dnl jlib stuff
AC_ARG_ENABLE(jlib,
[  --enable-jlib             enable JLIB support          [default=no]],
              , enable_jlib=no)
if test x$enable_jlib = xyes; then
    AC_DEFINE(JLIB)
   # INCLUDES="$INCLUDES -include \"../include/jlib.h\""
    LIBS="$LIBS ../jlib/libjlib.a"
fi

dnl dmalloc stuff
AC_ARG_ENABLE(dmalloc,
[  --enable-dmalloc          enable DMALLOC support       [default=no]],
              , enable_dmalloc=no)
if test x$enable_dmalloc = xyes; then
    AC_CHECK_HEADER(dmalloc.h, 
    	dnl header found
	AC_DEFINE(DMALLOC)
	AC_DEFINE(DMALLOC_FUNC_CHECK)
    	INCLUDES="$INCLUDES -include \"/usr/include/dmalloc.h\""
    	LIBS="$LIBS -ldmallocth"
	SHOULD_USE_WERROR=no
    	REDUNDANT_DECLS_WARN=no,
	dnl header not found, check local/include
	dnl invalid cache
	AC_CHECK_HEADER(/usr/local/include/dmalloc.h,
		dnl header found in local/include
		AC_DEFINE(DMALLOC)
		AC_DEFINE(DMALLOC_FUNC_CHECK)
		INCLUDES="$CFLAGS -include \"/usr/local/include/dmalloc.h\""
		LIBS="$LIBS -ldmallocth"
		SHOULD_USE_WERROR=no
		REDUNDANT_DECLS_WARN=no))
fi

dnl efence stuff
AC_ARG_ENABLE(efence,
[  --enable-efence           enable EFENCE support        [default=no]],
              , enable_efence=no)
if test x$enable_efence = xyes; then
    LIBS="$LIBS -lefence"
fi

dnl stubifying
AC_ARG_ENABLE(stub-notify,
[  --enable-debug-stub       enable stub debugging        [default=no]],
              , enable_debug_stub=no)
if test x$enable_debug_stub = xyes; then
	AC_DEFINE(DEBUG_STUB)
fi

dnl looping debug notification

dnl check for misspell
if test x$enable_debug_looping = xyes; then
enable_debug_loop=yes
fi

AC_ARG_ENABLE(debug-loop,
[  --enable-debug-loop       enable looping debugging     [default=no]],
              , enable_debug_loop=no)
if test x$enable_debug_loop = xyes; then
	AC_DEFINE(DEBUG_LOOP)
fi

dnl conversion debug notification
AC_ARG_ENABLE(debug-convert,
[  --enable-debug-convert    enable convertion debugging  [default=no]],
              , enable_debug_convert=no)
if test x$enable_debug_convert = xyes; then
	AC_DEFINE(DEBUG_CONVERT)
fi

dnl config file debug notification
AC_ARG_ENABLE(debug-config,
[  --enable-debug-config     enable config file debugging [default=no]],
              , enable_debug_config=no)
if test x$enable_debug_config = xyes; then
	AC_DEFINE(DEBUG_CONFIG)
fi

dnl lock debug notification

dnl check for misspell
if test x$enable_debug_locking = xyes; then
enable_debug_lock=yes
fi

AC_ARG_ENABLE(debug-lock,
[  --enable-debug-lock       enable lock debugging        [default=no]],
              , enable_debug_lock=no)
if test x$enable_debug_lock = xyes; then
	AC_DEFINE(DEBUG_LOCK)
fi

dnl extension debug notification
AC_ARG_ENABLE(debug-ext,
[  --enable-debug-ext        enable extension debugging   [default=no]],
              , enable_debug_ext=no)
if test x$enable_debug_ext = xyes; then
	AC_DEFINE(DEBUG_EXT)
fi

dnl buffer debug notification
AC_ARG_ENABLE(debug-buffer,
[  --enable-debug-buffer     enable buffer debugging      [default=no]],
              , enable_debug_buffer=no)
if test x$enable_debug_buffer = xyes; then
	AC_DEFINE(DEBUG_BUFFER)
fi

dnl source debug notification
AC_ARG_ENABLE(debug-source,
[  --enable-debug-source     enable source debugging      [default=no]],
              , enable_debug_source=no)
if test x$enable_debug_source = xyes; then
	AC_DEFINE(DEBUG_SOURCE)
fi

dnl mixer debug notification
AC_ARG_ENABLE(debug-mixer,
[  --enable-debug-mixer      enable mixer debugging       [default=no]],
              , enable_debug_mixer=no)
if test x$enable_debug_mixer = xyes; then
	AC_DEFINE(DEBUG_MIXER)
fi

dnl streaming debug notification
AC_ARG_ENABLE(debug-streaming,
[  --enable-debug-streaming  enable streaming debugging   [default=no]],
              , enable_debug_streaming=no)
if test x$enable_debug_streaming = xyes; then
	AC_DEFINE(DEBUG_STREAMING)
fi

dnl math debug notification
AC_ARG_ENABLE(debug-math,
[  --enable-debug-math       enable math debugging        [default=no]],
              , enable_debug_math=no)
if test x$enable_debug_math = xyes; then
	AC_DEFINE(DEBUG_MATH)
fi

dnl mem debug notification
AC_ARG_ENABLE(debug-mem,
[  --enable-debug-mem        enable mem debugging         [default=no]],
              , enable_debug_mem=no)
if test x$enable_debug_mem = xyes; then
	AC_DEFINE(DEBUG_MEM)
fi

dnl context debug notification
AC_ARG_ENABLE(debug-context,
[  --enable-debug-context    enable context debugging     [default=no]],
              , enable_debug_context=no)
if test x$enable_debug_context = xyes; then
	AC_DEFINE(DEBUG_CONTEXT)
fi

dnl debug queue structures/functions/etc
AC_ARG_ENABLE(debug-queue,
[  --enable-debug-queue      enable queue debugging       [default=no]],
              , enable_debug_queue=no)
if test x$enable_debug_queue = xyes; then
	AC_DEFINE(DEBUG_QUEUE)
fi

dnl debug maximus
AC_ARG_ENABLE(debug-maximus,
[  --enable-debug-maximus    enable all debugging         [default=no]],
              , enable_debug_maximus=no)
if test x$enable_debug_maximus = xyes; then
	AC_DEFINE(DEBUG_MAXIMUS)
fi

dnl Check available thread packages
AC_CHECK_HEADER(pthread.h, PTHREAD_AVAILABLE=yes, PTHREAD_AVAILABLE=no)

dnl do some platform specific threead mojo
case "$target" in
	*cygwin*)
		AC_CHECK_HEADER(windows.h, WINTHREAD_AVAILABLE=yes) ;;
	*) ;;
esac

dnl threadify.
if test x$PTHREAD_AVAILABLE = xyes; then
    SYS_MUTEX_OBJS="mutex/posixmutex.o"
    SYS_THREAD_OBJS="threads/posixthreads.o"

    if test $NO_PTHREAD_FLAG = yes; then
        LIBS="$LIBS"
    else
    if test $BROKEN_PTHREAD_FLAG = yes; then
	LIBS="$LIBS -pthread"
    else
	LIBS="$LIBS -lpthread"
    fi
    fi
    
    AC_DEFINE(USE_POSIXMUTEX)
    AC_DEFINE(USE_POSIXTHREADS)
else
	dnl no pthread, check others

	if test x$WINTHREAD_AVAILABLE = xyes; then
    		SYS_MUTEX_OBJS="mutex/windowsmutex.o"
    		SYS_THREAD_OBJS="threads/windowsthreads.o"

    		AC_DEFINE(USE_WINDOWSMUTEX)
    		AC_DEFINE(USE_WINDOWSTHREADS)
	else
    		dnl no thread available

    		AC_DEFINE(NO_THREADS)
	fi
fi


dnl arch specific ASM files
ARCH_OBJS="\$(PORTABLE_OBJS)"
AC_ARG_ENABLE(arch-asm,
[  --enable-arch-asm         enable arch specific asm     [default=no]],
              ,   enable_asm_asm=no)
if test x$enable_arch_asm = xyes; then
	AC_PATH_PROG(HAVENASM, nasm, , $PATH)
	if test ! -z $HAVENASM; then
		NASM=$HAVENASM
		AC_DEFINE(MMX_SUPPORT)
		AC_HAS_MMX( ARCH_OBJS="\$(MMX_OBJS) \$(PORTABLE_OBJS)", )
	fi

fi

dnl check for ALSA headers
AC_ARG_ENABLE(alsa,
[  --enable-alsa             enable the alsa backend      [default=no]],
              ,   enable_alsa=no)
if test x$enable_alsa = xyes; then
    AC_CHECK_HEADER(sys/asoundlib.h,
	SHADOW_WARN=no
	REDUNDANT_DECLS_WARN=no
        AC_DEFINE(ALSA_SUPPORT)
    	OS_OBJS="$OS_OBJS \$(ALSA_OBJS)"
	LIBS="$LIBS -lasound")
fi

dnl frequency based functions, should they be included?
AC_ARG_ENABLE(fft,
[  --enable-fft              enable fft mojo              [default=no]],
              ,   enable_fft=no)
if test x$enable_fft = xyes; then
	AC_WARN(Regarding the FFT: I hope you know what you're doing)
        AC_DEFINE(FFT)
fi

dnl   enable arts sound?
AC_ARG_ENABLE(arts,
[  --enable-arts             enable arts backend          [default=no]],
              ,   enable_arts=no)
if test x$enable_arts = xyes; then
AC_PATH_PROG(HAVEARTS, artsc-config, , $PATH)
if test ! -z "$HAVEARTS"; then
	ARTS_CFLAGS=`$HAVEARTS --cflags`
	ARTS_LIBS=`$HAVEARTS --libs`

        AC_DEFINE(ARTS_SUPPORT)
	CFLAGS="$CFLAGS $ARTS_CFLAGS"
	LIBS="$LIBS $ARTS_LIBS"

    	OS_OBJS="$OS_OBJS \$(ARTS_OBJS)"
else
	AC_MSG_WARN([*** artsc-config not found.  No support compiled in.])
fi

fi #   enable_arts = yes

dnl   enable esd sound?
AC_ARG_ENABLE(esd,
[  --enable-esd              enable esd backend           [default=no]],
              ,   enable_esd=no)
if test x$enable_esd = xyes; then
AC_PATH_PROG(HAVEESD, esd-config, , $PATH)
if test ! -z "$HAVEESD"; then
	ESD_CFLAGS=`$HAVEESD --cflags`
	ESD_LIBS=`$HAVEESD --libs`

        AC_DEFINE(ESD_SUPPORT)
	CFLAGS="$CFLAGS $ESD_CFLAGS"
	LIBS="$LIBS $ESD_LIBS"

    	OS_OBJS="$OS_OBJS \$(ESD_OBJS)"

        # bad audiofile.h!  bad!
	SHADOW_WARN=no
else
	AC_MSG_WARN([*** esd-config not found.  No support compiled in.])
fi

fi #   enable_esd = yes

dnl check for IRIS headers
dnl AC_ARG_ENABLE(iris,
dnl [  --enable-iris             enable the irix backend      [default=no]],
dnl             ,   enable_iris=no)
dnl if test x$enable_iris = xyes; then
dnl	CPPFLAGS=" "
dnl        OS_OBJS="$OS_OBJS \$(IRIS_OBJS)"
dnl        DEFINES="$DEFINES -DIRIS_SUPPORT"
dnl        LIBS="$LIBS -laudio"
dnl fi #   enable_iris = yes


dnl   enable wave output?
AC_ARG_ENABLE(waveout,
[  --enable-waveout          enable waveout backend       [default=yes]],
              ,   enable_waveout=yes)
if test x$enable_waveout = xyes; then
        AC_DEFINE(WAVEOUT_SUPPORT)
	OS_OBJS="$OS_OBJS \$(WAVEOUT_OBJS)"
fi #   enable_waveout = yes

dnl   enable null output?
AC_ARG_ENABLE(null,
[  --enable-null             enable null backend          [default=yes]],
              ,   enable_null=yes)
if test x$enable_null = xyes; then
        AC_DEFINE(NULL_SUPPORT)
	OS_OBJS="$OS_OBJS \$(NULL_OBJS)"
fi #   enable_null = yes

dnl   enable SDL sound?
AC_ARG_ENABLE(sdl,
[  --enable-sdl              enable sdl backend           [default=no]],
              ,   enable_sdl=no)
if test x$enable_sdl = xyes; then

	dnl On cygwin targets, we don't rely on sdl-config.
	case "$target" in
		*cygwin*)
		HAVESDL=1

		SDL_CFLAGS="-I/cygwin/usr/include/SDL"
		SDL_LIBS=""

		CFLAGS="$CFLAGS $SDL_CFLAGS"
		LIBS="$LIBS $SDL_LIBS"

		OS_OBJS="$OS_OBJS \$(SDL_OBJS)"
		AC_DEFINE(SDL_SUPPORT);;
		*)

		AC_PATH_PROG(HAVESDL, sdl-config, , $PATH)
		if test ! -z "$HAVESDL"; then
			SDL_CFLAGS=`$HAVESDL --cflags`
			SDL_LIBS=`$HAVESDL --libs`

			AC_DEFINE(SDL_SUPPORT)
			CFLAGS="$CFLAGS $SDL_CFLAGS"
			LIBS="$LIBS $SDL_LIBS"

			OLDCPPFLAGS="$CPPFLAGS"
			CPPFLAGS="/lib/cpp -I/usr/local/include/SDL -I/usr/local/include"

			OS_OBJS="$OS_OBJS \$(SDL_OBJS)"
		else
			AC_MSG_WARN([*** SDL not found.  No support compiled in.])
		fi ;;
	esac

fi #   enable_sdl = yes

dnl   enable directsound backend?
AC_ARG_ENABLE(dsound,
[  --enable-dsound           enable directsound backend   [default=no]],
              ,   enable_dsound=no)
if test x$enable_dsound = xyes; then

	dnl On cygwin targets, we don't rely on sdl-config.
	case "$target" in
		*cygwin*)
		AC_CHECK_HEADER(dsound.h,
			AC_DEFINE(DSOUND_SUPPORT)
			LIBS="$LIBS -ldsound")

		AC_DEFINE(DSOUND_SUPPORT);;
		*)

		echo "No dsound on nonwindows"
		;;
	esac

fi #   enable_dsound = yes

dnl   enable emu10k1 backend?
AC_ARG_ENABLE(emu10k1,
[  --enable-emu10k1          enable emu10k1 backend       [default=no]],
              ,   enable_emu10k1=no)
if test x$enable_emu10k1 = xyes; then
	AC_DEFINE(EMU10K1_SUPPORT)
	OS_OBJS="$OS_OBJS \$(EMU10K1_OBJS)"
fi #   enable_emu10k1 = yes

dnl Enable vorbis support
AC_ARG_ENABLE(vorbis,
[  --enable-vorbis           enable vorbis support        [default=no]],
              ,   enable_vorbis=no)
if test x$enable_vorbis = xyes; then

	AC_CHECK_LIB(vorbisfile, ov_info,
		AC_DEFINE( VORBIS_SUPPORT )
		LIBS="$LIBS -lvorbis -lvorbisfile",, -lvorbis )

fi #   enable_vorbis = no

dnl Enable SMPEG for mp3 stuff
AC_ARG_ENABLE(smpeg,
[  --enable-smpeg            enable smpeg support         [default=no]],
              ,   enable_smpeg=no)
if test x$enable_smpeg = xyes; then
	AC_PATH_PROG(HAVESMPEG, smpeg-config, , $PATH)
	if test ! -z "$HAVESMPEG"; then

		dnl smpeg requires sdl

		dnl Only test for SDL if we haven't already tested for it
		if test -z "$HAVESDL"; then
			AC_PATH_PROG(HAVESDL, sdl-config, , $PATH)

			if test ! -z "$HAVESDL"; then
				SDL_CFLAGS=`$HAVESDL --cflags`
				SDL_LIBS=`$HAVESDL --libs`

				AC_DEFINE(SDL_SUPPORT)
				CFLAGS="$CFLAGS $SDL_CFLAGS"
				LIBS="$LIBS $SDL_LIBS"

				OLDCPPFLAGS="$CPPFLAGS"
				CPPFLAGS="/lib/cpp -I/usr/local/include/SDL -I/usr/local/include"

				OS_OBJS="$OS_OBJS \$(SDL_OBJS)"
			fi
		fi

		if test ! -z "$HAVESDL"; then
			SMPEG_CFLAGS=`$HAVESMPEG --cflags`
			SMPEG_LIBS=`$HAVESMPEG --libs`

			AC_DEFINE(SMPEG_SUPPORT)
			CFLAGS="$CFLAGS $SMPEG_CFLAGS"
			LIBS="$LIBS $SMPEG_LIBS"
		else
			AC_MSG_WARN([*** smpeg requires SDL, and none found.])

		fi
else
	AC_MSG_WARN([*** smpeg not found.  No support compiled in.])
fi

fi #   enable_smpeg = yes

dnl Enable capture support
AC_ARG_ENABLE(capture,
[  --enable-capture          enable capture support       [default=no]],
              ,   enable_capture=no)
if test x$enable_capture = xyes; then
	AC_DEFINE(CAPTURE_SUPPORT)
fi #   enable_capture = no

dnl makeinfo stuff
AC_CHECK_PROG(MAKEINFO, makeinfo, yes, no)
if test $MAKEINFO = yes; then
	MAKEINFO='makeinfo'
else
	# for silly people without texinfo
	MAKEINFO='@echo'
fi

dnl
dnl  Warning flags
dnl      This is where we prune down warnings based on the limitations of
dnl      the platform or included headers.
dnl

dnl warning pruning based on cpu type
case "$target" in 
    *i386*) ;;
    *i486*) ;;
    *i586*) ;;
    *i686*) ;;
    *powerpc*);;
    *alpha*)
    SHOULD_ENFORCE_ANSI=no ;; # f***ed up math headers
    *) echo "Unknown target $target" ;;
esac

if test ! -z "$HAVESDL"; then
	# If we don't have SDL, we can use -ansi for gcc.  If we do, SDL
	# uses long long which is bad mojo
	SHOULD_USE_WERROR=no
fi

dnl Should we use turn warnings into errors?
if test x$SHOULD_USE_WERROR = xyes; then
	WFLAGS="$WFLAGS -Werror -pedantic-errors"
fi

dnl if we are forced to live with redundant decls, turn off those errors
if test $REDUNDANT_DECLS_WARN = no; then
WFLAGS="$WFLAGS -Wno-redundant-decls"
else
WFLAGS="$WFLAGS -Wredundant-decls"
fi

dnl Typical UNIX doesn't like -ansi
if test x$SHOULD_ENFORCE_ANSI = xyes; then
WFLAGS="-ansi $WFLAGS"
fi

dnl Stupid audiofile headers
if test x$SHADOW_WARN = xyes; then
WFLAGS="-Wshadow $WFLAGS"
fi

dnl Stupid audiofile headers
if test x$SHOULD_USE_FPIC = xyes; then
AC_DEFINE(PIC)
CFLAGS="$CFLAGS -fPIC"
fi

dnl add warnings to CFALGS
CFLAGS="$CFLAGS $WFLAGS"

dnl okay, rdynamic okay?
if test x$SHOULD_USE_RDYNAMIC = xyes; then
AC_DEFINE_UNQUOTED(RDYNAMIC, "-rdynamic")
fi

dnl Da domb!
AC_DEFINE(BOMB)

dnl look for install
AC_PROG_INSTALL
AC_PROG_LN_S

dnl look for make
AC_CHECK_PROG(MAKE, gmake, gmake, none)
if test $MAKE = none; then
	# no gmake?  Ouch
	AC_MSG_WARN(Could not find gmake: so setting \$MAKE to make.)
	MAKE=make
fi

dnl define version
AC_DEFINE_UNQUOTED(LAL_VERSION, "$VERSION")

AC_SUBST(NASM)
AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(DEFINES)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBS)
AC_SUBST(INCLUDES)
AC_SUBST(JLIB)
AC_SUBST(MAKE)
AC_SUBST(MAKEINFO)
AC_SUBST(OS_OBJS)
AC_SUBST(ARCH_OBJS)
AC_SUBST(SYS_THREAD_OBJS)
AC_SUBST(SYS_MUTEX_OBJS)
AC_SUBST(INSTALL)
AC_SUBST(LN_S)
AC_SUBST(SHARED_LIBRARY_EXT)
AC_SUBST(SIZEOF_VOID_P)
AC_SUBST(RDYNAMIC)

AC_OUTPUT(Makefile src/Makefile doc/Makefile jlib/Makefile audioconvert/Makefile test/Makefile)
