extensions.m4 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # serial 6 -*- Autoconf -*-
  2. # Enable extensions on systems that normally disable them.
  3. # Copyright (C) 2003, 2006, 2007, 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. m4_version_prereq([2.62],, [
  13. # AC_USE_SYSTEM_EXTENSIONS
  14. # ------------------------
  15. # Enable extensions on systems that normally disable them,
  16. # typically due to standards-conformance issues.
  17. # Remember that #undef in AH_VERBATIM gets replaced with #define by
  18. # AC_DEFINE. The goal here is to define all known feature-enabling
  19. # macros, then, if reports of conflicts are made, disable macros that
  20. # cause problems on some platforms (such as __EXTENSIONS__).
  21. AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS],
  22. [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
  23. AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
  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. AH_VERBATIM([__EXTENSIONS__],
  36. [/* Enable extensions on AIX 3, Interix. */
  37. #ifndef _ALL_SOURCE
  38. # undef _ALL_SOURCE
  39. #endif
  40. /* Enable GNU extensions on systems that have them. */
  41. #ifndef _GNU_SOURCE
  42. # undef _GNU_SOURCE
  43. #endif
  44. /* Enable threading extensions on Solaris. */
  45. #ifndef _POSIX_PTHREAD_SEMANTICS
  46. # undef _POSIX_PTHREAD_SEMANTICS
  47. #endif
  48. /* Enable extensions on HP NonStop. */
  49. #ifndef _TANDEM_SOURCE
  50. # undef _TANDEM_SOURCE
  51. #endif
  52. /* Enable general extensions on Solaris. */
  53. #ifndef __EXTENSIONS__
  54. # undef __EXTENSIONS__
  55. #endif
  56. ])
  57. AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
  58. [ac_cv_safe_to_define___extensions__],
  59. [AC_COMPILE_IFELSE(
  60. [AC_LANG_PROGRAM([
  61. # define __EXTENSIONS__ 1
  62. AC_INCLUDES_DEFAULT])],
  63. [ac_cv_safe_to_define___extensions__=yes],
  64. [ac_cv_safe_to_define___extensions__=no])])
  65. test $ac_cv_safe_to_define___extensions__ = yes &&
  66. AC_DEFINE([__EXTENSIONS__])
  67. AC_DEFINE([_ALL_SOURCE])
  68. AC_DEFINE([_GNU_SOURCE])
  69. AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
  70. AC_DEFINE([_TANDEM_SOURCE])
  71. ])# AC_USE_SYSTEM_EXTENSIONS
  72. ])