]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2256] Improve configure's function searches in libraries
authorHarlan Stenn <stenn@ntp.org>
Thu, 17 Oct 2013 07:15:02 +0000 (07:15 +0000)
committerHarlan Stenn <stenn@ntp.org>
Thu, 17 Oct 2013 07:15:02 +0000 (07:15 +0000)
bk: 525f8e76wJqm-1tQMwwQhUflUh5G0A

ChangeLog
sntp/configure.ac
sntp/m4/hms_search_lib.m4 [new file with mode: 0644]
sntp/m4/ntp_libntp.m4

index e0cd05bcab64faddcc607a7cf70e1248467371e7..d938f186057e1d15fa020d767c618ec1ad0318df 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* [Bug 2256] Improve configure's function searches in libraries.
 (4.2.7p391) 2013/10/12 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 2250] Rework of leap second handling machine.
 * [Bug 2419] [rc-nmea] Improve clockstats reporting when receiver sends
index 311c52cda20de81c87f65b7d825a62a1d8e35ba8..8a32978d41176b5a60dccf83ed12b0312aae4f10 100644 (file)
@@ -109,6 +109,8 @@ dnl NTP_LIBNTP checks for inet_XtoY
 dnl AC_SEARCH_LIBS([inet_pton], [nsl])
 
 dnl AC_SEARCH_LIBS([openlog], [gen syslog])
+LIB_SYSLOG=''
+AC_SUBST([LIB_SYSLOG])
 HMS_SEARCH_LIBS([LIB_SYSLOG], [openlog], [gen syslog])
 
 # Checks for header files.
diff --git a/sntp/m4/hms_search_lib.m4 b/sntp/m4/hms_search_lib.m4
new file mode 100644 (file)
index 0000000..e6dd601
--- /dev/null
@@ -0,0 +1,30 @@
+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])])
index 7a81b58639ef21edd22052a419dcef95e029f28b..351fca219106f0b10f6693df03aa0ba763ca9eae 100644 (file)
@@ -63,7 +63,7 @@ case "$host" in
        # 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
@@ -209,8 +209,8 @@ AC_CHECK_HEADERS([netinet/ip.h netinet/in_var.h], [], [], [
 ])
 
 # 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
@@ -219,11 +219,15 @@ AC_SEARCH_LIBS([inet_ntop], [resolv], , , [-lnsl])
 # 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"