
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
# Skeleton initially generated with autoscan
AC_PREREQ([2.69])
AC_INIT([sollya], [weekly-2026-06-15], [sollya-devl@lists.gforge.inria.fr])
AC_CONFIG_MACRO_DIR([m4])  # To please autoconf. See c8fd07aa1d2bd54f8c1b519052849aed1ec39663
AC_CONFIG_AUX_DIR([build-aux]) # Put auxiliary files of autoconf into a specific directory
AC_CONFIG_SRCDIR([sollya-library-wrappers.h]) # Checks that we are really trying to configure Sollya and not something else...
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.6 no-define dist-zip dist-bzip2]) # -Wall -Werror
AM_MAINTAINER_MODE([]) # Disables automatic call to ./configure after a modification has been made to configure.ac, Makefile.am, etc.
                       # This simplifies the life of Debian maintainers when they apply patches.
                       # The default behavior (automatic call to ./configure when necessary), that is probably desired for every-day developers is achieved by passing the option --enable-maintainer-mode to configure.

m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # On systems with a recent version of automake, produces a more synthetic output when compiling

# Checks for programs.
AC_PROG_YACC
AC_PROG_CC
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_AWK  # Used by ltmain.sh
AC_PROG_SED  # Used in some tests (although we do not currently use its replacement variable $SED)
AM_PROG_CC_C_O  # To please autoconf. See 68da652992422c073b8bd2fe0814cd1cf37ee1fc
AM_PROG_AR # To please automake when used with -Wall

AC_LANG_PUSH([C++])
AC_MSG_CHECKING([whether C++ compiler works])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]], [[exit(0);]])],
               [AC_MSG_RESULT(yes)],
               [AC_MSG_RESULT(no)
                AC_MSG_ERROR([C++ compiler does not work])])
AC_LANG_POP([C++])
AC_PROG_LEX(yywrap)
missing_dir=`cd $ac_aux_dir && pwd`
FLEX_IS_MISSING="no"
# Checks that $LEX contains something that looks like a lexer
if test "x$LEX" = "x:" || test `echo -e "%{\n%}\n\n%option prefix=\"coucou\"\n\n%%\n"test" { }\n%%\n" > conftest.l ; $LEX conftest.l > /dev/null 2> /dev/null ; echo $?; rm -f lex.coucou.c` -ne 0
then
  LEX="$SHELL $missing_dir/missing flex"
  AC_SUBST(LEX_OUTPUT_ROOT, lex.yy)
  AC_SUBST(LEXLIB, '')
  FLEX_IS_MISSING="yes"
fi

AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_MKDIR_P
LT_INIT([dlopen shared])   # AC_PROG_RANLIB is superseeded by LT_INIT
AC_SUBST(LIBTOOL_DEPS)
AC_SUBST(AR_FLAGS, "cr")   # To prevent a warning on some Ubuntu. See fbb8016beff7b45734e53ef8b80d2c306334c248
AC_PATH_PROG([HELP2MAN],[help2man],[no])
AM_CONDITIONAL([HAVE_HELP2MAN], [test "x$HELP2MAN" != "xno"])

if test "x$HELP2MAN" != "xno"
then
  AC_MSG_CHECKING([whether help2man supports the --locale option])
  if help2man --locale=C.UTF-8 -o .tmp_help2man help2man 2> /dev/null
  then
    HELP2MAN_SUPPORTS_LOCALE="yes"
  else
    HELP2MAN_SUPPORTS_LOCALE="no"
  fi
  AC_MSG_RESULT($HELP2MAN_SUPPORTS_LOCALE)
  rm -rf .tmp_help2man
fi
AM_CONDITIONAL([HAVE_HELP2MAN_LOCALE], [test "x$HELP2MAN_SUPPORTS_LOCALE" = "xyes"])

#Checking for pdflatex with the required packages
AC_PATH_PROG([PDFLATEX],[pdflatex],[no])
if test "x$PDFLATEX" != "xno"
then
  AC_MSG_CHECKING([that pdflatex comes with the necessary packages])
  rm -rf .tmp_sollya_ac_pdflatex
  mkdir .tmp_sollya_ac_pdflatex
  cd .tmp_sollya_ac_pdflatex
  echo "\documentclass@<:@a4paper@:>@{article}" > conftest.tex
  echo "\usepackage@<:@T1@:>@{fontenc}" >> conftest.tex
  echo "\usepackage@<:@utf8@:>@{inputenc}" >> conftest.tex
  echo "\usepackage@<:@english@:>@{babel}" >> conftest.tex
  echo "\usepackage@<:@naturalnames@:>@{hyperref}" >> conftest.tex
  echo "\usepackage{fullpage}" >> conftest.tex
  echo "\usepackage{xspace}" >> conftest.tex
  echo "\usepackage{amssymb}" >> conftest.tex
  echo "\usepackage{fancyvrb}" >> conftest.tex
  echo "\usepackage{cmap}" >> conftest.tex
  echo "\usepackage{lmodern}" >> conftest.tex
  echo "\usepackage{color}" >> conftest.tex
  echo "\usepackage{tocloft}" >> conftest.tex
  echo "\begin{document}" >> conftest.tex
  echo "Test" >> conftest.tex
  echo "\end{document}" >> conftest.tex
  PDFLATEX_WITH_PACKAGES="no"
  $PDFLATEX -interaction=batchmode conftest.tex 2>&1 1>/dev/null && PDFLATEX_WITH_PACKAGES="$PDFLATEX"
  PDFLATEX="$PDFLATEX_WITH_PACKAGES"
  cd ..
  rm -rf .tmp_sollya_ac_pdflatex
  if test "x$PDFLATEX" != "xno"
  then
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
  fi
fi
AM_CONDITIONAL([HAVE_PDFLATEX], [test "x$PDFLATEX" != "xno"])

