configure.ac: move gmp detection to a separate file
authorSebastian Pop <spop@codeaurora.org>
Fri, 14 Feb 2014 20:48:29 +0000 (14 14:48 -0600)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 29 May 2014 08:26:53 +0000 (29 10:26 +0200)
Move the code to detect the GMP lib to a separate file to simplify
the next commit.

Signed-off-by: Sebastian Pop <spop@codeaurora.org>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
configure.ac
m4/ax_detect_gmp.m4 [new file with mode: 0644]

index 48e53ee..1349095 100644 (file)
@@ -35,55 +35,11 @@ AM_CONDITIONAL(GENERATE_DOC, test -n "$PERL" -a -n "$PDFLATEX" -a -n "$POD2HTML"
 
 AX_CREATE_STDINT_H(include/isl/stdint.h)
 
-AX_SUBMODULE(gmp,system|build,system)
-
 AC_SUBST(GMP_CPPFLAGS)
 AC_SUBST(GMP_LDFLAGS)
 AC_SUBST(GMP_LIBS)
-case "$with_gmp" in
-system)
-       if test "x$with_gmp_prefix" != "x"; then
-               isl_configure_args="$isl_configure_args --with-gmp=$with_gmp_prefix"
-               GMP_CPPFLAGS="-I$with_gmp_prefix/include"
-               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"
-       GMP_LIBS="$with_gmp_builddir/libgmp.la"
-       ;;
-esac
-SAVE_CPPFLAGS="$CPPFLAGS"
-SAVE_LDFLAGS="$LDFLAGS"
-SAVE_LIBS="$LIBS"
-CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
-LDFLAGS="$GMP_LDFLAGS $LDFLAGS"
-LIBS="$GMP_LIBS $LIBS"
-need_get_memory_functions=false
-AC_CHECK_DECLS(mp_get_memory_functions,[],[
-       need_get_memory_functions=true
-],[#include <gmp.h>])
-CPPFLAGS="$SAVE_CPPFLAGS"
-LDFLAGS="$SAVE_LDFLAGS"
-LIBS="$SAVE_LIBS"
-AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
+AX_DETECT_GMP
+
 AC_CHECK_DECLS(ffs,[],[],[#include <strings.h>])
 AC_CHECK_DECLS(__builtin_ffs,[],[],[])
 
diff --git a/m4/ax_detect_gmp.m4 b/m4/ax_detect_gmp.m4
new file mode 100644 (file)
index 0000000..7748ff0
--- /dev/null
@@ -0,0 +1,47 @@
+AC_DEFUN([AX_DETECT_GMP], [
+AX_SUBMODULE(gmp,system|build,system)
+case "$with_gmp" in
+system)
+       if test "x$with_gmp_prefix" != "x"; then
+               isl_configure_args="$isl_configure_args --with-gmp=$with_gmp_prefix"
+               GMP_CPPFLAGS="-I$with_gmp_prefix/include"
+               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"
+       GMP_LIBS="$with_gmp_builddir/libgmp.la"
+       ;;
+esac
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+SAVE_LIBS="$LIBS"
+CPPFLAGS="$GMP_CPPFLAGS $CPPFLAGS"
+LDFLAGS="$GMP_LDFLAGS $LDFLAGS"
+LIBS="$GMP_LIBS $LIBS"
+need_get_memory_functions=false
+AC_CHECK_DECLS(mp_get_memory_functions,[],[
+       need_get_memory_functions=true
+],[#include <gmp.h>])
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+LIBS="$SAVE_LIBS"
+AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue)
+])