| 1 |
# serial 23 -*- Autoconf -*- |
| 2 |
# Enable extensions on systems that normally disable them. |
| 3 |
|
| 4 |
# Copyright (C) 2003, 2006-2024 Free Software Foundation, Inc. |
| 5 |
# This file is free software; the Free Software Foundation |
| 6 |
# gives unlimited permission to copy and/or distribute it, |
| 7 |
# with or without modifications, as long as this notice is preserved. |
| 8 |
|
| 9 |
dnl Define to empty for the benefit of Autoconf 2.69 and earlier, so that |
| 10 |
dnl AC_USE_SYSTEM_EXTENSIONS (below) can be used unchanged from Autoconf 2.70+. |
| 11 |
m4_ifndef([AC_CHECK_INCLUDES_DEFAULT], |
| 12 |
[AC_DEFUN([AC_CHECK_INCLUDES_DEFAULT], [])]) |
| 13 |
|
| 14 |
# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git |
| 15 |
# Autoconf. Perhaps we can remove this once we can assume Autoconf |
| 16 |
# is recent-enough everywhere, but since Autoconf mutates rapidly |
| 17 |
# enough in this area it's likely we'll need to redefine |
| 18 |
# AC_USE_SYSTEM_EXTENSIONS for quite some time. |
| 19 |
|
| 20 |
# If autoconf reports a warning |
| 21 |
# warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS |
| 22 |
# or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS |
| 23 |
# the fix is |
| 24 |
# 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked |
| 25 |
# but always AC_REQUIREd, |
| 26 |
# 2) to ensure that for each occurrence of |
| 27 |
# AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
| 28 |
# or |
| 29 |
# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
| 30 |
# the corresponding gnulib module description has 'extensions' among |
| 31 |
# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS |
| 32 |
# invocation occurs in gl_EARLY, not in gl_INIT. |
| 33 |
|
| 34 |
m4_version_prereq([2.72], [], [ |
| 35 |
|
| 36 |
# AC_USE_SYSTEM_EXTENSIONS |
| 37 |
# ------------------------ |
| 38 |
# Enable extensions on systems that normally disable them, |
| 39 |
# typically due to standards-conformance issues. |
| 40 |
# We unconditionally define as many of the known feature-enabling |
| 41 |
# as possible, reserving conditional behavior for macros that are |
| 42 |
# known to cause problems on some platforms (such as __EXTENSIONS__). |
| 43 |
AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], |
| 44 |
[AC_BEFORE([$0], [AC_PREPROC_IFELSE])dnl |
| 45 |
AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl |
| 46 |
AC_BEFORE([$0], [AC_LINK_IFELSE])dnl |
| 47 |
AC_BEFORE([$0], [AC_RUN_IFELSE])dnl |
| 48 |
AC_BEFORE([$0], [AC_CHECK_INCLUDES_DEFAULT])dnl |
| 49 |
dnl #undef in AH_VERBATIM gets replaced with #define by AC_DEFINE. |
| 50 |
dnl Use a different key than __EXTENSIONS__, as that name broke existing |
| 51 |
dnl configure.ac when using autoheader 2.62. |
| 52 |
dnl The macros below are in alphabetical order ignoring leading _ or __ |
| 53 |
dnl prefixes. |
| 54 |
AH_VERBATIM([USE_SYSTEM_EXTENSIONS], |
| 55 |
[/* Enable extensions on AIX 3, Interix. */ |
| 56 |
#ifndef _ALL_SOURCE |
| 57 |
# undef _ALL_SOURCE |
| 58 |
#endif |
| 59 |
/* Enable general extensions on macOS. */ |
| 60 |
#ifndef _DARWIN_C_SOURCE |
| 61 |
# undef _DARWIN_C_SOURCE |
| 62 |
#endif |
| 63 |
/* Enable general extensions on Solaris. */ |
| 64 |
#ifndef __EXTENSIONS__ |
| 65 |
# undef __EXTENSIONS__ |
| 66 |
#endif |
| 67 |
/* Enable GNU extensions on systems that have them. */ |
| 68 |
#ifndef _GNU_SOURCE |
| 69 |
# undef _GNU_SOURCE |
| 70 |
#endif |
| 71 |
/* Enable X/Open compliant socket functions that do not require linking |
| 72 |
with -lxnet on HP-UX 11.11. */ |
| 73 |
#ifndef _HPUX_ALT_XOPEN_SOCKET_API |
| 74 |
# undef _HPUX_ALT_XOPEN_SOCKET_API |
| 75 |
#endif |
| 76 |
/* Identify the host operating system as Minix. |
| 77 |
This macro does not affect the system headers' behavior. |
| 78 |
A future release of Autoconf may stop defining this macro. */ |
| 79 |
#ifndef _MINIX |
| 80 |
# undef _MINIX |
| 81 |
#endif |
| 82 |
/* Enable general extensions on NetBSD. |
| 83 |
Enable NetBSD compatibility extensions on Minix. */ |
| 84 |
#ifndef _NETBSD_SOURCE |
| 85 |
# undef _NETBSD_SOURCE |
| 86 |
#endif |
| 87 |
/* Enable OpenBSD compatibility extensions on NetBSD. |
| 88 |
Oddly enough, this does nothing on OpenBSD. */ |
| 89 |
#ifndef _OPENBSD_SOURCE |
| 90 |
# undef _OPENBSD_SOURCE |
| 91 |
#endif |
| 92 |
/* Define to 1 if needed for POSIX-compatible behavior. */ |
| 93 |
#ifndef _POSIX_SOURCE |
| 94 |
# undef _POSIX_SOURCE |
| 95 |
#endif |
| 96 |
/* Define to 2 if needed for POSIX-compatible behavior. */ |
| 97 |
#ifndef _POSIX_1_SOURCE |
| 98 |
# undef _POSIX_1_SOURCE |
| 99 |
#endif |
| 100 |
/* Enable POSIX-compatible threading on Solaris. */ |
| 101 |
#ifndef _POSIX_PTHREAD_SEMANTICS |
| 102 |
# undef _POSIX_PTHREAD_SEMANTICS |
| 103 |
#endif |
| 104 |
/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ |
| 105 |
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ |
| 106 |
# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ |
| 107 |
#endif |
| 108 |
/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ |
| 109 |
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ |
| 110 |
# undef __STDC_WANT_IEC_60559_BFP_EXT__ |
| 111 |
#endif |
| 112 |
/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ |
| 113 |
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__ |
| 114 |
# undef __STDC_WANT_IEC_60559_DFP_EXT__ |
| 115 |
#endif |
| 116 |
/* Enable extensions specified by C23 Annex F. */ |
| 117 |
#ifndef __STDC_WANT_IEC_60559_EXT__ |
| 118 |
# undef __STDC_WANT_IEC_60559_EXT__ |
| 119 |
#endif |
| 120 |
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ |
| 121 |
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ |
| 122 |
# undef __STDC_WANT_IEC_60559_FUNCS_EXT__ |
| 123 |
#endif |
| 124 |
/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */ |
| 125 |
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ |
| 126 |
# undef __STDC_WANT_IEC_60559_TYPES_EXT__ |
| 127 |
#endif |
| 128 |
/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ |
| 129 |
#ifndef __STDC_WANT_LIB_EXT2__ |
| 130 |
# undef __STDC_WANT_LIB_EXT2__ |
| 131 |
#endif |
| 132 |
/* Enable extensions specified by ISO/IEC 24747:2009. */ |
| 133 |
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__ |
| 134 |
# undef __STDC_WANT_MATH_SPEC_FUNCS__ |
| 135 |
#endif |
| 136 |
/* Enable extensions on HP NonStop. */ |
| 137 |
#ifndef _TANDEM_SOURCE |
| 138 |
# undef _TANDEM_SOURCE |
| 139 |
#endif |
| 140 |
/* Enable X/Open extensions. Define to 500 only if necessary |
| 141 |
to make mbstate_t available. */ |
| 142 |
#ifndef _XOPEN_SOURCE |
| 143 |
# undef _XOPEN_SOURCE |
| 144 |
#endif |
| 145 |
])dnl |
| 146 |
|
| 147 |
AC_REQUIRE([AC_CHECK_INCLUDES_DEFAULT])dnl |
| 148 |
_AC_CHECK_HEADER_ONCE([wchar.h]) |
| 149 |
_AC_CHECK_HEADER_ONCE([minix/config.h]) |
| 150 |
|
| 151 |
dnl Defining __EXTENSIONS__ may break the system headers on some systems. |
| 152 |
dnl (FIXME: Which ones?) |
| 153 |
AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], |
| 154 |
[ac_cv_safe_to_define___extensions__], |
| 155 |
[AC_COMPILE_IFELSE( |
| 156 |
[AC_LANG_PROGRAM([[ |
| 157 |
# define __EXTENSIONS__ 1 |
| 158 |
]AC_INCLUDES_DEFAULT])], |
| 159 |
[ac_cv_safe_to_define___extensions__=yes], |
| 160 |
[ac_cv_safe_to_define___extensions__=no])]) |
| 161 |
|
| 162 |
dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to |
| 163 |
dnl 500, regardless of whether compiling with -Ae or -D_HPUX_SOURCE=1. |
| 164 |
dnl But defining _XOPEN_SOURCE may turn *off* extensions on platforms |
| 165 |
dnl not covered by turn-on-extensions macros (notably Dragonfly, Free, |
| 166 |
dnl and OpenBSD, which don't have any equivalent of _NETBSD_SOURCE) so |
| 167 |
dnl it should only be defined when necessary. |
| 168 |
AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined], |
| 169 |
[ac_cv_should_define__xopen_source], |
| 170 |
[ac_cv_should_define__xopen_source=no |
| 171 |
AS_IF([test $ac_cv_header_wchar_h = yes], |
| 172 |
[AC_COMPILE_IFELSE( |
| 173 |
[AC_LANG_PROGRAM([[ |
| 174 |
#include <wchar.h> |
| 175 |
mbstate_t x;]])], |
| 176 |
[], |
| 177 |
[AC_COMPILE_IFELSE( |
| 178 |
[AC_LANG_PROGRAM([[ |
| 179 |
#define _XOPEN_SOURCE 500 |
| 180 |
#include <wchar.h> |
| 181 |
mbstate_t x;]])], |
| 182 |
[ac_cv_should_define__xopen_source=yes])])])]) |
| 183 |
|
| 184 |
AC_DEFINE([_ALL_SOURCE]) |
| 185 |
AC_DEFINE([_DARWIN_C_SOURCE]) |
| 186 |
AC_DEFINE([_GNU_SOURCE]) |
| 187 |
AC_DEFINE([_HPUX_ALT_XOPEN_SOCKET_API]) |
| 188 |
AC_DEFINE([_NETBSD_SOURCE]) |
| 189 |
AC_DEFINE([_OPENBSD_SOURCE]) |
| 190 |
AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) |
| 191 |
AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__]) |
| 192 |
AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__]) |
| 193 |
AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__]) |
| 194 |
AC_DEFINE([__STDC_WANT_IEC_60559_EXT__]) |
| 195 |
AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__]) |
| 196 |
AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__]) |
| 197 |
AC_DEFINE([__STDC_WANT_LIB_EXT2__]) |
| 198 |
AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__]) |
| 199 |
AC_DEFINE([_TANDEM_SOURCE]) |
| 200 |
AS_IF([test $ac_cv_header_minix_config_h = yes], |
| 201 |
[MINIX=yes |
| 202 |
AC_DEFINE([_MINIX]) |
| 203 |
AC_DEFINE([_POSIX_SOURCE]) |
| 204 |
AC_DEFINE([_POSIX_1_SOURCE], [2])], |
| 205 |
[MINIX=]) |
| 206 |
AS_IF([test $ac_cv_safe_to_define___extensions__ = yes], |
| 207 |
[AC_DEFINE([__EXTENSIONS__])]) |
| 208 |
AS_IF([test $ac_cv_should_define__xopen_source = yes], |
| 209 |
[AC_DEFINE([_XOPEN_SOURCE], [500])]) |
| 210 |
])# AC_USE_SYSTEM_EXTENSIONS |
| 211 |
]) |
| 212 |
|
| 213 |
# gl_USE_SYSTEM_EXTENSIONS |
| 214 |
# ------------------------ |
| 215 |
# Enable extensions on systems that normally disable them, |
| 216 |
# typically due to standards-conformance issues. |
| 217 |
AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], |
| 218 |
[ |
| 219 |
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
| 220 |
|
| 221 |
dnl On OpenBSD 6.8 with GCC, the include files contain a couple of |
| 222 |
dnl definitions that are only activated with an explicit -D_ISOC11_SOURCE. |
| 223 |
dnl That's because this version of GCC (4.2.1) supports the option |
| 224 |
dnl '-std=gnu99' but not the option '-std=gnu11'. |
| 225 |
AC_REQUIRE([AC_CANONICAL_HOST]) |
| 226 |
case "$host_os" in |
| 227 |
openbsd*) |
| 228 |
AC_DEFINE([_ISOC11_SOURCE], [1], |
| 229 |
[Define to enable the declarations of ISO C 11 types and functions.]) |
| 230 |
;; |
| 231 |
esac |
| 232 |
]) |