Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.2 KiB

  1. AC_DEFUN([CHECK_PROGNAME], [
  2. AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
  3. AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],
  4. [[ extern char *__progname; printf("%s", __progname); ]])],
  5. [ ac_cv_libc_defines___progname="yes" ],
  6. [ ac_cv_libc_defines___progname="no"
  7. ])
  8. ])
  9. if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
  10. AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname])
  11. fi
  12. ])
  13. AC_DEFUN([CHECK_SYSCALL_COMPAT], [
  14. AC_CHECK_FUNCS([accept4 pledge poll])
  15. AM_CONDITIONAL([HAVE_ACCEPT4], [test "x$ac_cv_func_accept4" = xyes])
  16. AM_CONDITIONAL([HAVE_PLEDGE], [test "x$ac_cv_func_pledge" = xyes])
  17. AM_CONDITIONAL([HAVE_POLL], [test "x$ac_cv_func_poll" = xyes])
  18. ])
  19. AC_DEFUN([CHECK_B64_NTOP], [
  20. AC_SEARCH_LIBS([b64_ntop],[resolv])
  21. AC_SEARCH_LIBS([__b64_ntop],[resolv])
  22. AC_CACHE_CHECK([for b64_ntop], ac_cv_have_b64_ntop_arg, [
  23. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  24. #include <sys/types.h>
  25. #include <sys/socket.h>
  26. #include <netinet/in.h>
  27. #include <arpa/inet.h>
  28. #include <resolv.h>
  29. ]], [[ b64_ntop(NULL, 0, NULL, 0); ]])],
  30. [ ac_cv_have_b64_ntop_arg="yes" ],
  31. [ ac_cv_have_b64_ntop_arg="no"
  32. ])
  33. ])
  34. AM_CONDITIONAL([HAVE_B64_NTOP], [test "x$ac_cv_func_b64_ntop_arg" = xyes])
  35. ])
  36. AC_DEFUN([CHECK_CRYPTO_COMPAT], [
  37. # Check crypto-related libc functions and syscalls
  38. AC_CHECK_FUNCS([arc4random arc4random_buf arc4random_uniform])
  39. AC_CHECK_FUNCS([explicit_bzero getauxval getentropy])
  40. AC_CHECK_FUNCS([timingsafe_bcmp timingsafe_memcmp])
  41. AM_CONDITIONAL([HAVE_ARC4RANDOM], [test "x$ac_cv_func_arc4random" = xyes])
  42. AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF], [test "x$ac_cv_func_arc4random_buf" = xyes])
  43. AM_CONDITIONAL([HAVE_ARC4RANDOM_UNIFORM], [test "x$ac_cv_func_arc4random_uniform" = xyes])
  44. AM_CONDITIONAL([HAVE_EXPLICIT_BZERO], [test "x$ac_cv_func_explicit_bzero" = xyes])
  45. AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = xyes])
  46. AM_CONDITIONAL([HAVE_TIMINGSAFE_BCMP], [test "x$ac_cv_func_timingsafe_bcmp" = xyes])
  47. AM_CONDITIONAL([HAVE_TIMINGSAFE_MEMCMP], [test "x$ac_cv_func_timingsafe_memcmp" = xyes])
  48. # Override arc4random_buf implementations with known issues
  49. AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF],
  50. [test "x$USE_BUILTIN_ARC4RANDOM" != yes \
  51. -a "x$ac_cv_func_arc4random_buf" = xyes])
  52. # Check for getentropy fallback dependencies
  53. AC_CHECK_FUNC([getauxval])
  54. AC_CHECK_FUNC([clock_gettime],, [AC_SEARCH_LIBS([clock_gettime],[rt posix4])])
  55. AC_CHECK_FUNC([dl_iterate_phdr],, [AC_SEARCH_LIBS([dl_iterate_phdr],[dl])])
  56. ])
  57. AC_DEFUN([CHECK_VA_COPY], [
  58. AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
  59. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  60. #include <stdarg.h>
  61. va_list x,y;
  62. ]], [[ va_copy(x,y); ]])],
  63. [ ac_cv_have_va_copy="yes" ],
  64. [ ac_cv_have_va_copy="no"
  65. ])
  66. ])
  67. if test "x$ac_cv_have_va_copy" = "xyes" ; then
  68. AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
  69. fi
  70. AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
  71. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  72. #include <stdarg.h>
  73. va_list x,y;
  74. ]], [[ __va_copy(x,y); ]])],
  75. [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
  76. ])
  77. ])
  78. if test "x$ac_cv_have___va_copy" = "xyes" ; then
  79. AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
  80. fi
  81. ])