New module 'frexpl'.
[gnulib.git] / m4 / frexpl.m4
1 # frexpl.m4 serial 1
2 dnl Copyright (C) 2007 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_FREXPL],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   FREXPL_LIBM=
11   AC_CACHE_CHECK([whether frexpl() can be used without linking with libm],
12     [gl_cv_func_frexpl_no_libm],
13     [
14       AC_TRY_LINK([#include <math.h>
15                    long double x;],
16                   [int e; return frexpl (x, &e) > 0;],
17         [gl_cv_func_frexpl_no_libm=yes],
18         [gl_cv_func_frexpl_no_libm=no])
19     ])
20   if test $gl_cv_func_frexpl_no_libm = no; then
21     AC_CACHE_CHECK([whether frexpl() can be used with libm],
22       [gl_cv_func_frexpl_in_libm],
23       [
24         save_LIBS="$LIBS"
25         LIBS="$LIBS -lm"
26         AC_TRY_LINK([#include <math.h>
27                      long double x;],
28                     [int e; return frexpl (x, &e) > 0;],
29           [gl_cv_func_frexpl_in_libm=yes],
30           [gl_cv_func_frexpl_in_libm=no])
31         LIBS="$save_LIBS"
32       ])
33     if test $gl_cv_func_frexpl_in_libm = yes; then
34       FREXPL_LIBM=-lm
35     fi
36   fi
37   if test $gl_cv_func_frexpl_no_libm = yes \
38      || test $gl_cv_func_frexpl_in_libm = yes; then
39     AC_DEFINE([HAVE_FREXPL], 1,
40       [Define if the frexpl() function is available.])
41     dnl Also check whether it's declared.
42     dnl MacOS X 10.3 has frexpl() in libc but doesn't declare it in <math.h>.
43     AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [#include <math.h>])
44   else
45     AC_LIBOBJ([frexpl])
46   fi
47 ])