extensions.m4 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # serial 8 -*- Autoconf -*-
  2. # Enable extensions on systems that normally disable them.
  3. # Copyright (C) 2003, 2006-2009 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. # AC_USE_SYSTEM_EXTENSIONS
  13. # ------------------------
  14. # Enable extensions on systems that normally disable them,
  15. # typically due to standards-conformance issues.
  16. # Remember that #undef in AH_VERBATIM gets replaced with #define by
  17. # AC_DEFINE. The goal here is to define all known feature-enabling
  18. # macros, then, if reports of conflicts are made, disable macros that
  19. # cause problems on some platforms (such as __EXTENSIONS__).
  20. AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
  21. [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
  22. AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
  23. AC_REQUIRE([AC_CANONICAL_HOST])
  24. AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
  25. if test "$MINIX" = yes; then
  26. AC_DEFINE([_POSIX_SOURCE], [1],
  27. [Define to 1 if you need to in order for `stat' and other
  28. things to work.])
  29. AC_DEFINE([_POSIX_1_SOURCE], [2],
  30. [Define to 2 if the system does not provide POSIX.1 features
  31. except with this defined.])
  32. AC_DEFINE([_MINIX], [1],
  33. [Define to 1 if on MINIX.])
  34. fi
  35. dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
  36. dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already
  37. dnl provided.
  38. case "$host_os" in
  39. hpux*)
  40. AC_DEFINE([_XOPEN_SOURCE], [500],
  41. [Define to 500 only on HP-UX.])
  42. ;;
  43. esac
  44. AH_VERBATIM([__EXTENSIONS__],
  45. [/* Enable extensions on AIX 3, Interix. */
  46. #ifndef _ALL_SOURCE
  47. # undef _ALL_SOURCE
  48. #endif
  49. /* Enable GNU extensions on systems that have them. */
  50. #ifndef _GNU_SOURCE
  51. # undef _GNU_SOURCE
  52. #endif
  53. /* Enable threading extensions on Solaris. */
  54. #ifndef _POSIX_PTHREAD_SEMANTICS
  55. # undef _POSIX_PTHREAD_SEMANTICS
  56. #endif
  57. /* Enable extensions on HP NonStop. */
  58. #ifndef _TANDEM_SOURCE
  59. # undef _TANDEM_SOURCE
  60. #endif
  61. /* Enable general extensions on Solaris. */
  62. #ifndef __EXTENSIONS__
  63. # undef __EXTENSIONS__
  64. #endif
  65. ])
  66. AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
  67. [ac_cv_safe_to_define___extensions__],
  68. [AC_COMPILE_IFELSE(
  69. [AC_LANG_PROGRAM([[
  70. # define __EXTENSIONS__ 1
  71. ]AC_INCLUDES_DEFAULT])],
  72. [ac_cv_safe_to_define___extensions__=yes],
  73. [ac_cv_safe_to_define___extensions__=no])])
  74. test $ac_cv_safe_to_define___extensions__ = yes &&
  75. AC_DEFINE([__EXTENSIONS__])
  76. AC_DEFINE([_ALL_SOURCE])
  77. AC_DEFINE([_GNU_SOURCE])
  78. AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
  79. AC_DEFINE([_TANDEM_SOURCE])
  80. ])# AC_USE_SYSTEM_EXTENSIONS
  81. # gl_USE_SYSTEM_EXTENSIONS
  82. # ------------------------
  83. # Enable extensions on systems that normally disable them,
  84. # typically due to standards-conformance issues.
  85. AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
  86. [
  87. dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
  88. dnl gnulib does not need it. But if it gets required by third-party macros
  89. dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
  90. dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
  91. dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
  92. dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
  93. AC_REQUIRE([AC_GNU_SOURCE])
  94. AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
  95. ])