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
committerSimone Basso <bassosimone@gmail.com>2016-12-10 20:58:04 +0100
commita206997ad9b7ebd4bb383b10212f02e26f924e56 (patch)
tree6162707ac972ff2d4092d6242e1b55087c85b5b3 /m4/check-os-options.m4
parent6fa2d21ba57b83c6148a8aa03a362ca9e771fe21 (diff)
downloadportable-a206997ad9b7ebd4bb383b10212f02e26f924e56.tar.gz
portable-a206997ad9b7ebd4bb383b10212f02e26f924e56.tar.bz2
portable-a206997ad9b7ebd4bb383b10212f02e26f924e56.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.m427
1 files changed, 26 insertions, 1 deletions
diff --git a/m4/check-os-options.m4 b/m4/check-os-options.m4
index ed7320a..1a7b940 100644
--- a/m4/check-os-options.m4
+++ b/m4/check-os-options.m4
@@ -17,18 +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
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 #
23 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
36#include <AvailabilityMacros.h>
24#include <unistd.h> 37#include <unistd.h>
25#include <sys/random.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
26 ]], [[ 49 ]], [[
27char buf[1]; getentropy(buf, 1); 50char buf[1]; getentropy(buf, 1);
28 ]])], 51 ]])],
29 [ USE_BUILTIN_ARC4RANDOM=no ], 52 [ USE_BUILTIN_ARC4RANDOM=no ],
30 [ USE_BUILTIN_ARC4RANDOM=yes ] 53 [ USE_BUILTIN_ARC4RANDOM=yes ]
31 ) 54 )
55 AC_MSG_CHECKING([whether to use builtin arc4random])
56 AC_MSG_RESULT([$USE_BUILTIN_ARC4RANDOM])
32 # Not available on iOS 57 # Not available on iOS
33 AC_CHECK_HEADER([arpa/telnet.h], [], [BUILD_NC=no]) 58 AC_CHECK_HEADER([arpa/telnet.h], [], [BUILD_NC=no])
34 ;; 59 ;;