git » libjio » commit 488f7b5

Detect librt availability

author Alberto Bertogli
2009-06-26 06:21:51 UTC
committer Alberto Bertogli
2009-06-26 06:38:48 UTC
parent b362314efb9858e5bcad156a9bbac97f61f0e71e

Detect librt availability

This patch checks if librt is available, so we don't link against it if
not. POSIX says it should be, but some systems do not have it
(DragonflyBSD, for example).

It's not very nice, but it does the trick.

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

libjio/Makefile +4 -1

diff --git a/libjio/Makefile b/libjio/Makefile
index fecbfda..8ce1ca1 100644
--- a/libjio/Makefile
+++ b/libjio/Makefile
@@ -10,7 +10,10 @@ MANDATORY_LDFLAGS := $(shell getconf LFS_LIBS 2>/dev/null)
 ALL_CFLAGS += $(CFLAGS) $(MANDATORY_CFLAGS) -fPIC
 ALL_LDFLAGS += $(LDFLAGS) $(MANDATORY_LDFLAGS) -fPIC
 
-LIBS = -lpthread -lrt
+# some platforms do not have librt, we only use it if available
+NEED_LIBRT := $(shell ld -o rtcheck.so -shared -lrt 2>/dev/null && echo -lrt; \
+	rm -f rtcheck.so)
+LIBS = -lpthread $(NEED_LIBRT)
 
 ifdef DEBUG
 ALL_CFLAGS += -g