dnl
dnl Process this file with autoconf to produce a configure script.
dnl

dnl
dnl Initialisation
dnl
AC_INIT(svd.h)

dnl
dnl Set up variables for Makefile.in
dnl
dnl Change variables here:

targetname=libsvd
AC_SUBST(targetname)

dnl
dnl Parse options
dnl

AC_ARG_WITH(
  svd,
  [  --with-svd    build the svd libray])

if test "$with_svd" = yes; then
  AC_DEFINE(HAVE_SVD)
fi

dnl
dnl add to -I and -L, if necessary
dnl
if (test "x${prefix} != xNONE && test "${prefix} != "/usr/local") || \
  test "${ac_default_prefix}" != "/usr/local" || \
  test "${includedir}" != '${prefix}/include'; then
  CPPFLAGS="-I${includedir} ${CPPFLAGS}"
fi

if (test "x${prefix} != xNONE && test "${prefix} != "/usr/local") || \
  test "${ac_default_prefix}" != "/usr/local" || \
  test "${libdir}" != '${prefix}/lib'; then
  LDFLAGS="-L${libdir} ${LDFLAGS}"
fi
LDFLAGS="-L. ${LDFLAGS}"

if test "${CXXFLAGS+set}" != set; then
  ac_cxxflags_set=no
  if test "$with_debug" = yes; then
    CXXFLAGS="-g"
  else
    CXXFLAGS="-O"
    AC_DEFINE(NDEBUG)
  fi
fi

#
# - check for libraries.
#
AC_CHECK_LIB(mpfr, mpfr_add, , [ AC_MSG_ERROR(libmpfr not found) ])

dnl
dnl Checks for programs.
dnl
AC_LANG([C++])
AC_PROG_CXX
AC_REQUIRE_CPP
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_CHECK_PROG(AR,ar,ar)
if test -z "$AR"; then
  AC_MSG_ERROR(Need ar)
fi

dnl
dnl programs for installation
dnl
dnl ac_save_path=${PATH}
dnl PATH="$PATH:.."
dnl AC_PROG_INSTALL
dnl AC_PATH_PROG(MKINSTALLDIRS, mkinstalldirs, -mkdir -p)
dnl PATH="$ac_save_path"

dnl
dnl Checks for header files.
dnl

dnl
dnl Checks for libraries.
dnl

dnl
dnl Checks for typedefs, structures, and compiler characteristics.
dnl

dnl
dnl Last, but not least, customize CFLAGS
dnl
if test x${GXX} = xyes; then

  if test "$ac_cxxflags_set" = no; then
    if test "$with_debug" = yes; then
       CXXFLAGS="-O -g"
    else
       CXXFLAGS="-O3 "
    fi
# check whether CXX accepts -fno-rtti
AC_LANG_SAVE
AC_LANG([C++])
AC_MSG_CHECKING(whether gcc accepts -fno-rtti)
tmp_flags=${CXXFLAGS}
CXXFLAGS="${CXXFLAGS} -fno-rtti"
AC_CACHE_VAL(ac_cv_cxx_have_rtti,
AC_TRY_COMPILE(,,ac_cv_cxx_have_rtti=yes,ac_cv_cxx_have_rtti=no)
)
AC_MSG_RESULT(${ac_cv_cxx_have_rtti})
CXXFLAGS=$tmp_flags
if test "${ac_cv_cxx_have_rtti}" = yes; then
CXXFLAGS="$CXXFLAGS -fno-rtti"
fi

AC_LANG_RESTORE

  fi
  CXXTEMPLFLAGS="-fno-implicit-templates"


else
  CXXTEMPFLAGS=""
fi
AC_SUBST(CXXTEMPLFLAGS)

AC_OUTPUT(Makefile)

