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