"Fossies" - the Fresh Open Source Software Archive

Member "gretl-2020e/macros/gmp.m4" (2 Oct 2015, 4279 Bytes) of package /linux/misc/gretl-2020e.tar.xz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # Configure paths for GMP
    2 # Hans Petter Jansson     2001-04-29
    3 # Modified slightly by Allin Cottrell, April 2003
    4 
    5 # Based on macros by Owen Taylor.
    6 
    7 dnl AM_PATH_GMP([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
    8 dnl Test for GMP, and define GMP_CFLAGS and GMP_LIBS.
    9 dnl
   10 AC_DEFUN([AM_PATH_GMP],
   11 [dnl 
   12 AC_ARG_WITH(gmp-prefix,[  --with-gmp-prefix=PFX   Prefix where GMP is installed (optional)],
   13             gmp_config_prefix="$withval", gmp_config_prefix="")
   14 
   15   if test x$gmp_config_prefix != x ; then
   16      gmp_config_args="$gmp_config_args --prefix=$gmp_config_prefix"
   17   fi
   18 
   19   min_gmp_version=ifelse([$1], ,1.0.0,$1)
   20 
   21   AC_MSG_CHECKING(for GMP - version >= $min_gmp_version)
   22 
   23   GMP_CFLAGS="-I$gmp_config_prefix/include"
   24   GMP_LIBS="-L$gmp_config_prefix/lib -lgmp"
   25 
   26   ac_save_CFLAGS="$CFLAGS"
   27   ac_save_LIBS="$LIBS"
   28   CFLAGS="$CFLAGS $GMP_CFLAGS"
   29   LIBS="$GMP_LIBS $LIBS"
   30 
   31 dnl
   32 dnl Now check if the installed GMP is sufficiently new.
   33 dnl
   34   rm -f conf.gmptest
   35   AC_TRY_RUN([
   36 #include <gmp.h>
   37 #include <stdio.h>
   38 #include <stdlib.h>
   39 #include <string.h>
   40 
   41 int 
   42 main ()
   43 {
   44   int gmp_major_version = 0, gmp_minor_version = 0, gmp_micro_version = 0;
   45   int major, minor, micro;
   46   char *tmp_version;
   47   mpz_t a, b, c;
   48 
   49   mpz_init(a);
   50   mpz_init(b);
   51   mpz_init(c);
   52   mpz_mul(c, a, b);
   53 
   54   system("touch conf.gmptest");
   55 
   56 #ifdef __GNU_MP_VERSION
   57   gmp_major_version = __GNU_MP_VERSION;
   58 #endif
   59 
   60 #ifdef __GNU_MP_VERSION_MINOR
   61   gmp_minor_version = __GNU_MP_VERSION_MINOR;
   62 #endif
   63 
   64 #ifdef __GNU_MP_VERSION_PATCHLEVEL
   65   gmp_micro_version = __GNU_MP_VERSION_PATCHLEVEL;
   66 #endif
   67 
   68   /* HP/UX 9 (%@#!) writes to sscanf strings */
   69   tmp_version = strdup("$min_gmp_version");
   70   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
   71      printf("%s, bad version string\n", "$min_gmp_version");
   72      exit(1);
   73   }
   74 
   75   if ((gmp_major_version > major) ||
   76      ((gmp_major_version == major) && (gmp_minor_version > minor)) ||
   77      ((gmp_major_version == major) && (gmp_minor_version == minor) && (gmp_micro_version >= micro))) {
   78     return 0;
   79   } else {
   80      printf("\n*** An old version of GNU MP (%d.%d.%d) was found.\n",
   81            gmp_major_version, gmp_minor_version, gmp_micro_version);
   82     printf("*** You need a version of GNU MP newer than %d.%d.%d. The latest version of\n",
   83            major, minor, micro);
   84 
   85     printf("*** GNU MP is always available from ftp://ftp.gnu.org.\n");
   86     printf("***\n");
   87   }
   88 
   89   return 1;
   90 }
   91 ],, no_gmp=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
   92   CFLAGS="$ac_save_CFLAGS"
   93   LIBS="$ac_save_LIBS"
   94 
   95   if test "x$no_gmp" = x ; then
   96      AC_MSG_RESULT(yes)
   97      ifelse([$2], , :, [$2])     
   98   else
   99      AC_MSG_RESULT(no)
  100      if test -f conf.gmptest ; then
  101        :
  102      else
  103        echo "*** Could not run GNU MP test program, checking why..."
  104        CFLAGS="$CFLAGS $GMP_CFLAGS"
  105        LIBS="$LIBS $GMP_LIBS"
  106        AC_TRY_LINK([
  107 #include <gmp.h>
  108 #include <stdio.h>
  109 ],     [ return (1); ],
  110        [ echo "*** The test program compiled, but did not run. This usually means"
  111          echo "*** that the run-time linker is not finding GNU MP or finding the wrong"
  112          echo "*** version of GNU MP. If it is not finding GNU MP, you'll need to set your"
  113          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
  114          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
  115          echo "*** is required on your system"
  116          echo "***"
  117          echo "*** If you have an old version installed, it is best to remove it, although"
  118          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
  119          echo "***" ],
  120        [ echo "*** The test program failed to compile or link. See the file config.log for the"
  121          echo "*** exact error that occured. This usually means GNU MP was incorrectly installed"
  122          echo "*** or that you have moved GNU MP since it was installed." ])
  123          CFLAGS="$ac_save_CFLAGS"
  124          LIBS="$ac_save_LIBS"
  125      fi
  126      GMP_CFLAGS=""
  127      GMP_LIBS=""
  128      ifelse([$3], , :, [$3])
  129   fi
  130   if test "$GMP_CFLAGS" = "-I/include" ; then 
  131      GMP_CFLAGS=""
  132   fi
  133   if test "$GMP_LIBS" = "-L/lib -lgmp" ; then 
  134      GMP_LIBS="-lgmp"
  135   fi
  136   AC_SUBST(GMP_CFLAGS)
  137   AC_SUBST(GMP_LIBS)
  138   rm -f conf.gmptest
  139 ])