clock_time.m4 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # clock_time.m4 serial 10
  2. dnl Copyright (C) 2002-2006, 2009-2017 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. # Check for clock_gettime and clock_settime, and set LIB_CLOCK_GETTIME.
  7. # For a program named, say foo, you should add a line like the following
  8. # in the corresponding Makefile.am file:
  9. # foo_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
  10. AC_DEFUN([gl_CLOCK_TIME],
  11. [
  12. dnl Persuade glibc and Solaris <time.h> to declare these functions.
  13. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
  14. # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
  15. # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
  16. # Save and restore LIBS so e.g., -lrt, isn't added to it. Otherwise, *all*
  17. # programs in the package would end up linked with that potentially-shared
  18. # library, inducing unnecessary run-time overhead.
  19. LIB_CLOCK_GETTIME=
  20. AC_SUBST([LIB_CLOCK_GETTIME])
  21. gl_saved_libs=$LIBS
  22. AC_SEARCH_LIBS([clock_gettime], [rt posix4],
  23. [if test "$ac_cv_search_clock_gettime" = "none required"; then
  24. AC_SEARCH_LIBS([clock_getcpuclockid], [rt posix4],
  25. [test "$ac_cv_search_clock_getcpuclockid" = "none required" \
  26. || LIB_CLOCK_GETTIME=$ac_cv_search_clock_getcpuclockid],
  27. [test "$ac_cv_search_clock_gettime" = "none required" \
  28. || LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime])
  29. else
  30. LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime
  31. fi])
  32. AC_CHECK_FUNCS([clock_gettime clock_settime clock_getcpuclockid])
  33. LIBS=$gl_saved_libs
  34. ])