Thank Ralf
[bpt/guile.git] / m4 / errno_h.m4
CommitLineData
0f00f2c3
LC
1# errno_h.m4 serial 7
2dnl Copyright (C) 2004, 2006, 2008-2010 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_ONCE([gl_HEADER_ERRNO_H],
8[
9 AC_REQUIRE([AC_PROG_CC])
10 AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [
11 AC_EGREP_CPP([booboo],[
12#include <errno.h>
13#if !defined ENOMSG
14booboo
15#endif
16#if !defined EIDRM
17booboo
18#endif
19#if !defined ENOLINK
20booboo
21#endif
22#if !defined EPROTO
23booboo
24#endif
25#if !defined EMULTIHOP
26booboo
27#endif
28#if !defined EBADMSG
29booboo
30#endif
31#if !defined EOVERFLOW
32booboo
33#endif
34#if !defined ENOTSUP
35booboo
36#endif
37#if !defined ESTALE
38booboo
39#endif
0f00f2c3
LC
40#if !defined EDQUOT
41booboo
42#endif
c4b681fd
LC
43#if !defined ECANCELED
44booboo
45#endif
46 ],
47 [gl_cv_header_errno_h_complete=no],
48 [gl_cv_header_errno_h_complete=yes])
49 ])
50 if test $gl_cv_header_errno_h_complete = yes; then
51 ERRNO_H=''
52 else
53 gl_CHECK_NEXT_HEADERS([errno.h])
54 ERRNO_H='errno.h'
55 fi
56 AC_SUBST([ERRNO_H])
57 gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
58 gl_REPLACE_ERRNO_VALUE([ENOLINK])
59 gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
60])
61
62# Assuming $1 = EOVERFLOW.
63# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
64# POSIX. But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and
65# some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
66# Check for the value of EOVERFLOW.
67# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
68AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
69[
70 if test -n "$ERRNO_H"; then
71 AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
72 AC_EGREP_CPP([yes],[
73#include <errno.h>
74#ifdef ]$1[
75yes
76#endif
77 ],
78 [gl_cv_header_errno_h_]$1[=yes],
79 [gl_cv_header_errno_h_]$1[=no])
80 if test $gl_cv_header_errno_h_]$1[ = no; then
81 AC_EGREP_CPP([yes],[
82#define _XOPEN_SOURCE_EXTENDED 1
83#include <errno.h>
84#ifdef ]$1[
85yes
86#endif
87 ], [gl_cv_header_errno_h_]$1[=hidden])
88 if test $gl_cv_header_errno_h_]$1[ = hidden; then
89 dnl The macro exists but is hidden.
90 dnl Define it to the same value.
91 AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [
92#define _XOPEN_SOURCE_EXTENDED 1
93#include <errno.h>
94/* The following two lines are a workaround against an autoconf-2.52 bug. */
95#include <stdio.h>
96#include <stdlib.h>
97])
98 fi
99 fi
100 ])
101 case $gl_cv_header_errno_h_]$1[ in
102 yes | no)
103 ]$1[_HIDDEN=0; ]$1[_VALUE=
104 ;;
105 *)
106 ]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1["
107 ;;
108 esac
109 AC_SUBST($1[_HIDDEN])
110 AC_SUBST($1[_VALUE])
111 fi
112])
113
114dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
115dnl Remove this when we can assume autoconf >= 2.61.
116m4_ifdef([AC_COMPUTE_INT], [], [
117 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
118])