build: add check for clock_gettime() in librt

zuctest is another clock_gettime() user that fails to link against librt when
necessary.

Instead of adding another -lrt LDADD entry i've opted for the saner way and
converted the check to a configure test that will set CLOCK_GETTIME_LIBS
appropiately and replaced all instances of -lrt with it.
Built-tested against old and new glibc.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
diff --git a/configure.ac b/configure.ac
index 447cf6b..670200c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,6 +46,11 @@
               AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
 AC_SUBST(DLOPEN_LIBS)
 
+# In old glibc versions (< 2.17) clock_gettime() is in librt
+AC_SEARCH_LIBS([clock_gettime], [rt],
+             [CLOCK_GETTIME_LIBS="-lrt"])
+AC_SUBST([CLOCK_GETTIME_LIBS])
+
 AC_CHECK_DECL(SFD_CLOEXEC,[],
 	      [AC_MSG_ERROR("SFD_CLOEXEC is needed to compile weston")],
 	      [[#include <sys/signalfd.h>]])