Proper detection of installation directory and loading of plugins

Initial
Stephane Bortzmeyer 20 years ago
parent dfdf9866c0
commit 7671c535bc

761
SRC/configure vendored

File diff suppressed because it is too large Load Diff

@ -271,8 +271,8 @@ fi
interpolate() {
old=$1
AC_MSG_WARN(DEBUG-INTERPOLATE $old)
eval new=$old
AC_MSG_WARN(DEBUG-INTERPOLATE $new)
if test "$new" != "$old" ; then
interpolate $new
else
@ -281,7 +281,20 @@ interpolate() {
}
dnl TODO: the following is broken because installation prefix can be changed at instal-time,
dnl not compilation time.
plugins_dir=`interpolate '$prefix/lib/echoping'`
if test "x$libdir" = 'x${exec_prefix}/lib' ; then # Default value
if test "x$exec_prefix" = "xNONE" ; then # Default value
if test "x$prefix" = "xNONE" ; then # Default value
plugins_dir=`interpolate '$ac_default_prefix/lib/echoping'`
else
exec_prefix='${prefix}'
plugins_dir=`interpolate '$libdir/echoping'`
fi
else
plugins_dir=`interpolate '$libdir/echoping'`
fi
else
plugins_dir=`interpolate '$libdir/echoping'`
fi
AC_DEFINE_UNQUOTED(PLUGINS_DIR, "$plugins_dir", [Directory where the plugins will be installed])
AC_CONFIG_SUBDIRS(plugins)
AC_OUTPUT(Makefile)

@ -84,7 +84,7 @@ main (argc, argv)
unsigned int fill_i;
unsigned short fill_requested = 0;
unsigned int i = 0;
char *plugin_name = NULL;
char *plugin_name, *complete_plugin_name = NULL;
char *ext;
void *plugin;
char *dl_result;
@ -120,8 +120,6 @@ main (argc, argv)
unsigned short stop_at_newlines = 1;
char *newenv, *curenv;
#ifdef OPENSSL
SSL_METHOD *meth;
SSL_CTX *ctx = NULL;
@ -436,17 +434,16 @@ main (argc, argv)
ext = strstr(plugin_name, ".so");
if ((ext == NULL) || (strcmp (ext, ".so") != 0))
sprintf (plugin_name, "%s.so", plugin_name);
curenv = getenv ("LD_LIBRARY_PATH");
if (! curenv)
newenv = PLUGINS_DIR;
else
sprintf (newenv, "%s:%s", curenv, PLUGINS_DIR);
if (setenv ("LD_LIBRARY_PATH", newenv, 1) == -1)
err_sys ("Cannot change LD_LIBRARY_PATH");
plugin = dlopen (plugin_name, RTLD_NOW);
if (!plugin) { /* retries with the absolute name */
complete_plugin_name = (char *) malloc(MAX_LINE);
sprintf (complete_plugin_name, "%s/%s", PLUGINS_DIR, plugin_name);
plugin = dlopen (complete_plugin_name, RTLD_NOW);
}
if (!plugin)
{
err_sys ("Cannot load \"%s\": %s", plugin_name, dlerror ());
err_sys ("Cannot load \"%s\" (I tried the short name, then the complete name in \"%s\"): %s",
plugin_name, PLUGINS_DIR, dlerror ());
}
plugin_init = dlsym (plugin, "init");
dl_result = dlerror ();

Loading…
Cancel
Save