#Check whether flex and bison support interactive and pure parsers
AC_ARG_ENABLE(strict-lexer-parser-check,
              [[  --enable-strict-lexer-parser-check enables strict compatibility checking for building the lexer and parser files]],
              [ if test "x${enableval}y" = "xyesy"
	      	then
			STRICTFLEXBISONTESTING="1"
		else
			STRICTFLEXBISONTESTING=""
		fi
	      ],
              [STRICTFLEXBISONTESTING=""])

if test "x$FLEX_IS_MISSING" = "xno"
then
    AC_MSG_CHECKING([flex supports all required features])
    if test `echo -e "%{\n%}\n\n%option always-interactive\n%option reentrant\n%option prefix=\"coucou\"\n%option bison-bridge\n%option nounput\n\n%%\n"test" { }\n%%\n" > conftest.l ; $LEX conftest.l > /dev/null 2> /dev/null ; echo $?; rm -f lex.coucou.c` -eq 0
    then
       AC_MSG_RESULT(yes)
    else
       if test "x$STRICTFLEXBISONTESTING" = "x"
       then
          AC_MSG_RESULT([flex version unable to compile the lexer from the grammar files])
       else
          AC_MSG_RESULT(no)
          AC_MSG_ERROR([flex does not support all required features])
       fi
    fi
fi


YACC_IS_MISSING="no"
# Checks that $YACC contains something that looks like a yacc parser
if test "x$YACC" = "x:" || test `echo -e "%{\n%}\n\n%%\nstart: \".\"\n{ }\n;\n" > conftest.y ; rm -f y.tab.* ; $YACC conftest.y > /dev/null 2> /dev/null && test -e y.tab.c ; echo $?; rm -f y.tab.*` -ne 0
then
    YACC_IS_MISSING="yes"
fi
if test "x$YACC_IS_MISSING" = "xno"
then
    AC_MSG_CHECKING([bison supports all required features])
    if test `echo -e "%{\n#define YYERROR_VERBOSE 1\n#define YYPARSE_PARAM scanner\n#define YYLEX_PARAM scanner\n%}\n\n%defines\n%name-prefix \"internyy\"\n%pure-parser\n\n%%\nstart: \".\"\n{ }\n;\n\n" > conftest.y ; $YACC conftest.y > /dev/null 2> /dev/null ; echo $?; rm -f y.tab.*` -eq 0
    then
      AC_MSG_RESULT(yes)
    else
      if test "x$STRICTFLEXBISONTESTING" = "x"; then
        AC_MSG_RESULT([bison version unable to compile the parser from the grammar files])
      else
        AC_MSG_RESULT(no)
        AC_MSG_ERROR([bison does not support all required features])
      fi
    fi
fi

# withs...
SO_LIB_PATH=""
FPLLLVERSIONSTRING=""

AC_ARG_WITH(gmp-include,
            [  --with-gmp-include=DIR  GMP include directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_CPPFLAGS="$AM_CPPFLAGS -I$withval"
             fi])
AC_ARG_WITH(gmp-lib,
            [  --with-gmp-lib=DIR      GMP lib directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_LDFLAGS="$AM_LDFLAGS -L$withval"
               SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval"
             fi
            ])
AC_ARG_WITH(gmp,
            [  --with-gmp=DIR          GMP install directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_CPPFLAGS="$AM_CPPFLAGS -I$withval/include"
               AM_LDFLAGS="$AM_LDFLAGS -L$withval/lib"
               SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval/lib"
             fi
            ])


AC_ARG_WITH(mpfr-include,
            [  --with-mpfr-include=DIR  MPFR include directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_CPPFLAGS="$AM_CPPFLAGS -I$withval"
	     fi])
AC_ARG_WITH(mpfr-lib,
            [  --with-mpfr-lib=DIR      MPFR lib directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_LDFLAGS="$AM_LDFLAGS -L$withval"
               SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval"
	     fi
            ])
AC_ARG_WITH(mpfr,
            [  --with-mpfr=DIR          MPFR install directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_CPPFLAGS="$AM_CPPFLAGS -I$withval/include"
               AM_LDFLAGS="$AM_LDFLAGS -L$withval/lib"
               SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval/lib"
	     fi
            ])


AC_ARG_WITH(fplll-include,
            [  --with-fplll-include=DIR  fplll include directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
	       AM_CPPFLAGS="$AM_CPPFLAGS -I$withval"
               FPLLLVERSIONSTRING="$FPLLLVERSIONSTRING--with-fplll-include given as '$withval', "
	     fi
            ])
AC_ARG_WITH(fplll-lib,
            [  --with-fplll-lib=DIR      fplll lib directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_LDFLAGS="$AM_LDFLAGS -L$withval"
               SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval"
               FPLLLVERSIONSTRING="$FPLLLVERSIONSTRING--with-fplll-lib given as '$withval', "
	     fi
            ])
AC_ARG_WITH(fplll,
            [  --with-fplll=DIR          fplll install directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_CPPFLAGS="$AM_CPPFLAGS -I$withval/include"
               AM_LDFLAGS="$AM_LDFLAGS -L$withval/lib"
               SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval/lib"
               FPLLLVERSIONSTRING="$FPLLLVERSIONSTRING--with-fplll given as '$withval', "
	     fi
            ])


AC_ARG_WITH(z-include,
            [  --with-z-include=DIR  z include directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_CPPFLAGS="$AM_CPPFLAGS -I$withval"
	     fi])
AC_ARG_WITH(z-lib,
            [  --with-z-lib=DIR      z lib directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
	       AM_LDFLAGS="$AM_LDFLAGS -L$withval"
	     fi])
