[PATCH 2/6] configure: detect libdl and librt

Leonid Bobrov mazocomp at disroot.org
Fri Feb 8 17:28:13 UTC 2019


Signed-off-by: Leonid Bobrov <mazocomp at disroot.org>
---
 Makefile.am  |  8 ++++----
 configure.ac | 16 ++++++++++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index cce4d73..489f581 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -71,7 +71,7 @@ nodist_include_HEADERS =			\
 	protocol/wayland-client-protocol.h
 
 libwayland_server_la_CFLAGS = $(FFI_CFLAGS) $(AM_CFLAGS) -pthread
-libwayland_server_la_LIBADD = $(FFI_LIBS) libwayland-private.la libwayland-util.la -lrt -lm
+libwayland_server_la_LIBADD = $(FFI_LIBS) libwayland-private.la libwayland-util.la $(RT_LIBS) -lm
 libwayland_server_la_LDFLAGS = -version-info 1:0:1
 libwayland_server_la_SOURCES =			\
 	src/wayland-server.c			\
@@ -83,7 +83,7 @@ nodist_libwayland_server_la_SOURCES =		\
 	protocol/wayland-protocol.c
 
 libwayland_client_la_CFLAGS = $(FFI_CFLAGS) $(AM_CFLAGS) -pthread
-libwayland_client_la_LIBADD = $(FFI_LIBS) libwayland-private.la libwayland-util.la -lrt -lm
+libwayland_client_la_LIBADD = $(FFI_LIBS) libwayland-private.la libwayland-util.la $(RT_LIBS) -lm
 libwayland_client_la_LDFLAGS = -version-info 3:0:3
 libwayland_client_la_SOURCES =			\
 	src/wayland-client.c
@@ -215,7 +215,6 @@ noinst_LTLIBRARIES +=				\
 	libtest-helpers.la
 
 libtest_helpers_la_SOURCES = tests/test-helpers.c
-libtest_helpers_la_LIBADD = -lrt -ldl $(FFI_LIBS)
 
 libtest_runner_la_SOURCES =			\
 	tests/test-runner.c			\
@@ -227,7 +226,8 @@ libtest_runner_la_LIBADD =			\
 	libwayland-util.la			\
 	libwayland-client.la			\
 	libwayland-server.la			\
-	libtest-helpers.la
+	libtest-helpers.la			\
+	$(RT_LIBS) $(DL_LIBS) $(FFI_LIBS)
 
 array_test_SOURCES = tests/array-test.c
 array_test_LDADD = libtest-runner.la
diff --git a/configure.ac b/configure.ac
index 18fb649..f53408a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,22 @@ AC_SUBST(GCC_CFLAGS)
 AC_CHECK_HEADERS([sys/prctl.h])
 AC_CHECK_FUNCS([accept4 mkostemp posix_fallocate prctl])
 
+# *BSD don't have libdl, but they have its functions
+SAVE_LIBS="$LIBS"
+LIBS=
+AC_CHECK_LIB([dl], [dlsym])
+DL_LIBS="$LIBS"
+LIBS="$SAVE_LIBS"
+AC_SUBST(DL_LIBS)
+
+# *BSD don't have librt, but they have its functions
+SAVE_LIBS="$LIBS"
+LIBS=
+AC_CHECK_LIB([rt], [clock_gettime])
+RT_LIBS="$LIBS"
+LIBS="$SAVE_LIBS"
+AC_SUBST(RT_LIBS)
+
 AC_ARG_ENABLE([libraries],
 	      [AC_HELP_STRING([--disable-libraries],
 			      [Disable compilation of wayland libraries])],
-- 
2.20.1



More information about the wayland-devel mailing list