From 54b78660d712a32067ae0f33a86bbe09eeecbd35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Tue, 19 Jul 2016 11:53:28 +0200 Subject: [PATCH] Allowed dlopen API to be either in libc or libdl 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 --- configure.ac | 10 ++++++++++ src/Makefile.am | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 1f96263e..095d00b1 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 d689527d..8d984083 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