summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-11-05 09:16:14 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-11-05 09:16:14 -0700
commit644bea5c481365343e709d0f2ddbc553a6d8fc30 (patch)
tree8d33caebfc1e1427aa0d3b852b90022251843858
parentf476c0a09c0d0dd22d22f447cae9fa02eb560506 (diff)
downloadxorg-lib-libXfont-644bea5c481365343e709d0f2ddbc553a6d8fc30.tar.gz
Only link with libbsd if needed for reallocarray() or strlcat()
Avoid unnecessary library dependency when using a libc with these functions included Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--configure.ac12
1 files changed, 9 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 701f9fd..fe2f987 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,12 +50,18 @@ XORG_CHECK_SGML_DOCTOOLS(1.7)
# Checks for header files.
AC_CHECK_HEADERS([endian.h poll.h sys/poll.h])
-# Checks for library functions.
-PKG_CHECK_MODULES([LIBBSD], [libbsd-overlay], [
+# Checks for non-standard functions and fallback to libbsd if we can
+AC_LINK_IFELSE([AC_LANG_CALL([], [reallocarray])],
+ [TRY_LIBBSD="no"], [TRY_LIBBSD="yes"])
+AC_LINK_IFELSE([AC_LANG_CALL([], [strlcat])],
+ [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"
-], [:])
+], [:])])
+# Checks for library functions.
AC_CHECK_FUNCS([poll readlink strlcat])
AC_CONFIG_LIBOBJ_DIR([src/util])
AC_REPLACE_FUNCS([reallocarray realpath strlcat strlcpy])