diff options
author | Brent Cook <busterb@gmail.com> | 2015-05-01 07:18:12 -0500 |
---|---|---|
committer | Brent Cook <busterb@gmail.com> | 2015-05-23 19:27:57 -0500 |
commit | d3771a41cb106c945e0f538073d0a6e7b35d145b (patch) | |
tree | 0ec81fcb0eae37fc7f1f89e2a7d1de26e54d35d2 /m4/check-libc.m4 | |
parent | 28353c1df15c3d0482a10ffe33fa34c053af2c2e (diff) | |
download | portable-d3771a41cb106c945e0f538073d0a6e7b35d145b.tar.gz portable-d3771a41cb106c945e0f538073d0a6e7b35d145b.tar.bz2 portable-d3771a41cb106c945e0f538073d0a6e7b35d145b.zip |
refactor configure into separate m4 macros
this allows for some reusability with libtls
Diffstat (limited to 'm4/check-libc.m4')
-rw-r--r-- | m4/check-libc.m4 | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/m4/check-libc.m4 b/m4/check-libc.m4 new file mode 100644 index 0000000..2bbfb81 --- /dev/null +++ b/m4/check-libc.m4 | |||
@@ -0,0 +1,65 @@ | |||
1 | AC_DEFUN([CHECK_LIBC_COMPAT], [ | ||
2 | # Check for general libc functions | ||
3 | AC_CHECK_FUNCS([asprintf memmem poll reallocarray]) | ||
4 | AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strsep strtonum]) | ||
5 | AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes]) | ||
6 | AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes]) | ||
7 | AM_CONDITIONAL([HAVE_POLL], [test "x$ac_cv_func_poll" = xyes]) | ||
8 | AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes]) | ||
9 | AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes]) | ||
10 | AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes]) | ||
11 | AM_CONDITIONAL([HAVE_STRNDUP], [test "x$ac_cv_func_strndup" = xyes]) | ||
12 | AM_CONDITIONAL([HAVE_STRNLEN], [test "x$ac_cv_func_strnlen" = xyes]) | ||
13 | AM_CONDITIONAL([HAVE_STRSEP], [test "x$ac_cv_func_strsep" = xyes]) | ||
14 | AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes]) | ||
15 | ]) | ||
16 | |||
17 | AC_DEFUN([CHECK_LIBC_CRYPTO_COMPAT], [ | ||
18 | # Check crypto-related libc functions | ||
19 | AC_CHECK_FUNCS([arc4random_buf explicit_bzero getauxval getentropy]) | ||
20 | AC_CHECK_FUNCS([timingsafe_bcmp timingsafe_memcmp]) | ||
21 | AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF], [test "x$ac_cv_func_arc4random_buf" = xyes]) | ||
22 | AM_CONDITIONAL([HAVE_EXPLICIT_BZERO], [test "x$ac_cv_func_explicit_bzero" = xyes]) | ||
23 | AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = xyes]) | ||
24 | AM_CONDITIONAL([HAVE_TIMINGSAFE_BCMP], [test "x$ac_cv_func_timingsafe_bcmp" = xyes]) | ||
25 | AM_CONDITIONAL([HAVE_TIMINGSAFE_MEMCMP], [test "x$ac_cv_func_timingsafe_memcmp" = xyes]) | ||
26 | |||
27 | # Override arc4random_buf implementations with known issues | ||
28 | AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF], | ||
29 | [test "x$HOST_OS" != xdarwin \ | ||
30 | -a "x$HOST_OS" != xfreebsd \ | ||
31 | -a "x$HOST_OS" != xnetbsd \ | ||
32 | -a "x$ac_cv_func_arc4random_buf" = xyes]) | ||
33 | |||
34 | # Check for getentropy fallback dependencies | ||
35 | AC_CHECK_FUNC([getauxval]) | ||
36 | AC_CHECK_FUNC([clock_gettime],, [AC_SEARCH_LIBS([clock_gettime],[rt posix4])]) | ||
37 | AC_CHECK_FUNC([dl_iterate_phdr],, [AC_SEARCH_LIBS([dl_iterate_phdr],[dl])]) | ||
38 | ]) | ||
39 | |||
40 | AC_DEFUN([CHECK_VA_COPY], [ | ||
41 | AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [ | ||
42 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | ||
43 | #include <stdarg.h> | ||
44 | va_list x,y; | ||
45 | ]], [[ va_copy(x,y); ]])], | ||
46 | [ ac_cv_have_va_copy="yes" ], | ||
47 | [ ac_cv_have_va_copy="no" | ||
48 | ]) | ||
49 | ]) | ||
50 | if test "x$ac_cv_have_va_copy" = "xyes" ; then | ||
51 | AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists]) | ||
52 | fi | ||
53 | |||
54 | AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [ | ||
55 | AC_LINK_IFELSE([AC_LANG_PROGRAM([[ | ||
56 | #include <stdarg.h> | ||
57 | va_list x,y; | ||
58 | ]], [[ __va_copy(x,y); ]])], | ||
59 | [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no" | ||
60 | ]) | ||
61 | ]) | ||
62 | if test "x$ac_cv_have___va_copy" = "xyes" ; then | ||
63 | AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists]) | ||
64 | fi | ||
65 | ]) | ||