sys_random_h.m4 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # sys_random_h.m4 serial 8
  2. dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. AC_DEFUN_ONCE([gl_SYS_RANDOM_H],
  7. [
  8. AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS])
  9. dnl <sys/random.h> is always overridden, because of GNULIB_POSIXCHECK.
  10. gl_CHECK_NEXT_HEADERS([sys/random.h])
  11. if test $ac_cv_header_sys_random_h = yes; then
  12. HAVE_SYS_RANDOM_H=1
  13. else
  14. HAVE_SYS_RANDOM_H=0
  15. fi
  16. AC_SUBST([HAVE_SYS_RANDOM_H])
  17. m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])])
  18. if test $ac_cv_header_sys_random_h = yes; then
  19. UNISTD_H_HAVE_SYS_RANDOM_H=1
  20. fi
  21. dnl Check for declarations of anything we want to poison if the
  22. dnl corresponding gnulib module is not in use.
  23. gl_WARN_ON_USE_PREPARE([[
  24. #if HAVE_SYS_RANDOM_H
  25. /* Additional includes are needed before <sys/random.h> on uClibc
  26. and Mac OS X. */
  27. # include <sys/types.h>
  28. # include <stdlib.h>
  29. # include <sys/random.h>
  30. #endif
  31. ]],
  32. [getrandom])
  33. ])
  34. # gl_SYS_RANDOM_MODULE_INDICATOR([modulename])
  35. # sets the shell variable that indicates the presence of the given module
  36. # to a C preprocessor expression that will evaluate to 1.
  37. # This macro invocation must not occur in macros that are AC_REQUIREd.
  38. AC_DEFUN([gl_SYS_RANDOM_MODULE_INDICATOR],
  39. [
  40. dnl Ensure to expand the default settings once only.
  41. gl_SYS_RANDOM_H_REQUIRE_DEFAULTS
  42. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  43. dnl Define it also as a C macro, for the benefit of the unit tests.
  44. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  45. ])
  46. # Initializes the default values for AC_SUBSTed shell variables.
  47. # This macro must not be AC_REQUIREd. It must only be invoked, and only
  48. # outside of macros or in macros that are not AC_REQUIREd.
  49. AC_DEFUN([gl_SYS_RANDOM_H_REQUIRE_DEFAULTS],
  50. [
  51. m4_defun(GL_MODULE_INDICATOR_PREFIX[_SYS_RANDOM_H_MODULE_INDICATOR_DEFAULTS], [
  52. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETRANDOM])
  53. ])
  54. m4_require(GL_MODULE_INDICATOR_PREFIX[_SYS_RANDOM_H_MODULE_INDICATOR_DEFAULTS])
  55. AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS])
  56. ])
  57. AC_DEFUN([gl_SYS_RANDOM_H_DEFAULTS],
  58. [
  59. dnl Assume proper GNU behavior unless another module says otherwise.
  60. HAVE_GETRANDOM=1; AC_SUBST([HAVE_GETRANDOM])
  61. REPLACE_GETRANDOM=0; AC_SUBST([REPLACE_GETRANDOM])
  62. ])