AC_PREREQ(2.52)
AC_PROG_LN_S
AC_PROG_LIBTOOL
AC_PROG_CC
AC_LANG(C++)
AC_PROG_CXX(g++)
AC_CXX_NAMESPACES
AC_CXX_PARTIAL_SPECIALIZATION
AC_CXX_HAVE_KOENIG_LOOKUP
AC_C_BIGENDIAN
SYNAPS_MISC

if ! test -d ./include; then mkdir include; fi
if ! test -d ./include/synaps; then mkdir include/synaps; fi
if ! test -d ./lib; then mkdir lib; fi
if ! test x$with_gmp = xno; then 
RX_PROG_GXX_VERSION(3.2,
	 [],
	 [AC_MSG_ERROR(g++ has a version lower than 3.2)])
fi;
AM_PROG_LEX
if ! test x$with_blas = xno; then 
ACX_BLAS([rx_have_blas_lib=yes],
	 [rx_have_blas_lib=no
	  AC_MSG_WARN(failed to found a valid BLAS library. Install one 
	 from your OS distribution media or from
http://www.netlib.org/blas.)])
fi
if ! test x$with_lapack = xno; then 
ACX_LAPACK([],
	   [
            AC_MSG_WARN(failed to found a valid LAPACK library. Install one 
	    from your OS distribution media or from http://www.netlib.org/)])
AC_F77_WRAPPERS
fi;

AM_CONDITIONAL(SYNAPS_WITH_BLAS, [test x$rx_have_blas_lib = xyes])
AM_CONDITIONAL(SYNAPS_WITH_LAPACK, [test x$rx_have_lapack_lib = xyes])

RX_LIB_SEARCH_GMP(3.1)

## RX_LIB_SEARCH_MPSOLVE([have_lib_mpsolve=yes], [have_lib_mpsolve=no])
## AM_CONDITIONAL(SYNAPS_WITH_MPSOLVE, [test x$have_lib_mpsolve = xyes])


if test -d ./mpsolve; then
 if test "$gmp_cv_gmp_h" = yes && test "$gmp_cv_libgmp" = yes
 then
    LIBS="$LIBS -lmps"; 
    have_lib_mpsolve=yes;
    AC_MSG_NOTICE([configured with MPSOLVE ])
 else 
    have_lib_mpsolve=no;
    AC_MSG_NOTICE([without MPSOLVE ])
 fi;
 
fi;

AM_CONDITIONAL(SYNAPS_WITH_MPSOLVE, [test x$have_lib_mpsolve = xyes])

## RX_LIB_SEARCH_UDX([have_lib_udx=yes], [have_lib_udx=no])
## AM_CONDITIONAL(SYNAPS_WITH_UDX, [test x$have_lib_udx = xyes])

AC_CHECK_PROG(have_doxygen, doxygen, yes)
AM_CONDITIONAL(SYNAPS_WITH_DOXYGEN, [test x$have_doxygen = xyes])

axel_enabled=false 	
AC_ARG_ENABLE(axel,
[  --enable-axel    [default=no] ],
[case "${enableval}" in
  yes) axel_enabled=true 
	AXEL_LIBS="-laxel";;
  no)  axel_enabled=false 
	AXEL_LIBS="";;
  *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
esac],[AXEL_LIBS="-laxel"])
AC_SUBST(AXEL_LIBS)
AM_CONDITIONAL(ADD_AXEL, test x$axel_enabled = xtrue)

AC_ARG_ENABLE(synaps-install,
[  --enable-synaps-install    [default=yes] ],
[case "${enableval}" in
  yes) synaps_install_enabled=true ;;
  no)  synaps_install_enabled=false ;;
  *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
esac],[synaps_install_enabled=true])
AM_CONDITIONAL(ENABLE_SYNAPS_INSTALL, test x$synaps_install_enabled = xtrue)

AH_TOP([
#ifndef __SYNAPS_CONFIG_H_INCLUDED__
#define __SYNAPS_CONFIG_H_INCLUDED__
])
AH_BOTTOM([
#define USING_NAMESPACE_SYNAPS 1
#endif /* __SYNAPS_CONFIG_H_INCLUDED__ */
])
AM_CONFIG_HEADER(include/synaps/config.h)


