Debian Codegraph @

m4/check-math-lib.m4

raw
1 # check-math-lib.m4
2 # serial 6
3 dnl Copyright (C) 2007, 2009-2025 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8 dnl
9 dnl gl_CHECK_MATH_LIB (VARIABLE, TYPE, EXPRESSION [, EXTRA-CODE])
10 dnl
11 dnl Sets the shell VARIABLE according to the libraries needed by EXPRESSION
12 dnl (that operates on a variable x of type TYPE) to compile and link: to the
13 dnl empty string if no extra libraries are needed, to "-lm" if -lm is needed,
14 dnl or to "missing" if it does not compile and link either way.
15 dnl
16 dnl Example: gl_CHECK_MATH_LIB([ROUNDF_LIBM], [float], [x = roundf (x);])
17 AC_DEFUN([gl_CHECK_MATH_LIB], [
18 saved_LIBS="$LIBS"
19 $1=missing
20 for libm in "" "-lm"; do
21 LIBS="$saved_LIBS $libm"
22 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
23 #ifndef __NO_MATH_INLINES
24 # define __NO_MATH_INLINES 1 /* for glibc */
25 #endif
26 #include <math.h>
27 $4
28 $2 x;]],
29 [$3])],
30 [$1=$libm
31 break])
32 done
33 LIBS="$saved_LIBS"
34 ])