diff --git a/configure.ac b/configure.ac index 60ea2c316..bebf08432 100644 --- a/configure.ac +++ b/configure.ac @@ -164,8 +164,16 @@ AC_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup\ timingsafe_memcmp]) AM_CONDITIONAL(POLL, [test "x$ac_cv_func_poll" = "xyes"]) -AC_CHECK_LIB([bsd], [arc4random_buf]) -AC_CHECK_FUNCS([arc4random_buf]) +# Checks for non-standard functions and fallback to libbsd if we can +# We only check for arc4random_buf, because if we have that, we don't +# need/use getentropy. +AC_LINK_IFELSE([AC_LANG_CALL([], [arc4random_buf])], + [TRY_LIBBSD="no"], [TRY_LIBBSD="yes"]) +AS_IF([test "x$TRY_LIBBSD" = "xyes"], + [PKG_CHECK_MODULES([LIBBSD], [libbsd-overlay], [ + CFLAGS="$CFLAGS $LIBBSD_CFLAGS" + LIBS="$LIBS $LIBBSD_LIBS" +], [:])]) AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include ]]) diff --git a/include/os.h b/include/os.h index bb3348b18..7db24088f 100644 --- a/include/os.h +++ b/include/os.h @@ -50,16 +50,13 @@ SOFTWARE. #include "misc.h" #include #include +#if defined(HAVE_REALLOCARRAY) +#include /* for reallocarray */ +#endif #include #ifdef MONOTONIC_CLOCK #include #endif -#if defined(HAVE_LIBBSD) && defined(HAVE_REALLOCARRAY) -#include /* for reallocarray */ -#endif -#if defined(HAVE_LIBBSD) && defined(HAVE_STRLCPY) -#include /* for strlcpy, strlcat */ -#endif #define SCREEN_SAVER_ON 0 #define SCREEN_SAVER_OFF 1 diff --git a/meson.build b/meson.build index 637938a1b..7174cb542 100644 --- a/meson.build +++ b/meson.build @@ -96,7 +96,7 @@ applewmproto_dep = dependency('applewmproto', version: '>= 1.4', fallback: ['xor xshmfence_dep = dependency('xshmfence', version: '>= 1.1', required: false) pixman_dep = dependency('pixman-1') -libbsd_dep = dependency('libbsd', required: false) +libbsd_dep = dependency('libbsd-overlay', required: false) xkbcomp_dep = dependency('xkbcomp', required: false) xkbfile_dep = dependency('xkbfile') xfont2_dep = dependency('xfont2', version: '>= 2.0') diff --git a/os/auth.c b/os/auth.c index 611e4efb1..243d3c5a8 100644 --- a/os/auth.c +++ b/os/auth.c @@ -46,9 +46,7 @@ from The Open Group. #ifdef WIN32 #include #endif -#ifdef HAVE_LIBBSD -#include /* for arc4random_buf() */ -#endif +#include /* for arc4random_buf() */ struct protocol { unsigned short name_length;