@@ -783,55 +783,24 @@ AC_DEFUN(AC_LBL_DEVEL,
783783 fi] )
784784
785785dnl
786- dnl AC_LBL_LIBRARY_NET
787- dnl
788- dnl This test is for network applications that need socket() and
789- dnl gethostbyaddr() -ish functions. Under Solaris, those applications
790- dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
791- dnl with "-lnsl" but should *not* link with "-lsocket" because
792- dnl libsocket.a breaks a number of things (for instance:
793- dnl gethostbyaddr() under IRIX 5.2, and snoop sockets under most
794- dnl versions of IRIX).
795- dnl
796- dnl Unfortunately, many application developers are not aware of this,
797- dnl and mistakenly write tests that cause -lsocket to be used under
798- dnl IRIX. It is also easy to write tests that cause -lnsl to be used
799- dnl under operating systems where neither are necessary (or useful),
800- dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
801- dnl
802- dnl This test exists so that every application developer does not test
803- dnl this in a different, and subtly broken fashion.
804-
805- dnl It has been argued that this test should be broken up into two
806- dnl separate tests, one for the resolver libraries, and one for the
807- dnl libraries necessary for using Sockets API. Unfortunately, the two
808- dnl are carefully intertwined and allowing the autoconf user to use
809- dnl them independently potentially results in unfortunate ordering
810- dnl dependencies -- as such, such component macros would have to
811- dnl carefully use indirection and be aware if the other components were
812- dnl executed. Since other autoconf macros do not go to this trouble,
813- dnl and almost no applications use sockets without the resolver, this
814- dnl complexity has not been implemented.
815- dnl
816- dnl The check for libresolv is in case you are attempting to link
817- dnl statically and happen to have a libresolv.a lying around (and no
818- dnl libnsl.a).
786+ dnl This is a simplified adaptation of AC_LBL_LIBRARY_NET from libpcap.
787+ dnl In this context tcpdump needs gethostbyaddr() only.
819788dnl
820789AC_DEFUN ( AC_LBL_LIBRARY_NET , [
821- # Most operating systems have gethostbyaddr() in the default searched
822- # libraries (i.e. libc):
823- # Some OSes (eg. Solaris) place it in libnsl
824- # Some strange OSes (SINIX) have it in libsocket:
825- AC_SEARCH_LIBS ( gethostbyaddr , network nsl socket resolv )
826- # Unfortunately libsocket sometimes depends on libnsl and
827- # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
828- if test "$ac_cv_search_gethostbyaddr" = "no"
829- then
790+ AC_CHECK_FUNC ( gethostbyaddr ,,
791+ [
830792 AC_CHECK_LIB ( socket , gethostbyaddr ,
831- LIBS="-lsocket - lnsl $LIBS" , , - lnsl )
832- fi
833- AC_SEARCH_LIBS ( socket , socket , ,
834- AC_CHECK_LIB ( socket , socket , LIBS="-lsocket - lnsl $LIBS" , , - lnsl ) )
835- # DLPI needs putmsg under HPUX so test for -lstr while we're at it
836- AC_SEARCH_LIBS ( putmsg , str )
793+ [
794+ LIBS="-lsocket -lnsl $LIBS"
795+ ] ,
796+ [
797+ AC_CHECK_LIB ( network , gethostbyaddr ,
798+ [
799+ LIBS="-lnetwork $LIBS"
800+ ] ,
801+ [
802+ AC_MSG_ERROR ( [ gethostbyaddr is required, but wasn't found] )
803+ ] )
804+ ] , - lnsl )
837805 ] )
806+ ] )
0 commit comments