wmaker: remove useless null pointer check (Coverity #109612)
[wmaker-crm.git] / m4 / wm_libmath.m4
blobdf2b54feee76b9640e94ddb14805d7abf04394f3
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.
20 # WM_CHECK_LIBM
21 # -------------
23 # Checks the needed library link flags needed to have math lib
24 # Sets variable LIBM with the appropriates flags
25 AC_DEFUN_ONCE([WM_CHECK_LIBM],
26 [AC_CHECK_HEADER([math.h], [],
27                  [AC_MSG_ERROR([header for math library not found])])
28 AC_CHECK_FUNC(atan,
29     [LIBM=],
30     [AC_CHECK_LIB(m, [atan],
31         [LIBM=-lm],
32         [AC_MSG_WARN(Could not find Math library, you may experience problems)
33          LIBM=] )] ) dnl
34 AC_CACHE_CHECK([if M_PI is defined in math.h], [wm_cv_libm_pi],
35     [wm_cv_libm_pi="no"
36      wm_save_CFLAGS="$CFLAGS"
37      for wm_arg in dnl
38        "% yes" dnl natively available (Unix98 compliant?)
39        "-D_XOPEN_SOURCE=500" ; dnl Explicit request
40      do
41        AS_IF([wm_fn_lib_try_compile "math.h" "double val;" "val = M_PI" dnl
42                   "`echo "$wm_arg" | sed -e 's, *%.*$,,' `"],
43            [wm_cv_libm_pi="`echo "$wm_arg" | sed -e 's,^.*% *,,' `" ; break])
44      done
45      CFLAGS="$wm_save_CFLAGS"])
46 AS_IF([test "x$wm_cv_libm_pi" = "xno"],
47     [AC_DEFINE([WM_PI], [(3.14159265358979323846)],
48         [Defines how to access the value of Pi])],
49     [AC_DEFINE([WM_PI], [(M_PI)],
50         [Defines how to access the value of Pi])
51      AS_IF([test "x$wm_cv_libm_pi" != "xyes"],
52         [CFLAGS="$CFLAGS $wm_cv_libm_pi"]) ])
53 AC_SUBST(LIBM) dnl