On Linux, the functions in the dlopen API are in libdl.  However, on
FreeBSD, libdl doesn't exist and the functions are instead in libc.

Signed-off-by: Eric Biggers <ebigge...@gmail.com>
---
 configure.ac    | 10 ++++++++++
 src/Makefile.am |  4 ++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1f96263..095d00b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -543,6 +543,16 @@ AC_CHECK_FUNCS([ \
 ])
 AC_SYS_LARGEFILE
 
+# The dlopen API might be in libc or in libdl.  Check libc first, then
+# fall back to libdl.
+LIBDL=""
+if test "x${disable_plugins}" = "xno"; then
+       AC_CHECK_LIB(c, dlopen, ,
+               [AC_CHECK_LIB(dl, dlopen, [LIBDL="-ldl"],
+                       [AC_MSG_ERROR(["Unable to find libdl (required for 
external plugin support)"])])])
+fi
+AC_SUBST([LIBDL])
+
 if test "$GCC" = "yes" ; then
        # We add -Wall to enable some compiler warnings.
        CFLAGS="${CFLAGS} -Wall"
diff --git a/src/Makefile.am b/src/Makefile.am
index d689527..8d98408 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,7 +23,7 @@ rootbin_PROGRAMS = ntfs-3g lowntfs-3g
 rootsbin_DATA   = #Create directory
 man_MANS        = ntfs-3g.8 ntfs-3g.probe.8
 
-ntfs_3g_LDADD    = -ldl $(FUSE_LIBS) $(top_builddir)/libntfs-3g/libntfs-3g.la
+ntfs_3g_LDADD    = $(LIBDL) $(FUSE_LIBS) 
$(top_builddir)/libntfs-3g/libntfs-3g.la
 if REALLYSTATIC
 ntfs_3g_LDFLAGS  = $(AM_LDFLAGS) -all-static
 endif
@@ -35,7 +35,7 @@ ntfs_3g_CFLAGS   =                    \
        $(PLUGIN_CFLAGS)
 ntfs_3g_SOURCES  = ntfs-3g.c ntfs-3g_common.c
 
-lowntfs_3g_LDADD    = -ldl $(FUSE_LIBS) 
$(top_builddir)/libntfs-3g/libntfs-3g.la
+lowntfs_3g_LDADD    = $(LIBDL) $(FUSE_LIBS) 
$(top_builddir)/libntfs-3g/libntfs-3g.la
 if REALLYSTATIC
 lowntfs_3g_LDFLAGS  = $(AM_LDFLAGS) -all-static
 endif
-- 
2.9.0


------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
ntfs-3g-devel mailing list
ntfs-3g-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel

Reply via email to