AC_ARG_WITH(z,
            [  --with-z=DIR          z install directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_CPPFLAGS="$AM_CPPFLAGS -I$withval/include"
               AM_LDFLAGS="$AM_LDFLAGS -L$withval/lib"
	     fi
            ])


AC_ARG_WITH(iconv-include,
            [  --with-iconv-include=DIR  iconv include directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
	       AM_CPPFLAGS="$AM_CPPFLAGS -I$withval"
	     fi])
AC_ARG_WITH(iconv-lib,
            [  --with-iconv-lib=DIR      iconv lib directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
	       AM_LDFLAGS="$AM_LDFLAGS -L$withval"
	     fi])
AC_ARG_WITH(iconv,
            [  --with-iconv=DIR          iconv install directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_CPPFLAGS="$AM_CPPFLAGS -I$withval/include"
               AM_LDFLAGS="$AM_LDFLAGS -L$withval/lib"
             fi
	    ])


AC_ARG_WITH(mpfi-include,
            [  --with-mpfi-include=DIR  MPFI include directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
	       AM_CPPFLAGS="$AM_CPPFLAGS -I$withval"
	     fi])
AC_ARG_WITH(mpfi-lib,
            [  --with-mpfi-lib=DIR      MPFI lib directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_LDFLAGS="$AM_LDFLAGS -L$withval"
               SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval"
	     fi
            ])
AC_ARG_WITH(mpfi,
            [  --with-mpfi=DIR          MPFI install directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_CPPFLAGS="$AM_CPPFLAGS -I$withval/include"
               AM_LDFLAGS="$AM_LDFLAGS -L$withval/lib"
               SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval/lib"
	     fi
            ])


XML2INCLUDEGIVEN=""
XML2LIBGIVEN=""
AC_ARG_WITH(xml2-include,
            [  --with-xml2-include=DIR  XML2 include directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
	       AM_CPPFLAGS="$AM_CPPFLAGS -I$withval -I$withval/libxml2"
               XML2INCLUDEGIVEN=1
	     fi
            ])
AC_ARG_WITH(xml2-lib,
            [  --with-xml2-lib=DIR      XML2 lib directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_LDFLAGS="$AM_LDFLAGS -L$withval"
               SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval"
               XML2LIBGIVEN=1
	     fi
            ])
AC_ARG_WITH(xml2,
            [  --with-xml2=DIR          XML2 install directory ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               AM_CPPFLAGS="$AM_CPPFLAGS -I$withval/include -I$withval/include/libxml2"
               AM_LDFLAGS="$AM_LDFLAGS -L$withval/lib"
               SO_LIB_PATH="${SO_LIB_PATH:+$SO_LIB_PATH:}$withval/lib"
               XML2INCLUDEGIVEN=1
               XML2LIBGIVEN=1
	     fi
            ])


# The xml2 include and lib can be found either by xml2-config or pkg-config
# depending on what is available or provided by the user.
XML2CONFIGGIVEN=""
XML2CONFIG=""
AC_ARG_WITH(xml2-config,
            [  --with-xml2-config=executable XML2 config tool ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               XML2CONFIG="$withval"
               XML2CONFIGGIVEN=1
	     fi
            ])

PKGCONFIGGIVEN=""
PKGCONFIG=""
AC_ARG_WITH(pkg-config,
            [  --with-pkg-config=executable pkg-config tool ],
            [if test "x$withval" != "xyes" -a "x$withval" != "x"
             then
               PKGCONFIG="$withval"
               PKGCONFIGGIVEN=1
	     fi
            ])

# If none of xml2-config and pkg-config is provided by the user, we pick one
if test "x$XML2CONFIGGIVEN" = "x" -a "x$PKGCONFIGGIVEN" = "x"
then
  AC_CHECK_PROG(PKGCONFIG, pkg-config, [pkg-config])
  if test "x$PKGCONFIG" = "x"
  then
    AC_CHECK_PROG(XML2CONFIG, xml2-config, [xml2-config])
  fi
fi

XML2CFLAGS=""
XML2LIBS=""
if test "x$PKGCONFIG" != "x"
then
  XML2CFLAGS=`$PKGCONFIG --cflags libxml-2.0 2> /dev/null`
  XML2LIBS=`$PKGCONFIG --libs libxml-2.0 2> /dev/null`
else
  if test "x$XML2CONFIG" != "x"
  then
    XML2CFLAGS=`$XML2CONFIG --cflags`
    XML2LIBS=`$XML2CONFIG --libs`
  fi
fi

if test "x$XML2INCLUDEGIVEN" = "x" -a "x$XML2CFLAGS" != "x"
then
  AM_CPPFLAGS="$AM_CPPFLAGS $XML2CFLAGS"
fi

if test "x$XML2LIBGIVEN" = "x" -a "x$XML2LIBS" != "x"
then
  XML2LIBSPURE=`echo $XML2LIBS | $SED -e 's/^-l//g;s/ -l//g;s/\t-l//g;'`
  AC_SEARCH_LIBS([xmlTextReaderIsEmptyElement], [$XML2LIBSPURE], [], [], [$XML2LFLAGS])
fi


# Save user flags and set flags given by configure for the rest of the tests
USER_CFLAGS="$CFLAGS"
USER_CXXFLAGS="$CXXFLAGS"
USER_CPPFLAGS="$CPPFLAGS"
USER_LDFLAGS="$LDFLAGS"
CFLAGS="$AM_CFLAGS $USER_CFLAGS"
CXXFLAGS="$AM_CXXFLAGS $USER_CXXFLAGS"
CPPFLAGS="$AM_CPPFLAGS $USER_CPPFLAGS"
LDFLAGS="$AM_LDFLAGS $USER_LDFLAGS"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$SO_LIB_PATH"

