All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] build: use -lrt for clock_gettime on glibc < 2.17
@ 2013-09-06  6:43 Dirk-Jan C. Binnema
       [not found] ` <52E3B66B-DC7A-4225-8779-8C1E9B0FC15E@holtmann.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Dirk-Jan C. Binnema @ 2013-09-06  6:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Dirk-Jan C. Binnema

From: "Dirk-Jan C. Binnema" <djcb@djcbsoftware.nl>

glibc before 2.17 (e.g., fedora 18) requires -lrt for clock_gettime.
AC_SEARCH_LIBS adds it to LIBS in that case
---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index 050d30d..403e323 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,6 +40,7 @@ AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads],
 AC_CHECK_FUNC(signalfd, dummy=yes,
 			AC_MSG_ERROR(signalfd support is required))
 
+AC_SEARCH_LIBS(clock_gettime,rt)
 AC_CHECK_FUNC(clock_gettime, dummy=yes,
 			AC_MSG_ERROR(realtime clock support is required))
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] build: use -lrt for clock_gettime on glibc < 2.17
       [not found] ` <52E3B66B-DC7A-4225-8779-8C1E9B0FC15E@holtmann.org>
@ 2013-09-06  8:07   ` Dirk-Jan C. Binnema
  2013-09-06  8:09   ` Dirk-Jan C. Binnema
  1 sibling, 0 replies; 5+ messages in thread
From: Dirk-Jan C. Binnema @ 2013-09-06  8:07 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org

Hi Marcel,

marcel@holtmann.org writes:

> Hi Dirk-Jan,,
>
>> glibc before 2.17 (e.g., fedora 18) requires -lrt for clock_gettime.
>> AC_SEARCH_LIBS adds it to LIBS in that case
>> ---
>> configure.ac | 1 +
>> 1 file changed, 1 insertion(+)
>> 
>> diff --git a/configure.ac b/configure.ac
>> index 050d30d..403e323 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -40,6 +40,7 @@ AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads],
>> AC_CHECK_FUNC(signalfd, dummy=yes,
>> 			AC_MSG_ERROR(signalfd support is required))
>> 
>> +AC_SEARCH_LIBS(clock_gettime,rt)
>
> I do like this since this now it links everything with -lrt even if it is not needed.

Hmm, I suppose there's a missing 'not'...

Note, AC_SEARCH_LIBS tries without rt first, and only adds -lrt if
clock_gettime is not defined without it.

Or did you mean building parts of bluez without -lrt in the glibc < 2.17
case? If so, please see my next patch, which only uses -lrt (if needed)
for bluetoothd.

Cheers,
Dirk.


-- 
Dirk-Jan C. Binnema                  Helsinki, Finland
e:djcb@djcbsoftware.nl           w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] build: use -lrt for clock_gettime on glibc < 2.17
       [not found] ` <52E3B66B-DC7A-4225-8779-8C1E9B0FC15E@holtmann.org>
  2013-09-06  8:07   ` Dirk-Jan C. Binnema
