diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-09-13 19:23:30 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-09-13 19:23:30 +0000 |
commit | 0396eb2fc2815434ff0761b0b5d696029fbe36ef (patch) | |
tree | ec95e631576999e489d260041f894cbfb510fd82 /m4 | |
parent | 1af63125b388d372e44eff1f8f61d843018a819d (diff) | |
download | libmicrohttpd-0396eb2fc2815434ff0761b0b5d696029fbe36ef.tar.gz libmicrohttpd-0396eb2fc2815434ff0761b0b5d696029fbe36ef.zip |
Added autoconf macro for maximum platform features.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/mhd_sys_extentions.m4 | 1034 |
1 files changed, 1034 insertions, 0 deletions
diff --git a/m4/mhd_sys_extentions.m4 b/m4/mhd_sys_extentions.m4 new file mode 100644 index 00000000..fa5d0fda --- /dev/null +++ b/m4/mhd_sys_extentions.m4 | |||
@@ -0,0 +1,1034 @@ | |||
1 | # SYNOPSIS | ||
2 | # | ||
3 | # MHD_SYS_EXT([VAR-ADD-CPPFLAGS]) | ||
4 | # | ||
5 | # DESCRIPTION | ||
6 | # | ||
7 | # This macro checks system headers and add defines that enable maximum | ||
8 | # number of exposed system interfaces. Macro verifies that added defines | ||
9 | # will not break basic headers, some defines are also checked against | ||
10 | # real recognition by headers. | ||
11 | # If VAR-ADD-CPPFLAGS is specified, defines will be added to this variable | ||
12 | # in form suitable for CPPFLAGS. Otherwise defines will be added to | ||
13 | # configuration header (usually 'config.h'). | ||
14 | # | ||
15 | # Example usage: | ||
16 | # | ||
17 | # MHD_SYS_EXT | ||
18 | # | ||
19 | # or | ||
20 | # | ||
21 | # MHD_SYS_EXT([CPPFLAGS]) | ||
22 | # | ||
23 | # Macro is not enforced to be called before AC_COMPILE_IFELSE, but it | ||
24 | # advisable to call macro before any compile and header tests since | ||
25 | # additional defines can change results of those tests. | ||
26 | # | ||
27 | # Defined in command line macros are always honored and cache variables | ||
28 | # used in all checks so if any test will not work correctly on some | ||
29 | # platform, user may simply fix it by giving correct defines in CPPFLAGS | ||
30 | # or by giving cache variable in configure parameters, for example: | ||
31 | # | ||
32 | # ./configure CPPFLAGS='-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED' | ||
33 | # | ||
34 | # or | ||
35 | # | ||
36 | # ./configure mhd_cv_define__xopen_source_sevenh_works=no | ||
37 | # | ||
38 | # This simplify building from source on exotic platforms as patching | ||
39 | # of configure.ac is not required to change results of tests. | ||
40 | # | ||
41 | # LICENSE | ||
42 | # | ||
43 | # Copyright (c) 2016 Karlson2k (Evgeny Grin) <k2k@narod.ru> | ||
44 | # | ||
45 | # Copying and distribution of this file, with or without modification, are | ||
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 | ||
48 | # warranty. | ||
49 | |||
50 | #serial 1 | ||
51 | |||
52 | AC_DEFUN([MHD_SYS_EXT],[dnl | ||
53 | AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifnblank | ||
54 | AC_LANG_PUSH([C])dnl Use C language for simplicity | ||
55 | mhd_mse_added_exts_flags="" | ||
56 | mhd_mse_added_prolog="" | ||
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 | ||
63 | choke 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. */ | ||
89 | int main() | ||
90 | { | ||
91 | |||
92 | #ifndef stpncpy | ||
93 | (void) stpncpy; | ||
94 | #endif | ||
95 | #ifndef strnlen | ||
96 | (void) strnlen; | ||
97 | #endif | ||
98 | |||
99 | #ifndef __NetBSD__ | ||
100 | #ifndef wcsnlen | ||
101 | (void) wcsnlen; | ||
102 | #endif | ||
103 | #endif | ||
104 | |||
105 | #ifdef __CYGWIN__ | ||
106 | /* The only depend function on Cygwin, but missing on some other platforms */ | ||
107 | #ifndef strndup | ||
108 | (void) strndup; | ||
109 | #endif | ||
110 | #endif | ||
111 | |||
112 | #ifndef __sun | ||
113 | /* illumos forget to uncomment some _XPG7 macros. */ | ||
114 | #ifndef renameat | ||
115 | (void) renameat; | ||
116 | #endif | ||
117 | |||
118 | #ifndef getline | ||
119 | (void) getline; | ||
120 | #endif | ||
121 | #endif /* ! __sun */ | ||
122 | |||
123 | /* gmtime_r() becomes mandatory only in POSIX.1-2008. */ | ||
124 | #ifndef gmtime_r | ||
125 | (void) gmtime_r; | ||
126 | #endif | ||
127 | |||
128 | /* unsetenv() actually defined in POSIX.1-2001 so it | ||
129 | * must be present with _XOPEN_SOURCE == 700 too. */ | ||
130 | #ifndef unsetenv | ||
131 | (void) unsetenv; | ||
132 | #endif | ||
133 | |||
134 | return 0; | ||
135 | } | ||
136 | ]], | ||
137 | [[mhd_cv_define__xopen_source_sevenh_works="yes"]], | ||
138 | [[mhd_cv_define__xopen_source_sevenh_works="no"]] | ||
139 | )dnl | ||
140 | ])dnl | ||
141 | ]) | ||
142 | AS_IF([[test "x$mhd_cv_define__xopen_source_accepted_700" = "xyes" && | ||
143 | test "x$mhd_cv_define__xopen_source_sevenh_works" = "xyes"]], [dnl | ||
144 | _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_SOURCE]], [[700]]) | ||
145 | ], [dnl | ||
146 | MHD_CHECK_ACCEPT_DEFINE([[_XOPEN_SOURCE]], [[600]], [], [dnl | ||
147 | AC_CACHE_CHECK([[whether _XOPEN_SOURCE with value 600 really enable POSIX.1-2001/SUSv3 features]], | ||
148 | [[mhd_cv_define__xopen_source_sixh_works]], [dnl | ||
149 | _MHD_CHECK_XOPEN_ENABLE([[600]], [ | ||
150 | _MHD_BASIC_INCLUDES | ||
151 | [ | ||
152 | /* Check will be passed if ALL features are available | ||
153 | * and failed if ANY feature is not available. */ | ||
154 | int main() | ||
155 | { | ||
156 | |||
157 | #ifndef setenv | ||
158 | (void) setenv; | ||
159 | #endif | ||
160 | |||
161 | #ifndef __NetBSD__ | ||
162 | #ifndef vsscanf | ||
163 | (void) vsscanf; | ||
164 | #endif | ||
165 | #endif | ||
166 | |||
167 | /* Availability of next features varies, but they all must be present | ||
168 | * on platform with support for _XOPEN_SOURCE = 600. */ | ||
169 | |||
170 | /* vsnprintf() should be available with _XOPEN_SOURCE >= 500, but some platforms | ||
171 | * provide it only with _POSIX_C_SOURCE >= 200112 (autodefined when | ||
172 | * _XOPEN_SOURCE >= 600) where specification of vsnprintf() is aligned with | ||
173 | * ISO C99 while others platforms defined it with even earlier standards. */ | ||
174 | #ifndef vsnprintf | ||
175 | (void) vsnprintf; | ||
176 | #endif | ||
177 | |||
178 | /* On platforms that prefer POSIX over X/Open, fseeko() is available | ||
179 | * with _POSIX_C_SOURCE >= 200112 (autodefined when _XOPEN_SOURCE >= 600). | ||
180 | * On other platforms it should be available with _XOPEN_SOURCE >= 500. */ | ||
181 | #ifndef fseeko | ||
182 | (void) fseeko; | ||
183 | #endif | ||
184 | |||
185 | /* F_GETOWN must be defined with _XOPEN_SOURCE >= 600, but some platforms | ||
186 | * define it with _XOPEN_SOURCE >= 500. */ | ||
187 | #ifndef F_GETOWN | ||
188 | #error F_GETOWN is not defined | ||
189 | choke me now; | ||
190 | #endif | ||
191 | return 0; | ||
192 | } | ||
193 | ]], | ||
194 | [[mhd_cv_define__xopen_source_sixh_works="yes"]], | ||
195 | [[mhd_cv_define__xopen_source_sixh_works="no"]] | ||
196 | )dnl | ||
197 | ])dnl | ||
198 | ]) | ||
199 | AS_IF([[test "x$mhd_cv_define__xopen_source_accepted_600" = "xyes" && | ||
200 | test "x$mhd_cv_define__xopen_source_sixh_works" = "xyes"]], [dnl | ||
201 | _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_SOURCE]], [[600]]) | ||
202 | ], [dnl | ||
203 | MHD_CHECK_ACCEPT_DEFINE([[_XOPEN_SOURCE]], [[500]], [], [dnl | ||
204 | AC_CACHE_CHECK([[whether _XOPEN_SOURCE with value 500 really enable SUSv2/XPG5 features]], | ||
205 | [mhd_cv_define__xopen_source_fiveh_works], [dnl | ||
206 | _MHD_CHECK_XOPEN_ENABLE([[500]], [ | ||
207 | _MHD_BASIC_INCLUDES | ||
208 | [ | ||
209 | /* Check will be passed if ALL features are available | ||
210 | * and failed if ANY feature is not available. */ | ||
211 | int main() | ||
212 | { | ||
213 | /* It's not easy to write reliable test for _XOPEN_SOURCE = 500 as | ||
214 | * platforms not always precisely follow this standard and some | ||
215 | * functions are already deprecated in later standards. */ | ||
216 | |||
217 | /* Availability of next features varies, but they all must be present | ||
218 | * on platform with correct support for _XOPEN_SOURCE = 500. */ | ||
219 | |||
220 | /* Mandatory with _XOPEN_SOURCE >= 500 but as XSI extension available | ||
221 | * with much older standards. */ | ||
222 | #ifndef ftruncate | ||
223 | (void) ftruncate; | ||
224 | #endif | ||
225 | |||
226 | /* Added with _XOPEN_SOURCE >= 500 but was available in some standards | ||
227 | * before. XSI extension. */ | ||
228 | #ifndef pread | ||
229 | (void) pread; | ||
230 | #endif | ||
231 | |||
232 | #ifndef __APPLE__ | ||
233 | /* Actually comes from XPG4v2 and must be available | ||
234 | * with _XOPEN_SOURCE >= 500 as well. */ | ||
235 | #ifndef symlink | ||
236 | (void) symlink; | ||
237 | #endif | ||
238 | |||
239 | /* Actually comes from XPG4v2 and must be available | ||
240 | * with _XOPEN_SOURCE >= 500 as well. XSI extension. */ | ||
241 | #ifndef strdup | ||
242 | (void) strdup; | ||
243 | #endif | ||
244 | #endif /* ! __APPLE__ */ | ||
245 | return 0; | ||
246 | } | ||
247 | ]], | ||
248 | [[mhd_cv_define__xopen_source_fiveh_works="yes"]], | ||
249 | [[mhd_cv_define__xopen_source_fiveh_works="no"]] | ||
250 | )dnl | ||
251 | ])dnl | ||
252 | ]) | ||
253 | AS_IF([[test "x$mhd_cv_define__xopen_source_accepted_500" = "xyes" && ]dnl | ||
254 | [test "x$mhd_cv_define__xopen_source_fiveh_works" = "xyes"]], [dnl | ||
255 | _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_SOURCE]], [[500]]) | ||
256 | ], | ||
257 | [ | ||
258 | [#] Earlier standards are widely supported, so just define macros to maximum value | ||
259 | [#] which do not break headers. | ||
260 | _MHD_XOPEN_ADD([[#define _XOPEN_SOURCE 1]]) | ||
261 | AC_CACHE_CHECK([[whether headers accept _XOPEN_SOURCE with value 1]], | ||
262 | [mhd_cv_define__xopen_source_accepted_1], [dnl | ||
263 | AS_IF([[test "x$mhd_cv_define__xopen_source_extended_accepted" = "xyes" || ]dnl | ||
264 | [test "x$mhd_cv_define__xopen_version_accepted" = "xyes"]], | ||
265 | [[mhd_cv_define__xopen_source_accepted_1="yes"]], | ||
266 | [ | ||
267 | MHD_CHECK_BASIC_HEADERS([[#define _XOPEN_SOURCE 1]], | ||
268 | [[mhd_cv_define__xopen_source_accepted_1="yes"]], | ||
269 | [[mhd_cv_define__xopen_source_accepted_1="no"]]) | ||
270 | ]) | ||
271 | ]) | ||
272 | AS_VAR_IF([[mhd_cv_define__xopen_source_accepted_1]], [["yes"]], [dnl | ||
273 | _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_SOURCE]], [[1]]) | ||
274 | ]) | ||
275 | ]) | ||
276 | ]) | ||
277 | ]) | ||
278 | ]) | ||
279 | dnl Add other extensions. | ||
280 | dnl Use compiler-based test for determinig target. | ||
281 | |||
282 | dnl Always add _GNU_SOURCE if headers allow. | ||
283 | MHD_CHECK_DEF_AND_ACCEPT([[_GNU_SOURCE]], [], | ||
284 | [[${mhd_mse_added_prolog}]], [], | ||
285 | [_MHD_SYS_EXT_ADD_FLAG([[_GNU_SOURCE]])]) | ||
286 | |||
287 | dnl __BSD_VISIBLE is actually a small hack for FreeBSD. | ||
288 | dnl Funny that it's used in Android headers too. | ||
289 | AC_CACHE_CHECK([[whether to try __BSD_VISIBLE macro]], | ||
290 | [[mhd_cv_macro_try___bsd_visible]], [dnl | ||
291 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | ||
292 | #if !defined(__FreeBSD__) && !defined (__ANDROID__) | ||
293 | #error Target is not FreeBSD or Android | ||
294 | choke me now; | ||
295 | #endif | ||
296 | ]],[])], | ||
297 | [[mhd_cv_macro_try___bsd_visible="yes"]], | ||
298 | [[mhd_cv_macro_try___bsd_visible="no"]] | ||
299 | ) | ||
300 | ]) | ||
301 | AS_VAR_IF([[mhd_cv_macro_try___bsd_visible]], [["yes"]], | ||
302 | [dnl | ||
303 | AC_CACHE_CHECK([[whether __BSD_VISIBLE is already defined]], | ||
304 | [[mhd_cv_macro___bsd_visible_defined]], [dnl | ||
305 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | ||
306 | ${mhd_mse_added_prolog} | ||
307 | /* Warning: test with inverted logic! */ | ||
308 | #ifdef __BSD_VISIBLE | ||
309 | #error __BSD_VISIBLE is defined | ||
310 | choke me now; | ||
311 | #endif | ||
312 | #ifdef __ANDROID__ | ||
313 | /* if __BSD_VISIBLE is not defined, Android usually defines it to 1 */ | ||
314 | #include <stdio.h> | ||
315 | #if defined(__BSD_VISIBLE) && __BSD_VISIBLE == 1 | ||
316 | #error __BSD_VISIBLE is autodefined by headers to value 1 | ||
317 | choke me now; | ||
318 | #endif | ||
319 | #endif | ||
320 | ]],[]) | ||
321 | ], | ||
322 | [[mhd_cv_macro___bsd_visible_defined="no"]], | ||
323 | [[mhd_cv_macro___bsd_visible_defined="yes"]] | ||
324 | ) | ||
325 | ]) | ||
326 | AS_VAR_IF([[mhd_cv_macro___bsd_visible_defined]], [["yes"]], [[:]], | ||
327 | [dnl | ||
328 | MHD_CHECK_ACCEPT_DEFINE( | ||
329 | [[__BSD_VISIBLE]], [], [[${mhd_mse_added_prolog}]], | ||
330 | [_MHD_SYS_EXT_ADD_FLAG([[__BSD_VISIBLE]])] | ||
331 | )dnl | ||
332 | ]) | ||
333 | ]) | ||
334 | |||
335 | |||
336 | dnl _DARWIN_C_SOURCE enables additional functionality on Darwin. | ||
337 | MHD_CHECK_DEFINED_MSG([[__APPLE__]], [[${mhd_mse_added_prolog}]], | ||
338 | [[whether to try _DARWIN_C_SOURCE macro]], | ||
339 | [dnl | ||
340 | MHD_CHECK_DEF_AND_ACCEPT( | ||
341 | [[_DARWIN_C_SOURCE]], [], [[${mhd_mse_added_prolog}]], [], | ||
342 | [_MHD_SYS_EXT_ADD_FLAG([[_DARWIN_C_SOURCE]])] | ||
343 | )dnl | ||
344 | ]) | ||
345 | |||
346 | dnl __EXTENSIONS__ unlocks almost all interfaces on Solaris. | ||
347 | MHD_CHECK_DEFINED_MSG([[__sun]], [[${mhd_mse_added_prolog}]], | ||
348 | [[whether to try __EXTENSIONS__ macro]], | ||
349 | [dnl | ||
350 | MHD_CHECK_DEF_AND_ACCEPT( | ||
351 | [[__EXTENSIONS__]], [], [[${mhd_mse_added_prolog}]], [], | ||
352 | [_MHD_SYS_EXT_ADD_FLAG([[__EXTENSIONS__]])] | ||
353 | )dnl | ||
354 | ]) | ||
355 | |||
356 | dnl _NETBSD_SOURCE switch on almost all headers definitions on NetBSD. | ||
357 | MHD_CHECK_DEFINED_MSG([[__NetBSD__]], [[${mhd_mse_added_prolog}]], | ||
358 | [[whether to try _NETBSD_SOURCE macro]], | ||
359 | [dnl | ||
360 | MHD_CHECK_DEF_AND_ACCEPT( | ||
361 | [[_NETBSD_SOURCE]], [], [[${mhd_mse_added_prolog}]], [], | ||
362 | [_MHD_SYS_EXT_ADD_FLAG([[_NETBSD_SOURCE]])] | ||
363 | )dnl | ||
364 | ]) | ||
365 | |||
366 | dnl _BSD_SOURCE currently used only on OpenBSD to unhide functions. | ||
367 | MHD_CHECK_DEFINED_MSG([[__OpenBSD__]], [[${mhd_mse_added_prolog}]], | ||
368 | [[whether to try _BSD_SOURCE macro]], | ||
369 | [dnl | ||
370 | MHD_CHECK_DEF_AND_ACCEPT( | ||
371 | [[_BSD_SOURCE]], [], [[${mhd_mse_added_prolog}]], [], | ||
372 | [_MHD_SYS_EXT_ADD_FLAG([[_BSD_SOURCE]])] | ||
373 | )dnl | ||
374 | ]) | ||
375 | |||
376 | dnl _TANDEM_SOURCE unhides most functions on NonStop OS | ||
377 | dnl (which comes from Tandem Computers decades ago). | ||
378 | MHD_CHECK_DEFINED_MSG([[__TANDEM]], [[${mhd_mse_added_prolog}]], | ||
379 | [[whether to try _TANDEM_SOURCE macro]], | ||
380 | [dnl | ||
381 | MHD_CHECK_DEF_AND_ACCEPT( | ||
382 | [[_TANDEM_SOURCE]], [], [[${mhd_mse_added_prolog}]], [], | ||
383 | [_MHD_SYS_EXT_ADD_FLAG([[_TANDEM_SOURCE]])] | ||
384 | )dnl | ||
385 | ]) | ||
386 | |||
387 | dnl _ALL_SOURCE makes visible POSIX and non-POSIX symbols | ||
388 | dnl on z/OS, AIX and Interix. | ||
389 | AC_CACHE_CHECK([[whether to try _ALL_SOURCE macro]], | ||
390 | [[mhd_cv_macro_try__all_source]], [dnl | ||
391 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ | ||
392 | #if !defined(__TOS_MVS__) && !defined (__INTERIX) | ||
393 | #error Target is not z/OS, AIX or Interix | ||
394 | choke me now; | ||
395 | #endif | ||
396 | ]],[])], | ||
397 | [[mhd_cv_macro_try__all_source="yes"]], | ||
398 | [[mhd_cv_macro_try__all_source="no"]] | ||
399 | ) | ||
400 | ]) | ||
401 | AS_VAR_IF([[mhd_cv_macro_try__all_source]], [["yes"]], | ||
402 | [dnl | ||
403 | MHD_CHECK_DEF_AND_ACCEPT( | ||
404 | [[_ALL_SOURCE]], [], [[${mhd_mse_added_prolog}]], [], | ||
405 | [_MHD_SYS_EXT_ADD_FLAG([[_TANDEM_SOURCE]])] | ||
406 | )dnl | ||
407 | ]) | ||
408 | |||
409 | dnl Discard temporal prolog with set of defines. | ||
410 | AS_UNSET([[mhd_mse_added_prolog]]) | ||
411 | dnl Determined all required defines. | ||
412 | AC_MSG_CHECKING([[for final set of defined symbols]]) | ||
413 | m4_ifblank([$1], [dnl | ||
414 | AH_TEMPLATE([[_XOPEN_SOURCE]], [Define to maximum value supported by system headers])dnl | ||
415 | AH_TEMPLATE([[_XOPEN_SOURCE_EXTENDED]], [Define to 1 if _XOPEN_SOURCE is defined to value less than 500 ]dnl | ||
416 | [and system headers requre this symbol])dnl | ||
417 | AH_TEMPLATE([[_XOPEN_VERSION]], [Define to maximum value supported by system headers if _XOPEN_SOURCE ]dnl | ||
418 | [is defined to value less than 500 and headers do not support _XOPEN_SOURCE_EXTENDED])dnl | ||
419 | AH_TEMPLATE([[_GNU_SOURCE]], [Define to 1 to enable GNU-related header features])dnl | ||
420 | AH_TEMPLATE([[__BSD_VISIBLE]], [Define to 1 if it is required by headers to expose additional symbols])dnl | ||
421 | AH_TEMPLATE([[_DARWIN_C_SOURCE]], [Define to 1 if it is required by headers to expose additional symbols])dnl | ||
422 | AH_TEMPLATE([[__EXTENSIONS__]], [Define to 1 if it is required by headers to expose additional symbols])dnl | ||
423 | AH_TEMPLATE([[_NETBSD_SOURCE]], [Define to 1 if it is required by headers to expose additional symbols])dnl | ||
424 | AH_TEMPLATE([[_BSD_SOURCE]], [Define to 1 if it is required by headers to expose additional symbols])dnl | ||
425 | AH_TEMPLATE([[_TANDEM_SOURCE]], [Define to 1 if it is required by headers to expose additional symbols])dnl | ||
426 | AH_TEMPLATE([[_ALL_SOURCE]], [Define to 1 if it is required by headers to expose additional symbols])dnl | ||
427 | ]) | ||
428 | for mhd_mse_Flag in $mhd_mse_added_exts_flags | ||
429 | do | ||
430 | m4_ifnblank([$1], [dnl | ||
431 | AS_VAR_APPEND([$1],[[" -D$mhd_mse_Flag"]]) | ||
432 | ], [dnl | ||
433 | AS_CASE([[$mhd_mse_Flag]], [[*=*]], | ||
434 | [dnl | ||
435 | AC_DEFINE_UNQUOTED([[`echo $mhd_mse_Flag | cut -f 1 -d =`]], | ||
436 | [[`echo $mhd_mse_Flag | cut -f 2 -d = -s`]]) | ||
437 | ], [dnl | ||
438 | AC_DEFINE_UNQUOTED([[$mhd_mse_Flag]]) | ||
439 | ]) | ||
440 | ]) | ||
441 | done | ||
442 | dnl Trim whitespaces | ||
443 | mhd_mse_result=`echo $mhd_mse_added_exts_flags` | ||
444 | AC_MSG_RESULT([[$mhd_mse_result]]) | ||
445 | AS_UNSET([[mhd_mse_result]]) | ||
446 | |||
447 | AS_UNSET([[mhd_mse_added_exts_flags]]) | ||
448 | AC_LANG_POP([C]) | ||
449 | ]) | ||
450 | |||
451 | |||
452 | # | ||
453 | # _MHD_SYS_EXT_ADD_FLAG(FLAG, [FLAG-VALUE = 1]) | ||
454 | # | ||
455 | # Internal macro, only to be used from MHD_SYS_EXT, _MHD_XOPEN_ADD | ||
456 | |||
457 | m4_define([_MHD_SYS_EXT_ADD_FLAG], [dnl | ||
458 | m4_ifnblank([$2],[dnl | ||
459 | mhd_mse_added_exts_flags="$mhd_mse_added_exts_flags m4_normalize($1)=m4_normalize($2)" | ||
460 | mhd_mse_added_prolog="${mhd_mse_added_prolog}[#define ]m4_normalize($1) m4_normalize($2) | ||
461 | " | ||
462 | ], [dnl | ||
463 | mhd_mse_added_exts_flags="$mhd_mse_added_exts_flags m4_normalize($1)" | ||
464 | mhd_mse_added_prolog="${mhd_mse_added_prolog}[#define ]m4_normalize($1) 1 | ||
465 | " | ||
466 | ])dnl | ||
467 | ]) | ||
468 | |||
469 | # | ||
470 | # _MHD_VAR_IF(VAR, VALUE, [IF-EQ], [IF-NOT-EQ]) | ||
471 | # | ||
472 | # Same as AS_VAR_IF, except that it expands to nothing if | ||
473 | # both IF-EQ and IF-NOT-EQ are empty. | ||
474 | |||
475 | m4_define([_MHD_VAR_IF],[dnl | ||
476 | m4_ifnblank([$3][$4],[dnl | ||
477 | m4_ifblank([$4],[AS_VAR_IF([$1],[$2],[$3])],[dnl | ||
478 | AS_VAR_IF([$1],[$2],[$3],[$4])])])]) | ||
479 | |||
480 | # SYNOPSIS | ||
481 | # | ||
482 | # _MHD_CHECK_XOPEN_ENABLE(_XOPEN_SOURCE-VALUE, FEATURES_TEST, | ||
483 | # [ACTION-IF-ENABLED-BY-XOPEN_SOURCE], | ||
484 | # [ACTION-IF-NOT], | ||
485 | # [ACTION-IF-FEATURES-AVALABLE], | ||
486 | # [ACTION-IF-FEATURES-NOT-AVALABLE], | ||
487 | # [ACTION-IF-ONLY-WITH-EXTENSIONS] | ||
488 | # [ACTION-IF-WITHOUT-ALL]) | ||
489 | # | ||
490 | # DESCRIPTION | ||
491 | # | ||
492 | # This macro determines whether the _XOPEN_SOURCE with | ||
493 | # _XOPEN_SOURCE-VALUE really enable some header features. FEATURES_TEST | ||
494 | # must contains required includes and main function. | ||
495 | # One of ACTION-IF-ENABLED-BY-XOPEN_SOURCE and ACTION-IF-NOT | ||
496 | # is always executed depending on test results. | ||
497 | # One of ACTION-IF-FEATURES-AVALABLE and is ACTION-IF-FEATURES-NOT-AVALABLE | ||
498 | # is executed if features can be enabled by _XOPEN_SOURCE, by currently | ||
499 | # defined (by compiler flags or by predefined macros) extensions or | ||
500 | # all checked combinations are failed to enable features. | ||
501 | # ACTION-IF-ONLY-WITH-EXTENSIONS is executed if features can be | ||
502 | # enabled with not undefined extension. | ||
503 | # ACTION-IF-WITHOUT-ALL is executed if features work with all | ||
504 | # disabled extensions (including _XOPEN_SOURCE). | ||
505 | |||
506 | AC_DEFUN([_MHD_CHECK_XOPEN_ENABLE], [dnl | ||
507 | AS_VAR_PUSHDEF([src_Var], [[mhd_cxoe_tmp_src_variable]])dnl | ||
508 | AS_VAR_SET([src_Var],[" | ||
509 | $2 | ||
510 | "])dnl Reduce 'configure' size | ||
511 | |||
512 | dnl Some platforms enable most features when no | ||
513 | dnl specific mode is requested by macro. | ||
514 | dnl Check whether features test works without _XOPEN_SOURCE and | ||
515 | dnl with disabled extensions (undefined most of | ||
516 | dnl predefined macros for specific requested mode). | ||
517 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | ||
518 | _MHD_UNDEF_ALL_EXT | ||
519 | $src_Var | ||
520 | ])], | ||
521 | [dnl | ||
522 | _AS_ECHO_LOG([[Checked features work with undefined all extensions and without _XOPEN_SOURCE]]) | ||
523 | dnl Checked features is enabled in platform's "default" mode. | ||
524 | dnl Try to disable features by requesting oldest X/Open mode. | ||
525 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | ||
526 | _MHD_UNDEF_ALL_EXT | ||
527 | [#define _XOPEN_SOURCE 1] | ||
528 | $src_Var | ||
529 | ])], | ||
530 | [dnl | ||
531 | _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _XOPEN_SOURCE=1]]) | ||
532 | dnl Features still work in oldest X/Open mode. | ||
533 | dnl Some platforms enable all XSI features for any _XOPEN_SOURCE value. | ||
534 | dnl Apply some fuzzy logic, try to use _POSIX_C_SOURCE with oldest number. | ||
535 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | ||
536 | _MHD_UNDEF_ALL_EXT | ||
537 | [#define _POSIX_C_SOURCE 1] | ||
538 | $src_Var | ||
539 | ])], | ||
540 | [dnl | ||
541 | _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _POSIX_C_SOURCE=1]]) | ||
542 | dnl Features still work in oldest _POSIX_C_SOURCE mode. | ||
543 | dnl Try to disable features by requesting strict ANSI C mode. | ||
544 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | ||
545 | _MHD_UNDEF_ALL_EXT | ||
546 | [#define _ANSI_SOURCE 1] | ||
547 | $src_Var | ||
548 | ])], | ||
549 | [dnl | ||
550 | _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _ANSI_SOURCE]]) | ||
551 | dnl Features still work in strict _ANSI_SOURCE mode. | ||
552 | dnl Assume that _XOPEN_SOURCE, _POSIX_C_SOURCE and _ANSI_SOURCE has no influence on | ||
553 | dnl enabling of features as features are enabled always unconditionally. | ||
554 | m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE | ||
555 | ], [dnl | ||
556 | _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _ANSI_SOURCE]]) | ||
557 | dnl Features do not work in strict _ANSI_SOURCE mode. | ||
558 | dnl Try to enable features by _XOPEN_SOURCE with specified value. | ||
559 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | ||
560 | _MHD_UNDEF_ALL_EXT | ||
561 | [#define _ANSI_SOURCE 1] | ||
562 | [#define _XOPEN_SOURCE] $1 | ||
563 | $src_Var | ||
564 | ])], | ||
565 | [dnl | ||
566 | _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _ANSI_SOURCE and _XOPEN_SOURCE=]$1]) | ||
567 | dnl Finally, features were disabled by strict ANSI mode and enabled by adding _XOPEN_SOURCE. | ||
568 | dnl Assume that _XOPEN_SOURCE can enable features. | ||
569 | m4_n([$3])dnl ACTION-IF-ENABLED-BY-XOPEN_SOURCE | ||
570 | ], [dnl | ||
571 | _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _ANSI_SOURCE and _XOPEN_SOURCE=]$1]) | ||
572 | dnl Features are not enabled in strict ANSI mode with _XOPEN_SOURCE. | ||
573 | dnl Actually this is not correct documented situation and _ANSI_SOURCE may have | ||
574 | dnl priority over _XOPEN_SOURCE or headers are not controlled by _XOPEN_SOURCE at all. | ||
575 | dnl As features work in all mode except strict ANSI regardless of _XOPEN_SOURCE, | ||
576 | dnl assume that _XOPEN_SOURCE do not control visibility of features. | ||
577 | m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE | ||
578 | ]) | ||
579 | ]) | ||
580 | ], [dnl | ||
581 | _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _POSIX_C_SOURCE=1]]) | ||
582 | dnl Features do not work in oldest _POSIX_C_SOURCE mode. | ||
583 | dnl OK, features were disabled by _POSIX_C_SOURCE. | ||
584 | dnl Check whether headers controlled by _XOPEN_SOURCE too. | ||
585 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | ||
586 | _MHD_UNDEF_ALL_EXT | ||
587 | [#define _POSIX_C_SOURCE 1] | ||
588 | [#define _XOPEN_SOURCE] $1 | ||
589 | $src_Var | ||
590 | ])], | ||
591 | [dnl | ||
592 | _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _POSIX_C_SOURCE=1 and _XOPEN_SOURCE=]$1]) | ||
593 | dnl Features were enabled again after adding _XOPEN_SOURCE with value. | ||
594 | dnl Assume that headers can be controlled by _XOPEN_SOURCE with specified value. | ||
595 | m4_n([$3])dnl ACTION-IF-ENABLED-BY-XOPEN_SOURCE | ||
596 | ], [dnl | ||
597 | _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _POSIX_C_SOURCE=1 and _XOPEN_SOURCE=]$1]) | ||
598 | dnl Features still work after adding _XOPEN_SOURCE with value. | ||
599 | dnl It's unclear whether headers know only about _POSIX_C_SOURCE or | ||
600 | dnl _POSIX_C_SOURCE have priority over _XOPEN_SOURCE (standards are | ||
601 | dnl silent about priorities). | ||
602 | dnl Assume that it's unknown whether _XOPEN_SOURCE can turn on features. | ||
603 | m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE | ||
604 | ]) | ||
605 | ]) | ||
606 | ], [dnl | ||
607 | _AS_ECHO_LOG([[Checked features does not work with undefined all extensions and with _XOPEN_SOURCE=1]]) | ||
608 | dnl Features disabled by oldest X/Open mode. | ||
609 | dnl Check whether requested _XOPEN_SOURCE value will turn on features. | ||
610 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | ||
611 | _MHD_UNDEF_ALL_EXT | ||
612 | [#define _XOPEN_SOURCE] $1 | ||
613 | $src_Var | ||
614 | ])], | ||
615 | [dnl | ||
616 | _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _XOPEN_SOURCE=]$1]) | ||
617 | dnl Features work with _XOPEN_SOURCE requested value and do not work | ||
618 | dnl with value 1. | ||
619 | dnl Assume that _XOPEN_SOURCE really turn on features. | ||
620 | m4_n([$3])dnl ACTION-IF-ENABLED-BY-XOPEN_SOURCE | ||
621 | ], [dnl | ||
622 | _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _XOPEN_SOURCE=]$1]) | ||
623 | dnl Features do not work with _XOPEN_SOURCE, but work in "default" mode. | ||
624 | dnl Assume that features cannot be enabled by requested _XOPEN_SOURCE value. | ||
625 | m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE | ||
626 | ]) | ||
627 | ]) | ||
628 | m4_n([$5])dnl ACTION-IF-FEATURES-AVALABLE | ||
629 | m4_n([$8])dnl ACTION-IF-WITHOUT-ALL | ||
630 | ], | ||
631 | [dnl | ||
632 | _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and without _XOPEN_SOURCE]]) | ||
633 | dnl Features do not work with turned off extensions. | ||
634 | dnl Check whether they can be enabled by _XOPEN_SOURCE. | ||
635 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | ||
636 | _MHD_UNDEF_ALL_EXT | ||
637 | [#define _XOPEN_SOURCE] $1 | ||
638 | $src_Var | ||
639 | ])], | ||
640 | [dnl | ||
641 | _AS_ECHO_LOG([[Checked features work with undefined all extensions and with _XOPEN_SOURCE=]$1]) | ||
642 | dnl Features work with _XOPEN_SOURCE and do not work without _XOPEN_SOURCE. | ||
643 | dnl Assume that _XOPEN_SOURCE really turn on features. | ||
644 | m4_n([$3])dnl ACTION-IF-ENABLED-BY-XOPEN_SOURCE | ||
645 | m4_n([$5])dnl ACTION-IF-FEATURES-AVALABLE | ||
646 | ], | ||
647 | [dnl | ||
648 | _AS_ECHO_LOG([[Checked features do not work with undefined all extensions and with _XOPEN_SOURCE=]$1]) | ||
649 | dnl Features do not work with _XOPEN_SOURCE and turned off extensions. | ||
650 | dnl Retry without turning off known extensions. | ||
651 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | ||
652 | [#define _XOPEN_SOURCE] $1 | ||
653 | $src_Var | ||
654 | ])], | ||
655 | [dnl | ||
656 | _AS_ECHO_LOG([[Checked features work with current extensions and with _XOPEN_SOURCE=]$1]) | ||
657 | dnl Features work with _XOPEN_SOURCE and without turning off extensions. | ||
658 | dnl Check whether features work with oldest _XOPEN_SOURCE or it was enabled only by extensions. | ||
659 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([ | ||
660 | [#define _XOPEN_SOURCE 1] | ||
661 | $src_Var | ||
662 | ])], | ||
663 | [dnl | ||
664 | _AS_ECHO_LOG([[Checked features work with current extensions and with _XOPEN_SOURCE=1]]) | ||
665 | dnl Features still work with oldest _XOPEN_SOURCE. | ||
666 | dnl Assume that _XOPEN_SOURCE has no influence on enabling of features. | ||
667 | m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE | ||
668 | ], [dnl | ||
669 | _AS_ECHO_LOG([[Checked features do not work with current extensions and with _XOPEN_SOURCE=1]]) | ||
670 | dnl Features do not work with oldest _XOPEN_SOURCE. | ||
671 | dnl Assume that _XOPEN_SOURCE really turn on features. | ||
672 | m4_n([$3])dnl ACTION-IF-ENABLED-BY-XOPEN_SOURCE | ||
673 | ]) | ||
674 | m4_n([$5])dnl ACTION-IF-FEATURES-AVALABLE | ||
675 | m4_n([$7])dnl ACTION-IF-ONLY-WITH-EXTENSIONS | ||
676 | ], [dnl | ||
677 | _AS_ECHO_LOG([[Checked features do not work with current extensions and with _XOPEN_SOURCE=]$1]) | ||
678 | dnl Features do not work in all checked conditions. | ||
679 | dnl Assume that _XOPEN_SOURCE cannot enable feature. | ||
680 | m4_n([$4])dnl ACTION-IF-NOT-ENABLED-BY-XOPEN_SOURCE | ||
681 | m4_n([$6])dnl ACTION-IF-FEATURE-NOT-AVALABLE | ||
682 | ]) | ||
683 | ]) | ||
684 | ]) | ||
685 | AS_UNSET([src_Var]) | ||
686 | AS_VAR_POPDEF([src_Var])dnl | ||
687 | ]) | ||
688 | |||
689 | |||
690 | # | ||
691 | # MHD_CHECK_HEADER_PRESENCE(headername.h) | ||
692 | # | ||
693 | # Check only by preprocessor whether header file is present. | ||
694 | |||
695 | AC_DEFUN([MHD_CHECK_HEADER_PRESENCE], [dnl | ||
696 | AC_PREREQ([2.64])dnl for AS_VAR_PUSHDEF, AS_VAR_SET | ||
697 | AS_VAR_PUSHDEF([mhd_cache_Var],[mhd_cv_header_[]$1[]_present])dnl | ||
698 | AC_CACHE_CHECK([for presence of $1], [mhd_cache_Var], [dnl | ||
699 | dnl Hack autoconf to get pure result of only single header presence | ||
700 | cat > conftest.$ac_ext <<_ACEOF | ||
701 | @%:@include <[]$1[]> | ||
702 | _ACEOF | ||
703 | AC_PREPROC_IFELSE([], | ||
704 | [AS_VAR_SET([mhd_cache_Var],[["yes"]])], | ||
705 | [AS_VAR_SET([mhd_cache_Var],[["no"]])] | ||
706 | ) | ||
707 | rm -f conftest.$ac_ext | ||
708 | ]) | ||
709 | AS_VAR_POPDEF([mhd_cache_Var])dnl | ||
710 | ]) | ||
711 | |||
712 | |||
713 | # | ||
714 | # MHD_CHECK_HEADERS_PRESENCE(oneheader.h otherheader.h ...) | ||
715 | # | ||
716 | # Check each specified header in whitespace-separated list for presence. | ||
717 | |||
718 | AC_DEFUN([MHD_CHECK_HEADERS_PRESENCE], [dnl | ||
719 | AC_PREREQ([2.60])dnl for m4_foreach_w | ||
720 | m4_foreach_w([mhd_chk_Header], [$1], | ||
721 | [MHD_CHECK_HEADER_PRESENCE(m4_defn([mhd_chk_Header]))] | ||
722 | )dnl | ||
723 | ]) | ||
724 | |||
725 | |||
726 | # | ||
727 | # MHD_CHECK_HEADERS_PRESENCE_COMPACT(oneheader.h otherheader.h ...) | ||
728 | # | ||
729 | # Same as MHD_CHECK_HEADERS_PRESENCE, but a bit slower and produce more compact 'configure'. | ||
730 | |||
731 | AC_DEFUN([MHD_CHECK_HEADERS_PRESENCE_COMPACT], [dnl | ||
732 | for mhd_chk_Header in $1 ; do | ||
733 | MHD_CHECK_HEADER_PRESENCE([[${mhd_chk_Header}]]) | ||
734 | done | ||
735 | ]) | ||
736 | |||
737 | |||
738 | # | ||
739 | # MHD_CHECK_BASIC_HEADERS_PRESENCE | ||
740 | # | ||
741 | # Check basic headers for presence. | ||
742 | |||
743 | AC_DEFUN([MHD_CHECK_BASIC_HEADERS_PRESENCE], [dnl | ||
744 | MHD_CHECK_HEADERS_PRESENCE([stdio.h wchar.h stdlib.h string.h strings.h stdint.h fcntl.h sys/types.h time.h unistd.h]) | ||
745 | ]) | ||
746 | |||
747 | |||
748 | # | ||
749 | # _MHD_SET_BASIC_INCLUDES | ||
750 | # | ||
751 | # Internal preparatory macro. | ||
752 | |||
753 | AC_DEFUN([_MHD_SET_BASIC_INCLUDES], [dnl | ||
754 | AC_REQUIRE([MHD_CHECK_BASIC_HEADERS_PRESENCE])dnl | ||
755 | AS_IF([[test -z "$mhd_basic_headers_includes"]], [dnl | ||
756 | AS_VAR_IF([mhd_cv_header_stdio_h_present], [["yes"]], | ||
757 | [[mhd_basic_headers_includes="\ | ||
758 | #include <stdio.h> | ||
759 | " ]],[[mhd_basic_headers_includes=""]] | ||
760 | ) | ||
761 | AS_VAR_IF([mhd_cv_header_sys_types_h_present], [["yes"]], | ||
762 | [[mhd_basic_headers_includes="${mhd_basic_headers_includes}\ | ||
763 | #include <sys/types.h> | ||
764 | " ]] | ||
765 | ) | ||
766 | AS_VAR_IF([mhd_cv_header_wchar_h_present], [["yes"]], | ||
767 | [[mhd_basic_headers_includes="${mhd_basic_headers_includes}\ | ||
768 | #include <wchar.h> | ||
769 | " ]] | ||
770 | ) | ||
771 | AS_VAR_IF([mhd_cv_header_stdlib_h_present], [["yes"]], | ||
772 | [[mhd_basic_headers_includes="${mhd_basic_headers_includes}\ | ||
773 | #include <stdlib.h> | ||
774 | " ]] | ||
775 | ) | ||
776 | AS_VAR_IF([mhd_cv_header_string_h_present], [["yes"]], | ||
777 | [[mhd_basic_headers_includes="${mhd_basic_headers_includes}\ | ||
778 | #include <string.h> | ||
779 | " ]] | ||
780 | ) | ||
781 | AS_VAR_IF([mhd_cv_header_strings_h_present], [["yes"]], | ||
782 | [[mhd_basic_headers_includes="${mhd_basic_headers_includes}\ | ||
783 | #include <strings.h> | ||
784 | " ]] | ||
785 | ) | ||
786 | AS_VAR_IF([mhd_cv_header_stdint_h_present], [["yes"]], | ||
787 | [[mhd_basic_headers_includes="${mhd_basic_headers_includes}\ | ||
788 | #include <stdint.h> | ||
789 | " ]] | ||
790 | ) | ||
791 | AS_VAR_IF([mhd_cv_header_fcntl_h_present], [["yes"]], | ||
792 | [[mhd_basic_headers_includes="${mhd_basic_headers_includes}\ | ||
793 | #include <fcntl.h> | ||
794 | " ]] | ||
795 | ) | ||
796 | AS_VAR_IF([mhd_cv_header_time_h_present], [["yes"]], | ||
797 | [[mhd_basic_headers_includes="${mhd_basic_headers_includes}\ | ||
798 | #include <time.h> | ||
799 | " ]] | ||
800 | ) | ||
801 | AS_VAR_IF([mhd_cv_header_unistd_h_present], [["yes"]], | ||
802 | [[mhd_basic_headers_includes="${mhd_basic_headers_includes}\ | ||
803 | #include <unistd.h> | ||
804 | " ]] | ||
805 | ) | ||
806 | ])dnl | ||
807 | ]) | ||
808 | |||
809 | |||
810 | # | ||
811 | # _MHD_BASIC_INCLUDES | ||
812 | # | ||
813 | # Internal macro. Output set of basic includes. | ||
814 | |||
815 | AC_DEFUN([_MHD_BASIC_INCLUDES], [AC_REQUIRE([_MHD_SET_BASIC_INCLUDES])dnl | ||
816 | [ /* Start of MHD basic test includes */ | ||
817 | $mhd_basic_headers_includes /* End of MHD basic test includes */ | ||
818 | ]]) | ||
819 | |||
820 | |||
821 | # | ||
822 | # MHD_CHECK_BASIC_HEADERS([PROLOG], [ACTION-IF-OK], [ACTION-IF-FAIL]) | ||
823 | # | ||
824 | # Check whether basic headers can be compiled with specified prolog. | ||
825 | |||
826 | AC_DEFUN([MHD_CHECK_BASIC_HEADERS], [dnl | ||
827 | AC_COMPILE_IFELSE([dnl | ||
828 | AC_LANG_PROGRAM([m4_n([$1])dnl | ||
829 | _MHD_BASIC_INCLUDES | ||
830 | ], [[int i = 1; i++]]) | ||
831 | ], [$2], [$3]) | ||
832 | ]) | ||
833 | |||
834 | |||
835 | # | ||
836 | # _MHD_SET_UNDEF_ALL_EXT | ||
837 | # | ||
838 | # Internal preparatory macro. | ||
839 | |||
840 | AC_DEFUN([_MHD_SET_UNDEF_ALL_EXT], [m4_divert_text([INIT_PREPARE],[dnl | ||
841 | [mhd_undef_all_extensions=" | ||
842 | #ifdef _GNU_SOURCE | ||
843 | #undef _GNU_SOURCE | ||
844 | #endif | ||
845 | #ifdef _XOPEN_SOURCE | ||
846 | #undef _XOPEN_SOURCE | ||
847 | #endif | ||
848 | #ifdef _XOPEN_SOURCE_EXTENDED | ||
849 | #undef _XOPEN_SOURCE_EXTENDED | ||
850 | #endif | ||
851 | #ifdef _XOPEN_VERSION | ||
852 | #undef _XOPEN_VERSION | ||
853 | #endif | ||
854 | #ifdef _POSIX_C_SOURCE | ||
855 | #undef _POSIX_C_SOURCE | ||
856 | #endif | ||
857 | #ifdef _POSIX_SOURCE | ||
858 | #undef _POSIX_SOURCE | ||
859 | #endif | ||
860 | #ifdef _DEFAULT_SOURCE | ||
861 | #undef _DEFAULT_SOURCE | ||
862 | #endif | ||
863 | #ifdef _BSD_SOURCE | ||
864 | #undef _BSD_SOURCE | ||
865 | #endif | ||
866 | #ifdef _SVID_SOURCE | ||
867 | #undef _SVID_SOURCE | ||
868 | #endif | ||
869 | #ifdef __EXTENSIONS__ | ||
870 | #undef __EXTENSIONS__ | ||
871 | #endif | ||
872 | #ifdef _ALL_SOURCE | ||
873 | #undef _ALL_SOURCE | ||
874 | #endif | ||
875 | #ifdef _TANDEM_SOURCE | ||
876 | #undef _TANDEM_SOURCE | ||
877 | #endif | ||
878 | #ifdef _DARWIN_C_SOURCE | ||
879 | #undef _DARWIN_C_SOURCE | ||
880 | #endif | ||
881 | #ifdef __BSD_VISIBLE | ||
882 | #undef __BSD_VISIBLE | ||
883 | #endif | ||
884 | #ifdef _NETBSD_SOURCE | ||
885 | #undef _NETBSD_SOURCE | ||
886 | #endif | ||
887 | " | ||
888 | ]])]) | ||
889 | |||
890 | |||
891 | # | ||
892 | # _MHD_UNDEF_ALL_EXT | ||
893 | # | ||
894 | # Output prolog that undefine all known extension and visibility macros. | ||
895 | |||
896 | AC_DEFUN([_MHD_UNDEF_ALL_EXT], [dnl | ||
897 | AC_REQUIRE([_MHD_SET_UNDEF_ALL_EXT])dnl | ||
898 | $mhd_undef_all_extensions | ||
899 | ]) | ||
900 | |||
901 | |||
902 | # | ||
903 | # _MHD_CHECK_DEFINED(SYMBOL, [PROLOG], | ||
904 | # [ACTION-IF-DEFINED], [ACTION-IF-NOT-DEFINED]) | ||
905 | # | ||
906 | # Silently checks for defined symbols. | ||
907 | |||
908 | AC_DEFUN([_MHD_CHECK_DEFINED], [dnl | ||
909 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ | ||
910 | m4_n([$2])dnl | ||
911 | [#ifndef ]$1[ | ||
912 | #error ]$1[ is not defined | ||
913 | choke me now; | ||
914 | #endif | ||
915 | ]],[]) | ||
916 | ], [$3], [$4] | ||
917 | ) | ||
918 | ]) | ||
919 | |||
920 | |||
921 | # | ||
922 | # MHD_CHECK_DEFINED(SYMBOL, [PROLOG], | ||
923 | # [ACTION-IF-DEFINED], [ACTION-IF-NOT-DEFINED], | ||
924 | # [MESSAGE]) | ||
925 | # | ||
926 | # Cache-check for defined symbols with printing results. | ||
927 | |||
928 | AC_DEFUN([MHD_CHECK_DEFINED], [dnl | ||
929 | AS_VAR_PUSHDEF([mhd_cache_Var], | ||
930 | [mhd_cv_macro_[]m4_tolower($1)_defined])dnl | ||
931 | AC_CACHE_CHECK([dnl | ||
932 | m4_ifnblank([$5], [$5], [whether $1 is already defined])], | ||
933 | [mhd_cache_Var], | ||
934 | [ | ||
935 | _MHD_CHECK_DEFINED([$1], [$2], | ||
936 | [mhd_cache_Var="yes"], | ||
937 | [mhd_cache_Var="no"] | ||
938 | ) | ||
939 | ]) | ||
940 | _MHD_VAR_IF([mhd_cache_Var], [["yes"]], [$3], [$4]) | ||
941 | AS_VAR_POPDEF([mhd_cache_Var])dnl | ||
942 | ]) | ||
943 | |||
944 | |||
945 | # | ||
946 | # MHD_CHECK_DEFINED_MSG(SYMBOL, [PROLOG], [MESSAGE] | ||
947 | # [ACTION-IF-DEFINED], [ACTION-IF-NOT-DEFINED]) | ||
948 | # | ||
949 | # Cache-check for defined symbols with printing results. | ||
950 | # Reordered arguments for better readability. | ||
951 | |||
952 | AC_DEFUN([MHD_CHECK_DEFINED_MSG],[dnl | ||
953 | MHD_CHECK_DEFINED([$1],[$2],[$4],[$5],[$3])]) | ||
954 | |||
955 | # | ||
956 | # MHD_CHECK_ACCEPT_DEFINE(DEFINE-SYMBOL, [DEFINE-VALUE = 1], [PROLOG], | ||
957 | # [ACTION-IF-ACCEPTED], [ACTION-IF-NOT-ACCEPTED], | ||
958 | # [MESSAGE]) | ||
959 | # | ||
960 | # Cache-check whether specific defined symbol do not break basic headers. | ||
961 | |||
962 | AC_DEFUN([MHD_CHECK_ACCEPT_DEFINE], [dnl | ||
963 | AC_PREREQ([2.64])dnl for AS_VAR_PUSHDEF, AS_VAR_SET, m4_ifnblank | ||
964 | AS_VAR_PUSHDEF([mhd_cache_Var], | ||
965 | [mhd_cv_define_[]m4_tolower($1)_accepted[]m4_ifnblank([$2],[_[]$2])])dnl | ||
966 | AC_CACHE_CHECK([dnl | ||
967 | m4_ifnblank([$6],[$6],[whether headers accept $1[]m4_ifnblank([$2],[ with value $2])])], | ||
968 | [mhd_cache_Var], [dnl | ||
969 | MHD_CHECK_BASIC_HEADERS([ | ||
970 | m4_n([$3])[#define ]$1 m4_default_nblank([$2],[[1]])], | ||
971 | [mhd_cache_Var="yes"], [mhd_cache_Var="no"] | ||
972 | ) | ||
973 | ]) | ||
974 | _MHD_VAR_IF([mhd_cache_Var], [["yes"]], [$4], [$5]) | ||
975 | AS_VAR_POPDEF([mhd_cache_Var])dnl | ||
976 | ]) | ||
977 | |||
978 | |||
979 | # | ||
980 | # MHD_CHECK_DEF_AND_ACCEPT(DEFINE-SYMBOL, [DEFINE-VALUE = 1], [PROLOG], | ||
981 | # [ACTION-IF-DEFINED], | ||
982 | # [ACTION-IF-ACCEPTED], [ACTION-IF-NOT-ACCEPTED]) | ||
983 | # | ||
984 | # Combination of MHD_CHECK_DEFINED_ECHO and MHD_CHECK_ACCEPT_DEFINE. | ||
985 | # First check whether symbol is already defined and, if not defined, | ||
986 | # checks whether it can be defined. | ||
987 | |||
988 | AC_DEFUN([MHD_CHECK_DEF_AND_ACCEPT], [dnl | ||
989 | MHD_CHECK_DEFINED([$1], [$3], [$4], [dnl | ||
990 | MHD_CHECK_ACCEPT_DEFINE([$1], [$2], [$3], [$5], [$6])dnl | ||
991 | ])dnl | ||
992 | ]) | ||
993 | |||
994 | |||
995 | # | ||
996 | # _MHD_XOPEN_ADD([PROLOG]) | ||
997 | # | ||
998 | # Internal macro. Only to be used in MHD_SYS_EXT. | ||
999 | |||
1000 | AC_DEFUN([_MHD_XOPEN_ADD], [dnl | ||
1001 | MHD_CHECK_DEF_AND_ACCEPT([[_XOPEN_SOURCE_EXTENDED]], [], | ||
1002 | [[${mhd_mse_added_prolog}]m4_n([$1])], [], | ||
1003 | [dnl | ||
1004 | _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_SOURCE_EXTENDED]])dnl | ||
1005 | ], [dnl | ||
1006 | MHD_CHECK_DEFINED([[_XOPEN_VERSION]], | ||
1007 | [[${mhd_mse_added_prolog}]m4_n([$1])], [], | ||
1008 | [dnl | ||
1009 | AC_CACHE_CHECK([[for value of _XOPEN_VERSION accepted by headers]], | ||
1010 | [mhd_cv_define__xopen_version_accepted], [dnl | ||
1011 | MHD_CHECK_BASIC_HEADERS([ | ||
1012 | [${mhd_mse_added_prolog}]m4_n([$1]) | ||
1013 | [#define _XOPEN_VERSION 4]], | ||
1014 | [[mhd_cv_define__xopen_version_accepted="4"]], | ||
1015 | [ | ||
1016 | MHD_CHECK_BASIC_HEADERS([ | ||
1017 | [${mhd_mse_added_prolog}]m4_n([$1]) | ||
1018 | [#define _XOPEN_VERSION 3]], | ||
1019 | [[mhd_cv_define__xopen_version_accepted="3"]], | ||
1020 | [[mhd_cv_define__xopen_version_accepted="no"]] | ||
1021 | ) | ||
1022 | ]) | ||
1023 | ]) | ||
1024 | AS_VAR_IF([mhd_cv_define__xopen_version_accepted], [["no"]], | ||
1025 | [[:]], | ||
1026 | [dnl | ||
1027 | _MHD_SYS_EXT_ADD_FLAG([[_XOPEN_VERSION]], | ||
1028 | [[${mhd_cv_define__xopen_version_accepted}]]dnl | ||
1029 | ) | ||
1030 | ]) | ||
1031 | ]) | ||
1032 | ]) | ||
1033 | ]) | ||
1034 | |||