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