BUILD: Makefile: add USE_RT to pass -lrt for clock_gettime() and friends
Some code will require clock_gettime() which needs -lrt on most Linux
distros (those with glibc < 2.17). For this reason, this patch introduces
USE_RT to enable -lrt, which is implicitly set for all Linux flavors,
since it's harmless to link with it on more recent ones. Those who know
they can safely get rid of -lrt can remove it using "USE_RT=".
diff --git a/Makefile b/Makefile
index 821d314..b3b6895 100644
--- a/Makefile
+++ b/Makefile
@@ -40,6 +40,7 @@
# USE_TFO : enable TCP fast open. Supported on Linux >= 3.7.
# USE_NS : enable network namespace support. Supported on Linux >= 2.6.24.
# USE_DL : enable it if your system requires -ldl. Automatic on Linux.
+# USE_RT : enable it if your system requires -lrt. Automatic on Linux.
# USE_DEVICEATLAS : enable DeviceAtlas api.
# USE_51DEGREES : enable third party device detection library from 51Degrees
# USE_WURFL : enable WURFL detection library from Scientiamobile
@@ -281,6 +282,7 @@
USE_TPROXY = implicit
USE_LIBCRYPT = implicit
USE_DL = implicit
+ USE_RT = implicit
else
ifeq ($(TARGET),linux24)
# This is for standard Linux 2.4 with netfilter but without epoll()
@@ -289,6 +291,7 @@
USE_TPROXY = implicit
USE_LIBCRYPT = implicit
USE_DL = implicit
+ USE_RT = implicit
else
ifeq ($(TARGET),linux24e)
# This is for enhanced Linux 2.4 with netfilter and epoll() patch > 0.21
@@ -299,6 +302,7 @@
USE_TPROXY = implicit
USE_LIBCRYPT = implicit
USE_DL = implicit
+ USE_RT = implicit
else
ifeq ($(TARGET),linux26)
# This is for standard Linux 2.6 with netfilter and standard epoll()
@@ -309,6 +313,7 @@
USE_LIBCRYPT = implicit
USE_FUTEX = implicit
USE_DL = implicit
+ USE_RT = implicit
else
ifeq ($(TARGET),linux2628)
# This is for standard Linux >= 2.6.28 with netfilter, epoll, tproxy and splice
@@ -324,6 +329,7 @@
USE_CPU_AFFINITY= implicit
ASSUME_SPLICE_WORKS= implicit
USE_DL = implicit
+ USE_RT = implicit
USE_THREAD = implicit
else
ifeq ($(TARGET),solaris)
@@ -599,6 +605,11 @@
OPTIONS_LDFLAGS += -lpthread
endif
+ifneq ($(USE_RT),)
+BUILD_OPTIONS += $(call ignore_implicit,USE_RT)
+OPTIONS_LDFLAGS += -lrt
+endif
+
# report DLMALLOC_SRC only if explicitly specified
ifneq ($(DLMALLOC_SRC),)
BUILD_OPTIONS += DLMALLOC_SRC=$(DLMALLOC_SRC)