libglib2-fix-clock-gettime-check.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. Rework clock_gettime() test
  2. The test for clock_gettime() in configure.in doesn't work properly
  3. when a previous package has loaded the shared configuration cache with
  4. informations about the availability of clock_gettime. A package such
  5. as ctorrent does so, which means that compiling ctorrent *then*
  6. libglib2 currently fails.
  7. According to people on the Autoconf mailing list, the libglib2 test is
  8. likely the one that needs to be fixed. The problem is that the
  9. AC_CHECK_FUNCS() test assumes that if it finds clock_gettime() it
  10. means that there's no need to add any -lrt flag to the
  11. build. Unfortunately, due to the shared configuration cache, this test
  12. is already done with -lrt, so the test succeeds, and libglib2 does not
  13. know that it needs to add -lrt to G_THREAD_LIBS and
  14. G_THREAD_LIBS_FOR_GTHREAD.
  15. So instead, we remplace the test with an AC_SEARCH_LIBS() test,
  16. followed by a test on the result of this AC_SEARCH_LIBS() test to add
  17. the necessary -lrt to G_THREAD_LIBS and
  18. G_THREAD_LIBS_FOR_GTHREAD. Therefore, even if the result for the
  19. AC_SEARCH_LIBS() test is cached due to the prior execution ctorrent
  20. ./configure script, libglib2 ./configure will properly add -lrt to the
  21. appropriate variables.
  22. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  23. Index: glib-2.24.1/configure.in
  24. ===================================================================
  25. --- glib-2.24.1.orig/configure.in 2010-08-11 19:29:20.530916023 +0200
  26. +++ glib-2.24.1/configure.in 2010-08-11 19:46:41.308866269 +0200
  27. @@ -2392,13 +2392,14 @@
  28. LIBS="$glib_save_LIBS"
  29. fi
  30. -AC_CHECK_FUNCS(clock_gettime, [], [
  31. - AC_CHECK_LIB(rt, clock_gettime, [
  32. - AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
  33. +AC_SEARCH_LIBS([clock_gettime], [rt], [
  34. + AC_DEFINE(HAVE_CLOCK_GETTIME, 1,[Have clock_gettime])
  35. +])
  36. +
  37. +if test "$ac_cv_search_clock_gettime" = "-lrt"; then
  38. G_THREAD_LIBS="$G_THREAD_LIBS -lrt"
  39. G_THREAD_LIBS_FOR_GTHREAD="$G_THREAD_LIBS_FOR_GTHREAD -lrt"
  40. - ])
  41. -])
  42. +fi
  43. AC_CACHE_CHECK(for monotonic clocks,
  44. glib_cv_monotonic_clock,AC_COMPILE_IFELSE([AC_LANG_SOURCE([[