Make librt optional, required for at least OpenBSD
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
diff --git a/Makefile.am b/Makefile.am
index af84ae4..9071e90 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -209,7 +209,7 @@ test_keyseq_LDADD = $(TESTS_LDADD)
test_rulescomp_LDADD = $(TESTS_LDADD)
test_rmlvo_to_kccgst_LDADD = $(TESTS_LDADD)
test_print_compiled_keymap_LDADD = $(TESTS_LDADD)
-test_compose_LDADD = $(TESTS_LDADD) -lrt
+test_compose_LDADD = $(TESTS_LDADD) $(RT_LIBS)
if BUILD_LINUX_TESTS
check_PROGRAMS += \
@@ -242,7 +242,7 @@ check_PROGRAMS += $(TESTS)
# Benchmarks
##
-BENCH_LDADD = $(TESTS_LDADD) -lrt
+BENCH_LDADD = $(TESTS_LDADD) $(RT_LIBS)
check_PROGRAMS += \
bench/key-proc \
diff --git a/configure.ac b/configure.ac
index 7449954..52b0d3a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,6 +95,11 @@ XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wdocumentation])
XORG_CHECK_LINKER_FLAGS([-Wl,--no-undefined], [have_no_undefined=yes])
AM_CONDITIONAL([HAVE_NO_UNDEFINED], [test "x$have_no_undefined" = xyes])
+AC_CHECK_LIB(rt, clock_gettime,
+ [AC_SUBST(RT_LIBS, "-lrt")],
+ [AC_SUBST(RT_LIBS, "")],
+ [-lrt])
+
# Define a configuration option for the XKB config root
xkb_base=`$PKG_CONFIG --variable=xkb_base xkeyboard-config`
AS_IF([test "x$xkb_base" = x], [