aboutsummaryrefslogtreecommitdiff
path: root/m4/check-os-options.m4
diff options
context:
space:
mode:
authorSimone Basso <bassosimone@gmail.com>2016-12-10 20:58:04 +0100
committerBrent Cook <bcook@openbsd.org>2017-01-07 07:21:47 -0600
commit730f199c9c461fe2c94318138e6d316ee59f5a9f (patch)
tree4c229ca7f77398884827037a36c96567501892b3 /m4/check-os-options.m4
parentc4ee1a6fca8ce7c46e90fe8dcf856131e03bcb0b (diff)
downloadportable-730f199c9c461fe2c94318138e6d316ee59f5a9f.tar.gz
portable-730f199c9c461fe2c94318138e6d316ee59f5a9f.tar.bz2
portable-730f199c9c461fe2c94318138e6d316ee59f5a9f.zip
Sync getentropy() checks with use-builtin-arc4random checks
Without this, we actually fail to build a library that includes the bultin getentropy when compiling for 10.11 on 10.12.
Diffstat (limited to 'm4/check-os-options.m4')
-rw-r--r--m4/check-os-options.m435
1 files changed, 34 insertions, 1 deletions
diff --git a/m4/check-os-options.m4 b/m4/check-os-options.m4
index f2ff57f..1a7b940 100644
--- a/m4/check-os-options.m4
+++ b/m4/check-os-options.m4
@@ -17,10 +17,43 @@ case $host_os in
17 *darwin*) 17 *darwin*)
18 HOST_OS=darwin 18 HOST_OS=darwin
19 HOST_ABI=macosx 19 HOST_ABI=macosx
20 #
21 # Don't use arc4random on systems before 10.12 because of
20 # weak seed on failure to open /dev/random, based on latest 22 # weak seed on failure to open /dev/random, based on latest
21 # public source: 23 # public source:
22 # http://www.opensource.apple.com/source/Libc/Libc-997.90.3/gen/FreeBSD/arc4random.c 24 # http://www.opensource.apple.com/source/Libc/Libc-997.90.3/gen/FreeBSD/arc4random.c
23 USE_BUILTIN_ARC4RANDOM=yes 25 #
26 # We use the presence of getentropy() to detect 10.12. The
27 # following check take into account that:
28 #
29 # - iOS <= 10.1 fails because of missing getentropy and
30 # hence they miss sys/random.h
31 #
32 # - in macOS 10.12 getentropy is not tagged as introduced in
33 # 10.12 so we cannot use it for target < 10.12
34 #
35 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
36#include <AvailabilityMacros.h>
37#include <unistd.h>
38#include <sys/random.h> /* Systems without getentropy() should die here */
39
40/* Based on: https://gitweb.torproject.org/tor.git/commit/?id=16fcbd21 */
41#ifndef MAC_OS_X_VERSION_10_12
42# define MAC_OS_X_VERSION_10_12 101200
43#endif
44#if defined(MAC_OS_X_VERSION_MIN_REQUIRED)
45# if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12
46# error "Running on Mac OSX 10.11 or earlier"
47# endif
48#endif
49 ]], [[
50char buf[1]; getentropy(buf, 1);
51 ]])],
52 [ USE_BUILTIN_ARC4RANDOM=no ],
53 [ USE_BUILTIN_ARC4RANDOM=yes ]
54 )
55 AC_MSG_CHECKING([whether to use builtin arc4random])
56 AC_MSG_RESULT([$USE_BUILTIN_ARC4RANDOM])
24 # Not available on iOS 57 # Not available on iOS
25 AC_CHECK_HEADER([arpa/telnet.h], [], [BUILD_NC=no]) 58 AC_CHECK_HEADER([arpa/telnet.h], [], [BUILD_NC=no])
26 ;; 59 ;;