2N/A# strerror.m4 serial 9
2N/Adnl Copyright (C) 2002, 2007-2010 Free Software Foundation, Inc.
2N/Adnl This file is free software; the Free Software Foundation
2N/Adnl gives unlimited permission to copy and/or distribute it,
2N/Adnl with or without modifications, as long as this notice is preserved.
2N/A
2N/AAC_DEFUN([gl_FUNC_STRERROR],
2N/A[
2N/A AC_REQUIRE([gl_FUNC_STRERROR_SEPARATE])
2N/A if test $REPLACE_STRERROR = 1; then
2N/A AC_LIBOBJ([strerror])
2N/A AC_DEFINE_UNQUOTED([REPLACE_STRERROR], [$REPLACE_STRERROR],
2N/A [Define this to 1 if strerror is broken.])
2N/A fi
2N/A])
2N/A
2N/A# Like gl_FUNC_STRERROR, except prepare for separate compilation (no AC_LIBOBJ).
2N/AAC_DEFUN([gl_FUNC_STRERROR_SEPARATE],
2N/A[
2N/A AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
2N/A AC_REQUIRE([gl_HEADER_ERRNO_H])
2N/A if test -z "$ERRNO_H"; then
2N/A AC_CACHE_CHECK([for working strerror function],
2N/A [gl_cv_func_working_strerror],
2N/A [AC_RUN_IFELSE(
2N/A [AC_LANG_PROGRAM(
2N/A [[#include <string.h>
2N/A ]],
2N/A [[return !*strerror (-2);]])],
2N/A [gl_cv_func_working_strerror=yes],
2N/A [gl_cv_func_working_strerror=no],
2N/A [dnl Assume crossbuild works if it compiles.
2N/A AC_COMPILE_IFELSE(
2N/A [AC_LANG_PROGRAM(
2N/A [[#include <string.h>
2N/A ]],
2N/A [[return !*strerror (-2);]])],
2N/A [gl_cv_func_working_strerror=yes],
2N/A [gl_cv_func_working_strerror=no])
2N/A ])
2N/A ])
2N/A if test $gl_cv_func_working_strerror = no; then
2N/A dnl The system's strerror() fails to return a string for out-of-range
2N/A dnl integers. Replace it.
2N/A REPLACE_STRERROR=1
2N/A fi
2N/A else
2N/A dnl The system's strerror() cannot know about the new errno values we add
2N/A dnl to <errno.h>. Replace it.
2N/A REPLACE_STRERROR=1
2N/A fi
2N/A if test $REPLACE_STRERROR = 1; then
2N/A gl_PREREQ_STRERROR
2N/A fi
2N/A])
2N/A
2N/A# Prerequisites of lib/strerror.c.
2N/AAC_DEFUN([gl_PREREQ_STRERROR], [
2N/A AC_CHECK_DECLS([strerror])
2N/A AC_CHECK_HEADERS_ONCE([sys/socket.h])
2N/A if test $ac_cv_header_sys_socket_h != yes; then
2N/A dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
2N/A dnl the check for those headers unconditional; yet cygwin reports
2N/A dnl that the headers are present but cannot be compiled (since on
2N/A dnl cygwin, all socket information should come from sys/socket.h).
2N/A AC_CHECK_HEADERS([winsock2.h])
2N/A fi
2N/A])