Put the test whether the floor or ceil variant needs libm into a separate macro.
authorBruno Haible <bruno@clisp.org>
Mon, 29 Oct 2007 01:08:41 +0000 (02:08 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 29 Oct 2007 01:08:41 +0000 (02:08 +0100)
ChangeLog
m4/ceil.m4
m4/ceilf.m4
m4/ceill.m4
m4/floor.m4
m4/floorf.m4
m4/floorl.m4

index 6784a45..3baecae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
 2007-10-28  Bruno Haible  <bruno@clisp.org>
 
+       * m4/floorl.m4 (gl_FUNC_FLOORL_LIBS): New macro, extracted from
+       gl_FUNC_FLOORL. Cache the result.
+       (gl_FUNC_FLOORL): Use it.
+       * m4/ceill.m4 (gl_FUNC_CEILL_LIBS): New macro, extracted from
+       gl_FUNC_CEILL. Cache the result.
+       (gl_FUNC_CEILL): Use it.
+
+       * m4/floor.m4 (gl_FUNC_FLOOR_LIBS): New macro, extracted from
+       gl_FUNC_FLOOR. Cache the result.
+       (gl_FUNC_FLOOR): Use it.
+       * m4/ceil.m4 (gl_FUNC_CEIL_LIBS): New macro, extracted from
+       gl_FUNC_CEIL. Cache the result.
+       (gl_FUNC_CEIL): Use it.
+
+       * m4/floorf.m4 (gl_FUNC_FLOORF_LIBS): New macro, extracted from
+       gl_FUNC_FLOORF. Cache the result.
+       (gl_FUNC_FLOORF): Use it.
+       * m4/ceilf.m4 (gl_FUNC_CEILF_LIBS): New macro, extracted from
+       gl_FUNC_CEILF. Cache the result.
+       (gl_FUNC_CEILF): Use it.
+
+2007-10-28  Bruno Haible  <bruno@clisp.org>
+
        * gnulib-tool: Allow specifying the LGPL version number through
        --lgpl=2 or --lgpl=3.
        (func_usage): Document --lgpl with argument.
index 9e035f1..9a8eb05 100644 (file)
@@ -1,4 +1,4 @@
-# ceil.m4 serial 1
+# ceil.m4 serial 2
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,18 +7,19 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_CEIL],
 [
   dnl Test whether ceil() can be used without libm.
-  CEIL_LIBM=?
-  AC_TRY_LINK([
-     #ifndef __NO_MATH_INLINES
-     # define __NO_MATH_INLINES 1 /* for glibc */
-     #endif
-     #include <math.h>
-     double x;],
-    [x = ceil(x);],
-    [CEIL_LIBM=])
+  gl_FUNC_CEIL_LIBS
   if test "$CEIL_LIBM" = "?"; then
-    save_LIBS="$LIBS"
-    LIBS="$LIBS -lm"
+    CEIL_LIBM=
+  fi
+  AC_SUBST([CEIL_LIBM])
+])
+
+# Determines the libraries needed to get the ceil() function.
+# Sets CEIL_LIBM.
+AC_DEFUN([gl_FUNC_CEIL_LIBS],
+[
+  AC_CACHE_VAL([gl_func_ceil_libm], [
+    gl_func_ceil_libm=?
     AC_TRY_LINK([
        #ifndef __NO_MATH_INLINES
        # define __NO_MATH_INLINES 1 /* for glibc */
@@ -26,11 +27,20 @@ AC_DEFUN([gl_FUNC_CEIL],
        #include <math.h>
        double x;],
       [x = ceil(x);],
-      [CEIL_LIBM="-lm"])
-    LIBS="$save_LIBS"
-  fi
-  if test "$CEIL_LIBM" = "?"; then
-    CEIL_LIBM=
-  fi
-  AC_SUBST([CEIL_LIBM])
+      [gl_func_ceil_libm=])
+    if test "$gl_func_ceil_libm" = "?"; then
+      save_LIBS="$LIBS"
+      LIBS="$LIBS -lm"
+      AC_TRY_LINK([
+         #ifndef __NO_MATH_INLINES
+         # define __NO_MATH_INLINES 1 /* for glibc */
+         #endif
+         #include <math.h>
+         double x;],
+        [x = ceil(x);],
+        [gl_func_ceil_libm="-lm"])
+      LIBS="$save_LIBS"
+    fi
+  ])
+  CEIL_LIBM="$gl_func_ceil_libm"
 ])
