extensions.m4 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. # serial 15 -*- Autoconf -*-
  2. # Enable extensions on systems that normally disable them.
  3. # Copyright (C) 2003, 2006-2017 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 git
  8. # Autoconf. Perhaps we can remove this once we can assume Autoconf
  9. # 2.70 or later everywhere, but since 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. #
  30. # Remember that #undef in AH_VERBATIM gets replaced with #define by
  31. # AC_DEFINE. The goal here is to define all known feature-enabling
  32. # macros, then, if reports of conflicts are made, disable macros that
  33. # cause problems on some platforms (such as __EXTENSIONS__).
  34. AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
  35. [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
  36. AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
  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. AC_DEFINE([_NETBSD_SOURCE], [1],
  48. [Define to 1 to make NetBSD features available. MINIX 3 needs this.])
  49. fi
  50. dnl Use a different key than __EXTENSIONS__, as that name broke existing
  51. dnl configure.ac when using autoheader 2.62.
  52. AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
  53. [/* Enable extensions on AIX 3, Interix. */
  54. #ifndef _ALL_SOURCE
  55. # undef _ALL_SOURCE
  56. #endif
  57. /* Enable general extensions on macOS. */
  58. #ifndef _DARWIN_C_SOURCE
  59. # undef _DARWIN_C_SOURCE
  60. #endif
  61. /* Enable GNU extensions on systems that have them. */
  62. #ifndef _GNU_SOURCE
  63. # undef _GNU_SOURCE
  64. #endif
  65. /* Enable threading extensions on Solaris. */
  66. #ifndef _POSIX_PTHREAD_SEMANTICS
  67. # undef _POSIX_PTHREAD_SEMANTICS
  68. #endif
  69. /* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
  70. #ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
  71. # undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
  72. #endif
  73. /* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
  74. #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
  75. # undef __STDC_WANT_IEC_60559_BFP_EXT__
  76. #endif
  77. /* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
  78. #ifndef __STDC_WANT_IEC_60559_DFP_EXT__
  79. # undef __STDC_WANT_IEC_60559_DFP_EXT__
  80. #endif
  81. /* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
  82. #ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
  83. # undef __STDC_WANT_IEC_60559_FUNCS_EXT__
  84. #endif
  85. /* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
  86. #ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
  87. # undef __STDC_WANT_IEC_60559_TYPES_EXT__
  88. #endif
  89. /* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
  90. #ifndef __STDC_WANT_LIB_EXT2__
  91. # undef __STDC_WANT_LIB_EXT2__
  92. #endif
  93. /* Enable extensions specified by ISO/IEC 24747:2009. */
  94. #ifndef __STDC_WANT_MATH_SPEC_FUNCS__
  95. # undef __STDC_WANT_MATH_SPEC_FUNCS__
  96. #endif
  97. /* Enable extensions on HP NonStop. */
  98. #ifndef _TANDEM_SOURCE
  99. # undef _TANDEM_SOURCE
  100. #endif
  101. /* Enable X/Open extensions if necessary. HP-UX 11.11 defines
  102. mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of
  103. whether compiling with -Ae or -D_HPUX_SOURCE=1. */
  104. #ifndef _XOPEN_SOURCE
  105. # undef _XOPEN_SOURCE
  106. #endif
  107. /* Enable general extensions on Solaris. */
  108. #ifndef __EXTENSIONS__
  109. # undef __EXTENSIONS__
  110. #endif
  111. ])
  112. AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
  113. [ac_cv_safe_to_define___extensions__],
  114. [AC_COMPILE_IFELSE(
  115. [AC_LANG_PROGRAM([[
  116. # define __EXTENSIONS__ 1
  117. ]AC_INCLUDES_DEFAULT])],
  118. [ac_cv_safe_to_define___extensions__=yes],
  119. [ac_cv_safe_to_define___extensions__=no])])
  120. test $ac_cv_safe_to_define___extensions__ = yes &&
  121. AC_DEFINE([__EXTENSIONS__])
  122. AC_DEFINE([_ALL_SOURCE])
  123. AC_DEFINE([_DARWIN_C_SOURCE])
  124. AC_DEFINE([_GNU_SOURCE])
  125. AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
  126. AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__])
  127. AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__])
  128. AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__])
  129. AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__])
  130. AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__])
  131. AC_DEFINE([__STDC_WANT_LIB_EXT2__])
  132. AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__])
  133. AC_DEFINE([_TANDEM_SOURCE])
  134. AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
  135. [ac_cv_should_define__xopen_source],
  136. [ac_cv_should_define__xopen_source=no
  137. AC_COMPILE_IFELSE(
  138. [AC_LANG_PROGRAM([[
  139. #include <wchar.h>
  140. mbstate_t x;]])],
  141. [],
  142. [AC_COMPILE_IFELSE(
  143. [AC_LANG_PROGRAM([[
  144. #define _XOPEN_SOURCE 500
  145. #include <wchar.h>
  146. mbstate_t x;]])],
  147. [ac_cv_should_define__xopen_source=yes])])])
  148. test $ac_cv_should_define__xopen_source = yes &&
  149. AC_DEFINE([_XOPEN_SOURCE], [500])
  150. ])# AC_USE_SYSTEM_EXTENSIONS
  151. # gl_USE_SYSTEM_EXTENSIONS
  152. # ------------------------
  153. # Enable extensions on systems that normally disable them,
  154. # typically due to standards-conformance issues.
  155. AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
  156. [
  157. dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
  158. dnl gnulib does not need it. But if it gets required by third-party macros
  159. dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
  160. dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
  161. dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
  162. dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
  163. AC_REQUIRE([AC_GNU_SOURCE])
  164. AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
  165. ])