]> git.ipfire.org Git - thirdparty/git.git/commit - Makefile
Makefile: add NEEDS_LIBRT to optionally link with librt
authorRonald Wampler <rdwampler@gmail.com>
Thu, 7 Jul 2016 20:45:54 +0000 (16:45 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 7 Jul 2016 21:15:08 +0000 (14:15 -0700)
commitd19e3a5b21f28c07886801616e02e08eab64a7d8
treef3ad8e4dbce119ebe2a4bbde60b041a44177f0b6
parent0b65a8dbdb38962e700ee16776a3042beb489060
Makefile: add NEEDS_LIBRT to optionally link with librt

We unconditionally link with librt, when HAVE_CLOCK_GETTIME is defined.
But clock_gettime() has been available in most libc implementations for
some time now (e.g., for glibc since version 2.17) and no longer
requires linking with librt. Furthermore, commit a6c3c63 (configure.ac:
check for clock_gettime() and CLOCK_MONOTONIC) will automatically
determined which library (libc or librt) is required for linking when
checking for clock_gettime().

The assumption to unconditionally link with librt was OK, since either
almost every Unix-like system provides a version of librt for backwards
compatibility or other systems, namely Windows or OS X, never provided
clock_gettime(). However, in the latest release of OS X (macOS Sierra),
this function has been added to OS X libc version. As a result, when
running the configuration script, HAVE_CLOCK_GETTIME is set and since
librt is not present, it causes a linker error.

This patches requires those not building via the configuration scripts
to define NEEDS_LIBRT in addition to HAVE_CLOCK_GETTIME, if needed.

Signed-off-by: Ronald Wampler <rdwampler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile