From 488f7b53b49a1253b3eef12b7482efe2b55f450e Mon Sep 17 00:00:00 2001
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Fri, 26 Jun 2009 03:21:51 -0300
Subject: [PATCH 7/9] 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 |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

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
-- 
1.6.2.2.646.gb214


