Debian Codegraph @

m4/extensions.m4

raw
1 # serial 18 -*- 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 dnl Use a different key than __EXTENSIONS__, as that name broke existing
43 dnl configure.ac when using autoheader 2.62.
44 AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
45 [/* Enable extensions on AIX 3, Interix. */
46 #ifndef _ALL_SOURCE
47 # undef _ALL_SOURCE
48 #endif
49 /* Enable general extensions on macOS. */
50 #ifndef _DARWIN_C_SOURCE
51 # undef _DARWIN_C_SOURCE
52 #endif
53 /* Enable GNU extensions on systems that have them. */
54 #ifndef _GNU_SOURCE
55 # undef _GNU_SOURCE
56 #endif
57 /* Enable NetBSD extensions on NetBSD. */
58 #ifndef _NETBSD_SOURCE
59 # undef _NETBSD_SOURCE
60 #endif
61 /* Enable OpenBSD extensions on NetBSD. */
62 #ifndef _OPENBSD_SOURCE
63 # undef _OPENBSD_SOURCE
64 #endif
65 /* Enable threading extensions on Solaris. */
66 #ifndef _POSIX_PTHREAD_SEMANTICS
67 # undef _POSIX_PTHREAD_SEMANTICS
68 #endif
69 /* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
70 #ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
71 # undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
72 #endif
73 /* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
74 #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
75 # undef __STDC_WANT_IEC_60559_BFP_EXT__
76 #endif
77 /* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
78 #ifndef __STDC_WANT_IEC_60559_DFP_EXT__
79 # undef __STDC_WANT_IEC_60559_DFP_EXT__
80 #endif
81 /* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
82 #ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
83 # undef __STDC_WANT_IEC_60559_FUNCS_EXT__
84 #endif
85 /* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
86 #ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
87 # undef __STDC_WANT_IEC_60559_TYPES_EXT__
88 #endif
89 /* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
90 #ifndef __STDC_WANT_LIB_EXT2__
91 # undef __STDC_WANT_LIB_EXT2__
92 #endif
93 /* Enable extensions specified by ISO/IEC 24747:2009. */
94 #ifndef __STDC_WANT_MATH_SPEC_FUNCS__
95 # undef __STDC_WANT_MATH_SPEC_FUNCS__
96 #endif
97 /* Enable extensions on HP NonStop. */
98 #ifndef _TANDEM_SOURCE
99 # undef _TANDEM_SOURCE
100 #endif
101 /* Enable X/Open extensions if necessary. HP-UX 11.11 defines
102 mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of
103 whether compiling with -Ae or -D_HPUX_SOURCE=1. */
104 #ifndef _XOPEN_SOURCE
105 # undef _XOPEN_SOURCE
106 #endif
107 /* Enable X/Open compliant socket functions that do not require linking
108 with -lxnet on HP-UX 11.11. */
109 #ifndef _HPUX_ALT_XOPEN_SOCKET_API
110 # undef _HPUX_ALT_XOPEN_SOCKET_API
111 #endif
112 /* Enable general extensions on Solaris. */
113 #ifndef __EXTENSIONS__
114 # undef __EXTENSIONS__
115 #endif
116 ])
117 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
118 [ac_cv_safe_to_define___extensions__],
119 [AC_COMPILE_IFELSE(
120 [AC_LANG_PROGRAM([[
121 # define __EXTENSIONS__ 1
122 ]AC_INCLUDES_DEFAULT])],
123 [ac_cv_safe_to_define___extensions__=yes],
124 [ac_cv_safe_to_define___extensions__=no])])
125 test $ac_cv_safe_to_define___extensions__ = yes &&
126 AC_DEFINE([__EXTENSIONS__])
127 AC_DEFINE([_ALL_SOURCE])
128 AC_DEFINE([_DARWIN_C_SOURCE])
129 AC_DEFINE([_GNU_SOURCE])
130 AC_DEFINE([_NETBSD_SOURCE])
131 AC_DEFINE([_OPENBSD_SOURCE])
132 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
133 AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__])
134 AC_DEFINE([__STDC_WANT_IEC_60559_BFP_EXT__])
135 AC_DEFINE([__STDC_WANT_IEC_60559_DFP_EXT__])
136 AC_DEFINE([__STDC_WANT_IEC_60559_FUNCS_EXT__])
137 AC_DEFINE([__STDC_WANT_IEC_60559_TYPES_EXT__])
138 AC_DEFINE([__STDC_WANT_LIB_EXT2__])
139 AC_DEFINE([__STDC_WANT_MATH_SPEC_FUNCS__])
140 AC_DEFINE([_TANDEM_SOURCE])
141 AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
142 [ac_cv_should_define__xopen_source],
143 [ac_cv_should_define__xopen_source=no
144 AC_COMPILE_IFELSE(
145 [AC_LANG_PROGRAM([[
146 #include <wchar.h>
147 mbstate_t x;]])],
148 [],
149 [AC_COMPILE_IFELSE(
150 [AC_LANG_PROGRAM([[
151 #define _XOPEN_SOURCE 500
152 #include <wchar.h>
153 mbstate_t x;]])],
154 [ac_cv_should_define__xopen_source=yes])])])
155 test $ac_cv_should_define__xopen_source = yes &&
156 AC_DEFINE([_XOPEN_SOURCE], [500])
157 AC_DEFINE([_HPUX_ALT_XOPEN_SOCKET_API])
158 ])# AC_USE_SYSTEM_EXTENSIONS
159
160 # gl_USE_SYSTEM_EXTENSIONS
161 # ------------------------
162 # Enable extensions on systems that normally disable them,
163 # typically due to standards-conformance issues.
164 AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
165 [
166 dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
167 dnl gnulib does not need it. But if it gets required by third-party macros
168 dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
169 dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
170 dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
171 dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
172 AC_REQUIRE([AC_GNU_SOURCE])
173
174 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
175 ])