Blame m4/clock_time.m4

Packit Service a2489d
# clock_time.m4 serial 10
Packit Service a2489d
dnl Copyright (C) 2002-2006, 2009-2018 Free Software Foundation, Inc.
Packit Service a2489d
dnl This file is free software; the Free Software Foundation
Packit Service a2489d
dnl gives unlimited permission to copy and/or distribute it,
Packit Service a2489d
dnl with or without modifications, as long as this notice is preserved.
Packit Service a2489d
Packit Service a2489d
# Check for clock_gettime and clock_settime, and set LIB_CLOCK_GETTIME.
Packit Service a2489d
# For a program named, say foo, you should add a line like the following
Packit Service a2489d
# in the corresponding Makefile.am file:
Packit Service a2489d
# foo_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_CLOCK_TIME],
Packit Service a2489d
[
Packit Service a2489d
  dnl Persuade glibc and Solaris <time.h> to declare these functions.
Packit Service a2489d
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
Packit Service a2489d
Packit Service a2489d
  # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function.
Packit Service a2489d
  # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4.
Packit Service a2489d
Packit Service a2489d
  # Save and restore LIBS so e.g., -lrt, isn't added to it.  Otherwise, *all*
Packit Service a2489d
  # programs in the package would end up linked with that potentially-shared
Packit Service a2489d
  # library, inducing unnecessary run-time overhead.
Packit Service a2489d
  LIB_CLOCK_GETTIME=
Packit Service a2489d
  AC_SUBST([LIB_CLOCK_GETTIME])
Packit Service a2489d
  gl_saved_libs=$LIBS
Packit Service a2489d
    AC_SEARCH_LIBS([clock_gettime], [rt posix4],
Packit Service a2489d
                   [test "$ac_cv_search_clock_gettime" = "none required" ||
Packit Service a2489d
                    LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime])
Packit Service a2489d
    AC_CHECK_FUNCS([clock_gettime clock_settime])
Packit Service a2489d
  LIBS=$gl_saved_libs
Packit Service a2489d
])