AC_DEFUN([KDE_C_LONG_DOUBLE],
[
  AC_CACHE_CHECK(for long double, ac_cv_c_long_double,
  [
    ac_save_LIBS="$LIBS"
    LIBS="-lm $LIBS"
    AC_TRY_RUN(
    [
#define _ISOC99_SOURCE	1
#define _GNU_SOURCE	1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
/* The Stardent Vistra knows sizeof(long double), but does not support it.  */
long double foo = 1.0;
char buffer[10];
/* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
int result = (sizeof(long double) <= sizeof(double));
/* the following is needed for a broken printf in glibc2 */
if (!result) {
    foo = foo * 3;
    sprintf(buffer,"%0.0Lf",foo);
    result = strcmp(buffer, "3");
/* and now something mean ;-) */
    foo = powl(fabsl(foo), 1);
}
exit(result); }
    ],
    ac_cv_c_long_double=yes, ac_cv_c_long_double=no,
    ac_cv_c_long_double=no
    )
    LIBS="$ac_save_LIBS"
  ])
  if test $ac_cv_c_long_double = yes; then
    AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have support for long double in printf])
  fi
])
KDE_C_LONG_DOUBLE

have_l_funcs=yes
AC_CHECK_LIB(m, sqrtl,,have_l_funcs=no)

if test "xyes" = "x$have_l_funcs" ; then
  AC_DEFINE(HAVE_L_FUNCS,1,[Define if you have *l math functions (absl, ...)])
fi

LIBGMP=
KDE_CHECK_HEADER([gmp.h], [
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS

  kde_save_LIBS=$LIBS
  LIBS="$all_libraries -lgmp -ltqt"
  AC_TRY_LINK(dnl
  [
    #include <gmp.h>
  ],
  [ 
    mpz_t _mpz;
    mpz_init_set_si(_mpz, 0);
  ],
  [LIBGMP="-lgmp"],
  [
    DO_NOT_COMPILE="$DO_NOT_COMPILE kcalc"
  ])
  LIBS=$kde_save_LIBS
  AC_LANG_RESTORE

])
AC_SUBST(LIBGMP)
