dnl -*-shell-script-*-
dnl Process this file with autoconf to produce a configure script.-
AC_INIT(choleski.cc)
AC_LANG_CPLUSPLUS

optimise_b=yes
shared_b=no
LIB_SUFFIX=.a

if test x$host = xNONE; then
    OUTDIR_NAME=${OUTDIR_NAME-"out"}
else
    OUTDIR_NAME=${OUTDIR_NAME-"out-$host"}
fi

for a in `find -type d -and -not -name 'out'`; do
	if test ! -d  $a/$OUTDIR_NAME; then
		mkdir $a/$OUTDIR_NAME;
	fi
done

    
AC_ARG_ENABLE(shared,
    [  enable-shared       shared flower library],
    [shared_b=$enableval])
    
AC_ARG_ENABLE(optimise,
    [  disable-optimise    optimisations off],
    [optimise_b=$enableval])

AC_ARG_ENABLE(out-dir,
    [  out-dir			set the directory for machine generated files. Default out or out-HOST],
    [OUTDIR_NAME=$enableval]
    [])

if test $shared_b = yes; then
	MODULE_CXXFLAGS="$MODULE_CXXFLAGS -fPIC"
	MODULE_LDFLAGS="-shared -Wl,-soname,libflower.so "
	LIB_SUFFIX=.so
fi

if test $optimise_b = yes; then
    MODULE_CXXFLAGS="$MODULE_CXXFLAGS -O2 -DSTRING_UTILS_INLINED"
fi

AC_SUBST(MODULE_CXXFLAGS)
AC_SUBST(MODULE_LDFLAGS)
AC_SUBST(LIB_SUFFIX)

AC_PROG_CXX
AC_FUNC_MEMCMP
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(memmem snprintf )

if test ! -d $OUTDIR_NAME ; then
    mkdir $OUTDIR_NAME
fi

AC_CONFIG_HEADER($OUTDIR_NAME/config.hh:config.hh.in)
AC_OUTPUT($OUTDIR_NAME/Flower-flags.make:Flower-flags.make.in)

