Commit | Line | Data |
---|---|---|
5e8754f9 | 1 | # serial 15 -*- Autoconf -*- |
f6ea5628 DJ |
2 | # Enable extensions on systems that normally disable them. |
3 | ||
5e8754f9 | 4 | # Copyright (C) 2003, 2006-2016 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 | ||
4a626d0a | 9 | # This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git |
f6ea5628 | 10 | # Autoconf. Perhaps we can remove this once we can assume Autoconf |
4a626d0a | 11 | # 2.70 or later everywhere, but since Autoconf mutates rapidly |
f6ea5628 DJ |
12 | # enough in this area it's likely we'll need to redefine |
13 | # AC_USE_SYSTEM_EXTENSIONS for quite some time. | |
14 | ||
f434ba03 PA |
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 | ||
f6ea5628 DJ |
29 | # AC_USE_SYSTEM_EXTENSIONS |
30 | # ------------------------ | |
31 | # Enable extensions on systems that normally disable them, | |
32 | # typically due to standards-conformance issues. | |
4a626d0a | 33 | # |
f6ea5628 DJ |
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__). | |
f434ba03 | 38 | AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS], |
f6ea5628 DJ |
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], | |
770d76d7 | 45 | [Define to 1 if you need to in order for 'stat' and other |
f6ea5628 DJ |
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.]) | |
4a626d0a PA |
52 | AC_DEFINE([_NETBSD_SOURCE], [1], |
53 | [Define to 1 to make NetBSD features available. MINIX 3 needs this.]) | |
f6ea5628 DJ |
54 | fi |
55 | ||
4a626d0a PA |
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], | |
f6ea5628 DJ |
59 | [/* Enable extensions on AIX 3, Interix. */ |
60 | #ifndef _ALL_SOURCE | |
61 | # undef _ALL_SOURCE | |
62 | #endif | |
49e4877c | 63 | /* Enable general extensions on macOS. */ |
770d76d7 PA |
64 | #ifndef _DARWIN_C_SOURCE |
65 | # undef _DARWIN_C_SOURCE | |
66 | #endif | |
f6ea5628 DJ |
67 | /* Enable GNU extensions on systems that have them. */ |
68 | #ifndef _GNU_SOURCE | |
69 | # undef _GNU_SOURCE | |
70 | #endif | |
71 | /* Enable threading extensions on Solaris. */ | |
72 | #ifndef _POSIX_PTHREAD_SEMANTICS | |
73 | # undef _POSIX_PTHREAD_SEMANTICS | |
74 | #endif | |
49e4877c PA |
75 | /* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ |
76 | #ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ | |
77 | # undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ | |
78 | #endif | |
79 | /* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ | |
80 | #ifndef __STDC_WANT_IEC_60559_BFP_EXT__ | |
81 | # undef __STDC_WANT_IEC_60559_BFP_EXT__ | |
82 | #endif | |
83 | /* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ | |
84 | #ifndef __STDC_WANT_IEC_60559_DFP_EXT__ | |
85 | # undef __STDC_WANT_IEC_60559_DFP_EXT__ | |
86 | #endif | |
87 | /* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ | |
88 | #ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ | |
89 | # undef __STDC_WANT_IEC_60559_FUNCS_EXT__ | |
90 | #endif | |
91 | /* Enable extensions specified by ISO/IEC TS 18661-3:2015. */ | |
92 | #ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ | |
93 | # undef __STDC_WANT_IEC_60559_TYPES_EXT__ | |
94 | #endif | |
95 | /* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ | |
96 | #ifndef __STDC_WANT_LIB_EXT2__ | |
97 | # undef __STDC_WANT_LIB_EXT2__ | |
98 | #endif | |
99 | /* Enable extensions specified by ISO/IEC 24747:2009. */ | |
100 | #ifndef __STDC_WANT_MATH_SPEC_FUNCS__ | |
101 | # undef __STDC_WANT_MATH_SPEC_FUNCS__ | |
102 | #endif | |
f6ea5628 DJ |
103 | /* Enable extensions on HP NonStop. */ |
104 | #ifndef _TANDEM_SOURCE | |
105 | # undef _TANDEM_SOURCE | |
106 | #endif | |
4a626d0a PA |
107 | /* Enable X/Open extensions if necessary. HP-UX 11.11 defines |
108 | mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of | |
109 | whether compiling with -Ae or -D_HPUX_SOURCE=1. */ | |
110 | #ifndef _XOPEN_SOURCE | |
111 | # undef _XOPEN_SOURCE | |
112 | #endif | |
f6ea5628 DJ |
113 | /* Enable general extensions on Solaris. */ |
114 | #ifndef __EXTENSIONS__ | |
115 | # undef __EXTENSIONS__ | |
116 | #endif | |
117 | ]) | |
118 | AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], | |
119 | [ac_cv_safe_to_define___extensions__], | |
120 | [AC_COMPILE_IFELSE( | |
f434ba03 PA |
121 | [AC_LANG_PROGRAM([[ |
122 | # define __EXTENSIONS__ 1 | |
123 | ]AC_INCLUDES_DEFAULT])], | |
f6ea5628 DJ |
124 | [ac_cv_safe_to_define___extensions__=yes], |
125 | [ac_cv_safe_to_define___extensions__=no])]) | |
126 | test $ac_cv_safe_to_define___extensions__ = yes && | |
127 | AC_DEFINE([__EXTENSIONS__]) | |
128 | AC_DEFINE([_ALL_SOURCE]) | |
770d76d7 | 129 | AC_DEFINE([_DARWIN_C_SOURCE]) |
f6ea5628 DJ |
130 | AC_DEFINE([_GNU_SOURCE]) |
131 | AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) | |
49e4877c PA |
132 | AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__]) |
133 | AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__]) | |
134 | AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__]) | |
135 | AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__]) | |
136 | AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__]) | |
137 | AC_DEFINE([__STDC_WANT_LIB_EXT2__]) | |
138 | AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__]) | |
f6ea5628 | 139 | AC_DEFINE([_TANDEM_SOURCE]) |
4a626d0a PA |
140 | AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined], |
141 | [ac_cv_should_define__xopen_source], | |
142 | [ac_cv_should_define__xopen_source=no | |
143 | AC_COMPILE_IFELSE( | |
144 | [AC_LANG_PROGRAM([[ | |
145 | #include <wchar.h> | |
146 | mbstate_t x;]])], | |
147 | [], | |
148 | [AC_COMPILE_IFELSE( | |
149 | [AC_LANG_PROGRAM([[ | |
150 | #define _XOPEN_SOURCE 500 | |
151 | #include <wchar.h> | |
152 | mbstate_t x;]])], | |
153 | [ac_cv_should_define__xopen_source=yes])])]) | |
154 | test $ac_cv_should_define__xopen_source = yes && | |
155 | AC_DEFINE([_XOPEN_SOURCE], [500]) | |
f6ea5628 DJ |
156 | ])# AC_USE_SYSTEM_EXTENSIONS |
157 | ||
158 | # gl_USE_SYSTEM_EXTENSIONS | |
159 | # ------------------------ | |
160 | # Enable extensions on systems that normally disable them, | |
161 | # typically due to standards-conformance issues. | |
f434ba03 PA |
162 | AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS], |
163 | [ | |
164 | dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS. | |
165 | dnl gnulib does not need it. But if it gets required by third-party macros | |
166 | dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a | |
167 | dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS". | |
168 | dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE, | |
169 | dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck. | |
170 | AC_REQUIRE([AC_GNU_SOURCE]) | |
171 | ||
172 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) | |
173 | ]) |