From b7ce33cf5191b99b5edcb0cde3fa5a4950cbe451 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 12 Feb 2016 22:56:09 +0100 Subject: [PATCH] build: Support clock_gettime() provided in librt In older glibc versions (< 2.17) clock_gettime() is in librt. Add a check for this to avoid build breakage for programs/libraries that use libbsd on such systems. Based-on-patch-by: Gustavo Zacarias Signed-off-by: Guillem Jover --- configure.ac | 10 ++++++++++ src/Makefile.am | 2 ++ 2 files changed, 12 insertions(+) diff --git a/configure.ac b/configure.ac index d334774..fe45b5c 100644 --- a/configure.ac +++ b/configure.ac @@ -44,6 +44,16 @@ AC_SUBST([TESTU01_LIBS]) AM_CONDITIONAL([HAVE_LIBTESTU01], [test "x$ac_cv_lib_testu01_unif01_CreateExternGenBits" = "xyes"]) +# In old glibc versions (< 2.17) clock_gettime() is in librt. +AS_CASE([$host_os], + [*-gnu], [ + saved_LIBS="$LIBS" + AC_SEARCH_LIBS([clock_gettime], [rt], [CLOCK_GETTIME_LIBS="-lrt"]) + AC_SUBST([CLOCK_GETTIME_LIBS]) + LIBS="$saved_LIBS" + ] +) + # Checks for header files. AC_CHECK_HEADERS([sys/ndir.h sys/dir.h ndir.h dirent.h]) diff --git a/src/Makefile.am b/src/Makefile.am index 4649937..ad83dbf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,6 +52,8 @@ hash/md5hl.c: $(srcdir)/hash/helper.c libbsd_la_DEPENDENCIES = \ $(libbsd_la_included_sources) \ libbsd.map +libbsd_la_LIBADD = \ + $(CLOCK_GETTIME_LIBS) libbsd_la_LDFLAGS = \ -Wl,--version-script=$(srcdir)/libbsd.map \ -version-number $(LIBBSD_ABI)