2 dnl Copyright (C) 2010 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 # gl_MATHFUNC(FUNC, RETTYPE, PARAMTYPES)
8 # --------------------------------------------------
9 # tests whether the function FUNC is available in libc or libm.
10 # RETTYPE is the return type. PARAMTYPES is a parameter list, with parentheses.
11 # It sets FUNC_LIBM to empty or "-lm" accordingly.
13 AC_DEFUN([gl_MATHFUNC],
15 dnl We need the RETTYPE and PARAMTYPES in order to force linking with the
16 dnl function. With gcc >= 4.3 on glibc/x86_64, calls to the 'fabs' function
17 dnl are inlined by the compiler, therefore linking of these calls does not
18 dnl require -lm, but taking the function pointer of 'fabs' does.
19 m4_pushdef([func], [$1])
20 m4_pushdef([FUNC], [translit([$1],[abcdefghijklmnopqrstuvwxyz],
21 [ABCDEFGHIJKLMNOPQRSTUVWXYZ])])
23 AC_CACHE_CHECK([whether func() can be used without linking with libm],
24 [gl_cv_func_]func[_no_libm],
27 [AC_LANG_PROGRAM([[#ifndef __NO_MATH_INLINES
28 # define __NO_MATH_INLINES 1 /* for glibc */
31 $2 (*funcptr) $3 = ]func[;]],
33 [gl_cv_func_]func[_no_libm=yes],
34 [gl_cv_func_]func[_no_libm=no])
36 if test $gl_cv_func_[]func[]_no_libm = no; then
37 AC_CACHE_CHECK([whether func() can be used with libm],
38 [gl_cv_func_]func[_in_libm],
43 [AC_LANG_PROGRAM([[#ifndef __NO_MATH_INLINES
44 # define __NO_MATH_INLINES 1 /* for glibc */
47 $2 (*funcptr) $3 = ]func[;]],
49 [gl_cv_func_]func[_in_libm=yes],
50 [gl_cv_func_]func[_in_libm=no])
53 if test $gl_cv_func_[]func[]_in_libm = yes; then