# Checks for libraries.
dlopen_ok="yes"
AC_CHECK_LIB([c], [dlopen], [], [dlopen_ok="no"])
if test "x${dlopen_ok}y" = "xnoy" ; then
  AC_CHECK_LIB([dl], [dlopen], [], AC_MSG_ERROR([libdl unusable]))
fi
AC_CHECK_LIB([gmp], [__gmpz_init], [true], AC_MSG_ERROR([libgmp unusable]))
AC_CHECK_LIB([gmp], [__gmpz_fac_ui], [true], AC_MSG_ERROR([libgmp version too old]))
AC_CHECK_LIB([gmp], [__gmpz_bin_uiui], [true], AC_MSG_ERROR([libgmp version too old]))
AC_CHECK_LIB([gmp], [__gmpz_export], [], AC_MSG_ERROR([libgmp version too old])) # This one adds -lgmp in case of success
AC_CHECK_LIB([mpfr], [mpfr_init], [true], AC_MSG_ERROR([libmpfr unusable]))
AC_CHECK_LIB([mpfr], [mpfr_set_z_2exp], [true], AC_MSG_ERROR([libmpfr version too old]))
AC_CHECK_LIB([mpfr], [mpfr_erfc], [], AC_MSG_ERROR([libmpfr version too old])) # This one adds -lmpfr in case of success
AC_CHECK_LIB([mpfi], [mpfi_init], [], AC_MSG_ERROR([libmpfi unusable]))
AC_CHECK_LIB([z], [gzdopen], [], [])
AC_CHECK_LIB([iconv], [libiconv_open], [], []) # This for providing a statically linked program under Cygwin. See e0d7171f9daf0027e075723d21fb40a864578cd5
AC_CHECK_LIB([m],[cos])
AC_CHECK_LIB([xml2], [xmlTextReaderIsEmptyElement], [], AC_MSG_ERROR([libxml2 unusable]))

# Check that dynamic libraries are available at runtime
AC_MSG_CHECKING([if libgmp is found at runtime])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]],
                               [[mpz_t a; mpz_init(a); mpz_clear(a); return 0;]])],
	      [AC_MSG_RESULT(yes)],
              [AC_MSG_RESULT(no)
               AC_MSG_WARN([libgmp is found at compile time but not at run time. This may or may not be an issue. If it is an issue (viz. if compilation fails), try checking /etc/ld.so.conf and run ldconfig and/or check all settings concerning search paths for shared libraries.])],
              [AC_MSG_RESULT([skipped (cross-compilation)])])


AC_MSG_CHECKING([if libmpfr is found at runtime])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <mpfr.h>]],
                               [[mpfr_t a; mpfr_init2(a, 53); mpfr_clear(a); return 0;]])],
	      [AC_MSG_RESULT(yes)],
              [AC_MSG_RESULT(no)
               AC_MSG_WARN([libmpfr is found at compile time but not at run time. This may or may not be an issue. If it is an issue (viz. if compilation fails), try checking /etc/ld.so.conf and run ldconfig and/or check all settings concerning search paths for shared libraries.])],
              [AC_MSG_RESULT([skipped (cross-compilation)])])


AC_MSG_CHECKING([if libmpfi is found at runtime])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <mpfi.h>]],
                               [[mpfi_t a; mpfi_init(a); mpfi_clear(a); return 0;]])],
	      [AC_MSG_RESULT(yes)],
              [AC_MSG_RESULT(no)
               AC_MSG_WARN([libmpfi is found at compile time but not at run time. This may or may not be an issue. If it is an issue (viz. if compilation fails), try checking /etc/ld.so.conf and run ldconfig and/or check all settings concerning search paths for shared libraries.])],
              [AC_MSG_RESULT([skipped (cross-compilation)])])


AC_MSG_CHECKING([if libxml2 is found at runtime])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <libxml/xmlreader.h>]],
                               [[xmlCleanupParser(); return 0;]])],
	      [AC_MSG_RESULT(yes)],
              [AC_MSG_RESULT(no)
               AC_MSG_WARN([libxml2 is found at compile time but not at run time. This may or may not be an issue. If it is an issue (viz. if compilation fails), try checking /etc/ld.so.conf and run ldconfig and/or check all settings concerning search paths for shared libraries.])],
              [AC_MSG_RESULT([skipped (cross-compilation)])])



#Special check for fplll
AC_LANG_PUSH([C++])

#Check for -std=c++11 or -std=gnu++11
CXXFLAGS="$AM_CXXFLAGS -std=c++11 $USER_CXXFLAGS"
AC_MSG_CHECKING([for -std=c++11 or -std=gnu++11 support])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                  [
                     AC_MSG_RESULT(yes)
                     STDCXX11="-std=c++11"
                  ],
                  [
		     CXXFLAGS="$AM_CXXFLAGS -std=gnu++11 $USER_CXXFLAGS"
		     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                     		       [
                                          AC_MSG_RESULT(yes)
					  STDCXX11="-std=gnu++11"
				       ],
				       [
				          AC_MSG_RESULT(no)
					  STDCXX11=""
				       ])
		  ])

# We currently have 4 parameters that can take two values and depending on the version of fplll and g++, a given combination of them might work or not:
#  - include <fplll.h> or <fplll/fplll.h>
#  - link with -lfplll flag or not
#  - use -std=c+11 or not
#  - use the old or new API of fplll
# It seems reasonable to filter the 16 possible cases by noticing that the the necessity of including the -std option is quite recent, whereas the include <fplll/fplll.h> actually corresponds to fairly old versions of fplll. Also, the compilation with -lfplll is required for quite a while now.
# We first assume a relatively recent vers of fplll: trying include <fplll.h> and linking with -lfplll, we explore the 4 remaining possibilities.
# If none of these possibilities worked, we assume a fairly old version of fplll: trying the old API and without the -std option, we explore the 3 remaining possibilitie.
# If nothing worked of these 7 possibilities, we give up.

