xwayland: Fix build without <sys/random.h>

The include <sys/random.h> was added to glibc-2.25, previously was
<linux/random.h>.

Adjust meson build and code to accomodate both.

Fixes: a8984a81c "xwayland: Generate a Xauth file and pass this to
                  Xwayland when starting it"

https://gitlab.gnome.org/GNOME/mutter/merge_requests/633
This commit is contained in:
Olivier Fourdan 2019-06-20 12:11:29 +02:00
parent 7fcdd60ac5
commit c63d0173b5
3 changed files with 16 additions and 2 deletions

View File

@ -61,5 +61,6 @@
/* XKB base prefix */
#mesondefine XKB_BASE
/* Default rules for allowing Xwayland grabs */
#mesondefine XWAYLAND_GRAB_DEFAULT_ACCESS_RULES
/* Either <sys/random.h> or <linux/random.h> */
#mesondefine HAVE_SYS_RANDOM
#mesondefine HAVE_LINUX_RANDOM

View File

@ -364,6 +364,15 @@ if have_wayland
xwayland_path = find_program('Xwayland').path()
endif
cdata.set_quoted('XWAYLAND_PATH', xwayland_path)
# For Xwayland authority file generation.
if cc.has_header_symbol('sys/random.h', 'getrandom')
cdata.set('HAVE_SYS_RANDOM', 1)
elif cc.has_header_symbol('linux/random.h', 'getrandom')
cdata.set('HAVE_LINUX_RANDOM', 1)
else
error('Required function getrandom not found')
endif
endif
xwayland_grab_default_access_rules = get_option('xwayland_grab_default_access_rules')

View File

@ -31,7 +31,11 @@
#include <glib.h>
#include <sys/socket.h>
#include <sys/un.h>
#if defined(HAVE_SYS_RANDOM)
#include <sys/random.h>
#elif defined(HAVE_LINUX_RANDOM)
#include <linux/random.h>
#endif
#include <unistd.h>
#include <X11/Xauth.h>