| 1 |
# serial 20 -*- Autoconf -*- |
| 2 |
# Enable extensions on systems that normally disable them. |
| 3 |
|
| 4 |
# Copyright (C) 2003, 2006-2020 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 |
# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git |
| 10 |
# Autoconf. Perhaps we can remove this once we can assume Autoconf |
| 11 |
# 2.70 or later everywhere, but since Autoconf mutates rapidly |
| 12 |
# enough in this area it's likely we'll need to redefine |
| 13 |
# AC_USE_SYSTEM_EXTENSIONS for quite some time. |
| 14 |
|
| 15 |
# If autoconf reports a warning |
| 16 |
# warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS |
| 17 |
# or warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS |
| 18 |
# the fix is |
| 19 |
# 1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked |
| 20 |
# but always AC_REQUIREd, |
| 21 |
# 2) to ensure that for each occurrence of |
| 22 |
# AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
| 23 |
# or |
| 24 |
# AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) |
| 25 |
# the corresponding gnulib module description has 'extensions' among |
| 26 |
# its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS |
| 27 |
# invocation occurs in gl_EARLY, not in gl_INIT. |
| 28 |
|
| 29 |
# AC_USE_SYSTEM_EXTENSIONS |
| 30 |
# ------------------------ |
| 31 |
# Enable extensions on systems that normally disable them, |
| 32 |
# typically due to standards-conformance issues. |
| 33 |
# |
| 34 |
# Remember that #undef in AH_VERBATIM gets replaced with #define by |
| 35 |
# AC_DEFINE. The goal here is to define all known feature-enabling |
| 36 |
# macros, then, if reports of conflicts are made, disable macros that |
| 37 |
# cause problems on some platforms (such as __EXTENSIONS__). |
| 38 |
AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], |
| 39 |
[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl |
| 40 |
AC_BEFORE([$0], [AC_RUN_IFELSE])dnl |
| 41 |
|
| 42 |
AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=]) |
| 43 |
if test "$MINIX" = yes; then |
| 44 |
AC_DEFINE([_POSIX_SOURCE], [1], |
| 45 |
[Define to 1 if you need to in order for 'stat' and other |
| 46 |
things to work.]) |
| 47 |
AC_DEFINE([_POSIX_1_SOURCE], [2], |
| 48 |
[Define to 2 if the system does not provide POSIX.1 features |
| 49 |
except with this defined.]) |
| 50 |
AC_DEFINE([_MINIX], [1], |
| 51 |
[Define to 1 if on MINIX.]) |
| 52 |
AC_DEFINE([_NETBSD_SOURCE], [1], |
| 53 |
[Define to 1 to make NetBSD features available. MINIX 3 needs this.]) |
| 54 |
fi |
| 55 |
|
| 56 |
dnl Use a different key than __EXTENSIONS__, as that name broke existing |
| 57 |
dnl configure.ac when using autoheader 2.62. |
| 58 |
AH_VERBATIM([USE_SYSTEM_EXTENSIONS], |
| 59 |
[/* Enable extensions on AIX 3, Interix. */ |
| 60 |
#ifndef _ALL_SOURCE |
| 61 |
# undef _ALL_SOURCE |
| 62 |
#endif |
| 63 |
/* Enable general extensions on macOS. */ |
| 64 |
#ifndef _DARWIN_C_SOURCE |
| 65 |
# undef _DARWIN_C_SOURCE |
| 66 |
#endif |
| 67 |
/* Enable GNU extensions on systems that have them. */ |
| 68 |
#ifndef _GNU_SOURCE |
| 69 |
# undef _GNU_SOURCE |
| 70 |
#endif |
| 71 |
/* Enable NetBSD extensions on NetBSD. */ |
| 72 |
#ifndef _NETBSD_SOURCE |
| 73 |
# undef _NETBSD_SOURCE |
| 74 |
#endif |
| 75 |
/* Enable OpenBSD extensions on NetBSD. */ |
| 76 |
#ifndef _OPENBSD_SOURCE |
| 77 |
# undef _OPENBSD_SOURCE |
| 78 |
#endif |
| 79 |
/* Enable threading extensions on Solaris. */ |
| 80 |
#ifndef _POSIX_PTHREAD_SEMANTICS |
| 81 |
# undef _POSIX_PTHREAD_SEMANTICS |
| 82 |
#endif |
| 83 |
/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ |
| 84 |
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ |
| 85 |
# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ |
| 86 |
#endif |
| 87 |
/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ |
| 88 |
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ |
| 89 |
# undef __STDC_WANT_IEC_60559_BFP_EXT__ |
| 90 |
#endif |
| 91 |
/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ |
| 92 |
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__ |
| 93 |
# undef __STDC_WANT_IEC_60559_DFP_EXT__ |
| 94 |
#endif |
| 95 |
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ |
| 96 |
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ |
| 97 |
# undef __STDC_WANT_IEC_60559_FUNCS_EXT__ |
| 98 |
#endif |
| 99 |
/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */ |
| 100 |
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ |
| 101 |
# undef __STDC_WANT_IEC_60559_TYPES_EXT__ |
| 102 |
#endif |
| 103 |
/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ |
| 104 |
#ifndef __STDC_WANT_LIB_EXT2__ |
| 105 |
# undef __STDC_WANT_LIB_EXT2__ |
| 106 |
#endif |
| 107 |
/* Enable extensions specified by ISO/IEC 24747:2009. */ |
| 108 |
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__ |
| 109 |
# undef __STDC_WANT_MATH_SPEC_FUNCS__ |
| 110 |
#endif |
| 111 |
/* Enable extensions on HP NonStop. */ |
| 112 |
#ifndef _TANDEM_SOURCE |
| 113 |
# undef _TANDEM_SOURCE |
| 114 |
#endif |
| 115 |
/* Enable X/Open extensions if necessary. HP-UX 11.11 defines |
| 116 |
mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of |
| 117 |
whether compiling with -Ae or -D_HPUX_SOURCE=1. */ |
| 118 |
#ifndef _XOPEN_SOURCE |
| 119 |
# undef _XOPEN_SOURCE |
| 120 |
#endif |
| 121 |
/* Enable X/Open compliant socket functions that do not require linking |
| 122 |
with -lxnet on HP-UX 11.11. */ |
| 123 |
#ifndef _HPUX_ALT_XOPEN_SOCKET_API |
| 124 |
# undef _HPUX_ALT_XOPEN_SOCKET_API |
| 125 |
#endif |
| 126 |
/* Enable general extensions on Solaris. */ |
| 127 |
#ifndef __EXTENSIONS__ |
| 128 |
# undef __EXTENSIONS__ |
| 129 |
#endif |
| 130 |
]) |
| 131 |
AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], |
| 132 |
[ac_cv_safe_to_define___extensions__], |
| 133 |
[AC_COMPILE_IFELSE( |
| 134 |
[AC_LANG_PROGRAM([[ |
| 135 |
# define __EXTENSIONS__ 1 |
| 136 |
]AC_INCLUDES_DEFAULT])], |
| 137 |
[ac_cv_safe_to_define___extensions__=yes], |
| 138 |
[ac_cv_safe_to_define___extensions__=no])]) |
| 139 |
test $ac_cv_safe_to_define___extensions__ = yes && |
| 140 |
AC_DEFINE([__EXTENSIONS__]) |
| 141 |
AC_DEFINE([_ALL_SOURCE]) |
| 142 |
AC_DEFINE([_DARWIN_C_SOURCE]) |
| 143 |
AC_DEFINE([_GNU_SOURCE]) |
| 144 |
AC_DEFINE([_NETBSD_SOURCE]) |
| 145 |
AC_DEFINE([_OPENBSD_SOURCE]) |
| 146 |
AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) |
| 147 |
AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__]) |
| 148 |
AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__]) |
| 149 |
AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__]) |
| 150 |
AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__]) |
| 151 |
AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__]) |
| 152 |
AC_DEFINE([__STDC_WANT_LIB_EXT2__]) |
| 153 |
AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__]) |
| 154 |
AC_DEFINE([_TANDEM_SOURCE]) |
| 155 |
AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined], |
| 156 |
[ac_cv_should_define__xopen_source], |
| 157 |
[ac_cv_should_define__xopen_source=no |
| 158 |
AC_COMPILE_IFELSE( |
| 159 |
[AC_LANG_PROGRAM([[ |
| 160 |
#include <wchar.h> |
| 161 |
mbstate_t x;]])], |
| 162 |
[], |
| 163 |
[AC_COMPILE_IFELSE( |
| 164 |
[AC_LANG_PROGRAM([[ |
| 165 |
#define _XOPEN_SOURCE 500 |
| 166 |
#include <wchar.h> |
| 167 |
mbstate_t x;]])], |
| 168 |
[ac_cv_should_define__xopen_source=yes])])]) |
| 169 |
test $ac_cv_should_define__xopen_source = yes && |
| 170 |
AC_DEFINE([_XOPEN_SOURCE], [500]) |
| 171 |
AC_DEFINE([_HPUX_ALT_XOPEN_SOCKET_API]) |
| 172 |
])# AC_USE_SYSTEM_EXTENSIONS |
| 173 |
|
| 174 |
# gl_USE_SYSTEM_EXTENSIONS |
| 175 |
# ------------------------ |
| 176 |
# Enable extensions on systems that normally disable them, |
| 177 |
# typically due to standards-conformance issues. |
| 178 |
AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], |
| 179 |
[ |
| 180 |
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
| 181 |
]) |