FPLLL_PROGV3=`printf "\
  ZZ_mat<mpz_t> *M; Z_NR<mpz_t>  zval; mpz_t mpzval; wrapper *LLLwrapper; int i,j;\n\
  mpz_init(mpzval);\n\
  M = new ZZ_mat<mpz_t>(3, 3);\n\
  for(i=0;i<=2;i++) {\n\
    for(j=0;j<=2;j++) {\n\
      mpz_set_ui(mpzval, (i+1)*(j+2));\n\
      zval.set(mpzval);\n\
      M->Set(i,j,zval);\n\
    }\n\
  }\n\
  LLLwrapper = new wrapper(M);\n\
  LLLwrapper->LLL();\
"`
FPLLL_PROG=`printf "\
  ZZ_mat<mpz_t> *M; Z_NR<mpz_t>  zval; mpz_t mpzval; int i,j;\n\
  mpz_init(mpzval);\n\
  M = new ZZ_mat<mpz_t>(3, 3);\n\
  for(i=0;i<=2;i++) {\n\
    for(j=0;j<=2;j++) {\n\
      mpz_set_ui(mpzval, (i+1)*(j+2));\n\
      zval = mpzval;\n\
      (*M)@<:@i@:>@@<:@j@:>@ = zval;\n\
    }\n\
  }\n\
  lll_reduction(*M);\
"`

FPLLL_NORMAL_HEADER=`printf "\
  #include <stdlib.h>\n\
  #include <fplll.h>\n\
  #include <gmp.h>\n\
"`

# Starting with fplll 5.3 or so, explicitly using namespace fplll is
# required. It prevents sollya to compile against fplll 3 though.
FPLLL_NORMAL_HEADER_WITH_NAMESPACE=`printf "\
  #include <stdlib.h>\n\
  #include <fplll.h>\n\
  #include <gmp.h>\n\
  using namespace fplll;\n\
"`

FPLLL_SPECIAL_HEADER=`printf "\
  #include <stdlib.h>\n\
  #include <fplll/fplll.h>\n\
  #include <gmp.h>\n\
"`

FPLLLSPECIALINCLUDE="no"
FPLLLISREALLIB="no"
FPLLLCXX11="no"
FPLLLMODERNAPI="no"

AC_MSG_CHECKING([for a suitable installation of fplll])
OLD_LIBS="$LIBS";

LIBS="-lfplll $LIBS";
CXXFLAGS="$AM_CXXFLAGS $STDCXX11 $USER_CXXFLAGS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[$FPLLL_NORMAL_HEADER_WITH_NAMESPACE]], [[$FPLLL_PROG]])],
               [
                  FPLLLSPECIALINCLUDE="no"
                  FPLLLISREALLIB="yes"
                  FPLLLCXX11="yes"
                  FPLLLMODERNAPI="yes"
		  AC_MSG_RESULT(yes)
               ],
  [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$FPLLL_NORMAL_HEADER]], [[$FPLLL_PROGV3]])],
                  [
                     FPLLLSPECIALINCLUDE="no"
                     FPLLLISREALLIB="yes"
                     FPLLLCXX11="yes"
                     FPLLLMODERNAPI="no"
		     AC_MSG_RESULT(yes)
		  ],
    [CXXFLAGS="$AM_CXXFLAGS $USER_CXXFLAGS"
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[$FPLLL_NORMAL_HEADER]], [[$FPLLL_PROGV3]])],
                                     [
                                        FPLLLSPECIALINCLUDE="no"
                                        FPLLLISREALLIB="yes"
                                        FPLLLCXX11="no"
                                        FPLLLMODERNAPI="no"
                                        AC_MSG_RESULT(yes)
                                     ],
      [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$FPLLL_NORMAL_HEADER_WITH_NAMESPACE]], [[$FPLLL_PROG]])],
                                       [
                                          FPLLLSPECIALINCLUDE="no"
                                          FPLLLISREALLIB="yes"
                                          FPLLLCXX11="no"
                                          FPLLLMODERNAPI="yes"
                                          AC_MSG_RESULT(yes)
                                       ],
        [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$FPLLL_SPECIAL_HEADER]], [[$FPLLL_PROGV3]])],
                                         [
                                            FPLLLSPECIALINCLUDE="yes"
                                            FPLLLISREALLIB="yes"
                                            FPLLLCXX11="no"
                                            FPLLLMODERNAPI="no"
                                            AC_MSG_RESULT(yes)
                                         ],
          [LIBS="$OLD_LIBS"
	   AC_LINK_IFELSE([AC_LANG_PROGRAM([[$FPLLL_SPECIAL_HEADER]], [[$FPLLL_PROGV3]])],
                                           [
                                              FPLLLSPECIALINCLUDE="yes"
                                              FPLLLISREALLIB="no"
                                              FPLLLCXX11="no"
                                              FPLLLMODERNAPI="no"
                                              AC_MSG_RESULT(yes)
                                           ],
            [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$FPLLL_NORMAL_HEADER]], [[$FPLLL_PROGV3]])],
                                             [
                                                FPLLLSPECIALINCLUDE="no"
                                                FPLLLISREALLIB="no"
                                                FPLLLCXX11="no"
                                                FPLLLMODERNAPI="no"
                                                AC_MSG_RESULT(yes)
                                             ],
                                             [AC_MSG_RESULT(no)
                                              AC_MSG_ERROR([libfplll not found])]
            )]
          )]
        )]
      )]
    )]
  )]
)

if test "x${FPLLLSPECIALINCLUDE}y" = "xyesy"
then
  FPLLL_GOOD_HEADER="$FPLLL_SPECIAL_HEADER"
  AC_DEFINE([HAVE_SPECIAL_FPLLL_INCLUDE],[1],[Define for determining a special version of FPLLL])
  FPLLLVERSIONSTRING="$FPLLLVERSIONSTRING""fplll.h lies inside a subdirectory of the include directory (Debian-like), "
