From: Harlan Stenn Date: Thu, 17 Oct 2013 07:15:02 +0000 (+0000) Subject: [Bug 2256] Improve configure's function searches in libraries X-Git-Tag: NTP_4_2_7P394~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e5eb44a0b61586a38049bce0b504277b4f7ed70;p=thirdparty%2Fntp.git [Bug 2256] Improve configure's function searches in libraries bk: 525f8e76wJqm-1tQMwwQhUflUh5G0A --- diff --git a/ChangeLog b/ChangeLog index e0cd05bca..d938f1860 100644 --- 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 * [Bug 2250] Rework of leap second handling machine. * [Bug 2419] [rc-nmea] Improve clockstats reporting when receiver sends diff --git a/sntp/configure.ac b/sntp/configure.ac index 311c52cda..8a32978d4 100644 --- a/sntp/configure.ac +++ b/sntp/configure.ac @@ -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 index 000000000..e6dd60140 --- /dev/null +++ b/sntp/m4/hms_search_lib.m4 @@ -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])]) diff --git a/sntp/m4/ntp_libntp.m4 b/sntp/m4/ntp_libntp.m4 index 7a81b5863..351fca219 100644 --- a/sntp/m4/ntp_libntp.m4 +++ b/sntp/m4/ntp_libntp.m4 @@ -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"