diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2019-05-30 23:32:09 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2019-06-01 19:19:25 +0300 |
commit | 2db0eabd118370fd2937bd9021ade9b0e40473fa (patch) | |
tree | 480e21fbc818471dea52e642e1c8611b5c347e66 /m4 | |
parent | 2a59d367d6ff2be09d5cc952f3ece82517062702 (diff) | |
download | libmicrohttpd-2db0eabd118370fd2937bd9021ade9b0e40473fa.tar.gz libmicrohttpd-2db0eabd118370fd2937bd9021ade9b0e40473fa.zip |
configure: fixed detection of 'getsockname' on some systems (W32 x32),
do not use 'getsockname()' if it is not detected by configure.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/mhd_check_func.m4 | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/m4/mhd_check_func.m4 b/m4/mhd_check_func.m4 new file mode 100644 index 00000000..983d0306 --- /dev/null +++ b/m4/mhd_check_func.m4 | |||
@@ -0,0 +1,80 @@ | |||
1 | # SYNOPSIS | ||
2 | # | ||
3 | # MHD_CHECK_FUNC([FUNCTION_NAME], | ||
4 | # [INCLUDES=AC_INCLUDES_DEFAULT], [CHECK_CODE], | ||
5 | # [ACTION-IF-AVAILABLE], [ACTION-IF-NOT-AVAILABLE], | ||
6 | # [ADDITIONAL_LIBS]) | ||
7 | # | ||
8 | # DESCRIPTION | ||
9 | # | ||
10 | # This macro checks for presence of specific function by including | ||
11 | # specified headers and compiling and linking CHECK_CODE. | ||
12 | # This check both declaration and presence in library. | ||
13 | # Unlike AC_CHECK_FUNCS macro, this macro do not produce false | ||
14 | # negative result if function is declared with specific calling | ||
15 | # conventions like __stdcall' or attribute like | ||
16 | # __attribute__((__dllimport__)) and linker failed to build test | ||
17 | # program if library contains function with calling conventions | ||
18 | # different from declared. | ||
19 | # By using definition from provided headers, this macro ensures that | ||
20 | # correct calling convention is used for detection. | ||
21 | # | ||
22 | # Example usage: | ||
23 | # | ||
24 | # MHD_CHECK_FUNC([memmem], | ||
25 | # [[#include <string.h>]], | ||
26 | # [const void *ptr = memmem("aa", 2, "a", 1); (void)ptr;], | ||
27 | # [var_use_memmem='yes'], [var_use_memmem='no']) | ||
28 | # | ||
29 | # Defined cache variable used in check so if any test will not work | ||
30 | # correctly on some platform, user may simply fix it by giving cache | ||
31 | # variable in configure parameters, for example: | ||
32 | # | ||
33 | # ./configure mhd_cv_func_memmem_have=no | ||
34 | # | ||
35 | # This simplify building from source on exotic platforms as patching | ||
36 | # of configure.ac is not required to change results of tests. | ||
37 | # | ||
38 | # LICENSE | ||
39 | # | ||
40 | # Copyright (c) 2019 Karlson2k (Evgeny Grin) <k2k@narod.ru> | ||
41 | # | ||
42 | # Copying and distribution of this file, with or without modification, are | ||
43 | # permitted in any medium without royalty provided the copyright notice | ||
44 | # and this notice are preserved. This file is offered as-is, without any | ||
45 | # warranty. | ||
46 | |||
47 | #serial 1 | ||
48 | |||
49 | AC_DEFUN([MHD_CHECK_FUNC],[dnl | ||
50 | AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifblank, m4_ifnblank | ||
51 | m4_ifblank(m4_translit([$1],[()],[ ]), [m4_fatal([First macro argument must not be empty])])dnl | ||
52 | m4_ifblank([$3], [m4_fatal([Third macro argument must not be empty])])dnl | ||
53 | m4_bmatch(m4_normalize([$1]), [\s],dnl | ||
54 | [m4_fatal([First macro argument must not contain whitespaces])])dnl | ||
55 | m4_if(m4_index([$3], m4_normalize(m4_translit([$1],[()],[ ]))), [-1], dnl | ||
56 | [m4_fatal([CHECK_CODE parameter (third macro argument) do not contain ']m4_normalize([$1])[' token])])dnl | ||
57 | AS_VAR_PUSHDEF([cv_Var], [mhd_cv_func_]m4_bpatsubst(m4_normalize(m4_translit([$1],[()],[ ])),[[^a-zA-Z0-9]],[_]))dnl | ||
58 | dnl | ||
59 | AC_CACHE_CHECK([for function $1], [cv_Var], | ||
60 | [dnl | ||
61 | m4_ifnblank([$6],[dnl | ||
62 | mhd_check_func_SAVE_LIBS="$LIBS" | ||
63 | LIBS="$LIBS m4_normalize([$6])" | ||
64 | ])dnl | ||
65 | AC_LINK_IFELSE( | ||
66 | [AC_LANG_PROGRAM([m4_default_nblank([$2],[AC_INCLUDES_DEFAULT])], [$3]) ], | ||
67 | [AS_VAR_SET([cv_Var],["yes"])], [AS_VAR_SET([cv_Var],["no"])] ) | ||
68 | m4_ifnblank([$6],[dnl | ||
69 | LIBS="${mhd_check_func_SAVE_LIBS}" | ||
70 | AS_UNSET([mhd_check_func_SAVE_LIBS]) | ||
71 | ])dnl | ||
72 | ]) | ||
73 | AS_VAR_IF([cv_Var], ["yes"], | ||
74 | [AC_DEFINE([[HAVE_]]m4_bpatsubst(m4_toupper(m4_normalize(m4_translit([$1],[()],[ ]))),[[^A-Z0-9]],[_]), | ||
75 | [1], [Define to 1 if you have the `]m4_normalize(m4_translit([$1],[()],[ ]))[' function.]) | ||
76 | m4_n([$4])dnl | ||
77 | ], [$5]) | ||
78 | AS_VAR_POPDEF([cv_Var])dnl | ||
79 | ]) | ||
80 | |||