else
  FPLLL_GOOD_HEADER="$FPLLL_NORMAL_HEADER"
  AC_DEFINE([HAVE_SPECIAL_FPLLL_INCLUDE],[0],[Define for determining a special version of FPLLL])
  FPLLLVERSIONSTRING="$FPLLLVERSIONSTRING""fplll.h lies directly in the include directory, "
fi


if test "x${FPLLLISREALLIB}y" = "xyesy"
then
  LIBS="-lfplll $OLD_LIBS"
  FPLLLVERSIONSTRING="$FPLLLVERSIONSTRING""linkage with -lfplll is compatible, "
else
  LIBS="$OLD_LIBS"
  FPLLLVERSIONSTRING="$FPLLLVERSIONSTRING""linkage with -lfplll is not compatible, "
fi

if test "x${FPLLLCXX11}y" = "xyesy"
then
  AM_CXXFLAGS="$AM_CXXFLAGS $STDCXX11"
  FPLLLVERSIONSTRING="$FPLLLVERSIONSTRING""-std option is passed (""$STDCXX11""), "
else
  FPLLLVERSIONSTRING="$FPLLLVERSIONSTRING""no -std option is passed, "
fi
CXXFLAGS="$AM_CXXFLAGS $USER_CXXFLAGS"

if test "x${FPLLLMODERNAPI}y" = "xyesy"
then
  FPLLL_GOOD_PROG="$FPLLL_PROG"
  AC_DEFINE([HAVE_FPLLL_OLD_API],[0],[Define for determining what API to use with FPLLL])
  FPLLLVERSIONSTRING="$FPLLLVERSIONSTRING""using standard API."
else
  FPLLL_GOOD_PROG="$FPLLL_PROGV3"
  AC_DEFINE([HAVE_FPLLL_OLD_API],[1],[Define for determining what API to use with FPLLL])
  FPLLLVERSIONSTRING="$FPLLLVERSIONSTRING""using the FPLLL_V3_COMPAT API."
fi

AC_DEFINE_UNQUOTED([HAVE_FPLLL_VERSION_STRING],["$FPLLLVERSIONSTRING"],[Define a kind of a version string for FPLLL])
AC_LANG_POP([C++])

# Testing if -lstdc++ works both with the C compiler and the C++ compiler.
# We add it only if it works with both.
ADD_LSTDC="yes"
OLD_LIBS="$LIBS"; LIBS="$LIBS -lstdc++"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                  [],
                  [ADD_LSTDC="no"])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                  [],
                  [ADD_LSTDC="no"])
AC_LANG_POP([C++])
if test "x${ADD_LSTDC}y" = "xnoy"
then
  LIBS="$OLD_LIBS"
fi

AC_LANG_PUSH([C++])
# Checking that libfplll is found at runtime
AC_MSG_CHECKING([if libfplll is found at runtime])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #undef malloc
                                  #undef realloc
                                  $FPLLL_GOOD_HEADER]],
                               [[$FPLLL_GOOD_PROG]])
              ],
              [AC_MSG_RESULT(yes)],
              [AC_MSG_RESULT(no)
               AC_MSG_WARN([libfplll is found at compile time but not at run time. This may or may not be an issue. If it is an issue (viz. if compilation fails), try checking /etc/ld.so.conf and run ldconfig and/or check all settings concerning search paths for shared libraries.])],
              [AC_MSG_RESULT([skipped (cross-compilation)])])

AC_LANG_POP([C++])



#Check for -Wl,-export-dynamic etc.
CFLAGS="$AM_CFLAGS -fPIC -Werror $USER_CFLAGS"
AC_MSG_CHECKING([for -fPIC support])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                  [
                     AC_MSG_RESULT(yes)
                     AM_CFLAGS="$AM_CFLAGS -fPIC"
                  ],
                  [
                     AC_MSG_RESULT(no)
                  ])
CFLAGS="$AM_CFLAGS $USER_CFLAGS"

LDFLAGS="$AM_LDFLAGS -Wl,--export-dynamic $USER_LDFLAGS"
AC_MSG_CHECKING([for --export-dynamic support])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
                                [[exit(0);]]
                               )],
               [
                  AC_MSG_RESULT(yes)
                  AM_LDFLAGS="$AM_LDFLAGS -Wl,--export-dynamic"
               ],
               [
                  AC_MSG_RESULT(no)
               ])
LDFLAGS="$AM_LDFLAGS $USER_LDFLAGS"

LDFLAGS="$AM_LDFLAGS -Xlinker --allow-multiple-definition $USER_LDFLAGS"
AC_MSG_CHECKING([for -Xlinker --allow-multiple-definition support])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
                                [[exit(0);]]
                               )],
               [
                  AC_MSG_RESULT(yes)
                  AM_LDFLAGS="$AM_LDFLAGS -Xlinker --allow-multiple-definition"
               ],
               [
                  AC_MSG_RESULT(no)
               ])
LDFLAGS="$AM_LDFLAGS $USER_LDFLAGS"

LDFLAGS="$AM_LDFLAGS -z muldefs $USER_LDFLAGS"
AC_MSG_CHECKING([for -z muldefs support])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
                                [[exit(0);]]
                               )],
               [
                  AC_MSG_RESULT(yes)
                  AM_LDFLAGS="$AM_LDFLAGS -z muldefs"
               ],
               [
                  AC_MSG_RESULT(no)
               ])
LDFLAGS="$AM_LDFLAGS $USER_LDFLAGS"

AC_ARG_ENABLE(lto-compilation,
              [[  --enable-lto-compilation enables the use of LTO compilation when available]],
              [ if test "x${enableval}y" = "xyesy"
	      	then
			TRYUSELTO="1"
		else
			TRYUSELTO=""
		fi
	      ],
              [TRYUSELTO=""])

