stdio.h stdarg.h \
time.h errno.h fcntl.h io.h direct.h \
ctype.h sys/types.h sys/socket.h \
- signal.h unistd.h \
+ signal.h unistd.h dlfcn.h \
netinet/in.h netinet/in_systm.h \
netinet/tcp.h arpa/inet.h netdb.h \
windows.h winsock2.h ws2tcpip.h \
AC_CHECK_FUNCS(SOCKET_OPT_FUNCS)
fi
+AC_CHECK_LIB(
+ [dl],
+ [dlopen],
+ [DL_LIBS="-ldl"]
+)
+AC_SUBST([DL_LIBS])
+
case "${with_mem_check}" in
valgrind)
AC_CHECK_HEADER(
;;
esac
-dnl
-dnl Check for dlopen -- first try libc then libdl.
-dnl
-if test "${WIN32}" != "yes" -a "${enable_plugins}" = "yes"; then
- AC_CHECK_HEADER(
- [dlfcn.h],
- [AC_CHECK_FUNC(
- [dlopen],
- [AC_DEFINE(USE_LIBDL, 1, [Use libdl for dynamic library loading])],
- [AC_CHECK_LIB(
- [dl],
- [dlopen],
- [
- LIBS="${LIBS} -ldl"
- AC_DEFINE(USE_LIBDL, 1, [Use libdl for dynamic library loading])
- ],
- [AC_MSG_RESULT([libdl library not found.])]
- )],
- )],
- )
- if test "${enable_eurephia}" = "yes"; then
- AC_DEFINE([ENABLE_EUREPHIA], [1], [Enable support for the eurephia plug-in])
- fi
-fi
-
-dnl
-dnl Check if LoadLibrary exists on Windows
-dnl
-if test "${WIN32}" = "yes"; then
- AC_DEFINE(USE_LOAD_LIBRARY, 1, [Use LoadLibrary to load DLLs on Windows])
-fi
-
dnl
dnl check for LZO library
dnl
test "${enable_password_save}" = "yes" && AC_DEFINE([ENABLE_PASSWORD_SAVE], [1], [Allow --askpass and --auth-user-pass passwords to be read from a file])
test "${enable_systemd}" = "yes" && AC_DEFINE([ENABLE_SYSTEMD], [1], [Enable systemd support])
+if test "${enable_plugins}" = "yes"; then
+ test "${WIN32}" != "yes" -a -z "${DL_LIBS}" && AC_MSG_ERROR([libdl is required for plugins])
+ OPTIONAL_DL_LIBS="${DL_LIBS}"
+ AC_DEFINE([ENABLE_PLUGIN], [1], [Enable systemd support])
+ test "${enable_eurephia}" = "yes" && AC_DEFINE([ENABLE_EUREPHIA], [1], [Enable support for the eurephia plug-in])
+fi
+
if test "${enable_iproute2}" = "yes"; then
test -z "${IPROUTE}" && AC_MSG_ERROR([ip utility is required but missing])
AC_DEFINE([ENABLE_IPROUTE], [1], [enable iproute2 support])
AC_SUBST([TAP_WIN_MIN_MAJOR])
AC_SUBST([TAP_WIN_MIN_MINOR])
+AC_SUBST([OPTIONAL_DL_LIBS])
+
AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
AC_CONFIG_FILES([
#ifdef ENABLE_PLUGIN
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
#include "buffer.h"
#include "error.h"
#include "misc.h"
}
#endif
-#if defined(USE_LIBDL)
+#ifndef WIN32
static void
libdl_resolve_symbol (void *handle, void **dest, const char *symbol, const char *plugin_name, const unsigned int flags)
msg (M_FATAL, "PLUGIN: could not find required symbol '%s' in plugin shared object %s: %s", symbol, plugin_name, dlerror());
}
-#elif defined(USE_LOAD_LIBRARY)
+#else
static void
dll_resolve_symbol (HMODULE module, void **dest, const char *symbol, const char *plugin_name, const unsigned int flags)
p->so_pathname = o->so_pathname;
p->plugin_type_mask = plugin_supported_types ();
-#if defined(USE_LIBDL)
+#ifndef WIN32
p->handle = NULL;
#if defined(PLUGIN_LIBDIR)
# define PLUGIN_SYM(var, name, flags) libdl_resolve_symbol (p->handle, (void*)&p->var, name, p->so_pathname, flags)
-#elif defined(USE_LOAD_LIBRARY)
+#else
rel = !absolute_pathname (p->so_pathname);
p->module = LoadLibraryW (wide_string (p->so_pathname, &gc));
if (p->plugin_handle)
(*p->close)(p->plugin_handle);
-#if defined(USE_LIBDL)
+#ifndef WIN32
if (dlclose (p->handle))
msg (M_WARN, "PLUGIN_CLOSE: dlclose() failed on plugin: %s", p->so_pathname);
-#elif defined(USE_LOAD_LIBRARY)
+#elif defined(WIN32)
if (!FreeLibrary (p->module))
msg (M_WARN, "PLUGIN_CLOSE: FreeLibrary() failed on plugin: %s", p->so_pathname);
#endif