@ 2013-09-06  8:09   ` Dirk-Jan C. Binnema
       [not found]     ` <4A735792-B4D7-468A-A61A-488F605AAB30@holtmann.org>
  2013-09-10  7:55     ` Johan Hedberg
  1 sibling, 2 replies; 5+ messages in thread
From: Dirk-Jan C. Binnema @ 2013-09-06  8:09 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Dirk-Jan C. Binnema

From: "Dirk-Jan C. Binnema" <djcb@djcbsoftware.nl>

glibc before 2.17 (e.g., fedora 18) requires -lrt for clock_gettime;
add -lrt where needed in that case.
---
 Makefile.am  | 2 +-
 configure.ac | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 61daec4..8069af2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -152,7 +152,7 @@ src_bluetoothd_SOURCES = $(builtin_sources) \
 			src/shared/util.h src/shared/util.c \
 			src/shared/mgmt.h src/shared/mgmt.c
 src_bluetoothd_LDADD = lib/libbluetooth-internal.la gdbus/libgdbus-internal.la \
-			@GLIB_LIBS@ @DBUS_LIBS@ -ldl -lrt
+			@GLIB_LIBS@ @DBUS_LIBS@ @RT_LIBS@ -ldl
 src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \
 				-Wl,--version-script=$(srcdir)/src/bluetooth.ver
 
diff --git a/configure.ac b/configure.ac
index 050d30d..e7a7b85 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,8 +40,10 @@ AC_ARG_ENABLE(threads, AC_HELP_STRING([--enable-threads],
 AC_CHECK_FUNC(signalfd, dummy=yes,
 			AC_MSG_ERROR(signalfd support is required))
 
-AC_CHECK_FUNC(clock_gettime, dummy=yes,
-			AC_MSG_ERROR(realtime clock support is required))
+AC_CHECK_FUNC(clock_gettime, [], [
+  AC_CHECK_LIB(rt, clock_gettime, RT_LIBS="-lrt",
+    AC_MSG_ERROR(realtime clock support is required))])
+AC_SUBST(RT_LIBS)
 
 AC_CHECK_LIB(pthread, pthread_create, dummy=yes,
 			AC_MSG_ERROR(posix thread support is required))
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] build: use -lrt for clock_gettime on glibc < 2.17
       [not found]     ` <4A735792-B4D7-468A-A61A-488F605AAB30@holtmann.org>
@ 2013-09-10  7:20       ` Dirk-Jan C. Binnema
  0 siblings, 0 replies; 5+ messages in thread
From: Dirk-Jan C. Binnema @ 2013-09-10  7:20 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth


marcel@holtmann.org writes:

> Hi Dirk-Jan,
>

<snip>

>
> so I fixed this upstream a lot simpler by always checking for
> clock_gettime in -lrt. Can you check if that works for you. On an
> older Debian test box it just works fine for me.

Sure, that works; but that's equivalent to the first patch I made... I
only made the more complicated one after your comment:

,----
| > +AC_SEARCH_LIBS(clock_gettime,rt)
|
| I do [not] like this since this now it links everything with -lrt even if it
| is not needed.
`----

AC_SEARCH_LIBS doesn't add -lrt if it's not needed, so I interpreted
your comment as you not wanting -lrt in parts of the code that don't
need it.

Anyway, good it works now...

Thanks,
Dirk.

-- 
Dirk-Jan C. Binnema                  Helsinki, Finland
e:djcb@djcbsoftware.nl           w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] build: use -lrt for clock_gettime on glibc < 2.17
  2013-09-06  8:09   ` Dirk-Jan C. Binnema
       [not found]     ` <4A735792-B4D7-468A-A61A-488F605AAB30@holtmann.org>
@ 2013-09-10  7:55     ` Johan Hedberg
  1 sibling, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2013-09-10  7:55 UTC (permalink / raw)
  To: Dirk-Jan C. Binnema; +Cc: linux-bluetooth, Dirk-Jan C. Binnema

Hi Dirk-Jan,

On Fri, Sep 06, 2013, Dirk-Jan C. Binnema wrote:
> From: "Dirk-Jan C. Binnema" <djcb@djcbsoftware.nl>
> 
> glibc before 2.17 (e.g., fedora 18) requires -lrt for clock_gettime;
> add -lrt where needed in that case.
> ---
>  Makefile.am  | 2 +-
>  configure.ac | 6 ++++--
>  2 files changed, 5 insertions(+), 3 deletions(-)

It seems Marcel went ahead and applied his own patch for this (I think
he didn't realize there was a pending one here). Could you check if
latest git now works for you?

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-09-10  7:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-06  6:43 [PATCH] build: use -lrt for clock_gettime on glibc < 2.17 Dirk-Jan C. Binnema
     [not found] ` <52E3B66B-DC7A-4225-8779-8C1E9B0FC15E@holtmann.org>
2013-09-06  8:07   ` Dirk-Jan C. Binnema
2013-09-06  8:09   ` Dirk-Jan C. Binnema
     [not found]     ` <4A735792-B4D7-468A-A61A-488F605AAB30@holtmann.org>
2013-09-10  7:20       ` Dirk-Jan C. Binnema
2013-09-10  7:55     ` Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.