detect missing gmp.h or missing/old gmp library during configure
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 28 Apr 2013 12:09:46 +0000 (14:09 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 30 Apr 2013 04:37:47 +0000 (06:37 +0200)
Until now a missing gmp.h was only detected during compilation
and a missing/old library only during linking.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
configure.ac

index 3213de0..bb19dde 100644 (file)
@@ -48,6 +48,22 @@ system)
                GMP_LDFLAGS="-L$with_gmp_prefix/lib"
        fi
        GMP_LIBS=-lgmp
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       SAVE_LDFLAGS="$LDFLAGS"
+       SAVE_LIBS="$LIBS"
+       CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
+       LDFLAGS="$GMP_LDFLAGS $LDFLAGS"
+       LIBS="$GMP_LIBS $LIBS"
+       AC_CHECK_HEADER([gmp.h], [], [AC_ERROR([gmp.h header not found])])
+       AC_CHECK_LIB([gmp], [main], [], [AC_ERROR([gmp library not found])])
+       AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <gmp.h>]], [[
+               mpz_t n, d;
+               if (mpz_divisible_p(n, d))
+                       mpz_divexact_ui(n, n, 4);
+       ]])], [], [AC_ERROR([gmp library too old])])
+       CPPFLAGS="$SAVE_CPPFLAGS"
+       LDFLAGS="$SAVE_LDFLAGS"
+       LIBS="$SAVE_LIBS"
        ;;
 build)
        GMP_CPPFLAGS="-I$gmp_srcdir -I$with_gmp_builddir"