1 # wm_libmath.m4 - Macros to check proper libMath usage for WINGs
3 # Copyright (c) 2013 Christophe Curis
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 # Checks the needed library link flags needed to have math lib
23 # Sets variable LIBM with the appropriates flags
24 AC_DEFUN_ONCE([WM_CHECK_LIBM],
25 [AC_CHECK_HEADER([math.h], [],
26 [AC_MSG_ERROR([header for math library not found])])
29 [AC_CHECK_LIB(m, [atan],
31 [AC_MSG_WARN(Could not find Math library, you may experience problems)
33 AC_CACHE_CHECK([if M_PI is defined in math.h], [wm_cv_libm_pi],
35 wm_save_CFLAGS="$CFLAGS"
37 "% yes" dnl natively available (Unix98 compliant?)
38 "-D_XOPEN_SOURCE=500" ; dnl Explicit request
40 AS_IF([wm_fn_lib_try_compile "math.h" "double val;" "val = M_PI" dnl
41 "`echo "$wm_arg" | sed -e 's, *%.*$,,' `"],
42 [wm_cv_libm_pi="`echo "$wm_arg" | sed -e 's,^.*% *,,' `" ; break])
44 CFLAGS="$wm_save_CFLAGS"])
45 AS_IF([test "x$wm_cv_libm_pi" = "xno"],
46 [AC_DEFINE([WM_PI], [(3.14159265358979323846)],
47 [Defines how to access the value of Pi])],
48 [AC_DEFINE([WM_PI], [(M_PI)],
49 [Defines how to access the value of Pi])
50 AS_IF([test "x$wm_cv_libm_pi" != "xyes"],
51 [CFLAGS="$CFLAGS $wm_cv_libm_pi"]) ])