--- /dev/null
+dnl Helper function to manage granular libraries
+dnl
+dnl Usage:
+dnl
+dnl LIB_MATH=''
+dnl AC_SUBST([LIB_MATH])
+dnl ...
+dnl HMS_SEARCH_LIBS([LIB_MATH], [sqrt], [m], [AIF], [AINF], [OL])
+dnl
+dnl which expands to something like:
+dnl
+dnl AC_SEARCH_LIBS([sqrt], [m], [case "$ac_cv_search_sqrt" in
+dnl 'none required') ;;
+dnl no) ;;
+dnl *) LIB_MATH="$ac_cv_search_sqrt $LIB_MATH" ;;
+dnl esac
+dnl [AIF]],
+dnl [AINF],
+dnl [OL])
+dnl
+dnl arguments are: lib-var, function, search-libs, [AIF], [AINF], [other-libs]
+AC_DEFUN([HMS_SEARCH_LIBS],
+[AC_SEARCH_LIBS([$2], [$3], [case "$ac_cv_search_$2[]" in
+ 'none required') ;;
+ no) ;;
+ *) $1[]="$ac_cv_search_$2[] $[]$1" ;;
+ esac
+ [$4]],
+ [$5],
+ [$6])])
# instead to try to set the time to itself and check errno.
;;
*)
- AC_SEARCH_LIBS([clock_gettime], [rt])
+ HMS_SEARCH_LIBS([LDADD_LIBNTP], [clock_gettime], [rt])
AC_CHECK_FUNCS([clock_getres clock_gettime clock_settime])
;;
esac
])
# HMS: Do we need to check for -lsocket before or after these tests?
-AC_SEARCH_LIBS([inet_pton], [nsl])
-AC_SEARCH_LIBS([inet_ntop], [resolv], , , [-lnsl])
+HMS_SEARCH_LIBS([LDADD_LIBNTP], [inet_pton], [nsl])
+HMS_SEARCH_LIBS([LDADD_LIBNTP], [inet_ntop], [resolv], , , [-lnsl])
# [Bug 1628] On Solaris, we need -lxnet -lsocket. Generalize this to
# avoid keying on the OS name: If we find socket functions in
# functions there and never add libsocket. See also [Bug 660]
# http://bugs.ntp.org/show_bug.cgi?id=660#c9
saved_LIBS=$LIBS
-AC_SEARCH_LIBS([setsockopt], [socket])
+HMS_SEARCH_LIBS([LDADD_LIBNTP], [setsockopt], [socket])
case "$ac_cv_search_setsockopt" in
-lsocket)
LIBS="$saved_LIBS"
- AC_SEARCH_LIBS([getsockopt], [xnet])
+ HMS_SEARCH_LIBS([LDADD_LIBNTP], [getsockopt], [xnet])
+ # XXX Possible trouble here - reading the comments above and looking at the
+ # code below I wonder if we'll add -lxnet when we don't need it.
+ # Also, do we need to add -lxnet to LDADD_LIBNTP, or perhaps see if it's
+ # there when it is not needed?
case "$ac_cv_search_getsockopt" in
-lxnet)
LIBS="-lxnet -lsocket $saved_LIBS"