TRYUSEFATOBJECTS=""
if test "x${TRYUSELTO}y" = "x1y"
then
    CFLAGS="$AM_CFLAGS -flto $USER_CFLAGS"
    CXXFLAGS="$AM_CXXFLAGS -flto $USER_CXXFLAGS"
    AC_MSG_CHECKING([for -flto support])
    AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                      [
                         AC_LANG_PUSH([C++])
                         AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                                           [
                                              AC_MSG_RESULT(yes)
                                              AM_CFLAGS="$AM_CFLAGS -flto"
                                              AM_CXXFLAGS="$AM_CXXFLAGS -flto"
					      TRYUSEFATOBJECTS="1"
                                            ],
                                            [
                                              AC_MSG_RESULT(no)
                                            ],
					    [AC_MSG_RESULT([skipped (cross-compilation)])])
                         AC_LANG_POP([C++])
                      ],
                      [
                         AC_MSG_RESULT(no)
                      ],
		      [AC_MSG_RESULT([skipped (cross-compilation)])])
    CFLAGS="$AM_CFLAGS $USER_CFLAGS"
    CXXFLAGS="$AM_CXXFLAGS $USER_CXXFLAGS"
fi

if test "x${TRYUSEFATOBJECTS}y" = "x1y"
then
    CFLAGS="$AM_CFLAGS -ffat-lto-objects $USER_CFLAGS"
    CXXFLAGS="$AM_CXXFLAGS -ffat-lto-objects $USER_CXXFLAGS"
    AC_MSG_CHECKING([for -ffat-lto-objects support])
    AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                      [
                         AC_LANG_PUSH([C++])
                         AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                                           [
                                              AC_MSG_RESULT(yes)
                                              AM_CFLAGS="$AM_CFLAGS -ffat-lto-objects"
                                              AM_CXXFLAGS="$AM_CXXFLAGS -ffat-lto-objects"
                                            ],
                                            [
                                              AC_MSG_RESULT(no)
                                            ],
					    [AC_MSG_RESULT([skipped (cross-compilation)])])
                         AC_LANG_POP([C++])
                      ],
                      [
                         AC_MSG_RESULT(no)
                      ],
		      [AC_MSG_RESULT([skipped (cross-compilation)])])
    CFLAGS="$AM_CFLAGS $USER_CFLAGS"
    CXXFLAGS="$AM_CXXFLAGS $USER_CXXFLAGS"
fi

AC_ARG_ENABLE(visibility-attributes,
              [[  --enable-visibility-attributes enables the use of visibility attributes where available]],
              [ if test "x${enableval}y" = "xyesy"
	      	then
			TRYUSEVISIBILITY="1"
		else
			TRYUSEVISIBILITY=""
		fi
	      ],
              [TRYUSEVISIBILITY="1"])

if test "x${TRYUSEVISIBILITY}y" = "x1y"
then
CFLAGS="$AM_CFLAGS -fvisibility=hidden $USER_CFLAGS"
CXXFLAGS="$AM_CXXFLAGS -fvisibility=hidden $USER_CXXFLAGS"
VISIBILITY_HEADER=`printf "\
  #include <stdlib.h>\n\
  __attribute__((__visibility__("default"))) int f(void) { return 17; }\
"`
VISIBILITY_PROG=`printf "\
  if (f() == 17) exit(0); else exit(1);\
"`
AC_CACHE_CHECK([for support for visibility attributes], [sollya_cv_compileoptions_visibility],
               [ AC_RUN_IFELSE([AC_LANG_PROGRAM([[$VISIBILITY_HEADER]], [[$VISIBILITY_PROG]])],
                               [
                                 AC_LANG_PUSH([C++])
                                 AC_RUN_IFELSE([AC_LANG_PROGRAM([[$VISIBILITY_HEADER]], [[$VISIBILITY_PROG]])],
                                               [sollya_cv_compileoptions_visibility="yes"],
                                               [sollya_cv_compileoptions_visibility="no"],
                                               [sollya_cv_compileoptions_visibility="no"] # pessimistic when cross-compiling
                                              )
                                 AC_LANG_POP([C++])
                               ],
                               [sollya_cv_compileoptions_visibility="no"],
                               [sollya_cv_compileoptions_visibility="no"] # pessimistic when cross-compiling
                              )
               ])
if test "x${sollya_cv_compileoptions_visibility}" = "xyes"
then
  AC_DEFINE([HAVE_VISIBILITY_ATTRIBUTE],[1],[Define for the support of the visibility attribute])
  AM_CFLAGS="$AM_CFLAGS -fvisibility=hidden"
  AM_CXXFLAGS="$AM_CXXFLAGS -fvisibility=hidden"
fi
CFLAGS="$AM_CFLAGS $USER_CFLAGS"
CXXFLAGS="$AM_CXXFLAGS $USER_CXXFLAGS"
fi

AC_CACHE_CHECK([if compiler activates FTZ by default], [sollya_cv_features_ftz],
               [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
	                                         #include <stdint.h>
                                               ]],
                                               [[
                                                  union {
                                                    uint64_t i;
                                                    double d;
                                                  } xct, yct;
                                                  volatile double x, y;
                                                  xct.i = 0x1f20000000000000ull;
                                                  x = xct.d;
                                                  y = x * x;
                                                  yct.d = y;
                                                  if (yct.i == 0x0000000000000000ull) return 1;
                                               ]])],
                              [ sollya_cv_features_ftz="no" ],
                              [ sollya_cv_features_ftz="yes" ],
                              [ sollya_cv_features_ftz="yes" ])  # pessimistic when cross-compiling
               ])
