strerror.m4 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # strerror.m4 serial 9
  2. dnl Copyright (C) 2002, 2007-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. AC_DEFUN([gl_FUNC_STRERROR],
  7. [
  8. AC_REQUIRE([gl_FUNC_STRERROR_SEPARATE])
  9. if test $REPLACE_STRERROR = 1; then
  10. AC_LIBOBJ([strerror])
  11. AC_DEFINE_UNQUOTED([REPLACE_STRERROR], [$REPLACE_STRERROR],
  12. [Define this to 1 if strerror is broken.])
  13. fi
  14. ])
  15. # Like gl_FUNC_STRERROR, except prepare for separate compilation (no AC_LIBOBJ).
  16. AC_DEFUN([gl_FUNC_STRERROR_SEPARATE],
  17. [
  18. AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
  19. AC_REQUIRE([gl_HEADER_ERRNO_H])
  20. if test -z "$ERRNO_H"; then
  21. AC_CACHE_CHECK([for working strerror function],
  22. [gl_cv_func_working_strerror],
  23. [AC_RUN_IFELSE(
  24. [AC_LANG_PROGRAM(
  25. [[#include <string.h>
  26. ]],
  27. [[return !*strerror (-2);]])],
  28. [gl_cv_func_working_strerror=yes],
  29. [gl_cv_func_working_strerror=no],
  30. [dnl Assume crossbuild works if it compiles.
  31. AC_COMPILE_IFELSE(
  32. [AC_LANG_PROGRAM(
  33. [[#include <string.h>
  34. ]],
  35. [[return !*strerror (-2);]])],
  36. [gl_cv_func_working_strerror=yes],
  37. [gl_cv_func_working_strerror=no])
  38. ])
  39. ])
  40. if test $gl_cv_func_working_strerror = no; then
  41. dnl The system's strerror() fails to return a string for out-of-range
  42. dnl integers. Replace it.
  43. REPLACE_STRERROR=1
  44. fi
  45. else
  46. dnl The system's strerror() cannot know about the new errno values we add
  47. dnl to <errno.h>. Replace it.
  48. REPLACE_STRERROR=1
  49. fi
  50. if test $REPLACE_STRERROR = 1; then
  51. gl_PREREQ_STRERROR
  52. fi
  53. ])
  54. # Prerequisites of lib/strerror.c.
  55. AC_DEFUN([gl_PREREQ_STRERROR], [
  56. AC_CHECK_DECLS([strerror])
  57. AC_CHECK_HEADERS_ONCE([sys/socket.h])
  58. if test $ac_cv_header_sys_socket_h != yes; then
  59. dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
  60. dnl the check for those headers unconditional; yet cygwin reports
  61. dnl that the headers are present but cannot be compiled (since on
  62. dnl cygwin, all socket information should come from sys/socket.h).
  63. AC_CHECK_HEADERS([winsock2.h])
  64. fi
  65. ])