m4-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FYI: 17-gary-evalmp-libgmp-autoconfiscation.patch


From: Gary V. Vaughan
Subject: FYI: 17-gary-evalmp-libgmp-autoconfiscation.patch
Date: Fri, 21 Sep 2001 01:21:52 +0100
User-agent: Mutt/1.3.22.1i

This completes my original intention from the recently demised mpeval
TODO entry.

Cheers,
        Gary.

Index: ChangeLog
from  Gary V. Vaughan  <address@hidden>

        * config/gmp.m4 (AC_ARG_WITH): Removed.
        (GMP_LIB): Renamed to LIBADD_GMP for consistency.
        (AC_LIB_GMP): When performing a test compile against libgmp,
        include the header gmp.h if possible, and link against -lgmp.  If
        they both work define USE_GMP.
        * modules/Makefile.am (mpeval_la_LIBADD): Add LIBADD_GMP.
        (mpeval_LTX_init_func): Complain on load that there was no libgmp
        at compile time.

Index: config/gmp.m4
===================================================================
RCS file: /cvsroot/m4/m4/config/gmp.m4,v
retrieving revision 1.3
diff -u -p -u -r1.3 gmp.m4
--- config/gmp.m4 2001/09/20 08:49:31 1.3
+++ config/gmp.m4 2001/09/21 00:12:58
@@ -16,44 +16,52 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 # 02111-1307  USA
 
-# serial 4
+# serial 5
 
 m4_define([_AC_LIB_GMP],
-[AC_ARG_WITH(gmp,
-[  --without-gmp           don't use GNU multiple precision arithmetic 
library],
-[use_gmp=$withval], [use_gmp=yes])
-
-case $use_gmp:$GMP_LIB:$ac_cv_header_gmp_h in
-  *::yes)
+[case $LIBADD_GMP:$ac_cv_header_gmp_h in
+  :yes)
     AC_MSG_WARN([gmp library not found or does not appear to work
                  but `gmp.h' is present])
     ac_cv_using_lib_gmp=no
     ;;
-  *:-lgmp:no)
+  -lgmp:no)
     AC_MSG_WARN([gmp works but `gmp.h' is missing])
     ac_cv_using_lib_gmp=no
     ;;
-  yes:*:yes)
+  *:yes)
     ac_cv_using_lib_gmp=yes
     ;;
-  no:*)
+  *)
     ac_cv_using_lib_gmp=no
     ;;
 esac
