[PATCH] Fix clock_gettime detection
Gilles Espinasse
g.esp at free.fr
Sat Jan 21 23:41:51 CET 2012
AC_CHECK_FUNCS is not enought as AC_SEARCH_LIBS has to be used before
Tested to work with
ac_cv_func_gettimeofday= ./configure using --enable-minimal or no other option than --enable-maintainer-mode
Signed-off-by: Gilles Espinasse <g.esp at free.fr>
---
configure.ac | 23 +++++++++++++++++++++--
g10/Makefile.am | 2 +-
tools/Makefile.am | 2 +-
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/configure.ac b/configure.ac
index 181c07b..54d0dd0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1023,7 +1023,7 @@ AC_FUNC_VPRINTF
AC_FUNC_FORK
AC_CHECK_FUNCS(strerror stpcpy strlwr tcgetattr strtoul mmap sysconf)
AC_CHECK_FUNCS(strcasecmp strncasecmp ctermid times unsetenv getpwnam getpwuid)
-AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime)
+AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit)
AC_CHECK_FUNCS(atexit raise getpagesize strftime nl_langinfo setlocale)
AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask rand pipe stat getaddrinfo)
AC_CHECK_FUNCS(fcntl ftruncate)
@@ -1037,7 +1037,26 @@ AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include <signal.h>])
AC_CHECK_FUNC(getopt,,AC_CHECK_LIB(iberty,getopt,AC_SUBST(GETOPT,"-liberty")))
-#
+dnl Check for clock_gettime, in libc for FreeBSD, in rt for linux,
+dnl in rt for Solaris 7, in posix4 for Solaris 2.5.1
+LIB_CLOCK_GETTIME=
+clk_saved_libs=$LIBS
+AC_SEARCH_LIBS([clock_gettime], [rt posix4],
+ [test "$ac_cv_search_clock_gettime" = "none required" ||
+ LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime])
+AC_SUBST([LIB_CLOCK_GETTIME])
+
+AC_MSG_CHECKING([for working clock_gettime])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]],
+ [[clock_gettime(CLOCK_REALTIME, 0);]])], [gnupg_cv_clock_gettime=yes], [gnupg_cv_clock_gettime=no])
+AC_MSG_RESULT($gnupg_cv_clock_gettime)
+
+if test x"$gnupg_cv_clock_gettime" = xyes; then
+ AC_DEFINE([HAVE_CLOCK_GETTIME], 1,
+ [Define to 1 if you have the `clock_gettime' function.])
+fi
+LIBS=$clk_saved_libs
+
# check for gethrtime and run a testprogram to see whether
# it is broken. It has been reported that some Solaris and HP UX systems
# raise an SIGILL
diff --git a/g10/Makefile.am b/g10/Makefile.am
index 60e7e11..ebceb2e 100644
--- a/g10/Makefile.am
+++ b/g10/Makefile.am
@@ -127,7 +127,7 @@ gpgv_SOURCES = gpgv.c \
verify.c
LDADD = $(needed_libs) $(other_libs) @ZLIBS@ @W32LIBS@
-gpg_LDADD = $(LDADD) @LIBREADLINE@ @DLLIBS@ @NETLIBS@ @LIBUSB@
+gpg_LDADD = $(LDADD) @LIBREADLINE@ @DLLIBS@ @NETLIBS@ @LIBUSB@ @LIB_CLOCK_GETTIME@
$(PROGRAMS): $(needed_libs)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 0c6e691..604354a 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -41,7 +41,7 @@ endif
gpgsplit_LDADD = $(needed_libs) $(other_libs) @ZLIBS@
mpicalc_LDADD = $(needed_libs) $(other_libs) @W32LIBS@
-bftest_LDADD = $(needed_libs) $(other_libs) @W32LIBS@ @DLLIBS@ @NETLIBS@ @LIBREADLINE@
+bftest_LDADD = $(needed_libs) $(other_libs) @W32LIBS@ @DLLIBS@ @NETLIBS@ @LIBREADLINE@ @LIB_CLOCK_GETTIME@
shmtest_LDADD = $(needed_libs) $(other_libs) @LIBREADLINE@
gpgsplit mpicalc bftest shmtest: $(needed_libs)
--
1.5.6.5
More information about the Gnupg-devel
mailing list