1 # check-libm.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.
7 dnl AC_CHECK_LIBM_FUNC (MATH_FUNCTION, INVOCATION,
8 dnl [RUN-IF-FOUND], [RUN-IF-NOT-FOUND])
10 dnl Checks for a declaration of the given MATH_FUNCTION in <math.h>, and
11 dnl substitutes HAVE_DECL_<func> accordingly. If a declaration is found,
12 dnl determines the needed library (if any), assigns it to <func>_LIBM, and
13 dnl executes RUN-IF-FOUND; otherwise, executes RUN-IF-NOT-FOUND.
15 dnl INVOCATION should be a C statement that invokes MATH_FUNCTION, both
16 dnl using and assigning back to double variable 'x', e.g. "x = floor
18 AC_DEFUN([gl_CHECK_LIBM_FUNC],
20 m4_pushdef([FUNC_LIBM], m4_toupper([$1])[_LIBM])dnl
21 m4_pushdef([HAVE_DECL_FUNC], HAVE_DECL_[]m4_toupper([$1]))dnl
22 AC_CHECK_DECLS([$1], , , [#include <math.h>])
23 if test "$ac_cv_have_decl_$1" = yes; then
26 for libm in "" "-lm"; do
27 LIBS="$save_LIBS $libm"
29 #ifndef __NO_MATH_INLINES
30 # define __NO_MATH_INLINES 1 /* for glibc */
39 if test "$FUNC_LIBM" = "?"; then
42 m4_ifvaln([$3], [$3])dnl
46 m4_ifvaln([$4], [$4])dnl
48 AC_SUBST(HAVE_DECL_FUNC)
50 m4_popdef([FUNC_LIBM])
51 m4_popdef([HAVE_DECL_FUNC])])