extensions.m4 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. # serial 9 -*- Autoconf -*-
  2. # Enable extensions on systems that normally disable them.
  3. # Copyright (C) 2003, 2006-2011 Free Software Foundation, Inc.
  4. # This file is free software; the Free Software Foundation
  5. # gives unlimited permission to copy and/or distribute it,
  6. # with or without modifications, as long as this notice is preserved.
  7. # This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
  8. # Autoconf. Perhaps we can remove this once we can assume Autoconf
  9. # 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
  10. # enough in this area it's likely we'll need to redefine
  11. # AC_USE_SYSTEM_EXTENSIONS for quite some time.
  12. # If autoconf reports a warning
  13. # warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
  14. # or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
  15. # the fix is
  16. # 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked
  17. # but always AC_REQUIREd,
  18. # 2) to ensure that for each occurrence of
  19. # AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
  20. # or
  21. # AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
  22. # the corresponding gnulib module description has 'extensions' among
  23. # its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
  24. # invocation occurs in gl_EARLY, not in gl_INIT.
  25. # AC_USE_SYSTEM_EXTENSIONS
  26. # ------------------------
  27. # Enable extensions on systems that normally disable them,
  28. # typically due to standards-conformance issues.
  29. # Remember that #undef in AH_VERBATIM gets replaced with #define by
  30. # AC_DEFINE. The goal here is to define all known feature-enabling
  31. # macros, then, if reports of conflicts are made, disable macros that
  32. # cause problems on some platforms (such as __EXTENSIONS__).
  33. AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
  34. [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
  35. AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
  36. AC_REQUIRE([AC_CANONICAL_HOST])
  37. AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
  38. if test "$MINIX" = yes; then
  39. AC_DEFINE([_POSIX_SOURCE], [1],
  40. [Define to 1 if you need to in order for `stat' and other
  41. things to work.])
  42. AC_DEFINE([_POSIX_1_SOURCE], [2],
  43. [Define to 2 if the system does not provide POSIX.1 features
  44. except with this defined.])
  45. AC_DEFINE([_MINIX], [1],
  46. [Define to 1 if on MINIX.])
  47. fi
  48. dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
  49. dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already
  50. dnl provided.
  51. case "$host_os" in
  52. hpux*)
  53. AC_DEFINE([_XOPEN_SOURCE], [500],
  54. [Define to 500 only on HP-UX.])
  55. ;;
  56. esac
  57. AH_VERBATIM([__EXTENSIONS__],
  58. [/* Enable extensions on AIX 3, Interix. */
  59. #ifndef _ALL_SOURCE
  60. # undef _ALL_SOURCE
  61. #endif
  62. /* Enable GNU extensions on systems that have them. */
  63. #ifndef _GNU_SOURCE
  64. # undef _GNU_SOURCE
  65. #endif
  66. /* Enable threading extensions on Solaris. */
  67. #ifndef _POSIX_PTHREAD_SEMANTICS
  68. # undef _POSIX_PTHREAD_SEMANTICS
  69. #endif
  70. /* Enable extensions on HP NonStop. */
  71. #ifndef _TANDEM_SOURCE
  72. # undef _TANDEM_SOURCE
  73. #endif
  74. /* Enable general extensions on Solaris. */
  75. #ifndef __EXTENSIONS__
  76. # undef __EXTENSIONS__
  77. #endif
  78. ])
  79. AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
  80. [ac_cv_safe_to_define___extensions__],
  81. [AC_COMPILE_IFELSE(
  82. [AC_LANG_PROGRAM([[
  83. # define __EXTENSIONS__ 1
  84. ]AC_INCLUDES_DEFAULT])],
  85. [ac_cv_safe_to_define___extensions__=yes],
  86. [ac_cv_safe_to_define___extensions__=no])])
  87. test $ac_cv_safe_to_define___extensions__ = yes &&
  88. AC_DEFINE([__EXTENSIONS__])
  89. AC_DEFINE([_ALL_SOURCE])
  90. AC_DEFINE([_GNU_SOURCE])
  91. AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
  92. AC_DEFINE([_TANDEM_SOURCE])
  93. ])# AC_USE_SYSTEM_EXTENSIONS
  94. # gl_USE_SYSTEM_EXTENSIONS
  95. # ------------------------
  96. # Enable extensions on systems that normally disable them,
  97. # typically due to standards-conformance issues.
  98. AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
  99. [
  100. dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
  101. dnl gnulib does not need it. But if it gets required by third-party macros
  102. dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
  103. dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
  104. dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
  105. dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
  106. AC_REQUIRE([AC_GNU_SOURCE])
  107. AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
  108. ])