Doc tweak.
[gnulib.git] / m4 / errno_h.m4
1 # errno_h.m4 serial 1
2 dnl Copyright (C) 2004, 2006, 2008 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_HEADER_ERRNO_H],
8 [
9   dnl Use AC_REQUIRE here, so that the default behavior below is expanded
10   dnl once only, before all statements that occur in other macros.
11   AC_REQUIRE([gl_HEADER_ERRNO_H_BODY])
12 ])
13
14 AC_DEFUN([gl_HEADER_ERRNO_H_BODY],
15 [
16   AC_REQUIRE([AC_PROG_CC])
17   AC_CACHE_CHECK([for complete errno.h], gl_cv_header_errno_h_complete, [
18     AC_EGREP_CPP(booboo,[
19 #include <errno.h>
20 #ifndef EOVERFLOW
21 booboo
22 #endif
23       ],
24       [gl_cv_header_errno_h_complete=no],
25       [gl_cv_header_errno_h_complete=yes])
26   ])
27   if test $gl_cv_header_errno_h_complete = yes; then
28     ERRNO_H=''
29   else
30     gl_CHECK_NEXT_HEADERS([errno.h])
31     ERRNO_H='errno.h'
32   fi
33   AC_SUBST([ERRNO_H])
34   gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
35   gl_REPLACE_ERRNO_VALUE([ENOLINK])
36   gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
37 ])
38
39 # Assuming $1 = EOVERFLOW.
40 # The EOVERFLOW errno value ought to be defined in <errno.h>, according to
41 # POSIX.  But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and
42 # some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
43 # Check for the value of EOVERFLOW.
44 # Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
45 AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
46 [
47   if test -n "$ERRNO_H"; then
48     AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
49       AC_EGREP_CPP(yes,[
50 #include <errno.h>
51 #ifdef ]$1[
52 yes
53 #endif
54       ],
55       [gl_cv_header_errno_h_]$1[=yes],
56       [gl_cv_header_errno_h_]$1[=no])
57       if test $gl_cv_header_errno_h_]$1[ = no; then
58         AC_EGREP_CPP(yes,[
59 #define _XOPEN_SOURCE_EXTENDED 1
60 #include <errno.h>
61 #ifdef ]$1[
62 yes
63 #endif
64           ], [gl_cv_header_errno_h_]$1[=hidden])
65         if test $gl_cv_header_errno_h_]$1[ = hidden; then
66           dnl The macro exists but is hidden.
67           dnl Define it to the same value.
68           AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [
69 #define _XOPEN_SOURCE_EXTENDED 1
70 #include <errno.h>
71 /* The following two lines are a workaround against an autoconf-2.52 bug.  */
72 #include <stdio.h>
73 #include <stdlib.h>
74 ])
75         fi
76       fi
77     ])
78     case $gl_cv_header_errno_h_]$1[ in
79       yes | no)
80         ]$1[_HIDDEN=0; ]$1[_VALUE=
81         ;;
82       *)
83         ]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1["
84         ;;
85     esac
86     AC_SUBST($1[_HIDDEN])
87     AC_SUBST($1[_VALUE])
88   fi
89 ])