meson: detect getrandom in sys/random.h, fall back to linux/random.h
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 20 Apr 2017 01:20:54 +0000 (21:20 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 24 Apr 2017 01:47:29 +0000 (21:47 -0400)
This is analogous to commit e84397d95c3da2b9722ff265843ad4a8874643d8.

meson.build

index 52ef13d..df08545 100644 (file)
@@ -381,7 +381,6 @@ foreach ident : [
                                  #include <fcntl.h>'''],
         ['setns',             '''#define _GNU_SOURCE
                                  #include <sched.h>'''],
-        ['getrandom',         '''#include <sys/random.h>'''],
         ['renameat2',         '''#include <stdio.h>'''],
         ['kcmp',              '''#include <linux/kcmp.h>'''],
         ['keyctl',            '''#include <sys/types.h>
@@ -395,6 +394,14 @@ foreach ident : [
         conf.set10('HAVE_DECL_' + ident[0].to_upper(), have)
 endforeach
 
+if cc.has_function('getrandom', prefix : '''#include <sys/random.h>''')
+        conf.set('USE_SYS_RANDOM_H', 1)
+        conf.set10('HAVE_DECL_GETRANDOM', 1)
+else
+        have = cc.has_function('getrandom', prefix : '''#include <linux/random.h>''')
+        conf.set10('HAVE_DECL_GETRANDOM', have)
+endif
+
 #####################################################################
 
 sed = find_program('sed')