if test "x${sollya_cv_features_ftz}" = "xyes"
then
  AC_MSG_CHECKING([if compiler supports -fp-model precise flag])
  CFLAGS="$AM_CFLAGS -fp-model precise $USER_CFLAGS"
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
                                     [[exit(0);]]
                                     )],
                    [AC_MSG_RESULT(yes)
                     AM_CFLAGS="$AM_CFLAGS -fp-model precise"
                    ],
                    [AC_MSG_RESULT(no)]
                    )
  CFLAGS="$AM_CFLAGS $USER_CFLAGS"
fi

# Checks for linker script support:
gl_LD_VERSION_SCRIPT

# Checks for header files.
AC_FUNC_ALLOCA
AC_HEADER_SYS_WAIT

# If we do not have these ones, we consider that we cannot work properly.
# As for termios.h we might do something even if it is missing (e.g., build the
# library and provide the tool able to read files but not working
# interactively). The current position is: we do not.
AC_CHECK_HEADERS([inttypes.h stddef.h stdint.h stdlib.h string.h termios.h unistd.h limits.h wchar.h], [ ], AC_MSG_ERROR([Necessary header is missing]))
# If we do not have these ones, we can survive, protecting corresponding calls by a #ifdef HAVE_....
AC_CHECK_HEADERS([sys/ioctl.h sys/time.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_HEADER_STDBOOL
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_CHECK_HEADERS_ONCE([sys/time.h])

AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_C_VOLATILE
AC_C_INLINE
AC_CHECK_TYPES([ptrdiff_t])

# Checks for library functions.
AC_FUNC_FORK
AC_PROG_GCC_TRADITIONAL  # To support very old versions of gcc
AC_FUNC_VPRINTF
AC_FUNC_MALLOC
AC_FUNC_REALLOC

# If we do not have these functions we should survive because they shall be reimplemented in Sollya if necessaray if they are not provided by the system. In any case a test #ifdef HAVE_ shall protect any call to a function listed here.
AC_CHECK_FUNCS(gettimeofday memmove memset memcpy strchr strerror strrchr strtol dup2 strstr dladdr clock_gettime time sigaction sigaddset sigemptyset sigprocmask)

AC_CACHE_CHECK([if the system allows %n in a writable segment], [sollya_cv_features_completeprintf],
               [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#define _BSD_SOURCE
                                                 #define _DEFAULT_SOURCE
                                                 #include <stdio.h>
                                                 #include <stdlib.h>]],
                                                [[ char *str;
                                                   int count;
                                                   str = malloc(20*sizeof(char));
                                                   sprintf(str, "%%n");
                                                   printf(str, &count);
                                                   free(str);
                                                   return 0;]]
                                                )],
                               [ sollya_cv_features_completeprintf="yes" ],
                               [ sollya_cv_features_completeprintf="no" ],
                               [ sollya_cv_features_completeprintf="no" ]  # pessimistic when cross-compiling
                               )
                ])
if test "x${sollya_cv_features_completeprintf}" = "xno"
then
  AC_DEFINE([SYSTEM_DOES_NOT_ALLOW_COMPLETE_PRINTF],[1],[The system does not allow %n in malloced strings])
fi


AC_CACHE_CHECK([if the Dl_info type is usable], [sollya_cv_features_dlinfo],
               [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#define _GNU_SOURCE 1
                                                 #define _DARWIN_C_SOURCE 1
                                                 #include <dlfcn.h>
                                                 #include <stdlib.h>]],
                                               [[ Dl_info myInfo;
                                                  if (dladdr(main, &myInfo) != 0) return 0;
                                                  exit(1);]]
                                               )],
                              [ sollya_cv_features_dlinfo="yes" ],
                              [ sollya_cv_features_dlinfo="no" ],
                              [ sollya_cv_features_dlinfo="no" ]  # pessimistic when cross-compiling
                              )
                ])
if test "x${sollya_cv_features_dlinfo}" = "xyes"
then
  AC_DEFINE([HAVE_DL_INFO_TYPE],[1],[Enabling Dl_info type usage])
fi

FALLTHRU_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_CACHE_CHECK([if the "__attribute__((fallthrough));" syntax is supported], [sollya_cv_features_fallthrough],
               [AC_RUN_IFELSE([AC_LANG_PROGRAM([[]],
                                               [[ volatile int a, b;
                                                  a = 1;
                                                  b = 0;
                                                  switch (a) {
                                                    case 1:
                                                      b = 1;
                                                      __attribute__((fallthrough));
                                                    case 2:
                                                      b = 2;
                                                  }
                                                  if (b != 2) return 1;
                                                  return 0;]]
                                               )],
                               [sollya_cv_features_fallthrough="yes"],
                               [sollya_cv_features_fallthrough="no"],
                               [sollya_cv_features_fallthrough="no"]  # pessimistic when cross-compiling
                               )
               ])
if test "x${sollya_cv_features_fallthrough}" = "xyes"
then
  AC_DEFINE([HAVE_FALLTHRU_ATTRIBUTE],[1],[Enabling the fallthrough attribute])
fi
CFLAGS="$FALLTHRU_CFLAGS"



AC_CHECK_TYPES([mp_bitcnt_t], [], [], [[#include <gmp.h>]])

CPPFLAGS="$USER_CPPFLAGS"
CFLAGS="$USER_CFLAGS"
LDFLAGS="$USER_LDFLAGS"


# The following two lines are supposed to fix bug #17197.
AM_CPPFLAGS="-I\${abs_top_srcdir} $AM_CPPFLAGS"


AC_SUBST(AM_CPPFLAGS)
AC_SUBST(AM_CFLAGS)
AC_SUBST(AM_LDFLAGS)
AC_CONFIG_FILES([Makefile doc/Makefile tests-tool/Makefile tests-lib/Makefile])
AC_OUTPUT
