tests: fix 'invalid path dir' error
[gnulib.git] / m4 / gc-random.m4
blobbb04939498d014ea6d2ad6ef6e1e84fcb07257db
1 # gc-random.m4 serial 6
2 dnl Copyright (C) 2005-2017 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.
7 AC_DEFUN([gl_GC_RANDOM],
9   # Devices with randomness.
10   # FIXME: Are these the best defaults?
12   AC_REQUIRE([AC_CANONICAL_HOST])dnl
14   case "$host_os" in
15     *openbsd* | *mirbsd*)
16       NAME_OF_RANDOM_DEVICE="/dev/srandom"
17       NAME_OF_PSEUDO_RANDOM_DEVICE="/dev/prandom"
18       NAME_OF_NONCE_DEVICE="/dev/urandom"
19       ;;
21     *netbsd*)
22       NAME_OF_RANDOM_DEVICE="/dev/srandom"
23       NAME_OF_PSEUDO_RANDOM_DEVICE="/dev/urandom"
24       NAME_OF_NONCE_DEVICE="/dev/urandom"
25       ;;
27     *solaris* | *irix* | *dec-osf* )
28       NAME_OF_RANDOM_DEVICE="/dev/random"
29       NAME_OF_PSEUDO_RANDOM_DEVICE="/dev/random"
30       NAME_OF_NONCE_DEVICE="/dev/random"
31       ;;
33     *)
34       NAME_OF_RANDOM_DEVICE="/dev/random"
35       NAME_OF_PSEUDO_RANDOM_DEVICE="/dev/urandom"
36       NAME_OF_NONCE_DEVICE="/dev/urandom"
37       ;;
38   esac
40   AC_MSG_CHECKING([device with (strong) random data...])
41   AC_ARG_ENABLE([random-device],
42         AS_HELP_STRING([--enable-random-device],
43                 [device with (strong) randomness (for Nettle)]),
44         NAME_OF_RANDOM_DEVICE=$enableval)
45   AC_MSG_RESULT([$NAME_OF_RANDOM_DEVICE])
47   AC_MSG_CHECKING([device with pseudo random data...])
48   AC_ARG_ENABLE([pseudo-random-device],
49         AS_HELP_STRING([--enable-pseudo-random-device],
50                 [device with pseudo randomness (for Nettle)]),
51         NAME_OF_PSEUDO_RANDOM_DEVICE=$enableval)
52   AC_MSG_RESULT([$NAME_OF_PSEUDO_RANDOM_DEVICE])
54   AC_MSG_CHECKING([device with unpredictable data for nonces...])
55   AC_ARG_ENABLE([nonce-device],
56         AS_HELP_STRING([--enable-nonce-device],
57                 [device with unpredictable nonces (for Nettle)]),
58         NAME_OF_NONCE_DEVICE=$enableval)
59   AC_MSG_RESULT([$NAME_OF_NONCE_DEVICE])
61   if test "$cross_compiling" != yes; then
62     if test "$NAME_OF_RANDOM_DEVICE" != "no"; then
63       AC_CHECK_FILE([$NAME_OF_RANDOM_DEVICE],,
64         AC_MSG_WARN([[Device '$NAME_OF_RANDOM_DEVICE' does not exist, consider to use --enable-random-device]]))
65     fi
66     if test "$NAME_OF_PSEUDO_RANDOM_DEVICE" != "no"; then
67       AC_CHECK_FILE([$NAME_OF_PSEUDO_RANDOM_DEVICE],,
68         AC_MSG_WARN([[Device '$NAME_OF_PSEUDO_RANDOM_DEVICE' does not exist, consider to use --enable-pseudo-random-device]]))
69     fi
70     if test "$NAME_OF_NONCE_DEVICE" != "no"; then
71       AC_CHECK_FILE([$NAME_OF_NONCE_DEVICE],,
72         AC_MSG_WARN([[Device '$NAME_OF_NONCE_DEVICE' does not exist, consider to use --enable-nonce-device]]))
73     fi
74   else
75     AC_MSG_NOTICE([[Cross compiling, assuming random devices exists on the target host...]])
76   fi
78   # FIXME?: Open+read 42 bytes+close twice and compare data.  Should differ.
80   AC_DEFINE_UNQUOTED([NAME_OF_RANDOM_DEVICE], ["$NAME_OF_RANDOM_DEVICE"],
81                    [defined to the name of the (strong) random device])
82   AC_DEFINE_UNQUOTED([NAME_OF_PSEUDO_RANDOM_DEVICE],
83                          "$NAME_OF_PSEUDO_RANDOM_DEVICE",
84                    [defined to the name of the pseudo random device])
85   AC_DEFINE_UNQUOTED([NAME_OF_NONCE_DEVICE], ["$NAME_OF_NONCE_DEVICE"],
86                    [defined to the name of the unpredictable nonce device])