X-Git-Url: https://ginac.de/CLN/cln.git//cln.git?a=blobdiff_plain;f=m4%2Fgmp.m4;h=455c200fcf062540f34d927777a61d3be1cc5f8b;hb=3c6225a8b3fedffaba7279d86db96b8f180b3f28;hp=205101e26589bf31316375491b31926644f55465;hpb=7da4d3ae46279298acd5d65637499caab7b57071;p=cln.git diff --git a/m4/gmp.m4 b/m4/gmp.m4 index 205101e..455c200 100644 --- a/m4/gmp.m4 +++ b/m4/gmp.m4 @@ -36,33 +36,46 @@ cl_cv_new_libgmp="yes", cl_cv_new_libgmp="no") dnl What is sizeof(mp_limb_t)? (It has to match sizeof(uintD) later.) AC_DEFUN([CL_GMP_SET_UINTD], [AC_CACHE_CHECK([how large gmp demands uintD to be], cl_cv_gmp_set_uintd, [ - AC_TRY_RUN([#include -#include -int main() { - FILE *f=fopen("conftestval", "w"); - if (!f) return(255); - if (sizeof(mp_limb_t) > sizeof(long)) - fprintf(f, "long long"); - else if (sizeof(mp_limb_t) == sizeof(long)) - fprintf(f, "long"); - else if (sizeof(mp_limb_t) == sizeof(int)) - fprintf(f, "int"); - else return(sizeof(mp_limb_t)); -#if defined(__GMP_BITS_PER_MP_LIMB) - /* Is there a nail in a limb? */ - if (8*sizeof(mp_limb_t)!=__GMP_BITS_PER_MP_LIMB) - return(254); -#endif - return(0); -}], cl_cv_gmp_set_uintd=`cat conftestval` - cl_gmp_demands="GMP_DEMANDS_UINTD_`echo ${cl_cv_gmp_set_uintd} | sed -e 'y/ gilnot/_GILNOT/'`", - gmp_retval="$ac_status" - if test x$gmp_retval = "x255"; then AC_MSG_ERROR([error opening output file.]); fi - if test x$gmp_retval = "x254"; then AC_MSG_ERROR([nails in MP limbs are unsupported.]); fi - AC_MSG_ERROR([Don't know which C-type has sizeof $gmp_retval.]), - AC_MSG_ERROR([cross-compiling - cannot determine])) -]) -AC_DEFINE_UNQUOTED($cl_gmp_demands) + dnl Note: we don't run any of compiled programs here, so this method + dnl both works for native and cross compilation + cl_gmp_demands="UNKNOWN" + cl_gmp_has_nails="no" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include + template struct Static_Assert; + template<> struct Static_Assert { }; + #if defined(__GMP_BITS_PER_MP_LIMB) + Static_Assert<8*sizeof(mp_limb_t) == __GMP_BITS_PER_MP_LIMB> check; + #endif]], [[]])], [], [cl_gmp_has_nails="yes"]) + if test "x$cl_gmp_has_nails" = "xyes"; then + AC_MSG_ERROR([nails in MP libms are unsupported.]) + fi + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include + template struct Static_Assert; + template<> struct Static_Assert { }; + Static_Assert sizeof(long)> check;]], [[]])], + [cl_gmp_demands='GMP_DEMANDS_UINTD_LONG_LONG'], []) + if test "x$cl_gmp_demands" = "xUNKNOWN"; then + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include + template struct Static_Assert; + template<> struct Static_Assert { }; + Static_Assert check;]], [[]])], + [cl_gmp_demands='GMP_DEMANDS_UINTD_LONG'], []) + fi + if test "x$cl_gmp_demands" = "xUNKNOWN"; then + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + template struct Static_Assert; + template<> struct Static_Assert { }; + Static_Assert check;]], [[]])], + [cl_gmp_demands='GMP_DEMANDS_UINTD_INT'], []) + fi + if test "x$cl_gmp_demands" = "xUNKNOWN"; then + AC_MSG_ERROR([Don't know which C-type has sizeof(mp_limb_t)]) + else + cl_cv_gmp_set_uintd="$cl_gmp_demands" + fi + ]) +AC_DEFINE_UNQUOTED($cl_cv_gmp_set_uintd) ]) dnl Whether or not to use GMP. Sets CL_USE_GMP. @@ -104,6 +117,9 @@ case $with_gmp in CPPFLAGS="$CPPFLAGS -I${withval}/include" saved_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -L${withval}/lib" + AC_LIB_LINKFLAGS_FROM_LIBS([GMP_RPATH_CFG], [$LDFLAGS]) + LDFLAGS="$GMP_RPATH_CFG $LDFLAGS" + AC_MSG_NOTICE([Using "\"$LDFLAGS\"" rpath to link with GMP]) CL_GMP_H_VERSION if test "$cl_cv_new_gmp_h" = yes; then CL_GMP_CHECK