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