[PATCH v2] build: clock_gettime might need librt

Gustavo Zacarias gustavo at zacarias.com.ar
Fri Feb 12 15:26:05 CET 2016


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.

Signed-off-by: Gustavo Zacarias <gustavo at zacarias.com.ar>
---
Change for v2: use LIBADD, not LDADD, d'oh!

 configure.ac    | 5 +++++
 src/Makefile.am | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/configure.ac b/configure.ac
index d334774..1862d19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,11 @@ 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
+AC_SEARCH_LIBS([clock_gettime], [rt],
+             [LIB_CLOCK_GETTIME="-lrt"])
+AC_SUBST([LIB_CLOCK_GETTIME])
+
 # 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..6b705f0 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 = \
+	$(LIB_CLOCK_GETTIME)
 libbsd_la_LDFLAGS = \
 	-Wl,--version-script=$(srcdir)/libbsd.map \
 	-version-number $(LIBBSD_ABI)
-- 
2.4.10



More information about the libbsd mailing list