dnl Process this file with autoconf to produce a configure script.
AC_INIT(README.SDL)

dnl Setup for automake
AM_INIT_AUTOMAKE(sdlquake, 1.0.9)

dnl Detect the canonical target build environment
AC_CANONICAL_HOST
AC_CANONICAL_TARGET

dnl Check for tools

AC_PROG_MAKE_SET
AC_PROG_CC
AC_PROG_INSTALL

dnl The alpha architecture needs special flags for binary portability
AC_CANONICAL_TARGET
case "$target" in
    i686-*-linux*)
        CFLAGS="-g -mpentiumpro -O6 -ffast-math -funroll-loops -fomit-frame-pointer -fexpensive-optimizations"
        #CFLAGS="-g -mpentiumpro -O6 -ffast-math -funroll-loops -fexpensive-optimizations"
        ;;
    alpha*-*-linux*)
        CFLAGS="$CFLAGS -mcpu=ev4 -Wa,-mall"
        ;;
esac

dnl Figure out which math and networking libraries to use
case "$target" in
    *-*-mingw32*)
        MATHLIB=""
        INETLIB="-lwsock32"
        ;;
    *-*-beos*)
        MATHLIB=""
        INETLIB=""
        ;;
    *)
        MATHLIB="-lm"
        INETLIB=""
        ;;
esac
AC_SUBST(MATHLIB)
AC_SUBST(INETLIB)

dnl Check for SDL
SDL_VERSION=1.0.1
AM_PATH_SDL($SDL_VERSION,
            :,
            AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
)
CFLAGS="$CFLAGS $SDL_CFLAGS -DSDL"
LIBS="$LIBS $SDL_LIBS"

dnl Set up the icon object file, for Mingw32
case "$target" in
    *-*-mingw32*)
        cp ico_o ico.o
	ICONOBJ="ico.o"
        ;;
    *)
	ICONOBJ=""
        ;;
esac
AC_SUBST(ICONOBJ)

dnl Enable/disable the i686 asm
AC_ARG_ENABLE(asm,
[  --enable-asm            enable i686 assembly routines [default=no]],
                  , enable_asm=no)
if test x$enable_asm = xyes; then
    CFLAGS="$CFLAGS -DUSE_ASM"
fi

CFLAGS="$CFLAGS -DELF"

# Finally create all the generated files
AC_OUTPUT([
Makefile
])