-
-if test "$ac_cv_using_lib_gmp" = yes; then
-  AC_DEFINE(WITH_GMP, 1,
-    [Define to 1 if the GNU multiple precision library should be used.])
-fi
 ])# _AC_LIB_GMP
 
 AC_DEFUN([AC_LIB_GMP],
 [AC_CHECK_HEADERS([gmp.h])
-AC_CHECK_LIB([gmp], [mpq_init], [GMP_LIB=-lgmp])
-AC_SUBST([GMP_LIB])dnl
+# Some versions of gmp provide mpq_init as a macro, so we need to
+# include the header file, otherwise the detection will fail.
+gmp_save_LIBS="$LIBS"
+LIBS="$LIBS -lgmp"
+AC_TRY_LINK([#if HAVE_GMP_H
+#  include <gmp.h>
+#endif],
+  [mpq_t n; mpq_init (n);],
+  [LIBADD_GMP=-lgmp])
+LIBS="$gmp_save_LIBS"
 
 AC_CACHE_CHECK([if using GNU multiple precision arithmetic library],
                 [ac_cv_using_lib_gmp],
                 [_AC_LIB_GMP])
-AC_SUBST([USE_GMP], [$ac_cv_using_lib_gmp])dnl
+
+# Don't try to link in libgmp if we are not using it after the last call
+if test "x$ac_cv_using_lib_gmp" = xyes; then
+  AC_DEFINE(USE_GMP, 1, [Define to 1 if using gmp library.])
+else
+  LIBADD_GMP=
+fi
+
+AC_SUBST([USE_GMP], [$ac_cv_using_lib_gmp])
+AC_SUBST([LIBADD_GMP])
 ])# AC_LIB_GMP
Index: modules/Makefile.am
===================================================================
RCS file: /cvsroot/m4/m4/modules/Makefile.am,v
retrieving revision 1.15
diff -u -p -u -r1.15 Makefile.am
--- modules/Makefile.am 2001/09/20 22:01:34 1.15
+++ modules/Makefile.am 2001/09/21 00:12:59
@@ -57,7 +57,7 @@ m4_la_LDFLAGS         = -module
 mpeval_la_SOURCES      = mpeval.c
 EXTRA_mpeval_la_SOURCES        = evalparse.c
 mpeval_la_LDFLAGS      = -module
-mpeval_la_LIBADD       = -lgmp
+mpeval_la_LIBADD       = $(LIBADD_GMP)
 
 traditional_la_SOURCES = traditional.c
 traditional_la_LDFLAGS = -module
Index: modules/mpeval.c
===================================================================
RCS file: /cvsroot/m4/m4/modules/mpeval.c,v
retrieving revision 1.8
diff -u -p -u -r1.8 mpeval.c
--- modules/mpeval.c 2001/09/20 22:01:34 1.8
+++ modules/mpeval.c 2001/09/21 00:12:59
@@ -22,10 +22,38 @@
 #endif
 
 #include <m4module.h>
-#include "m4private.h"
 
-#include <gmp.h>
+#if !USE_GMP
 
+M4INIT_HANDLER (mpeval)
+{
+  const char s[] = "libgmp support was not compiled in";
+
+  if (obs)
+    obstack_grow (obs, s, strlen(s));
+}
+
+#else /* USE_GMP */
+
+#if HAVE_GMP_H
+#  include <gmp.h>
+#endif
+
+
+/* Rename exported symbols for dlpreload()ing.  */
+#define m4_builtin_table       mpeval_LTX_m4_builtin_table
+#define m4_macro_table         mpeval_LTX_m4_macro_table
+
+
+/* Maintain each of the builtins implemented in this modules along
+   with their details in a single table for easy maintenance.
+
+               function        macros  blind */
+#define builtin_functions                      \
+       BUILTIN(mpeval,         FALSE,  TRUE )
+
+
+
 #define numb_set(ans,i) mpq_set(ans,i)
 #define numb_set_si(ans,i) mpq_set_si(*(ans),(long)i,(unsigned long)1)
 
@@ -62,19 +90,6 @@
 
 #define numb_decr(n) numb_minus(n,numb_ONE)
 
-/* Rename exported symbols for dlpreload()ing.  */
-#define m4_builtin_table       mpeval_LTX_m4_builtin_table
-#define m4_macro_table         mpeval_LTX_m4_macro_table
-
-
-/* Maintain each of the builtins implemented in this modules along
-   with their details in a single table for easy maintenance.
-
-               function        macros  blind */
-#define builtin_functions                      \
-       BUILTIN(mpeval,         FALSE,  TRUE )
-
-
 /* Generate prototypes for each builtin handler function. */
 #define BUILTIN(handler, macros,  blind)       M4BUILTIN(handler)
   builtin_functions
@@ -423,3 +438,5 @@ numb_rshift (number * x, const number * 
 
 #define m4_evaluate    builtin_mpeval
 #include "evalparse.c"
+
+#endif /* USE_GMP */
Index: modules/shadow.c
===================================================================
RCS file: /cvsroot/m4/m4/modules/shadow.c,v
retrieving revision 1.6
diff -u -p -u -r1.6 shadow.c
--- modules/shadow.c 2001/08/19 10:53:56 1.6
+++ modules/shadow.c 2001/09/21 00:12:59
@@ -64,7 +64,7 @@ M4INIT_HANDLER (shadow)
 
   if (handle)
     info = lt_dlgetinfo (handle);
-  
+
   /* Only display the message on first load.  */
   if (obs && info && (info->ref_count == 1))
     obstack_grow (obs, s, strlen(s));

-- 
  ())_. Gary V. Vaughan     gary@(oranda.demon.co.uk|gnu.org)
  ( '/  Research Scientist  http://www.oranda.demon.co.uk       ,_())____
  / )=  GNU Hacker          http://www.gnu.org/software/libtool  \'      `&
`(_~)_  Tech' Author        http://sources.redhat.com/autobook   =`---d__/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]