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.

90 lines
3.1 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_SEARCH_LIBS([clock_gettime],[rt posix4])
  55. AC_CHECK_FUNC([clock_gettime])
  56. AC_SEARCH_LIBS([dl_iterate_phdr],[dl])
  57. AC_CHECK_FUNC([dl_iterate_phdr])
  58. ])
  59. AC_DEFUN([CHECK_VA_COPY], [
  60. AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
  61. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  62. #include <stdarg.h>
  63. va_list x,y;
  64. ]], [[ va_copy(x,y); ]])],
  65. [ ac_cv_have_va_copy="yes" ],
  66. [ ac_cv_have_va_copy="no"
  67. ])
  68. ])
  69. if test "x$ac_cv_have_va_copy" = "xyes" ; then
  70. AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
  71. fi
  72. AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
  73. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  74. #include <stdarg.h>
  75. va_list x,y;
  76. ]], [[ __va_copy(x,y); ]])],
  77. [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
  78. ])
  79. ])
  80. if test "x$ac_cv_have___va_copy" = "xyes" ; then
  81. AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
  82. fi
  83. ])