index 65f10be..b409829 100644 (file)
@@ -1,4 +1,4 @@
-# ceilf.m4 serial 1
+# ceilf.m4 serial 2
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,7 +13,25 @@ AC_DEFUN([gl_FUNC_CEILF],
   AC_CHECK_DECLS([ceilf], , , [#include <math.h>])
   if test "$ac_cv_have_decl_ceilf" = yes; then
     dnl Test whether ceilf() can be used without libm.
-    CEILF_LIBM=?
+    gl_FUNC_CEILF_LIBS
+    if test "$CEILF_LIBM" = "?"; then
+      CEILF_LIBM=
+    fi
+  else
+    HAVE_DECL_CEILF=0
+    AC_LIBOBJ([ceilf])
+    CEILF_LIBM=
+  fi
+  AC_SUBST([HAVE_DECL_CEILF])
+  AC_SUBST([CEILF_LIBM])
+])
+
+# Determines the libraries needed to get the ceilf() function.
+# Sets CEILF_LIBM.
+AC_DEFUN([gl_FUNC_CEILF_LIBS],
+[
+  AC_CACHE_VAL([gl_func_ceilf_libm], [
+    gl_func_ceilf_libm=?
     AC_TRY_LINK([
        #ifndef __NO_MATH_INLINES
        # define __NO_MATH_INLINES 1 /* for glibc */
@@ -21,8 +39,8 @@ AC_DEFUN([gl_FUNC_CEILF],
        #include <math.h>
        float x;],
       [x = ceilf(x);],
-      [CEILF_LIBM=])
-    if test "$CEILF_LIBM" = "?"; then
+      [gl_func_ceilf_libm=])
+    if test "$gl_func_ceilf_libm" = "?"; then
       save_LIBS="$LIBS"
       LIBS="$LIBS -lm"
       AC_TRY_LINK([
@@ -32,17 +50,9 @@ AC_DEFUN([gl_FUNC_CEILF],
          #include <math.h>
          float x;],
         [x = ceilf(x);],
-        [CEILF_LIBM="-lm"])
+        [gl_func_ceilf_libm="-lm"])
       LIBS="$save_LIBS"
     fi
-    if test "$CEILF_LIBM" = "?"; then
-      CEILF_LIBM=
-    fi
-  else
-    HAVE_DECL_CEILF=0
-    AC_LIBOBJ([ceilf])
-    CEILF_LIBM=
-  fi
-  AC_SUBST([HAVE_DECL_CEILF])
-  AC_SUBST([CEILF_LIBM])
+  ])
+  CEILF_LIBM="$gl_func_ceilf_libm"
 ])
index 7413a31..577bc55 100644 (file)
@@ -1,4 +1,4 @@
-# ceill.m4 serial 1
+# ceill.m4 serial 2
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,7 +13,25 @@ AC_DEFUN([gl_FUNC_CEILL],
   AC_CHECK_DECLS([ceill], , , [#include <math.h>])
   if test "$ac_cv_have_decl_ceill" = yes; then
     dnl Test whether ceill() can be used without libm.
-    CEILL_LIBM=?
+    gl_FUNC_CEILL_LIBS
+    if test "$CEILL_LIBM" = "?"; then
+      CEILL_LIBM=
+    fi
+  else
+    HAVE_DECL_CEILL=0
+    AC_LIBOBJ([ceill])
+    CEILL_LIBM=
+  fi
+  AC_SUBST([HAVE_DECL_CEILL])
+  AC_SUBST([CEILL_LIBM])
+])
+
+# Determines the libraries needed to get the ceill() function.
+# Sets CEILL_LIBM.
+AC_DEFUN([gl_FUNC_CEILL_LIBS],
+[
+  AC_CACHE_VAL([gl_func_ceill_libm], [
+    gl_func_ceill_libm=?
     AC_TRY_LINK([
        #ifndef __NO_MATH_INLINES
        # define __NO_MATH_INLINES 1 /* for glibc */
@@ -21,8 +39,8 @@ AC_DEFUN([gl_FUNC_CEILL],
        #include <math.h>
        long double x;],
       [x = ceill(x);],
-      [CEILL_LIBM=])
-    if test "$CEILL_LIBM" = "?"; then
+      [gl_func_ceill_libm=])
+    if test "$gl_func_ceill_libm" = "?"; then
       save_LIBS="$LIBS"
       LIBS="$LIBS -lm"
       AC_TRY_LINK([
@@ -32,17 +50,9 @@ AC_DEFUN([gl_FUNC_CEILL],
          #include <math.h>
          long double x;],
         [x = ceill(x);],
-        [CEILL_LIBM="-lm"])
+        [gl_func_ceill_libm="-lm"])
       LIBS="$save_LIBS"
     fi
-    if test "$CEILL_LIBM" = "?"; then
-      CEILL_LIBM=
-    fi
-  else
-    HAVE_DECL_CEILL=0
-    AC_LIBOBJ([ceill])
-    CEILL_LIBM=
-  fi
-  AC_SUBST([HAVE_DECL_CEILL])
-  AC_SUBST([CEILL_LIBM])
+  ])
+  CEILL_LIBM="$gl_func_ceill_libm"
 ])
index dd1e6f6..780a88f 100644 (file)
@@ -1,4 +1,4 @@
-# floor.m4 serial 1
+# floor.m4 serial 2
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,18 +7,19 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_FLOOR],
 [
   dnl Test whether floor() can be used without libm.
-  FLOOR_LIBM=?
-  AC_TRY_LINK([
-     #ifndef __NO_MATH_INLINES
-     # define __NO_MATH_INLINES 1 /* for glibc */
-     #endif
-     #include <math.h>
-     double x;],
-    [x = floor(x);],
-    [FLOOR_LIBM=])
+  gl_FUNC_FLOOR_LIBS
   if test "$FLOOR_LIBM" = "?"; then
-    save_LIBS="$LIBS"
-    LIBS="$LIBS -lm"
+    FLOOR_LIBM=
+  fi
+  AC_SUBST([FLOOR_LIBM])
+])
+
+# Determines the libraries needed to get the floor() function.
+# Sets FLOOR_LIBM.
+AC_DEFUN([gl_FUNC_FLOOR_LIBS],
+[
+  AC_CACHE_VAL([gl_func_floor_libm], [
+    gl_func_floor_libm=?
     AC_TRY_LINK([
        #ifndef __NO_MATH_INLINES
        # define __NO_MATH_INLINES 1 /* for glibc */
@@ -26,11 +27,20 @@ AC_DEFUN([gl_FUNC_FLOOR],
        #include <math.h>
        double x;],
       [x = floor(x);],
-      [FLOOR_LIBM="-lm"])
-    LIBS="$save_LIBS"
-  fi
-  if test "$FLOOR_LIBM" = "?"; then
-    FLOOR_LIBM=
-  fi
-  AC_SUBST([FLOOR_LIBM])
+      [gl_func_floor_libm=])
+    if test "$gl_func_floor_libm" = "?"; then
+      save_LIBS="$LIBS"
+      LIBS="$LIBS -lm"
+      AC_TRY_LINK([
+         #ifndef __NO_MATH_INLINES
+         # define __NO_MATH_INLINES 1 /* for glibc */
+         #endif
+         #include <math.h>
+         double x;],
+        [x = floor(x);],
+        [gl_func_floor_libm="-lm"])
+      LIBS="$save_LIBS"
+    fi
+  ])
+  FLOOR_LIBM="$gl_func_floor_libm"
 ])
