Although I work with flameeyes closely in some of these issues... I disagree with his opinion here as generic approach.
He is write as in most cases people just adds libraries as they go in the configure process... So you check for dl, then rt, then resolv, then selinux etc... building your LIBS. The result is one long LIBS which is common to all executables. I take another approach and detect dependencies as atoms. Yes... if one day dl will be merged into libc we fail in this case, but then we can fix <something>. For now this is working perfectly. Alon. 2012/3/8 Samuli Seppänen <sam...@openvpn.net>: > Did some digging regarding AC_SEARCH_LIBS and AC_CHECK_LIB. Somebody > with more autotools knowledge might want to read this one: > > <http://www.flameeyes.eu/autotools-mythbuster/autoconf/finding.html> > > So, the question is: why AC_CHECK_LIB rather than AC_SEARCH_LIBS in this > particular case? Apparently both have their uses. > > -- > Samuli Seppänen > Community Manager > OpenVPN Technologies, Inc > > irc freenode net: mattock > > >> Signed-off-by: Alon Bar-Lev <alon.bar...@gmail.com> >> --- >> configure.ac | 27 +++++++++++++++++---------- >> src/openvpn/Makefile.am | 1 + >> 2 files changed, 18 insertions(+), 10 deletions(-) >> >> diff --git a/configure.ac b/configure.ac >> index a0dc462..c540f82 100644 >> --- a/configure.ac >> +++ b/configure.ac >> @@ -442,16 +442,6 @@ if test "${WIN32}" != "yes"; then >> [[${SOCKET_INCLUDES}]] >> ) >> >> - AC_CHECK_DECLS( >> - [SO_MARK], >> - , >> - , >> - [[${SOCKET_INCLUDES}]] >> - ) >> - >> - AC_SEARCH_LIBS([socket], [socket]) >> - AC_SEARCH_LIBS([inet_ntoa], [nsl]) >> - AC_SEARCH_LIBS([gethostbyname], [resolv nsl]) >> AC_FUNC_FORK >> fi >> >> @@ -613,6 +603,23 @@ AC_CHECK_LIB( >> ) >> AC_SUBST([DL_LIBS]) >> >> +AC_CHECK_LIB( >> + [nsl], >> + [inet_ntoa], >> + [SOCKETS_LIBS="${SOCKETS_LIBS} -lnsl"] >> +) >> +AC_CHECK_LIB( >> + [socket], >> + [socket], >> + [SOCKETS_LIBS="${SOCKETS_LIBS} -lsocket"] >> +) >> +AC_CHECK_LIB( >> + [resolv], >> + [gethostbyname], >> + [SOCKETS_LIBS="${SOCKETS_LIBS} -lresolv"] >> +) >> +AC_SUBST([SOCKETS_LIBS]) >> + >> case "${with_mem_check}" in >> valgrind) >> AC_CHECK_HEADER( >> diff --git a/src/openvpn/Makefile.am b/src/openvpn/Makefile.am >> index c7626c8..86abd09 100644 >> --- a/src/openvpn/Makefile.am >> +++ b/src/openvpn/Makefile.am >> @@ -96,6 +96,7 @@ openvpn_SOURCES = \ >> win32.h win32.c \ >> cryptoapi.h cryptoapi.c >> openvpn_LDADD = \ >> + $(SOCKETS_LIBS) \ >> $(OPTIONAL_DL_LIBS) >> if WIN32 >> openvpn_SOURCES += openvpn_win32_resources.rc >