New module 'hypotl'.
[gnulib.git] / m4 / hypotl.m4
1 # hypotl.m4 serial 1
2 dnl Copyright (C) 2012 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.
6
7 AC_DEFUN([gl_FUNC_HYPOTL],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   AC_REQUIRE([gl_FUNC_HYPOT])
11
12   dnl Test whether hypotl() exists. Assume that hypotl(), if it exists, is
13   dnl defined in the same library as hypot().
14   save_LIBS="$LIBS"
15   LIBS="$LIBS $HYPOT_LIBM"
16   AC_CHECK_FUNCS([hypotl])
17   LIBS="$save_LIBS"
18   if test $ac_cv_func_hypotl = yes; then
19     HYPOTL_LIBM="$HYPOT_LIBM"
20   else
21     HAVE_HYPOTL=0
22     dnl Find libraries needed to link lib/hypotl.c.
23     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
24       HYPOTL_LIBM="$HYPOT_LIBM"
25     else
26       AC_REQUIRE([gl_FUNC_FABSL])
27       AC_REQUIRE([gl_FUNC_FREXPL])
28       AC_REQUIRE([gl_FUNC_LDEXPL])
29       AC_REQUIRE([gl_FUNC_SQRTL])
30       HYPOTL_LIBM=
31       dnl Append $FABSL_LIBM to HYPOTL_LIBM, avoiding gratuitous duplicates.
32       case " $HYPOTL_LIBM " in
33         *" $FABSL_LIBM "*) ;;
34         *) HYPOTL_LIBM="$HYPOTL_LIBM $FABSL_LIBM" ;;
35       esac
36       dnl Append $FREXPL_LIBM to HYPOTL_LIBM, avoiding gratuitous duplicates.
37       case " $HYPOTL_LIBM " in
38         *" $FREXPL_LIBM "*) ;;
39         *) HYPOTL_LIBM="$HYPOTL_LIBM $FREXPL_LIBM" ;;
40       esac
41       dnl Append $LDEXPL_LIBM to HYPOTL_LIBM, avoiding gratuitous duplicates.
42       case " $HYPOTL_LIBM " in
43         *" $LDEXPL_LIBM "*) ;;
44         *) HYPOTL_LIBM="$HYPOTL_LIBM $LDEXPL_LIBM" ;;
45       esac
46       dnl Append $SQRTL_LIBM to HYPOTL_LIBM, avoiding gratuitous duplicates.
47       case " $HYPOTL_LIBM " in
48         *" $SQRTL_LIBM "*) ;;
49         *) HYPOTL_LIBM="$HYPOTL_LIBM $SQRTL_LIBM" ;;
50       esac
51     fi
52   fi
53   AC_SUBST([HYPOTL_LIBM])
54 ])