index 184c2ee..3baadc0 100644 (file)
@@ -1,4 +1,4 @@
-# floorf.m4 serial 1
+# floorf.m4 serial 2
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,7 +13,25 @@ AC_DEFUN([gl_FUNC_FLOORF],
   AC_CHECK_DECLS([floorf], , , [#include <math.h>])
   if test "$ac_cv_have_decl_floorf" = yes; then
     dnl Test whether floorf() can be used without libm.
-    FLOORF_LIBM=?
+    gl_FUNC_FLOORF_LIBS
+    if test "$FLOORF_LIBM" = "?"; then
+      FLOORF_LIBM=
+    fi
+  else
+    HAVE_DECL_FLOORF=0
+    AC_LIBOBJ([floorf])
+    FLOORF_LIBM=
+  fi
+  AC_SUBST([HAVE_DECL_FLOORF])
+  AC_SUBST([FLOORF_LIBM])
+])
+
+# Determines the libraries needed to get the floorf() function.
+# Sets FLOORF_LIBM.
+AC_DEFUN([gl_FUNC_FLOORF_LIBS],
+[
+  AC_CACHE_VAL([gl_func_floorf_libm], [
+    gl_func_floorf_libm=?
     AC_TRY_LINK([
        #ifndef __NO_MATH_INLINES
        # define __NO_MATH_INLINES 1 /* for glibc */
@@ -21,8 +39,8 @@ AC_DEFUN([gl_FUNC_FLOORF],
        #include <math.h>
        float x;],
       [x = floorf(x);],
-      [FLOORF_LIBM=])
-    if test "$FLOORF_LIBM" = "?"; then
+      [gl_func_floorf_libm=])
+    if test "$gl_func_floorf_libm" = "?"; then
       save_LIBS="$LIBS"
       LIBS="$LIBS -lm"
       AC_TRY_LINK([
@@ -32,17 +50,9 @@ AC_DEFUN([gl_FUNC_FLOORF],
          #include <math.h>
          float x;],
         [x = floorf(x);],
-        [FLOORF_LIBM="-lm"])
+        [gl_func_floorf_libm="-lm"])
       LIBS="$save_LIBS"
     fi
-    if test "$FLOORF_LIBM" = "?"; then
-      FLOORF_LIBM=
-    fi
-  else
-    HAVE_DECL_FLOORF=0
-    AC_LIBOBJ([floorf])
-    FLOORF_LIBM=
-  fi
-  AC_SUBST([HAVE_DECL_FLOORF])
-  AC_SUBST([FLOORF_LIBM])
+  ])
+  FLOORF_LIBM="$gl_func_floorf_libm"
 ])
index 0a5ecb7..ab54d93 100644 (file)
@@ -1,4 +1,4 @@
-# floorl.m4 serial 1
+# floorl.m4 serial 2
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,7 +13,25 @@ AC_DEFUN([gl_FUNC_FLOORL],
   AC_CHECK_DECLS([floorl], , , [#include <math.h>])
   if test "$ac_cv_have_decl_floorl" = yes; then
     dnl Test whether floorl() can be used without libm.
-    FLOORL_LIBM=?
+    gl_FUNC_FLOORL_LIBS
+    if test "$FLOORL_LIBM" = "?"; then
+      FLOORL_LIBM=
+    fi
+  else
+    HAVE_DECL_FLOORL=0
+    AC_LIBOBJ([floorl])
+    FLOORL_LIBM=
+  fi
+  AC_SUBST([HAVE_DECL_FLOORL])
+  AC_SUBST([FLOORL_LIBM])
+])
+
+# Determines the libraries needed to get the floorl() function.
+# Sets FLOORL_LIBM.
+AC_DEFUN([gl_FUNC_FLOORL_LIBS],
+[
+  AC_CACHE_VAL([gl_func_floorl_libm], [
+    gl_func_floorl_libm=?
     AC_TRY_LINK([
        #ifndef __NO_MATH_INLINES
        # define __NO_MATH_INLINES 1 /* for glibc */
@@ -21,8 +39,8 @@ AC_DEFUN([gl_FUNC_FLOORL],
        #include <math.h>
        long double x;],
       [x = floorl(x);],
-      [FLOORL_LIBM=])
-    if test "$FLOORL_LIBM" = "?"; then
+      [gl_func_floorl_libm=])
+    if test "$gl_func_floorl_libm" = "?"; then
       save_LIBS="$LIBS"
       LIBS="$LIBS -lm"
       AC_TRY_LINK([
@@ -32,17 +50,9 @@ AC_DEFUN([gl_FUNC_FLOORL],
          #include <math.h>
          long double x;],
         [x = floorl(x);],
-        [FLOORL_LIBM="-lm"])
+        [gl_func_floorl_libm="-lm"])
       LIBS="$save_LIBS"
     fi
-    if test "$FLOORL_LIBM" = "?"; then
-      FLOORL_LIBM=
-    fi
-  else
-    HAVE_DECL_FLOORL=0
-    AC_LIBOBJ([floorl])
-    FLOORL_LIBM=
-  fi
-  AC_SUBST([HAVE_DECL_FLOORL])
-  AC_SUBST([FLOORL_LIBM])
+  ])
+  FLOORL_LIBM="$gl_func_floorl_libm"
 ])