Import 'c-strcase' from Gnulib.
[bpt/guile.git] / m4 / float_h.m4
CommitLineData
35428fb6 1# float_h.m4 serial 9
af07e104 2dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
c4b681fd
LC
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FLOAT_H],
8[
9 AC_REQUIRE([AC_PROG_CC])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 FLOAT_H=
231c0e0e 12 REPLACE_FLOAT_LDBL=0
c4b681fd 13 case "$host_os" in
231c0e0e 14 aix* | beos* | openbsd* | mirbsd* | irix*)
c4b681fd 15 FLOAT_H=float.h
231c0e0e
LC
16 ;;
17 freebsd*)
18 case "$host_cpu" in
19changequote(,)dnl
20 i[34567]86 )
21changequote([,])dnl
22 FLOAT_H=float.h
23 ;;
24 x86_64 )
25 # On x86_64 systems, the C compiler may still be generating
26 # 32-bit code.
27 AC_EGREP_CPP([yes],
28 [#if defined __LP64__ || defined __x86_64__ || defined __amd64__
29 yes
30 #endif],
31 [],
32 [FLOAT_H=float.h])
33 ;;
34 esac
35 ;;
35428fb6
LC
36 linux*)
37 case "$host_cpu" in
38 powerpc*)
39 FLOAT_H=float.h
40 ;;
41 esac
42 ;;
231c0e0e
LC
43 esac
44 case "$host_os" in
35428fb6 45 aix* | freebsd* | linux*)
231c0e0e
LC
46 if test -n "$FLOAT_H"; then
47 REPLACE_FLOAT_LDBL=1
48 fi
c4b681fd
LC
49 ;;
50 esac
35428fb6
LC
51
52 dnl Test against glibc-2.7 Linux/SPARC64 bug.
53 REPLACE_ITOLD=0
54 AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works],
55 [gl_cv_func_itold_works],
56 [
57 AC_RUN_IFELSE(
58 [AC_LANG_SOURCE([[
59int i = -1;
60volatile long double ld;
61int main ()
62{
63 ld += i * 1.0L;
64 if (ld > 0)
65 return 1;
66 return 0;
67}]])],
68 [gl_cv_func_itold_works=yes],
69 [gl_cv_func_itold_works=no],
70 [case "$host" in
71 sparc*-*-linux*)
72 AC_EGREP_CPP([yes],
73 [#if defined __LP64__ || defined __arch64__
74 yes
75 #endif],
76 [gl_cv_func_itold_works="guessing no"],
77 [gl_cv_func_itold_works="guessing yes"])
78 ;;
79 *) gl_cv_func_itold_works="guessing yes" ;;
80 esac
81 ])
82 ])
83 case "$gl_cv_func_itold_works" in
84 *no)
85 REPLACE_ITOLD=1
86 dnl We add the workaround to <float.h> but also to <math.h>,
87 dnl to increase the chances that the fix function gets pulled in.
88 FLOAT_H=float.h
89 ;;
90 esac
91
231c0e0e
LC
92 if test -n "$FLOAT_H"; then
93 gl_NEXT_HEADERS([float.h])
94 fi
c4b681fd 95 AC_SUBST([FLOAT_H])
dd7d0148 96 AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])
35428fb6 97 AC_SUBST([REPLACE_ITOLD])
c4b681fd 98])