aboutsummaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-11-20 18:36:12 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2017-11-23 08:35:13 +0300
commitba43ee3b069eaefca3ae74b3eeb9d6d8e2d9e6b0 (patch)
treed2e52c2c564d270dad62d89ed9f11f64b24a0e7b /m4
parent8fce1b9bc794d0151eed70ed67b242b85d0fccd7 (diff)
downloadlibmicrohttpd-ba43ee3b069eaefca3ae74b3eeb9d6d8e2d9e6b0.tar.gz
libmicrohttpd-ba43ee3b069eaefca3ae74b3eeb9d6d8e2d9e6b0.zip
mhd_sys_extentions.m4: updated, fixed and improved.
Now better detect supported features, works with latest Android NDK, skips definition of _XOPEN_SOURCE on platforms where it conflicts with system-specific features, overall improvements and minor fixing.
Diffstat (limited to 'm4')
-rw-r--r--m4/mhd_sys_extentions.m41273
1 files changed, 781 insertions, 492 deletions
diff --git a/m4/mhd_sys_extentions.m4 b/m4/mhd_sys_extentions.m4
index 0fff57ed..51b8aeca 100644
--- a/m4/mhd_sys_extentions.m4
+++ b/m4/mhd_sys_extentions.m4
@@ -40,263 +40,57 @@
40# 40#
41# LICENSE 41# LICENSE
42# 42#
43# Copyright (c) 2016 Karlson2k (Evgeny Grin) <k2k@narod.ru> 43# Copyright (c) 2016, 2017 Karlson2k (Evgeny Grin) <k2k@narod.ru>
44# 44#
45# Copying and distribution of this file, with or without modification, are 45# Copying and distribution of this file, with or without modification, are
46# permitted in any medium without royalty provided the copyright notice 46# permitted in any medium without royalty provided the copyright notice
47# and this notice are preserved. This file is offered as-is, without any 47# and this notice are preserved. This file is offered as-is, without any
48# warranty. 48# warranty.
49 49
50#serial 1 50#serial 2
51 51
52AC_DEFUN([MHD_SYS_EXT],[dnl 52AC_DEFUN([MHD_SYS_EXT],[dnl
53 AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifnblank 53 AC_PREREQ([2.64])dnl for AS_VAR_IF, AS_VAR_SET_IF, m4_ifnblank
54 AC_LANG_PUSH([C])dnl Use C language for simplicity 54 AC_LANG_PUSH([C])dnl Use C language for simplicity
55 mhd_mse_added_exts_flags="" 55 mhd_mse_sys_ext_defines=""
56 mhd_mse_added_prolog="" 56 mhd_mse_sys_ext_flags=""
57 MHD_CHECK_DEFINED([[_XOPEN_SOURCE]], [], [dnl
58 AC_CACHE_CHECK([[whether predefined value of _XOPEN_SOURCE is more or equal 500]],
59 [[mhd_cv_macro__xopen_source_def_fiveh]], [dnl
60 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
61#if _XOPEN_SOURCE+0 < 500
62#error Value of _XOPEN_SOURCE is less than 500
63choke me now;
64#endif
65 ]],[[int i = 0; i++]])],dnl
66 [[mhd_cv_macro__xopen_source_def_fiveh="yes"]],
67 [[mhd_cv_macro__xopen_source_def_fiveh="no"]]
68 )
69 ])
70 AS_VAR_IF([mhd_cv_macro__xopen_source_def_fiveh], [["no"]], [dnl
71 _MHD_XOPEN_ADD([])
72 ])
73 ],
74 [
75 dnl Some platforms (namely: Solaris) use '==' checks instead of '>='
76 dnl for _XOPEN_SOURCE, resulting that unknown for platform values are
77 dnl interpreted as oldest and platform expose reduced number of
78 dnl interfaces. Next checks will ensure that platform recognise
79 dnl requested mode instead of blindly define high number that can
80 dnl be simply ignored by platform.
81 MHD_CHECK_ACCEPT_DEFINE([[_XOPEN_SOURCE]], [[700]], [], [dnl
82 AC_CACHE_CHECK([[whether _XOPEN_SOURCE with value 700 really enable POSIX.1-2008/SUSv4 features]],
83 [[mhd_cv_define__xopen_source_sevenh_works]], [dnl
84 _MHD_CHECK_XOPEN_ENABLE([[700]], [
85_MHD_BASIC_INCLUDES
86[
87/* Check will be passed if ALL features are avalable
88 * and failed if ANY feature is not avalable. */
89int main()
90{
91
92#ifndef stpncpy
93 (void) stpncpy;
94#endif
95#ifndef strnlen
96 (void) strnlen;
97#endif
98
99#if !defined(__NetBSD__) && !defined(__OpenBSD__)
100/* NetBSD and OpenBSD didn't implement wcsnlen() for some reason. */
101#ifndef wcsnlen
102 (void) wcsnlen;
103#endif
104#endif
105
106#ifdef __CYGWIN__
107/* The only depend function on Cygwin, but missing on some other platforms */
108#ifndef strndup
109 (void) strndup;
110#endif
111#endif
112
113#ifndef __sun
114/* illumos forget to uncomment some _XPG7 macros. */
115#ifndef renameat
116 (void) renameat;
117#endif
118
119#ifndef getline
120 (void) getline;
121#endif
122#endif /* ! __sun */
123
124/* gmtime_r() becomes mandatory only in POSIX.1-2008. */
125#ifndef gmtime_r
126 (void) gmtime_r;
127#endif
128
129/* unsetenv() actually defined in POSIX.1-2001 so it
130 * must be present with _XOPEN_SOURCE == 700 too. */
131#ifndef unsetenv
132 (void) unsetenv;
133#endif
134
135 return 0;
136}
137 ]],
138 [[mhd_cv_define__xopen_source_sevenh_works="yes"]],
139 [[mhd_cv_define__xopen_source_sevenh_works="no"]]
140 )dnl
141 ])dnl
142 ])
143 AS_IF([[test "x$mhd_cv_define__xopen_source_accepted_700" = "xyes" &&
144 test "x$mhd_cv_define__xopen_source_sevenh_works" = "xyes"]], [dnl
145 _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_SOURCE]], [[700]])
146 ], [dnl
147 MHD_CHECK_ACCEPT_DEFINE([[_XOPEN_SOURCE]], [[600]], [], [dnl
148 AC_CACHE_CHECK([[whether _XOPEN_SOURCE with value 600 really enable POSIX.1-2001/SUSv3 features]],
149 [[mhd_cv_define__xopen_source_sixh_works]], [dnl
150 _MHD_CHECK_XOPEN_ENABLE([[600]], [
151_MHD_BASIC_INCLUDES
152[
153/* Check will be passed if ALL features are available
154 * and failed if ANY feature is not available. */
155int main()
156{
157
158#ifndef setenv
159 (void) setenv;
160#endif
161
162#ifndef __NetBSD__
163#ifndef vsscanf
164 (void) vsscanf;
165#endif
166#endif
167
168/* Availability of next features varies, but they all must be present
169 * on platform with support for _XOPEN_SOURCE = 600. */
170
171/* vsnprintf() should be available with _XOPEN_SOURCE >= 500, but some platforms
172 * provide it only with _POSIX_C_SOURCE >= 200112 (autodefined when
173 * _XOPEN_SOURCE >= 600) where specification of vsnprintf() is aligned with
174 * ISO C99 while others platforms defined it with even earlier standards. */
175#ifndef vsnprintf
176 (void) vsnprintf;
177#endif
178
179/* On platforms that prefer POSIX over X/Open, fseeko() is available
180 * with _POSIX_C_SOURCE >= 200112 (autodefined when _XOPEN_SOURCE >= 600).
181 * On other platforms it should be available with _XOPEN_SOURCE >= 500. */
182#ifndef fseeko
183 (void) fseeko;
184#endif
185
186/* F_GETOWN must be defined with _XOPEN_SOURCE >= 600, but some platforms
187 * define it with _XOPEN_SOURCE >= 500. */
188#ifndef F_GETOWN
189#error F_GETOWN is not defined
190choke me now;
191#endif
192 return 0;
193}
194 ]],
195 [[mhd_cv_define__xopen_source_sixh_works="yes"]],
196 [[mhd_cv_define__xopen_source_sixh_works="no"]]
197 )dnl
198 ])dnl
199 ])
200 AS_IF([[test "x$mhd_cv_define__xopen_source_accepted_600" = "xyes" &&
201 test "x$mhd_cv_define__xopen_source_sixh_works" = "xyes"]], [dnl
202 _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_SOURCE]], [[600]])
203 ], [dnl
204 MHD_CHECK_ACCEPT_DEFINE([[_XOPEN_SOURCE]], [[500]], [], [dnl
205 AC_CACHE_CHECK([[whether _XOPEN_SOURCE with value 500 really enable SUSv2/XPG5 features]],
206 [mhd_cv_define__xopen_source_fiveh_works], [dnl
207 _MHD_CHECK_XOPEN_ENABLE([[500]], [
208_MHD_BASIC_INCLUDES
209[
210/* Check will be passed if ALL features are available
211 * and failed if ANY feature is not available. */
212int main()
213{
214/* It's not easy to write reliable test for _XOPEN_SOURCE = 500 as
215 * platforms not always precisely follow this standard and some
216 * functions are already deprecated in later standards. */
217
218/* Availability of next features varies, but they all must be present
219 * on platform with correct support for _XOPEN_SOURCE = 500. */
220
221/* Mandatory with _XOPEN_SOURCE >= 500 but as XSI extension available
222 * with much older standards. */
223#ifndef ftruncate
224 (void) ftruncate;
225#endif
226
227/* Added with _XOPEN_SOURCE >= 500 but was available in some standards
228 * before. XSI extension. */
229#ifndef pread
230 (void) pread;
231#endif
232 57
233#ifndef __APPLE__ 58 dnl Check platform-specific extensions.
234/* Actually comes from XPG4v2 and must be available
235 * with _XOPEN_SOURCE >= 500 as well. */
236#ifndef symlink
237 (void) symlink;
238#endif
239
240/* Actually comes from XPG4v2 and must be available
241 * with _XOPEN_SOURCE >= 500 as well. XSI extension. */
242#ifndef strdup
243 (void) strdup;
244#endif
245#endif /* ! __APPLE__ */
246 return 0;
247}
248 ]],
249 [[mhd_cv_define__xopen_source_fiveh_works="yes"]],
250 [[mhd_cv_define__xopen_source_fiveh_works="no"]]
251 )dnl
252 ])dnl
253 ])
254 AS_IF([[test "x$mhd_cv_define__xopen_source_accepted_500" = "xyes" && ]dnl
255 [test "x$mhd_cv_define__xopen_source_fiveh_works" = "xyes"]], [dnl
256 _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_SOURCE]], [[500]])
257 ],
258 [
259 [#] Earlier standards are widely supported, so just define macros to maximum value
260 [#] which do not break headers.
261 _MHD_XOPEN_ADD([[#define _XOPEN_SOURCE 1]])
262 AC_CACHE_CHECK([[whether headers accept _XOPEN_SOURCE with value 1]],
263 [mhd_cv_define__xopen_source_accepted_1], [dnl
264 AS_IF([[test "x$mhd_cv_define__xopen_source_extended_accepted" = "xyes" || ]dnl
265 [test "x$mhd_cv_define__xopen_version_accepted" = "xyes"]],
266 [[mhd_cv_define__xopen_source_accepted_1="yes"]],
267 [
268 MHD_CHECK_BASIC_HEADERS([[#define _XOPEN_SOURCE 1]],
269 [[mhd_cv_define__xopen_source_accepted_1="yes"]],
270 [[mhd_cv_define__xopen_source_accepted_1="no"]])
271 ])
272 ])
273 AS_VAR_IF([[mhd_cv_define__xopen_source_accepted_1]], [["yes"]], [dnl
274 _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_SOURCE]], [[1]])
275 ])
276 ])
277 ])
278 ])
279 ])
280 dnl Add other extensions.
281 dnl Use compiler-based test for determinig target. 59 dnl Use compiler-based test for determinig target.
282 60
283 dnl Always add _GNU_SOURCE if headers allow. 61 dnl Always add _GNU_SOURCE if headers allow.
284 MHD_CHECK_DEF_AND_ACCEPT([[_GNU_SOURCE]], [], 62 MHD_CHECK_DEF_AND_ACCEPT([[_GNU_SOURCE]], [],
285 [[${mhd_mse_added_prolog}]], [], 63 [[${mhd_mse_sys_ext_defines}]], [mhd_cv_macro_add__gnu_source="no"],
286 [_MHD_SYS_EXT_ADD_FLAG([[_GNU_SOURCE]])]) 64 [mhd_cv_macro_add__gnu_source="yes"],
65 [mhd_cv_macro_add__gnu_source="no"]
66 )
67 AS_VAR_IF([mhd_cv_macro_add__gnu_source], ["yes"],
68 [
69 _MHD_SYS_EXT_VAR_ADD_FLAG([[mhd_mse_sys_ext_defines]], [[mhd_mse_sys_ext_flags]], [[_GNU_SOURCE]])
70 ]
71 )
287 72
288 dnl __BSD_VISIBLE is actually a small hack for FreeBSD. 73 dnl __BSD_VISIBLE is actually a small hack for FreeBSD.
289 dnl Funny that it's used in Android headers too. 74 dnl Funny that it's used in some Android versions too.
290 AC_CACHE_CHECK([[whether to try __BSD_VISIBLE macro]], 75 AC_CACHE_CHECK([[whether to try __BSD_VISIBLE macro]],
291 [[mhd_cv_macro_try___bsd_visible]], [dnl 76 [[mhd_cv_macro_try___bsd_visible]], [dnl
292 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 77 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
293#if !defined(__FreeBSD__) && !defined (__ANDROID__) 78/* Warning: test with inverted logic! */
294#error Target is not FreeBSD or Android 79#ifdef __FreeBSD__
80#error Target FreeBSD
295choke me now; 81choke me now;
296#endif 82#endif /* __FreeBSD__ */
83
84#ifdef __ANDROID__
85#include <android/api-level.h>
86#ifndef __ANDROID_API_O__
87#error Target is Android NDK before R14
88choke me now;
89#endif /* ! __ANDROID_API_O__ */
90#endif /* __ANDROID__ */
297 ]],[])], 91 ]],[])],
298 [[mhd_cv_macro_try___bsd_visible="yes"]], 92 [[mhd_cv_macro_try___bsd_visible="no"]],
299 [[mhd_cv_macro_try___bsd_visible="no"]] 93 [[mhd_cv_macro_try___bsd_visible="yes"]]
300 ) 94 )
301 ]) 95 ])
302 AS_VAR_IF([[mhd_cv_macro_try___bsd_visible]], [["yes"]], 96 AS_VAR_IF([[mhd_cv_macro_try___bsd_visible]], [["yes"]],
@@ -304,20 +98,12 @@ choke me now;
304 AC_CACHE_CHECK([[whether __BSD_VISIBLE is already defined]], 98 AC_CACHE_CHECK([[whether __BSD_VISIBLE is already defined]],
305 [[mhd_cv_macro___bsd_visible_defined]], [dnl 99 [[mhd_cv_macro___bsd_visible_defined]], [dnl
306 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 100 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
307${mhd_mse_added_prolog} 101${mhd_mse_sys_ext_defines}
308/* Warning: test with inverted logic! */ 102/* Warning: test with inverted logic! */
309#ifdef __BSD_VISIBLE 103#ifdef __BSD_VISIBLE
310#error __BSD_VISIBLE is defined 104#error __BSD_VISIBLE is defined
311choke me now; 105choke me now;
312#endif 106#endif
313#ifdef __ANDROID__
314/* if __BSD_VISIBLE is not defined, Android usually defines it to 1 */
315#include <stdio.h>
316#if defined(__BSD_VISIBLE) && __BSD_VISIBLE == 1
317#error __BSD_VISIBLE is autodefined by headers to value 1
318choke me now;
319#endif
320#endif
321 ]],[]) 107 ]],[])
322 ], 108 ],
323 [[mhd_cv_macro___bsd_visible_defined="no"]], 109 [[mhd_cv_macro___bsd_visible_defined="no"]],
@@ -327,61 +113,73 @@ choke me now;
327 AS_VAR_IF([[mhd_cv_macro___bsd_visible_defined]], [["yes"]], [[:]], 113 AS_VAR_IF([[mhd_cv_macro___bsd_visible_defined]], [["yes"]], [[:]],
328 [dnl 114 [dnl
329 MHD_CHECK_ACCEPT_DEFINE( 115 MHD_CHECK_ACCEPT_DEFINE(
330 [[__BSD_VISIBLE]], [], [[${mhd_mse_added_prolog}]], 116 [[__BSD_VISIBLE]], [], [[${mhd_mse_sys_ext_defines}]],
331 [_MHD_SYS_EXT_ADD_FLAG([[__BSD_VISIBLE]])] 117 [
118 _MHD_SYS_EXT_VAR_ADD_FLAG([[mhd_mse_sys_ext_defines]], [[mhd_mse_sys_ext_flags]], [[__BSD_VISIBLE]])
119 ]
332 )dnl 120 )dnl
333 ]) 121 ])
334 ]) 122 ])
335 123
336 124
337 dnl _DARWIN_C_SOURCE enables additional functionality on Darwin. 125 dnl _DARWIN_C_SOURCE enables additional functionality on Darwin.
338 MHD_CHECK_DEFINED_MSG([[__APPLE__]], [[${mhd_mse_added_prolog}]], 126 MHD_CHECK_DEFINED_MSG([[__APPLE__]], [[${mhd_mse_sys_ext_defines}]],
339 [[whether to try _DARWIN_C_SOURCE macro]], 127 [[whether to try _DARWIN_C_SOURCE macro]],
340 [dnl 128 [dnl
341 MHD_CHECK_DEF_AND_ACCEPT( 129 MHD_CHECK_DEF_AND_ACCEPT(
342 [[_DARWIN_C_SOURCE]], [], [[${mhd_mse_added_prolog}]], [], 130 [[_DARWIN_C_SOURCE]], [], [[${mhd_mse_sys_ext_defines}]], [],
343 [_MHD_SYS_EXT_ADD_FLAG([[_DARWIN_C_SOURCE]])] 131 [
132 _MHD_SYS_EXT_VAR_ADD_FLAG([[mhd_mse_sys_ext_defines]], [[mhd_mse_sys_ext_flags]], [[_DARWIN_C_SOURCE]])
133 ]
344 )dnl 134 )dnl
345 ]) 135 ])
346 136
347 dnl __EXTENSIONS__ unlocks almost all interfaces on Solaris. 137 dnl __EXTENSIONS__ unlocks almost all interfaces on Solaris.
348 MHD_CHECK_DEFINED_MSG([[__sun]], [[${mhd_mse_added_prolog}]], 138 MHD_CHECK_DEFINED_MSG([[__sun]], [[${mhd_mse_sys_ext_defines}]],
349 [[whether to try __EXTENSIONS__ macro]], 139 [[whether to try __EXTENSIONS__ macro]],
350 [dnl 140 [dnl
351 MHD_CHECK_DEF_AND_ACCEPT( 141 MHD_CHECK_DEF_AND_ACCEPT(
352 [[__EXTENSIONS__]], [], [[${mhd_mse_added_prolog}]], [], 142 [[__EXTENSIONS__]], [], [[${mhd_mse_sys_ext_defines}]], [],
353 [_MHD_SYS_EXT_ADD_FLAG([[__EXTENSIONS__]])] 143 [
144 _MHD_SYS_EXT_VAR_ADD_FLAG([[mhd_mse_sys_ext_defines]], [[mhd_mse_sys_ext_flags]], [[__EXTENSIONS__]])
145 ]
354 )dnl 146 )dnl
355 ]) 147 ])
356 148
357 dnl _NETBSD_SOURCE switch on almost all headers definitions on NetBSD. 149 dnl _NETBSD_SOURCE switch on almost all headers definitions on NetBSD.
358 MHD_CHECK_DEFINED_MSG([[__NetBSD__]], [[${mhd_mse_added_prolog}]], 150 MHD_CHECK_DEFINED_MSG([[__NetBSD__]], [[${mhd_mse_sys_ext_defines}]],
359 [[whether to try _NETBSD_SOURCE macro]], 151 [[whether to try _NETBSD_SOURCE macro]],
360 [dnl 152 [dnl
361 MHD_CHECK_DEF_AND_ACCEPT( 153 MHD_CHECK_DEF_AND_ACCEPT(
362 [[_NETBSD_SOURCE]], [], [[${mhd_mse_added_prolog}]], [], 154 [[_NETBSD_SOURCE]], [], [[${mhd_mse_sys_ext_defines}]], [],
363 [_MHD_SYS_EXT_ADD_FLAG([[_NETBSD_SOURCE]])] 155 [
156 _MHD_SYS_EXT_VAR_ADD_FLAG([[mhd_mse_sys_ext_defines]], [[mhd_mse_sys_ext_flags]], [[_NETBSD_SOURCE]])
157 ]
364 )dnl 158 )dnl
365 ]) 159 ])
366 160
367 dnl _BSD_SOURCE currently used only on OpenBSD to unhide functions. 161 dnl _BSD_SOURCE currently used only on OpenBSD to unhide functions.
368 MHD_CHECK_DEFINED_MSG([[__OpenBSD__]], [[${mhd_mse_added_prolog}]], 162 MHD_CHECK_DEFINED_MSG([[__OpenBSD__]], [[${mhd_mse_sys_ext_defines}]],
369 [[whether to try _BSD_SOURCE macro]], 163 [[whether to try _BSD_SOURCE macro]],
370 [dnl 164 [dnl
371 MHD_CHECK_DEF_AND_ACCEPT( 165 MHD_CHECK_DEF_AND_ACCEPT(
372 [[_BSD_SOURCE]], [], [[${mhd_mse_added_prolog}]], [], 166 [[_BSD_SOURCE]], [], [[${mhd_mse_sys_ext_defines}]], [],
373 [_MHD_SYS_EXT_ADD_FLAG([[_BSD_SOURCE]])] 167 [
168 _MHD_SYS_EXT_VAR_ADD_FLAG([[mhd_mse_sys_ext_defines]], [[mhd_mse_sys_ext_flags]], [[_BSD_SOURCE]])
169 ]
374 )dnl 170 )dnl
375 ]) 171 ])
376 172
377 dnl _TANDEM_SOURCE unhides most functions on NonStop OS 173 dnl _TANDEM_SOURCE unhides most functions on NonStop OS
378 dnl (which comes from Tandem Computers decades ago). 174 dnl (which comes from Tandem Computers decades ago).
379 MHD_CHECK_DEFINED_MSG([[__TANDEM]], [[${mhd_mse_added_prolog}]], 175 MHD_CHECK_DEFINED_MSG([[__TANDEM]], [[${mhd_mse_sys_ext_defines}]],
380 [[whether to try _TANDEM_SOURCE macro]], 176 [[whether to try _TANDEM_SOURCE macro]],
381 [dnl 177 [dnl
382 MHD_CHECK_DEF_AND_ACCEPT( 178 MHD_CHECK_DEF_AND_ACCEPT(
383 [[_TANDEM_SOURCE]], [], [[${mhd_mse_added_prolog}]], [], 179 [[_TANDEM_SOURCE]], [], [[${mhd_mse_sys_ext_defines}]], [],
384 [_MHD_SYS_EXT_ADD_FLAG([[_TANDEM_SOURCE]])] 180 [
181 _MHD_SYS_EXT_VAR_ADD_FLAG([[mhd_mse_sys_ext_defines]], [[mhd_mse_sys_ext_flags]], [[_TANDEM_SOURCE]])
182 ]
385 )dnl 183 )dnl
386 ]) 184 ])
387 185
@@ -402,13 +200,134 @@ choke me now;
402 AS_VAR_IF([[mhd_cv_macro_try__all_source]], [["yes"]], 200 AS_VAR_IF([[mhd_cv_macro_try__all_source]], [["yes"]],
403 [dnl 201 [dnl
404 MHD_CHECK_DEF_AND_ACCEPT( 202 MHD_CHECK_DEF_AND_ACCEPT(
405 [[_ALL_SOURCE]], [], [[${mhd_mse_added_prolog}]], [], 203 [[_ALL_SOURCE]], [], [[${mhd_mse_sys_ext_defines}]], [],
406 [_MHD_SYS_EXT_ADD_FLAG([[_TANDEM_SOURCE]])] 204 [
205 _MHD_SYS_EXT_VAR_ADD_FLAG([[mhd_mse_sys_ext_defines]], [[mhd_mse_sys_ext_flags]], [[_ALL_SOURCE]])
206 ]
407 )dnl 207 )dnl
408 ]) 208 ])
409 209
410 dnl Discard temporal prolog with set of defines. 210 mhd_mse_xopen_features=""
411 AS_UNSET([[mhd_mse_added_prolog]]) 211 mhd_mse_xopen_defines=""
212 mhd_mse_xopen_flags=""
213
214 AC_CACHE_CHECK([[whether _XOPEN_SOURCE is already defined]],
215 [[mhd_cv_macro__xopen_source_defined]], [
216 _MHD_CHECK_DEFINED([[_XOPEN_SOURCE]], [[${mhd_mse_sys_ext_defines}]],
217 [[mhd_cv_macro__xopen_source_defined="yes"]],
218 [[mhd_cv_macro__xopen_source_defined="no"]]
219 )
220 ]
221 )
222 AS_VAR_IF([[mhd_cv_macro__xopen_source_defined]], [["no"]],
223 [
224 dnl Some platforms (namely: Solaris) use '==' checks instead of '>='
225 dnl for _XOPEN_SOURCE, resulting that unknown for platform values are
226 dnl interpreted as oldest and platform expose reduced number of
227 dnl interfaces. Next checks will ensure that platform recognise
228 dnl requested mode instead of blindly define high number that can
229 dnl be simply ignored by platform.
230 _MHD_CHECK_POSIX2008([[mhd_mse_xopen_defines]],
231 [[mhd_mse_xopen_flags]],
232 [[${mhd_mse_sys_ext_defines}]],
233 [mhd_mse_xopen_features="${mhd_cv_headers_posix2008}"],
234 [
235 _MHD_CHECK_POSIX2001([[mhd_mse_xopen_defines]],
236 [[mhd_mse_xopen_flags]],
237 [[${mhd_mse_sys_ext_defines}]],
238 [mhd_mse_xopen_features="${mhd_cv_headers_posix2001}"],
239 [
240 _MHD_CHECK_SUSV2([[mhd_mse_xopen_defines]],
241 [[mhd_mse_xopen_flags]],
242 [[${mhd_mse_sys_ext_defines}]],
243 [mhd_mse_xopen_features="${mhd_cv_headers_susv2}"],
244 [mhd_mse_xopen_features="${mhd_cv_headers_susv2}"]
245 )
246 ]
247 )
248 ]
249 )
250 ]
251 )
252
253 AS_IF([[test "x${mhd_cv_macro__xopen_source_defined}" = "xno" && \
254 test "x${mhd_cv_macro__xopen_source_def_fiveh}" = "xno" || \
255 test "x${mhd_mse_xopen_features}" = "xnot available" ]],
256 [
257 _MHD_XOPEN_VAR_ADD([mhd_mse_xopen_defines], [mhd_mse_xopen_flags], [${mhd_mse_sys_ext_defines}])
258 ]
259 )
260
261 mhd_mse_sys_features_src="
262#ifdef __APPLE__
263#include <sys/socket.h>
264#else
265#error No useful system features.
266choke me now;
267#endif
268
269int main()
270{
271#ifdef __APPLE__
272#ifndef sendfile
273 (void) sendfile;
274#endif
275#endif
276 return 0;
277}
278"
279 AC_CACHE_CHECK([[for useful system-specific features]],
280 [[mhd_cv_headers_useful_features_present]], [dnl
281 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
282${mhd_mse_sys_ext_defines}
283${mhd_mse_sys_features_src}
284 ]])],
285 [[mhd_cv_headers_useful_features_present="yes"]],
286 [[mhd_cv_headers_useful_features_present="no"]]
287 )dnl
288 ])
289 AS_VAR_IF([[mhd_cv_headers_useful_features_present]], [["yes"]],
290 [
291 AS_IF([[test "x${mhd_mse_xopen_flags}" = "x"]], [[:]],
292 [
293 AC_CACHE_CHECK([[whether useful system-specific features works with ${mhd_mse_xopen_flags}]],
294 [[mhd_cv_headers_useful_features_works_xopen]], [dnl
295 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
296${mhd_mse_sys_ext_defines}
297${mhd_mse_xopen_defines}
298${mhd_mse_sys_features_src}
299 ]])],
300 [[mhd_cv_headers_useful_features_works_xopen="yes"]],
301 [[mhd_cv_headers_useful_features_works_xopen="no"]]
302 )dnl
303 ])dnl
304 ]
305 )dnl
306 ]
307 )
308
309
310 AS_IF([[test "x${mhd_cv_headers_useful_features_present}" = "xyes" && \
311 test "x${mhd_cv_headers_useful_features_works_xopen}" = "xno" && \
312 test "x${mhd_mse_xopen_flags}" != "x"]],
313 [
314 _MHD_VAR_CONTAIN([[mhd_mse_xopen_features]], [[, activated by _XOPEN_SOURCE]],
315 [
316 AC_MSG_WARN([[_XOPEN_SOURCE macro is required to activate all headers symbols, however some useful system-specific features does not work with _XOPEN_SOURCE. ]dnl
317 [_XOPEN_SOURCE macro will not be used.]])
318 ]
319 )
320 AS_UNSET([[mhd_mse_xopen_defines]])
321 AS_UNSET([[mhd_mse_xopen_flags]])
322 AS_UNSET([[mhd_mse_xopen_values]])
323 ]
324 )
325
326 dnl Discard temporal source variables
327 AS_UNSET([[mhd_mse_sys_features_src]])
328 AS_UNSET([[mhd_mse_xopen_defines]])
329 AS_UNSET([[mhd_mse_sys_ext_defines]])
330
412 dnl Determined all required defines. 331 dnl Determined all required defines.
413 AC_MSG_CHECKING([[for final set of defined symbols]]) 332 AC_MSG_CHECKING([[for final set of defined symbols]])
414 m4_ifblank([$1], [dnl 333 m4_ifblank([$1], [dnl
@@ -426,7 +345,7 @@ choke me now;
426 AH_TEMPLATE([[_TANDEM_SOURCE]], [Define to 1 if it is required by headers to expose additional symbols])dnl 345 AH_TEMPLATE([[_TANDEM_SOURCE]], [Define to 1 if it is required by headers to expose additional symbols])dnl
427 AH_TEMPLATE([[_ALL_SOURCE]], [Define to 1 if it is required by headers to expose additional symbols])dnl 346 AH_TEMPLATE([[_ALL_SOURCE]], [Define to 1 if it is required by headers to expose additional symbols])dnl
428 ]) 347 ])
429 for mhd_mse_Flag in $mhd_mse_added_exts_flags 348 for mhd_mse_Flag in ${mhd_mse_sys_ext_flags} ${mhd_mse_xopen_flags}
430 do 349 do
431 m4_ifnblank([$1], [dnl 350 m4_ifnblank([$1], [dnl
432 AS_VAR_APPEND([$1],[[" -D$mhd_mse_Flag"]]) 351 AS_VAR_APPEND([$1],[[" -D$mhd_mse_Flag"]])
@@ -440,30 +359,38 @@ choke me now;
440 ]) 359 ])
441 ]) 360 ])
442 done 361 done
362 AS_UNSET([[mhd_mse_Flag]])
443 dnl Trim whitespaces 363 dnl Trim whitespaces
444 mhd_mse_result=`echo $mhd_mse_added_exts_flags` 364 mhd_mse_result=`echo ${mhd_mse_sys_ext_flags} ${mhd_mse_xopen_flags}`
445 AC_MSG_RESULT([[$mhd_mse_result]]) 365 AC_MSG_RESULT([[${mhd_mse_result}]])
446 AS_UNSET([[mhd_mse_result]]) 366 AS_UNSET([[mhd_mse_result]])
447 367 AS_UNSET([[mhd_mse_xopen_flags]])
448 AS_UNSET([[mhd_mse_added_exts_flags]]) 368 AS_UNSET([[mhd_mse_sys_ext_flags]])
449 AC_LANG_POP([C]) 369 AC_LANG_POP([C])
450]) 370])
451 371
452 372
453# 373#
454# _MHD_SYS_EXT_ADD_FLAG(FLAG, [FLAG-VALUE = 1]) 374# _MHD_SYS_EXT_VAR_ADD_FLAG(DEFINES_VAR, FLAGS_VAR,
375# FLAG, [FLAG-VALUE = 1])
455# 376#
456# Internal macro, only to be used from MHD_SYS_EXT, _MHD_XOPEN_ADD 377# Internal macro, only to be used from MHD_SYS_EXT, _MHD_XOPEN_VAR_ADD
457 378
458m4_define([_MHD_SYS_EXT_ADD_FLAG], [dnl 379m4_define([_MHD_SYS_EXT_VAR_ADD_FLAG], [dnl
459 m4_ifnblank([$2],[dnl 380 m4_ifnblank([$4],[dnl
460 mhd_mse_added_exts_flags="$mhd_mse_added_exts_flags m4_normalize($1)=m4_normalize($2)" 381 ]m4_normalize([$1])[="[$]{]m4_normalize([$1])[}[#define ]m4_normalize($3) ]m4_normalize([$4])[
461 mhd_mse_added_prolog="${mhd_mse_added_prolog}[#define ]m4_normalize($1) m4_normalize($2)
462" 382"
383 AS_IF([test "x[$]{]m4_normalize([$2])[}" = "x"],
384 []m4_normalize([$2])[="]m4_normalize([$3])[=]m4_normalize([$4])["],
385 []m4_normalize([$2])[="[$]{]m4_normalize([$2])[} ]m4_normalize([$3])[=]m4_normalize([$4])["]
386 )dnl
463 ], [dnl 387 ], [dnl
464 mhd_mse_added_exts_flags="$mhd_mse_added_exts_flags m4_normalize($1)" 388 ]m4_normalize([$1])[="[$]{]m4_normalize([$1])[}[#define ]m4_normalize($3) 1
465 mhd_mse_added_prolog="${mhd_mse_added_prolog}[#define ]m4_normalize($1) 1
466" 389"
390 AS_IF([test "x[$]{]m4_normalize([$2])[}" = "x"],
391 []m4_normalize([$2])[="]m4_normalize([$3])["],
392 []m4_normalize([$2])[="[$]{]m4_normalize([$2])[} ]m4_normalize([$3])["]
393 )dnl
467 ])dnl 394 ])dnl
468]) 395])
469 396
@@ -474,41 +401,360 @@ m4_define([_MHD_SYS_EXT_ADD_FLAG], [dnl
474# both IF-EQ and IF-NOT-EQ are empty. 401# both IF-EQ and IF-NOT-EQ are empty.
475 402
476m4_define([_MHD_VAR_IF],[dnl 403m4_define([_MHD_VAR_IF],[dnl
477m4_ifnblank([$3][$4],[dnl 404m4_ifnblank([$3$4],[dnl
478m4_ifblank([$4],[AS_VAR_IF([$1],[$2],[$3])],[dnl 405AS_VAR_IF([$1],[$2],[$3],[$4])])])
479AS_VAR_IF([$1],[$2],[$3],[$4])])])]) 406
407#
408# _MHD_STRING_CONTAIN(VAR, MATCH, [IF-MATCH], [IF-NOT-MATCH])
409#
410
411AC_DEFUN([_MHD_VAR_CONTAIN],[dnl
412AC_REQUIRE([AC_PROG_FGREP])dnl
413AS_IF([[`echo "${]$1[}" | $FGREP ']$2[' >/dev/null 2>&1`]], [$3], [$4])
414])
415
416#
417# _MHD_STRING_CONTAIN_BRE(VAR, BRE, [IF-MATCH], [IF-NOT-MATCH])
418#
419
420AC_DEFUN([_MHD_VAR_CONTAIN_BRE],[dnl
421AC_REQUIRE([AC_PROG_GREP])dnl
422AS_IF([[`echo "${]$1[}" | $GREP ']$2[' >/dev/null 2>&1`]], [$3], [$4])
423])
480 424
481# SYNOPSIS 425# SYNOPSIS
482# 426#
483# _MHD_CHECK_XOPEN_ENABLE(_XOPEN_SOURCE-VALUE, FEATURES_TEST, 427# _MHD_CHECK_POSIX2008(DEFINES_VAR, FLAGS_VAR,
484# [ACTION-IF-ENABLED-BY-XOPEN_SOURCE], 428# [EXT_DEFINES],
485# [ACTION-IF-NOT], 429# [ACTION-IF-AVAILABLE],
486# [ACTION-IF-FEATURES-AVALABLE], 430# [ACTION-IF-NOT-AVAILABLE])
487# [ACTION-IF-FEATURES-NOT-AVALABLE],
488# [ACTION-IF-ONLY-WITH-EXTENSIONS]
489# [ACTION-IF-WITHOUT-ALL])
490# 431#
491# DESCRIPTION
492# 432#
493# This macro determines whether the _XOPEN_SOURCE with 433AC_DEFUN([_MHD_CHECK_POSIX2008], [dnl
494# _XOPEN_SOURCE-VALUE really enable some header features. FEATURES_TEST 434 AC_CACHE_CHECK([headers for POSIX.1-2008/SUSv4 features],
495# must contains required includes and main function. 435 [[mhd_cv_headers_posix2008]], [dnl
496# One of ACTION-IF-ENABLED-BY-XOPEN_SOURCE and ACTION-IF-NOT 436 _MHD_CHECK_POSIX_FEATURES_SINGLE([
497# is always executed depending on test results. 437_MHD_BASIC_INCLUDES
498# One of ACTION-IF-FEATURES-AVALABLE and is ACTION-IF-FEATURES-NOT-AVALABLE 438[
499# is executed if features can be enabled by _XOPEN_SOURCE, by currently 439/* Check will be passed if ALL features are avalable
500# defined (by compiler flags or by predefined macros) extensions or 440 * and failed if ANY feature is not avalable. */
501# all checked combinations are failed to enable features. 441int main()
502# ACTION-IF-ONLY-WITH-EXTENSIONS is executed if features can be 442{
503# enabled with not undefined extension. 443
504# ACTION-IF-WITHOUT-ALL is executed if features work with all 444#ifndef stpncpy
505# disabled extensions (including _XOPEN_SOURCE). 445 (void) stpncpy;
506 446#endif
507AC_DEFUN([_MHD_CHECK_XOPEN_ENABLE], [dnl 447#ifndef strnlen
508 AS_VAR_PUSHDEF([src_Var], [[mhd_cxoe_tmp_src_variable]])dnl 448 (void) strnlen;
449#endif
450
451#if !defined(__NetBSD__) && !defined(__OpenBSD__)
452/* NetBSD and OpenBSD didn't implement wcsnlen() for some reason. */
453#ifndef wcsnlen
454 (void) wcsnlen;
455#endif
456#endif
457
458#ifdef __CYGWIN__
459/* The only depend function on Cygwin, but missing on some other platforms */
460#ifndef strndup
461 (void) strndup;
462#endif
463#endif
464
465#ifndef __sun
466/* illumos forget to uncomment some _XPG7 macros. */
467#ifndef renameat
468 (void) renameat;
469#endif
470
471#ifndef getline
472 (void) getline;
473#endif
474#endif /* ! __sun */
475
476/* gmtime_r() becomes mandatory only in POSIX.1-2008. */
477#ifndef gmtime_r
478 (void) gmtime_r;
479#endif
480
481/* unsetenv() actually defined in POSIX.1-2001 so it
482 * must be present with _XOPEN_SOURCE == 700 too. */
483#ifndef unsetenv
484 (void) unsetenv;
485#endif
486
487 return 0;
488}
489 ]],
490 [$3], [[700]],
491 [[mhd_cv_headers_posix2008]]dnl
492 )
493 ]
494 )
495 _MHD_VAR_CONTAIN_BRE([[mhd_cv_headers_posix2008]], [[^available]],
496 [
497 _MHD_VAR_CONTAIN([[mhd_cv_headers_posix2008]], [[does not work with _XOPEN_SOURCE]], [[:]],
498 [_MHD_SYS_EXT_VAR_ADD_FLAG([$1],[$2],[[_XOPEN_SOURCE]],[[700]])]
499 )
500 $4
501 ],
502 [$5]
503 )
504])
505
506
507# SYNOPSIS
508#
509# _MHD_CHECK_POSIX2001(DEFINES_VAR, FLAGS_VAR,
510# [EXT_DEFINES],
511# [ACTION-IF-AVAILABLE],
512# [ACTION-IF-NOT-AVAILABLE])
513#
514#
515AC_DEFUN([_MHD_CHECK_POSIX2001], [dnl
516 AC_CACHE_CHECK([headers for POSIX.1-2001/SUSv3 features],
517 [[mhd_cv_headers_posix2001]], [
518 _MHD_CHECK_POSIX_FEATURES_SINGLE([
519_MHD_BASIC_INCLUDES
520[
521/* Check will be passed if ALL features are available
522 * and failed if ANY feature is not available. */
523int main()
524{
525
526#ifndef setenv
527 (void) setenv;
528#endif
529
530#ifndef __NetBSD__
531#ifndef vsscanf
532 (void) vsscanf;
533#endif
534#endif
535
536/* Availability of next features varies, but they all must be present
537 * on platform with support for _XOPEN_SOURCE = 600. */
538
539/* vsnprintf() should be available with _XOPEN_SOURCE >= 500, but some platforms
540 * provide it only with _POSIX_C_SOURCE >= 200112 (autodefined when
541 * _XOPEN_SOURCE >= 600) where specification of vsnprintf() is aligned with
542 * ISO C99 while others platforms defined it with even earlier standards. */
543#ifndef vsnprintf
544 (void) vsnprintf;
545#endif
546
547/* On platforms that prefer POSIX over X/Open, fseeko() is available
548 * with _POSIX_C_SOURCE >= 200112 (autodefined when _XOPEN_SOURCE >= 600).
549 * On other platforms it should be available with _XOPEN_SOURCE >= 500. */
550#ifndef fseeko
551 (void) fseeko;
552#endif
553
554/* F_GETOWN must be defined with _XOPEN_SOURCE >= 600, but some platforms
555 * define it with _XOPEN_SOURCE >= 500. */
556#ifndef F_GETOWN
557#error F_GETOWN is not defined
558choke me now;
559#endif
560 return 0;
561}
562 ]],
563 [$3],[[600]],[[mhd_cv_headers_posix2001]]dnl
564 )
565 ]
566 )
567 _MHD_VAR_CONTAIN_BRE([[mhd_cv_headers_posix2001]], [[^available]],
568 [
569 _MHD_VAR_CONTAIN([[mhd_cv_headers_posix2001]], [[does not work with _XOPEN_SOURCE]], [[:]],
570 [_MHD_SYS_EXT_VAR_ADD_FLAG([$1],[$2],[[_XOPEN_SOURCE]],[[600]])]
571 )
572 $4
573 ],
574 [$5]
575 )
576])
577
578
579# SYNOPSIS
580#
581# _MHD_CHECK_SUSV2(DEFINES_VAR, FLAGS_VAR,
582# [EXT_DEFINES],
583# [ACTION-IF-AVAILABLE],
584# [ACTION-IF-NOT-AVAILABLE])
585#
586#
587AC_DEFUN([_MHD_CHECK_SUSV2], [dnl
588 AC_CACHE_CHECK([headers for SUSv2/XPG5 features],
589 [[mhd_cv_headers_susv2]], [
590 _MHD_CHECK_POSIX_FEATURES_SINGLE([
591_MHD_BASIC_INCLUDES
592[
593/* Check will be passed if ALL features are available
594 * and failed if ANY feature is not available. */
595int main()
596{
597/* It's not easy to write reliable test for _XOPEN_SOURCE = 500 as
598 * platforms not always precisely follow this standard and some
599 * functions are already deprecated in later standards. */
600
601/* Availability of next features varies, but they all must be present
602 * on platform with correct support for _XOPEN_SOURCE = 500. */
603
604/* Mandatory with _XOPEN_SOURCE >= 500 but as XSI extension available
605 * with much older standards. */
606#ifndef ftruncate
607 (void) ftruncate;
608#endif
609
610/* Added with _XOPEN_SOURCE >= 500 but was available in some standards
611 * before. XSI extension. */
612#ifndef pread
613 (void) pread;
614#endif
615
616#ifndef __APPLE__
617/* Actually comes from XPG4v2 and must be available
618 * with _XOPEN_SOURCE >= 500 as well. */
619#ifndef symlink
620 (void) symlink;
621#endif
622
623/* Actually comes from XPG4v2 and must be available
624 * with _XOPEN_SOURCE >= 500 as well. XSI extension. */
625#ifndef strdup
626 (void) strdup;
627#endif
628#endif /* ! __APPLE__ */
629 return 0;
630}
631 ]],
632 [$3],[[500]],[[mhd_cv_headers_susv2]]dnl
633 )
634 ]
635 )
636 _MHD_VAR_CONTAIN_BRE([[mhd_cv_headers_susv2]], [[^available]],
637 [
638 _MHD_VAR_CONTAIN([[mhd_cv_headers_susv2]], [[does not work with _XOPEN_SOURCE]], [[:]],
639 [_MHD_SYS_EXT_VAR_ADD_FLAG([$1],[$2],[[_XOPEN_SOURCE]],[[500]])]
640 )
641 $4
642 ],
643 [$5]
644 )
645])
646
647
648# SYNOPSIS
649#
650# _MHD_CHECK_POSIX_FEATURES_SINGLE(FEATURES_TEST,
651# EXT_DEFINES,
652# _XOPEN_SOURCE-VALUE,
653# VAR-RESULT)
654
655AC_DEFUN([_MHD_CHECK_POSIX_FEATURES_SINGLE], [dnl
656 AS_VAR_PUSHDEF([avail_Var], [mhd_cpsxfs_tmp_features_available])dnl
657 AS_VAR_PUSHDEF([ext_Var], [mhd_cpsxfs_tmp_extentions_allowed])dnl
658 AS_VAR_PUSHDEF([xopen_Var], [mhd_cpsxfs_tmp_src_xopen_allowed])dnl
659 AS_VAR_PUSHDEF([dislb_Var], [mhd_cpsxfs_tmp_features_disableable])dnl
660 AS_UNSET([avail_Var])
661 AS_UNSET([ext_Var])
662 AS_UNSET([xopen_Var])
663 AS_UNSET([dislb_Var])
664 _MHD_CHECK_POSIX_FEATURES([$1], [$2], [$3], [avail_Var], [ext_Var], [xopen_Var], [dislb_Var])
665 AS_VAR_IF([avail_Var], ["yes"],
666 [
667 AS_VAR_IF([dislb_Var], ["yes"],
668 [
669 AS_VAR_IF([ext_Var], ["required"],
670 [
671 AS_VAR_IF([xopen_Var], ["allowed"],
672 [
673 AS_VAR_SET(m4_normalize([$4]), ["available, activated by extension macro, works with _XOPEN_SOURCE=]m4_normalize([$3])["])
674 ],
675 [
676 AS_VAR_SET(m4_normalize([$4]), ["available, activated by extension macro, does not work with _XOPEN_SOURCE=]m4_normalize([$3])["])
677 ]
678 )
679 ],
680 [
681 AS_VAR_IF([ext_Var], ["allowed"],
682 [
683 AS_VAR_IF([xopen_Var], ["required"],
684 [
685 AS_VAR_SET(m4_normalize([$4]), ["available, activated by _XOPEN_SOURCE=]m4_normalize([$3])[, works with extension macro"])
686 ],
687 [
688 AS_VAR_IF([xopen_Var], ["allowed"],
689 [
690 AS_VAR_SET(m4_normalize([$4]), ["available, works with _XOPEN_SOURCE=]m4_normalize([$3])[, works with extension macro"])
691 ],
692 [
693 AS_VAR_SET(m4_normalize([$4]), ["available, works with extension macro, does not work with _XOPEN_SOURCE=]m4_normalize([$3])["])
694 ]
695 )
696 ]
697 )
698 ],
699 [
700 AS_VAR_IF([xopen_Var], ["required"],
701 [
702 AS_VAR_SET(m4_normalize([$4]), ["available, activated by _XOPEN_SOURCE=]m4_normalize([$3])[, does not work with extension macro"])
703 ],
704 [
705 AS_VAR_IF([xopen_Var], ["allowed"],
706 [
707 AS_VAR_SET(m4_normalize([$4]), ["available, works with _XOPEN_SOURCE=]m4_normalize([$3])[, does not work with extension macro"])
708 ],
709 [
710 AS_VAR_SET(m4_normalize([$4]), ["available, does not work with _XOPEN_SOURCE=]m4_normalize([$3])[, does not work with extension macro"])
711 ]
712 )
713 ]
714 )
715 ]
716 )
717 ]
718 )
719 ],
720 [
721 AS_VAR_SET(m4_normalize([$4]), ["available, works always"])
722 ]
723 )
724 ],
725 [
726 AS_VAR_SET(m4_normalize([$4]), ["not available"])
727 ]
728 )
729 AS_UNSET([dislb_Var])
730 AS_UNSET([xopen_Var])
731 AS_UNSET([ext_Var])
732 AS_UNSET([avail_Var])
733 AS_VAR_POPDEF([dislb_Var])dnl
734 AS_VAR_POPDEF([xopen_Var])dnl
735 AS_VAR_POPDEF([ext_Var])dnl
736 AS_VAR_POPDEF([avail_Var])dnl
737])
738
739# SYNOPSIS
740#
741# _MHD_CHECK_POSIX_FEATURES(FEATURES_TEST, EXT_DEFINES, _XOPEN_SOURCE-VALUE,
742# [VAR-FEATURES-AVAILABLE-YES_NO],
743# [VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED],
744# [VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED],
745# [VAR-FEATURES-DISABLEABLE-YES_NO])
746
747AC_DEFUN([_MHD_CHECK_POSIX_FEATURES], [dnl
748 AS_VAR_PUSHDEF([src_Var], [mhd_cpsxf_tmp_src_variable])dnl
749 AS_VAR_PUSHDEF([defs_Var], [mhd_cpsxf_tmp_defs_variable])dnl
509 AS_VAR_SET([src_Var],[" 750 AS_VAR_SET([src_Var],["
751$1
752"])
753 dnl To reduce 'configure' size
754 AS_VAR_SET([defs_Var],["
510$2 755$2
511"])dnl Reduce 'configure' size 756"])
757 dnl To reduce 'configure' size
512 758
513 dnl Some platforms enable most features when no 759 dnl Some platforms enable most features when no
514 dnl specific mode is requested by macro. 760 dnl specific mode is requested by macro.
@@ -519,171 +765,191 @@ $2
519_MHD_UNDEF_ALL_EXT 765_MHD_UNDEF_ALL_EXT
520$src_Var 766$src_Var
521 ])], 767 ])],
522 [dnl
523 _AS_ECHO_LOG([[Checked features work with undefined all extensions and without _XOPEN_SOURCE]])
524 dnl Checked features is enabled in platform's "default" mode.
525 dnl Try to disable features by requesting oldest X/Open mode.
526 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
527_MHD_UNDEF_ALL_EXT
528[#define _XOPEN_SOURCE 1]
529$src_Var
530 ])],
531 [dnl 768 [dnl
532 _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _XOPEN_SOURCE=1]]) 769 _AS_ECHO_LOG([[Checked features work with undefined all extensions and without _XOPEN_SOURCE]])
533 dnl Features still work in oldest X/Open mode. 770 AS_VAR_SET(m4_normalize([$4]),["yes"]) # VAR-FEATURES-AVAILABLE-YES_NO
534 dnl Some platforms enable all XSI features for any _XOPEN_SOURCE value. 771
535 dnl Apply some fuzzy logic, try to use _POSIX_C_SOURCE with oldest number. 772 dnl Check whether features will work extensions
536 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 773 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
537_MHD_UNDEF_ALL_EXT 774$defs_Var
538[#define _POSIX_C_SOURCE 1]
539$src_Var 775$src_Var
540 ])], 776 ])],
541 [dnl
542 _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _POSIX_C_SOURCE=1]])
543 dnl Features still work in oldest _POSIX_C_SOURCE mode.
544 dnl Try to disable features by requesting strict ANSI C mode.
545 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
546_MHD_UNDEF_ALL_EXT
547[#define _ANSI_SOURCE 1]
548$src_Var
549 ])],
550 [dnl 777 [dnl
551 _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _ANSI_SOURCE]]) 778 _AS_ECHO_LOG([[Checked features work with extensions]])
552 dnl Features still work in strict _ANSI_SOURCE mode. 779 AS_VAR_SET(m4_normalize([$5]),["allowed"]) # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED
553 dnl Assume that _XOPEN_SOURCE, _POSIX_C_SOURCE and _ANSI_SOURCE has no influence on 780 dnl Check whether features will work with _XOPEN_SOURCE
554 dnl enabling of features as features are enabled always unconditionally.
555 m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE
556 ], [dnl
557 _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _ANSI_SOURCE]])
558 dnl Features do not work in strict _ANSI_SOURCE mode.
559 dnl Try to enable features by _XOPEN_SOURCE with specified value.
560 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 781 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
561_MHD_UNDEF_ALL_EXT 782$defs_Var
562[#define _ANSI_SOURCE 1] 783[#define _XOPEN_SOURCE ]]m4_normalize([$3])[
563[#define _XOPEN_SOURCE] $1
564$src_Var 784$src_Var
565 ])], 785 ])],
566 [dnl 786 [dnl
567 _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _ANSI_SOURCE and _XOPEN_SOURCE=]$1]) 787 _AS_ECHO_LOG([Checked features work with extensions and with _XOPEN_SOURCE=]m4_normalize([$3])[])
568 dnl Finally, features were disabled by strict ANSI mode and enabled by adding _XOPEN_SOURCE. 788 AS_VAR_SET(m4_normalize([$6]),["allowed"]) # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED
569 dnl Assume that _XOPEN_SOURCE can enable features. 789 dnl Check whether features could be disabled
570 m4_n([$3])dnl ACTION-IF-ENABLED-BY-XOPEN_SOURCE 790 dnl Request oldest POSIX mode and strict ANSI mode
571 ], [dnl 791 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
572 _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _ANSI_SOURCE and _XOPEN_SOURCE=]$1])
573 dnl Features are not enabled in strict ANSI mode with _XOPEN_SOURCE.
574 dnl Actually this is not correct documented situation and _ANSI_SOURCE may have
575 dnl priority over _XOPEN_SOURCE or headers are not controlled by _XOPEN_SOURCE at all.
576 dnl As features work in all mode except strict ANSI regardless of _XOPEN_SOURCE,
577 dnl assume that _XOPEN_SOURCE do not control visibility of features.
578 m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE
579 ])
580 ])
581 ], [dnl
582 _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _POSIX_C_SOURCE=1]])
583 dnl Features do not work in oldest _POSIX_C_SOURCE mode.
584 dnl OK, features were disabled by _POSIX_C_SOURCE.
585 dnl Check whether headers controlled by _XOPEN_SOURCE too.
586 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
587_MHD_UNDEF_ALL_EXT 792_MHD_UNDEF_ALL_EXT
588[#define _POSIX_C_SOURCE 1] 793[#define _POSIX_C_SOURCE 1]
589[#define _XOPEN_SOURCE] $1 794[#define _ANSI_SOURCE 1]
590$src_Var 795$src_Var
591 ])], 796 ])],
797 [dnl
798 _AS_ECHO_LOG([[Checked features work with disabled extensions, with _POSIX_C_SOURCE=1 and _ANSI_SOURCE=1]])
799 AS_VAR_SET(m4_normalize([$7]),["no"]) # VAR-FEATURES-DISABLEABLE-YES_NO
800 ],
801 [dnl
802 _AS_ECHO_LOG([[Checked features DO NOT work with disabled extensions, with _POSIX_C_SOURCE=1 and _ANSI_SOURCE=1]])
803 AS_VAR_SET(m4_normalize([$7]),["yes"]) # VAR-FEATURES-DISABLEABLE-YES_NO
804 ]
805 )
806 ],
807 [dnl
808 _AS_ECHO_LOG([Checked features DO NOT work with extensions and with _XOPEN_SOURCE=]m4_normalize([$3])[])
809 AS_VAR_SET(m4_normalize([$6]),["not allowed"]) # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED
810 AS_VAR_SET(m4_normalize([$7]),["yes"]) # VAR-FEATURES-DISABLEABLE-YES_NO
811 ]
812 )
813 ],
592 [dnl 814 [dnl
593 _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _POSIX_C_SOURCE=1 and _XOPEN_SOURCE=]$1]) 815 _AS_ECHO_LOG([[Checked features DO NOT work with extensions]])
594 dnl Features were enabled again after adding _XOPEN_SOURCE with value. 816 AS_VAR_SET(m4_normalize([$7]),["yes"]) # VAR-FEATURES-DISABLEABLE-YES_NO
595 dnl Assume that headers can be controlled by _XOPEN_SOURCE with specified value. 817 dnl Check whether features work with _XOPEN_SOURCE
596 m4_n([$3])dnl ACTION-IF-ENABLED-BY-XOPEN_SOURCE 818 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
597 ], [dnl 819[#define _XOPEN_SOURCE ]m4_normalize($3)
598 _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _POSIX_C_SOURCE=1 and _XOPEN_SOURCE=]$1])
599 dnl Features still work after adding _XOPEN_SOURCE with value.
600 dnl It's unclear whether headers know only about _POSIX_C_SOURCE or
601 dnl _POSIX_C_SOURCE have priority over _XOPEN_SOURCE (standards are
602 dnl silent about priorities).
603 dnl Assume that it's unknown whether _XOPEN_SOURCE can turn on features.
604 m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE
605 ])
606 ])
607 ], [dnl
608 _AS_ECHO_LOG([[Checked features does not work with undefined all extensions and with _XOPEN_SOURCE=1]])
609 dnl Features disabled by oldest X/Open mode.
610 dnl Check whether requested _XOPEN_SOURCE value will turn on features.
611 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
612_MHD_UNDEF_ALL_EXT
613[#define _XOPEN_SOURCE] $1
614$src_Var 820$src_Var
615 ])], 821 ])],
616 [dnl 822 [dnl
617 _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _XOPEN_SOURCE=]$1]) 823 _AS_ECHO_LOG([Checked features work with _XOPEN_SOURCE=]m4_normalize([$3])[])
618 dnl Features work with _XOPEN_SOURCE requested value and do not work 824 dnl Check default state (without enabling/disabling)
619 dnl with value 1. 825 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
620 dnl Assume that _XOPEN_SOURCE really turn on features.
621 m4_n([$3])dnl ACTION-IF-ENABLED-BY-XOPEN_SOURCE
622 ], [dnl
623 _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _XOPEN_SOURCE=]$1])
624 dnl Features do not work with _XOPEN_SOURCE, but work in "default" mode.
625 dnl Assume that features cannot be enabled by requested _XOPEN_SOURCE value.
626 m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE
627 ])
628 ])
629 m4_n([$5])dnl ACTION-IF-FEATURES-AVALABLE
630 m4_n([$8])dnl ACTION-IF-WITHOUT-ALL
631 ],
632 [dnl
633 _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and without _XOPEN_SOURCE]])
634 dnl Features do not work with turned off extensions.
635 dnl Check whether they can be enabled by _XOPEN_SOURCE.
636 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
637_MHD_UNDEF_ALL_EXT
638[#define _XOPEN_SOURCE] $1
639$src_Var 826$src_Var
640 ])], 827 ])],
641 [dnl 828 [dnl
642 _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _XOPEN_SOURCE=]$1]) 829 _AS_ECHO_LOG([[Checked features work by default]])
643 dnl Features work with _XOPEN_SOURCE and do not work without _XOPEN_SOURCE. 830 AS_VAR_SET(m4_normalize([$6]),["allowed"]) # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED
644 dnl Assume that _XOPEN_SOURCE really turn on features. 831 ],
645 m4_n([$3])dnl ACTION-IF-ENABLED-BY-XOPEN_SOURCE 832 [dnl
646 m4_n([$5])dnl ACTION-IF-FEATURES-AVALABLE 833 _AS_ECHO_LOG([[Checked features DO NOT by default]])
834 AS_VAR_SET(m4_normalize([$6]),["required"]) # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED
835 ]
836 )
837 dnl Check whether features work with _XOPEN_SOURCE and extensions
838 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
839$defs_Var
840[#define _XOPEN_SOURCE] ]m4_normalize([$3])[
841$src_Var
842 ])],
843 [dnl
844 _AS_ECHO_LOG([[Checked features work with _XOPEN_SOURCE and extensions]])
845 AS_VAR_SET(m4_normalize([$5]),["allowed"]) # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED
846 ],
847 [dnl
848 _AS_ECHO_LOG([[Checked features DO NOT work with _XOPEN_SOURCE and extensions]])
849 AS_VAR_SET(m4_normalize([$5]),["not allowed"]) # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED
850 ]
851 )
852 ],
853 [dnl
854 _AS_ECHO_LOG([Checked features DO NOT work with _XOPEN_SOURCE=]m4_normalize([$3])[])
855 AS_VAR_SET(m4_normalize([$5]),["not allowed"]) # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED
856 AS_VAR_SET(m4_normalize([$6]),["not allowed"]) # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED
857 ]
858 )
859 ]
860 )
647 ], 861 ],
648 [dnl 862 [dnl
649 _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _XOPEN_SOURCE=]$1]) 863 _AS_ECHO_LOG([[Checked features DO NOT work with undefined all extensions and without _XOPEN_SOURCE]])
650 dnl Features do not work with _XOPEN_SOURCE and turned off extensions. 864 dnl Let's find the way to enable POSIX features
651 dnl Retry without turning off known extensions.
652 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 865 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
653[#define _XOPEN_SOURCE] $1 866$defs_Var
654$src_Var 867$src_Var
655 ])], 868 ])],
656 [dnl 869 [dnl
657 _AS_ECHO_LOG([[Checked features work with current extensions and with _XOPEN_SOURCE=]$1]) 870 _AS_ECHO_LOG([[Checked features work with extensions]])
658 dnl Features work with _XOPEN_SOURCE and without turning off extensions. 871 AS_VAR_SET(m4_normalize([$4]),["yes"]) # VAR-FEATURES-AVAILABLE-YES_NO
659 dnl Check whether features work with oldest _XOPEN_SOURCE or it was enabled only by extensions. 872 AS_VAR_SET(m4_normalize([$7]),["yes"]) # VAR-FEATURES-DISABLEABLE-YES_NO
660 AC_COMPILE_IFELSE([AC_LANG_SOURCE([ 873 dnl Check default state (without enabling/disabling)
661[#define _XOPEN_SOURCE 1] 874 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
875$src_Var
876 ])],
877 [dnl
878 _AS_ECHO_LOG([[Checked features work by default]])
879 AS_VAR_SET(m4_normalize([$5]),["allowed"]) # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED
880 ],
881 [dnl
882 _AS_ECHO_LOG([[Checked features DO NOT by default]])
883 AS_VAR_SET(m4_normalize([$5]),["required"]) # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED
884 ]
885 )
886 dnl Check whether features work with extensions and _XOPEN_SOURCE
887 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
888$defs_Var
889[#define _XOPEN_SOURCE] ]m4_normalize([$3])[
662$src_Var 890$src_Var
663 ])], 891 ])],
892 [dnl
893 _AS_ECHO_LOG([Checked features work with extensions and _XOPEN_SOURCE=]m4_normalize([$3])[])
894 AS_VAR_SET(m4_normalize([$6]),["allowed"]) # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED
895 ],
896 [dnl
897 _AS_ECHO_LOG([Checked features DO NOT work with extensions and _XOPEN_SOURCE=]m4_normalize([$3])[])
898 AS_VAR_SET(m4_normalize([$6]),["not allowed"]) # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED
899 ]
900 )
901 ],
664 [dnl 902 [dnl
665 _AS_ECHO_LOG([[Checked features work with current extensions and with _XOPEN_SOURCE=1]]) 903 _AS_ECHO_LOG([[Checked features DO NOT work with extensions]])
666 dnl Features still work with oldest _XOPEN_SOURCE. 904 dnl Check whether features work with _XOPEN_SOURCE
667 dnl Assume that _XOPEN_SOURCE has no influence on enabling of features. 905 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
668 m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE 906[#define _XOPEN_SOURCE] ]m4_normalize([$3])[
669 ], [dnl 907$src_Var
670 _AS_ECHO_LOG([[Checked features do not work with current extensions and with _XOPEN_SOURCE=1]]) 908 ])],
671 dnl Features do not work with oldest _XOPEN_SOURCE. 909 [dnl
672 dnl Assume that _XOPEN_SOURCE really turn on features. 910 _AS_ECHO_LOG([Checked features work with _XOPEN_SOURCE=]m4_normalize([$3])[])
673 m4_n([$3])dnl ACTION-IF-ENABLED-BY-XOPEN_SOURCE 911 AS_VAR_SET(m4_normalize([$4]),["yes"]) # VAR-FEATURES-AVAILABLE-YES_NO
674 ]) 912 dnl Check default state (without enabling/disabling)
675 m4_n([$5])dnl ACTION-IF-FEATURES-AVALABLE 913 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
676 m4_n([$7])dnl ACTION-IF-ONLY-WITH-EXTENSIONS 914$src_Var
677 ], [dnl 915 ])],
678 _AS_ECHO_LOG([[Checked features do not work with current extensions and with _XOPEN_SOURCE=]$1]) 916 [dnl
679 dnl Features do not work in all checked conditions. 917 _AS_ECHO_LOG([[Checked features work by default]])
680 dnl Assume that _XOPEN_SOURCE cannot enable feature. 918 AS_VAR_SET(m4_normalize([$6]),["allowed"]) # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED
681 m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE 919 ],
682 m4_n([$6])dnl ACTION-IF-FEATURE-NOT-AVALABLE 920 [dnl
683 ]) 921 _AS_ECHO_LOG([[Checked features DO NOT by default]])
684 ]) 922 AS_VAR_SET(m4_normalize([$6]),["required"]) # VAR-XOPEN-REQUIRED_NOT-ALLOWED_ALLOWED
685 ]) 923 ]
924 )
925 dnl Check whether features work with _XOPEN_SOURCE and extensions
926 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
927$defs_Var
928[#define _XOPEN_SOURCE] ]m4_normalize([$3])[
929$src_Var
930 ])],
931 [dnl
932 _AS_ECHO_LOG([Checked features work with _XOPEN_SOURCE=]m4_normalize([$3])[ and extensions])
933 AS_VAR_SET(m4_normalize([$5]),["allowed"]) # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED
934 ],
935 [dnl
936 _AS_ECHO_LOG([Checked features DO NOT work with _XOPEN_SOURCE=]m4_normalize([$3])[ and extensions])
937 AS_VAR_SET(m4_normalize([$5]),["not allowed"]) # VAR-EXTENSIONS-REQUIRED_NOT-ALLOWED_ALLOWED
938 ]
939 )
940 ],
941 [dnl
942 _AS_ECHO_LOG([Checked features DO NOT work with _XOPEN_SOURCE=]m4_normalize([$3])[])
943 AS_VAR_SET(m4_normalize([$4]),["no"]) # VAR-FEATURES-AVAILABLE-YES_NO
944 ]
945 )
946 ]
947 )
948 ]
949 )
950 AS_UNSET([defs_Var])
686 AS_UNSET([src_Var]) 951 AS_UNSET([src_Var])
952 AS_VAR_POPDEF([defs_Var])dnl
687 AS_VAR_POPDEF([src_Var])dnl 953 AS_VAR_POPDEF([src_Var])dnl
688]) 954])
689 955
@@ -828,7 +1094,7 @@ AC_DEFUN([MHD_CHECK_BASIC_HEADERS], [dnl
828 AC_COMPILE_IFELSE([dnl 1094 AC_COMPILE_IFELSE([dnl
829 AC_LANG_PROGRAM([m4_n([$1])dnl 1095 AC_LANG_PROGRAM([m4_n([$1])dnl
830_MHD_BASIC_INCLUDES 1096_MHD_BASIC_INCLUDES
831 ], [[int i = 1; i++]]) 1097 ], [[int i = 1; i++; if(i) return i]])
832 ], [$2], [$3]) 1098 ], [$2], [$3])
833]) 1099])
834 1100
@@ -914,7 +1180,7 @@ m4_n([$2])dnl
914choke me now; 1180choke me now;
915#endif 1181#endif
916 ]],[]) 1182 ]],[])
917 ], [$3], [$4] 1183 ], [m4_default_nblank([$3])], [m4_default_nblank([$4])]
918 ) 1184 )
919]) 1185])
920 1186
@@ -927,13 +1193,11 @@ choke me now;
927# Cache-check for defined symbols with printing results. 1193# Cache-check for defined symbols with printing results.
928 1194
929AC_DEFUN([MHD_CHECK_DEFINED], [dnl 1195AC_DEFUN([MHD_CHECK_DEFINED], [dnl
930 AS_VAR_PUSHDEF([mhd_cache_Var], 1196 AS_VAR_PUSHDEF([mhd_cache_Var],[mhd_cv_macro_[]m4_tolower(m4_normalize($1))_defined])dnl
931 [mhd_cv_macro_[]m4_tolower($1)_defined])dnl
932 AC_CACHE_CHECK([dnl 1197 AC_CACHE_CHECK([dnl
933m4_ifnblank([$5], [$5], [whether $1 is already defined])], 1198m4_ifnblank([$5], [$5], [whether ]m4_normalize([$1])[ is already defined])],
934 [mhd_cache_Var], 1199 [mhd_cache_Var], [dnl
935 [ 1200 _MHD_CHECK_DEFINED(m4_normalize([$1]), [$2],
936 _MHD_CHECK_DEFINED([$1], [$2],
937 [mhd_cache_Var="yes"], 1201 [mhd_cache_Var="yes"],
938 [mhd_cache_Var="no"] 1202 [mhd_cache_Var="no"]
939 ) 1203 )
@@ -963,12 +1227,12 @@ MHD_CHECK_DEFINED([$1],[$2],[$4],[$5],[$3])])
963AC_DEFUN([MHD_CHECK_ACCEPT_DEFINE], [dnl 1227AC_DEFUN([MHD_CHECK_ACCEPT_DEFINE], [dnl
964 AC_PREREQ([2.64])dnl for AS_VAR_PUSHDEF, AS_VAR_SET, m4_ifnblank 1228 AC_PREREQ([2.64])dnl for AS_VAR_PUSHDEF, AS_VAR_SET, m4_ifnblank
965 AS_VAR_PUSHDEF([mhd_cache_Var], 1229 AS_VAR_PUSHDEF([mhd_cache_Var],
966 [mhd_cv_define_[]m4_tolower($1)_accepted[]m4_ifnblank([$2],[_[]$2])])dnl 1230 [mhd_cv_define_[]m4_tolower(m4_normalize($1))[]_accepted[]m4_ifnblank([$2],[_[]$2])])dnl
967 AC_CACHE_CHECK([dnl 1231 AC_CACHE_CHECK([dnl
968m4_ifnblank([$6],[$6],[whether headers accept $1[]m4_ifnblank([$2],[ with value $2])])], 1232m4_ifnblank([$6],[$6],[whether headers accept $1[]m4_ifnblank([$2],[[ with value ]$2])])],
969 [mhd_cache_Var], [dnl 1233 [mhd_cache_Var], [dnl
970 MHD_CHECK_BASIC_HEADERS([ 1234 MHD_CHECK_BASIC_HEADERS([
971m4_n([$3])[#define ]$1 m4_default_nblank([$2],[[1]])], 1235m4_n([$3])[#define ]$1 m4_default_nblank($2,[[1]])],
972 [mhd_cache_Var="yes"], [mhd_cache_Var="no"] 1236 [mhd_cache_Var="yes"], [mhd_cache_Var="no"]
973 ) 1237 )
974 ]) 1238 ])
@@ -992,44 +1256,69 @@ AC_DEFUN([MHD_CHECK_DEF_AND_ACCEPT], [dnl
992 ])dnl 1256 ])dnl
993]) 1257])
994 1258
995
996# 1259#
997# _MHD_XOPEN_ADD([PROLOG]) 1260# _MHD_XOPEN_VAR_ADD(DEFINES_VAR, FLAGS_VAR, [PROLOG])
998# 1261#
999# Internal macro. Only to be used in MHD_SYS_EXT. 1262# Internal macro. Only to be used in MHD_SYS_EXT.
1000 1263
1001AC_DEFUN([_MHD_XOPEN_ADD], [dnl 1264AC_DEFUN([_MHD_XOPEN_VAR_ADD], [dnl
1002 MHD_CHECK_DEF_AND_ACCEPT([[_XOPEN_SOURCE_EXTENDED]], [], 1265 MHD_CHECK_DEF_AND_ACCEPT([[_XOPEN_SOURCE]], [[1]], [$3],
1003 [[${mhd_mse_added_prolog}]m4_n([$1])], [], 1266 [
1004 [dnl 1267 AC_CACHE_CHECK([[whether predefined value of _XOPEN_SOURCE is more or equal 500]],
1005 _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_SOURCE_EXTENDED]])dnl 1268 [[mhd_cv_macro__xopen_source_def_fiveh]], [dnl
1006 ], [dnl 1269 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1007 MHD_CHECK_DEFINED([[_XOPEN_VERSION]], 1270m4_n([$3])dnl
1008 [[${mhd_mse_added_prolog}]m4_n([$1])], [], 1271[#if _XOPEN_SOURCE+0 < 500
1009 [dnl 1272#error Value of _XOPEN_SOURCE is less than 500
1010 AC_CACHE_CHECK([[for value of _XOPEN_VERSION accepted by headers]], 1273choke me now;
1011 [mhd_cv_define__xopen_version_accepted], [dnl 1274#endif
1012 MHD_CHECK_BASIC_HEADERS([ 1275 ]],[[int i = 0; i++; if(i) return i]])],
1013[${mhd_mse_added_prolog}]m4_n([$1]) 1276 [[mhd_cv_macro__xopen_source_def_fiveh="yes"]],
1014[#define _XOPEN_VERSION 4]], 1277 [[mhd_cv_macro__xopen_source_def_fiveh="no"]]
1015 [[mhd_cv_define__xopen_version_accepted="4"]], 1278 )dnl
1279 ]
1280 )dnl
1281 ],
1282 [_MHD_SYS_EXT_VAR_ADD_FLAG([$1], [$2], [[_XOPEN_SOURCE]], [[1]])]
1283 )
1284 AS_IF([[test "x${mhd_cv_define__xopen_source_accepted_1}" = "xyes" || \
1285 test "x${mhd_cv_macro__xopen_source_def_fiveh}" = "xno"]],
1286 [
1287 MHD_CHECK_DEF_AND_ACCEPT([[_XOPEN_SOURCE_EXTENDED]], [],
1016 [ 1288 [
1017 MHD_CHECK_BASIC_HEADERS([ 1289m4_n([$3])], [],
1018[${mhd_mse_added_prolog}]m4_n([$1]) 1290 [dnl
1291 _MHD_SYS_EXT_VAR_ADD_FLAG([$1],[$2],[[_XOPEN_SOURCE_EXTENDED]])
1292 ], [dnl
1293 MHD_CHECK_DEFINED([[_XOPEN_VERSION]],
1294 [
1295m4_n([$3])], [],
1296 [dnl
1297 AC_CACHE_CHECK([[for value of _XOPEN_VERSION accepted by headers]],
1298 [mhd_cv_define__xopen_version_accepted], [dnl
1299 MHD_CHECK_BASIC_HEADERS([
1300m4_n([$3])
1301[#define _XOPEN_VERSION 4]],
1302 [[mhd_cv_define__xopen_version_accepted="4"]],
1303 [
1304 MHD_CHECK_BASIC_HEADERS([
1305m4_n([$3])
1019[#define _XOPEN_VERSION 3]], 1306[#define _XOPEN_VERSION 3]],
1020 [[mhd_cv_define__xopen_version_accepted="3"]], 1307 [[mhd_cv_define__xopen_version_accepted="3"]],
1021 [[mhd_cv_define__xopen_version_accepted="no"]] 1308 [[mhd_cv_define__xopen_version_accepted="no"]]
1022 ) 1309 )
1310 ])
1311 ])
1312 AS_VAR_IF([mhd_cv_define__xopen_version_accepted], [["no"]],
1313 [[:]],
1314 [dnl
1315 _MHD_SYS_EXT_VAR_ADD_FLAG([$1],[$2],[[_XOPEN_VERSION]],
1316 [[${mhd_cv_define__xopen_version_accepted}]]dnl
1317 )
1318 ])
1023 ]) 1319 ])
1024 ]) 1320 ])
1025 AS_VAR_IF([mhd_cv_define__xopen_version_accepted], [["no"]], 1321 ]
1026 [[:]], 1322 )dnl
1027 [dnl
1028 _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_VERSION]],
1029 [[${mhd_cv_define__xopen_version_accepted}]]dnl
1030 )
1031 ])
1032 ])
1033 ])
1034]) 1323])
1035 1324