1 # strerror.m4 serial 10
2 dnl Copyright (C) 2002, 2007-2011 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.
7 AC_DEFUN([gl_FUNC_STRERROR],
9 AC_REQUIRE([gl_FUNC_STRERROR_SEPARATE])
10 if test $REPLACE_STRERROR = 1; then
12 AC_DEFINE_UNQUOTED([REPLACE_STRERROR], [$REPLACE_STRERROR],
13 [Define this to 1 if strerror is broken.])
17 # Like gl_FUNC_STRERROR, except prepare for separate compilation (no AC_LIBOBJ).
18 AC_DEFUN([gl_FUNC_STRERROR_SEPARATE],
20 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
21 AC_REQUIRE([gl_HEADER_ERRNO_H])
22 if test -z "$ERRNO_H"; then
23 AC_CACHE_CHECK([for working strerror function],
24 [gl_cv_func_working_strerror],
31 if (!*strerror (-2)) result |= 1;
33 if (!*strerror (0)) result |= 2;
34 if (errno) result |= 4;
36 [gl_cv_func_working_strerror=yes],
37 [gl_cv_func_working_strerror=no],
38 [dnl Be pessimistic on cross-compiles for now.
39 gl_cv_func_working_strerror=no])
41 if test $gl_cv_func_working_strerror = no; then
42 dnl The system's strerror() fails to return a string for out-of-range
43 dnl integers. Replace it.
47 dnl The system's strerror() cannot know about the new errno values we add
48 dnl to <errno.h>. Replace it.
51 if test $REPLACE_STRERROR = 1; then
56 # Prerequisites of lib/strerror.c.
57 AC_DEFUN([gl_PREREQ_STRERROR], [
58 AC_CHECK_DECLS([strerror])
59 AC_CHECK_HEADERS_ONCE([sys/socket.h])
60 if test $ac_cv_header_sys_socket_h != yes; then
61 dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
62 dnl the check for those headers unconditional; yet cygwin reports
63 dnl that the headers are present but cannot be compiled (since on
64 dnl cygwin, all socket information should come from sys/socket.h).
65 AC_CHECK_HEADERS([winsock2.h])