From 399dcf13bef188b1e9c70e48777ec1c72edc375d Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Fri, 14 Feb 2014 14:48:29 -0600 Subject: [PATCH] configure.ac: move gmp detection to a separate file Move the code to detect the GMP lib to a separate file to simplify the next commit. Signed-off-by: Sebastian Pop Signed-off-by: Sven Verdoolaege --- configure.ac | 48 ++---------------------------------------------- m4/ax_detect_gmp.m4 | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 46 deletions(-) create mode 100644 m4/ax_detect_gmp.m4 diff --git a/configure.ac b/configure.ac index 48e53ee1..13490953 100644 --- a/configure.ac +++ b/configure.ac @@ -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 ]], [[ - 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 ]) -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 ]) AC_CHECK_DECLS(__builtin_ffs,[],[],[]) diff --git a/m4/ax_detect_gmp.m4 b/m4/ax_detect_gmp.m4 new file mode 100644 index 00000000..7748ff09 --- /dev/null +++ b/m4/ax_detect_gmp.m4 @@ -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 ]], [[ + 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 ]) +CPPFLAGS="$SAVE_CPPFLAGS" +LDFLAGS="$SAVE_LDFLAGS" +LIBS="$SAVE_LIBS" +AM_CONDITIONAL(NEED_GET_MEMORY_FUNCTIONS, test x$need_get_memory_functions = xtrue) +]) -- 2.11.4.GIT