Commit | Line | Data |
---|---|---|
9c9d63b1 | 1 | # serial 22 -*- Autoconf -*- |
f6ea5628 DJ |
2 | # Enable extensions on systems that normally disable them. |
3 | ||
9c9d63b1 | 4 | # Copyright (C) 2003, 2006-2021 Free Software Foundation, Inc. |
f6ea5628 DJ |
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 | ||
9c9d63b1 PM |
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 | ||
4a626d0a | 14 | # This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git |
f6ea5628 | 15 | # Autoconf. Perhaps we can remove this once we can assume Autoconf |
9c9d63b1 | 16 | # is recent-enough everywhere, but since Autoconf mutates rapidly |
f6ea5628 DJ |
17 | # enough in this area it's likely we'll need to redefine |
18 | # AC_USE_SYSTEM_EXTENSIONS for quite some time. | |
19 | ||
f434ba03 PA |
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 | ||
9c9d63b1 PM |
34 | m4_version_prereq([2.70.1], [], [ |
35 | ||
f6ea5628 DJ |
36 | # AC_USE_SYSTEM_EXTENSIONS |
37 | # ------------------------ | |
38 | # Enable extensions on systems that normally disable them, | |
39 | # typically due to standards-conformance issues. | |
9c9d63b1 PM |
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__). | |
f434ba03 | 43 | AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], |
9c9d63b1 PM |
44 | [AC_BEFORE([$0], [AC_PREPROC_IFELSE])dnl |
45 | AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl | |
46 | AC_BEFORE([$0], [AC_LINK_IFELSE])dnl | |
f6ea5628 | 47 | AC_BEFORE([$0], [AC_RUN_IFELSE])dnl |
9c9d63b1 PM |
48 | AC_BEFORE([$0], [AC_CHECK_INCLUDES_DEFAULT])dnl |
49 | dnl #undef in AH_VERBATIM gets replaced with #define by AC_DEFINE. | |
4a626d0a PA |
50 | dnl Use a different key than __EXTENSIONS__, as that name broke existing |
51 | dnl configure.ac when using autoheader 2.62. | |
9c9d63b1 PM |
52 | dnl The macros below are in alphabetical order ignoring leading _ or __ |
53 | dnl prefixes. | |
54 | AH_VERBATIM([USE_SYSTEM_EXTENSIONS], | |
f6ea5628 DJ |
55 | [/* Enable extensions on AIX 3, Interix. */ |
56 | #ifndef _ALL_SOURCE | |
57 | # undef _ALL_SOURCE | |
58 | #endif | |
49e4877c | 59 | /* Enable general extensions on macOS. */ |
770d76d7 PA |
60 | #ifndef _DARWIN_C_SOURCE |
61 | # undef _DARWIN_C_SOURCE | |
62 | #endif | |
9c9d63b1 PM |
63 | /* Enable general extensions on Solaris. */ |
64 | #ifndef __EXTENSIONS__ | |
65 | # undef __EXTENSIONS__ | |
66 | #endif | |
f6ea5628 DJ |
67 | /* Enable GNU extensions on systems that have them. */ |
68 | #ifndef _GNU_SOURCE | |
69 | # undef _GNU_SOURCE | |
70 | #endif | |
9c9d63b1 PM |
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. */ | |
c0c3707f CB |
84 | #ifndef _NETBSD_SOURCE |
85 | # undef _NETBSD_SOURCE | |
86 | #endif | |
9c9d63b1 PM |
87 | /* Enable OpenBSD compatibility extensions on NetBSD. |
88 | Oddly enough, this does nothing on OpenBSD. */ | |
c0c3707f CB |
89 | #ifndef _OPENBSD_SOURCE |
90 | # undef _OPENBSD_SOURCE | |
91 | #endif | |
9c9d63b1 PM |
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. */ | |
f6ea5628 DJ |
101 | #ifndef _POSIX_PTHREAD_SEMANTICS |
102 | # undef _POSIX_PTHREAD_SEMANTICS | |
103 | #endif | |
49e4877c PA |
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 | |
f6ea5628 DJ |
132 | /* Enable extensions on HP NonStop. */ |
133 | #ifndef _TANDEM_SOURCE | |
134 | # undef _TANDEM_SOURCE | |
135 | #endif | |
9c9d63b1 PM |
136 | /* Enable X/Open extensions. Define to 500 only if necessary |
137 | to make mbstate_t available. */ | |
4a626d0a PA |
138 | #ifndef _XOPEN_SOURCE |
139 | # undef _XOPEN_SOURCE | |
140 | #endif | |
9c9d63b1 PM |
141 | ])dnl |
142 | ||
143 | AC_REQUIRE([AC_CHECK_INCLUDES_DEFAULT])dnl | |
144 | _AC_CHECK_HEADER_ONCE([wchar.h]) | |
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?) | |
f6ea5628 DJ |
149 | AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], |
150 | [ac_cv_safe_to_define___extensions__], | |
151 | [AC_COMPILE_IFELSE( | |
f434ba03 PA |
152 | [AC_LANG_PROGRAM([[ |
153 | # define __EXTENSIONS__ 1 | |
154 | ]AC_INCLUDES_DEFAULT])], | |
f6ea5628 DJ |
155 | [ac_cv_safe_to_define___extensions__=yes], |
156 | [ac_cv_safe_to_define___extensions__=no])]) | |
9c9d63b1 PM |
157 | |
158 | dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to | |
159 | dnl 500, regardless of whether compiling with -Ae or -D_HPUX_SOURCE=1. | |
160 | dnl But defining _XOPEN_SOURCE may turn *off* extensions on platforms | |
161 | dnl not covered by turn-on-extensions macros (notably Dragonfly, Free, | |
162 | dnl and OpenBSD, which don't have any equivalent of _NETBSD_SOURCE) so | |
163 | dnl it should only be defined when necessary. | |
164 | AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined], | |
165 | [ac_cv_should_define__xopen_source], | |
166 | [ac_cv_should_define__xopen_source=no | |
167 | AS_IF([test $ac_cv_header_wchar_h = yes], | |
168 | [AC_COMPILE_IFELSE( | |
169 | [AC_LANG_PROGRAM([[ | |
170 | #include <wchar.h> | |
171 | mbstate_t x;]])], | |
172 | [], | |
173 | [AC_COMPILE_IFELSE( | |
174 | [AC_LANG_PROGRAM([[ | |
175 | #define _XOPEN_SOURCE 500 | |
176 | #include <wchar.h> | |
177 | mbstate_t x;]])], | |
178 | [ac_cv_should_define__xopen_source=yes])])])]) | |
179 | ||
f6ea5628 | 180 | AC_DEFINE([_ALL_SOURCE]) |
770d76d7 | 181 | AC_DEFINE([_DARWIN_C_SOURCE]) |
f6ea5628 | 182 | AC_DEFINE([_GNU_SOURCE]) |
9c9d63b1 | 183 | AC_DEFINE([_HPUX_ALT_XOPEN_SOCKET_API]) |
c0c3707f CB |
184 | AC_DEFINE([_NETBSD_SOURCE]) |
185 | AC_DEFINE([_OPENBSD_SOURCE]) | |
f6ea5628 | 186 | AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) |
49e4877c PA |
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__]) | |
f6ea5628 | 194 | AC_DEFINE([_TANDEM_SOURCE]) |
9c9d63b1 PM |
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])]) | |
f6ea5628 | 205 | ])# AC_USE_SYSTEM_EXTENSIONS |
9c9d63b1 | 206 | ]) |
f6ea5628 DJ |
207 | |
208 | # gl_USE_SYSTEM_EXTENSIONS | |
209 | # ------------------------ | |
210 | # Enable extensions on systems that normally disable them, | |
211 | # typically due to standards-conformance issues. | |
f434ba03 PA |
212 | AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], |
213 | [ | |
f434ba03 | 214 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) |
9c9d63b1 PM |
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 | |
f434ba03 | 227 | ]) |