Commit | Line | Data |
---|---|---|
005de2e8 | 1 | # check-math-lib.m4 serial 4 |
f0007cad | 2 | dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc. |
2e65b52f LC |
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 | dnl | |
005de2e8 | 7 | dnl gl_CHECK_MATH_LIB (VARIABLE, EXPRESSION [, EXTRA-CODE]) |
2e65b52f LC |
8 | dnl |
9 | dnl Sets the shell VARIABLE according to the libraries needed by EXPRESSION | |
10 | dnl to compile and link: to the empty string if no extra libraries are needed, | |
11 | dnl to "-lm" if -lm is needed, or to "missing" if it does not compile and | |
12 | dnl link either way. | |
13 | dnl | |
14 | dnl Example: gl_CHECK_MATH_LIB([ROUNDF_LIBM], [x = roundf (x);]) | |
15 | AC_DEFUN([gl_CHECK_MATH_LIB], [ | |
16 | save_LIBS=$LIBS | |
17 | $1=missing | |
18 | for libm in "" "-lm"; do | |
19 | LIBS="$save_LIBS $libm" | |
20 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | |
21 | #ifndef __NO_MATH_INLINES | |
22 | # define __NO_MATH_INLINES 1 /* for glibc */ | |
23 | #endif | |
24 | #include <math.h> | |
005de2e8 | 25 | $3 |
2e65b52f LC |
26 | double x;]], |
27 | [$2])], | |
28 | [$1=$libm | |
29 | break]) | |
30 | done | |
31 | LIBS=$save_LIBS | |
32 | ]) |