diff options
Diffstat (limited to 'm4')
-rw-r--r-- | m4/mhd_check_func.m4 | 96 |
1 files changed, 55 insertions, 41 deletions
diff --git a/m4/mhd_check_func.m4 b/m4/mhd_check_func.m4 index 502a9b15..77e6baca 100644 --- a/m4/mhd_check_func.m4 +++ b/m4/mhd_check_func.m4 | |||
@@ -9,13 +9,15 @@ | |||
9 | # | 9 | # |
10 | # This macro checks for presence of specific function by including | 10 | # This macro checks for presence of specific function by including |
11 | # specified headers and compiling and linking CHECK_CODE. | 11 | # specified headers and compiling and linking CHECK_CODE. |
12 | # This check both declaration and presence in library. | 12 | # This checks both declaration and presence in library. |
13 | # If function is available then macro HAVE_function_name (the name | ||
14 | # of the function convetedd to all uppercase characters) is defined | ||
15 | # automatically. | ||
13 | # Unlike AC_CHECK_FUNCS macro, this macro do not produce false | 16 | # Unlike AC_CHECK_FUNCS macro, this macro do not produce false |
14 | # negative result if function is declared with specific calling | 17 | # negative result if function is declared with specific calling |
15 | # conventions like __stdcall' or attribute like | 18 | # conventions like __stdcall' or attribute like |
16 | # __attribute__((__dllimport__)) and linker failed to build test | 19 | # __attribute__((__dllimport__)) and linker failing to build test |
17 | # program if library contains function with calling conventions | 20 | # program due to the different calling conventions. |
18 | # different from declared. | ||
19 | # By using definition from provided headers, this macro ensures that | 21 | # By using definition from provided headers, this macro ensures that |
20 | # correct calling convention is used for detection. | 22 | # correct calling convention is used for detection. |
21 | # | 23 | # |
@@ -26,13 +28,13 @@ | |||
26 | # [const void *ptr = memmem("aa", 2, "a", 1); (void)ptr;], | 28 | # [const void *ptr = memmem("aa", 2, "a", 1); (void)ptr;], |
27 | # [var_use_memmem='yes'], [var_use_memmem='no']) | 29 | # [var_use_memmem='yes'], [var_use_memmem='no']) |
28 | # | 30 | # |
29 | # Defined cache variable used in check so if any test will not work | 31 | # The 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 | 32 | # correctly on some platform, user may simply fix it by giving cache |
31 | # variable in configure parameters, for example: | 33 | # variable in configure parameters, for example: |
32 | # | 34 | # |
33 | # ./configure mhd_cv_func_memmem_have=no | 35 | # ./configure mhd_cv_func_memmem_have=no |
34 | # | 36 | # |
35 | # This simplify building from source on exotic platforms as patching | 37 | # This simplifies building from source on exotic platforms as patching |
36 | # of configure.ac is not required to change results of tests. | 38 | # of configure.ac is not required to change results of tests. |
37 | # | 39 | # |
38 | # LICENSE | 40 | # LICENSE |
@@ -44,47 +46,59 @@ | |||
44 | # and this notice are preserved. This file is offered as-is, without any | 46 | # and this notice are preserved. This file is offered as-is, without any |
45 | # warranty. | 47 | # warranty. |
46 | 48 | ||
47 | #serial 4 | 49 | #serial 5 |
48 | 50 | ||
49 | AC_DEFUN([MHD_CHECK_FUNC],[dnl | 51 | AC_DEFUN([MHD_CHECK_FUNC],[dnl |
50 | AC_PREREQ([2.64])dnl for AS_VAR_IF, m4_ifblank, m4_ifnblank | 52 | 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 | 53 | m4_newline([[# Expansion of $0 macro starts here]]) |
52 | m4_ifblank([$3], [m4_fatal([Third macro argument must not be empty])])dnl | 54 | AC_LANG_ASSERT([C])dnl |
53 | m4_bmatch(m4_normalize([$1]), [\s],dnl | 55 | m4_ifblank(m4_translit([$1],[()],[ ]), [m4_fatal([First macro argument must not be empty])])dnl |
54 | [m4_fatal([First macro argument must not contain whitespaces])])dnl | 56 | m4_ifblank([$3], [m4_fatal([Third macro argument must not be empty])])dnl |
55 | m4_if(m4_index([$3], m4_normalize(m4_translit([$1],[()],[ ]))), [-1], dnl | 57 | m4_bmatch(m4_normalize([$1]), [\s],dnl |
56 | [m4_fatal([CHECK_CODE parameter (third macro argument) does not contain ']m4_normalize([$1])[' token])])dnl | 58 | [m4_fatal([First macro argument must not contain whitespaces])])dnl |
57 | AS_VAR_PUSHDEF([cv_Var], [mhd_cv_func_]m4_bpatsubst(_mhd_norm_expd(m4_translit([$1],[()],[ ])),[[^a-zA-Z0-9]],[_]))dnl | 59 | m4_if(m4_index([$3], m4_normalize(m4_translit([$1],[()],[ ]))), [-1], dnl |
58 | dnl | 60 | [m4_fatal([CHECK_CODE parameter (third macro argument) does not contain ']m4_normalize([$1])[' token])])dnl |
59 | AC_CACHE_CHECK([for function $1], cv_Var, | 61 | AS_VAR_PUSHDEF([decl_cv_Var],[ac_cv_have_decl_]m4_bpatsubst(_mhd_norm_expd(m4_translit([$1],[()],[ ])),[[^a-zA-Z0-9]],[_]))dnl |
60 | [dnl | 62 | AS_VAR_PUSHDEF([cv_Var],[mhd_cv_func_]m4_bpatsubst(_mhd_norm_expd(m4_translit([$1],[()],[ ])),[[^a-zA-Z0-9]],[_]))dnl |
61 | m4_ifnblank([$6],[dnl | 63 | AS_VAR_SET_IF([cv_Var],[],[AC_CHECK_DECL(_mhd_norm_expd([$1]),[],[],[$2])]) |
62 | mhd_check_func_SAVE_LIBS="$LIBS" | 64 | AC_CACHE_CHECK([for function $1], [cv_Var],dnl |
63 | LIBS="$LIBS _mhd_norm_expd([$6])" | 65 | [dnl |
64 | ])dnl | 66 | AS_VAR_IF([decl_cv_Var],["yes"],dnl |
65 | AC_LINK_IFELSE( | 67 | [dnl |
66 | [AC_LANG_SOURCE([ | 68 | m4_ifnblank([$6],[dnl |
69 | mhd_check_func_SAVE_LIBS="$LIBS" | ||
70 | LIBS="_mhd_norm_expd([$6]) $LIBS" | ||
71 | ])dnl | ||
72 | AC_LINK_IFELSE( | ||
73 | [AC_LANG_SOURCE([ | ||
67 | m4_default_nblank([$2],[AC_INCLUDES_DEFAULT]) | 74 | m4_default_nblank([$2],[AC_INCLUDES_DEFAULT]) |
68 | 75 | ||
69 | int main(void) | 76 | [int main(void) |
70 | { | 77 | { |
71 | 78 | ||
72 | $3 | 79 | ]$3[ |
73 | 80 | ||
74 | return 0; | 81 | return 0; |
75 | } | 82 | } |
76 | ]) | 83 | ]]) |
77 | ], | 84 | ], |
78 | [AS_VAR_SET([cv_Var],["yes"])], [AS_VAR_SET([cv_Var],["no"])] ) | 85 | [AS_VAR_SET([cv_Var],["yes"])], |
79 | m4_ifnblank([$6],[dnl | 86 | [AS_VAR_SET([cv_Var],["no"])]dnl |
80 | LIBS="${mhd_check_func_SAVE_LIBS}" | 87 | ) |
81 | AS_UNSET([mhd_check_func_SAVE_LIBS]) | 88 | m4_ifnblank([$6],[dnl |
82 | ])dnl | 89 | LIBS="${mhd_check_func_SAVE_LIBS}" |
83 | ]) | 90 | AS_UNSET([mhd_check_func_SAVE_LIBS]) |
84 | AS_VAR_IF([cv_Var], ["yes"], | 91 | ])dnl |
85 | [AC_DEFINE([[HAVE_]]m4_bpatsubst(m4_toupper(_mhd_norm_expd(m4_translit([$1],[()],[ ]))),[[^A-Z0-9]],[_]), | 92 | ],[AS_VAR_SET([cv_Var],["no"])]dnl |
86 | [1], [Define to 1 if you have the ']_mhd_norm_expd(m4_translit([$1],[()],[ ]))[' function.]) | 93 | )dnl |
87 | m4_n([$4])dnl | 94 | ]dnl |
88 | ], [$5]) | 95 | ) |
89 | AS_VAR_POPDEF([cv_Var])dnl | 96 | AS_VAR_IF([cv_Var], ["yes"], |
90 | ]) | 97 | [AC_DEFINE([[HAVE_]]m4_bpatsubst(m4_toupper(_mhd_norm_expd(m4_translit([$1],[()],[ ]))),[[^A-Z0-9]],[_]), |
98 | [1], [Define to 1 if you have the ']_mhd_norm_expd(m4_translit([$1],[()],[ ]))[' function.]) | ||
99 | m4_n([$4])dnl | ||
100 | ],[$5]) | ||
101 | AS_VAR_POPDEF([cv_Var])dnl | ||
102 | AS_VAR_POPDEF([decl_cv_Var])dnl | ||
103 | m4_newline([[# Expansion of $0 macro ends here]]) | ||
104 | ])dnl AC_DEFUN MHD_CHECK_FUNC | ||