build: Fix errors with glibc < 2.25
authorFabrice Fontaine <fontaine.fabrice@gmail.com>
Mon, 14 Feb 2022 20:17:39 +0000 (21:17 +0100)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:53 +0000 (14:55 +0530)
commit2436aa412a6214421588e646b79c6df4fd241065
tree3aae587111e7888c6478c43beb55b15efc5ee14c
parent0823adc49ca4f17af369f60b96e3fa2ec07377d6
build: Fix errors with glibc < 2.25

getrandom and sys/random.h are only available since glibc 2.25:
https://www.gnu.org/software/gnulib/manual/html_node/sys_002frandom_002eh.html
resulting in the following build failures since version 5.63 and
https://git.kernel.org/pub/scm/bluetooth/bluez.git/log/?qt=grep&q=getrandom:

plugins/autopair.c:20:24: fatal error: sys/random.h: No such file or directory
 #include <sys/random.h>
                        ^

To fix this build failure, add util_getrandom and a fallback (borrowed
from pipewire and licensed under MIT):
https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/src/pipewire/utils.c

Fixes:
 - http://autobuild.buildroot.org/results/6b8870d12e0804d6154230a7322c49416c1dc0e2
Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
configure.ac
emulator/le.c
emulator/phy.c
peripheral/main.c
plugins/autopair.c
profiles/health/hdp.c
profiles/health/mcap.c
src/shared/util.c
src/shared/util.h
tools/btgatt-server.c