[tor-commits] [torsocks/master] Find out if we really need libdl.

dgoulet at torproject.org dgoulet at torproject.org
Fri Apr 4 22:40:26 UTC 2014


commit 3876c9441ba3df0412b9740a28a72f79e31c4668
Author: Linus Nordberg <linus at nordberg.se>
Date:   Sun Aug 25 12:19:18 2013 +0200

    Find out if we really need libdl.
    
    Some systems (like FreeBSD) have dlopen(3) and friends in libc and don't
    need -ldl.
    
    Removing the AC_CHECK_LIB for -ldl. Can't see the need for that, nor the
    'have_libdl' outcome.
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 configure.ac        |    9 +++------
 src/lib/Makefile.am |    7 ++++---
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3a646ce..70c9efb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,12 +105,9 @@ AC_CHECK_FUNC(gethostbyname, AC_DEFINE([HAVE_GETHOSTBYNAME],[],[Description]), [
 		      "torsocks disabled"])])])
 
 
-dnl Our main libs to link against are -dl and -lresolv.
-AC_CHECK_LIB([dl], [dlopen],
-[
-	AC_DEFINE_UNQUOTED([TORSOCKS_HAVE_DL], 1, [Has libdl support.])
-	have_libdl=yes
-])
+dnl Do we have dlopen(3) without -ldl?
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[return dlopen ();]])], [have_builtin_dl=yes])
+AM_CONDITIONAL([HAVE_BUILTIN_DL], [test "$have_builtin_dl" = "yes"])
 
 dnl OpenBSD needs -lpthread. It also doesn't support AI_V4MAPPED.
 case $host in
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index f043392..f7320e3 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -10,6 +10,7 @@ libtorsocks_la_SOURCES = torsocks.c torsocks.h \
                          connect.c gethostbyname.c getaddrinfo.c close.c \
                          getpeername.c socket.c syscall.c socketpair.c recv.c
 
-libtorsocks_la_LIBADD = \
-		$(top_builddir)/src/common/libcommon.la \
-		-ldl
+libtorsocks_la_LIBADD = $(top_builddir)/src/common/libcommon.la
+if ! HAVE_BUILTIN_DL
+libtorsocks_la_LIBADD += -ldl
+endif





More information about the tor-commits mailing list