mirror of
https://framagit.org/bortzmeyer/echoping
synced 2024-11-10 19:10:34 +00:00
Proper detection of installation directory and loading of plugins
This commit is contained in:
parent
dfdf9866c0
commit
7671c535bc
771
SRC/configure
vendored
771
SRC/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -271,8 +271,8 @@ fi
|
|||||||
|
|
||||||
interpolate() {
|
interpolate() {
|
||||||
old=$1
|
old=$1
|
||||||
|
AC_MSG_WARN(DEBUG-INTERPOLATE $old)
|
||||||
eval new=$old
|
eval new=$old
|
||||||
AC_MSG_WARN(DEBUG-INTERPOLATE $new)
|
|
||||||
if test "$new" != "$old" ; then
|
if test "$new" != "$old" ; then
|
||||||
interpolate $new
|
interpolate $new
|
||||||
else
|
else
|
||||||
@ -281,7 +281,20 @@ interpolate() {
|
|||||||
}
|
}
|
||||||
dnl TODO: the following is broken because installation prefix can be changed at instal-time,
|
dnl TODO: the following is broken because installation prefix can be changed at instal-time,
|
||||||
dnl not compilation 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_DEFINE_UNQUOTED(PLUGINS_DIR, "$plugins_dir", [Directory where the plugins will be installed])
|
||||||
AC_CONFIG_SUBDIRS(plugins)
|
AC_CONFIG_SUBDIRS(plugins)
|
||||||
AC_OUTPUT(Makefile)
|
AC_OUTPUT(Makefile)
|
||||||
|
@ -84,7 +84,7 @@ main (argc, argv)
|
|||||||
unsigned int fill_i;
|
unsigned int fill_i;
|
||||||
unsigned short fill_requested = 0;
|
unsigned short fill_requested = 0;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
char *plugin_name = NULL;
|
char *plugin_name, *complete_plugin_name = NULL;
|
||||||
char *ext;
|
char *ext;
|
||||||
void *plugin;
|
void *plugin;
|
||||||
char *dl_result;
|
char *dl_result;
|
||||||
@ -120,8 +120,6 @@ main (argc, argv)
|
|||||||
|
|
||||||
unsigned short stop_at_newlines = 1;
|
unsigned short stop_at_newlines = 1;
|
||||||
|
|
||||||
char *newenv, *curenv;
|
|
||||||
|
|
||||||
#ifdef OPENSSL
|
#ifdef OPENSSL
|
||||||
SSL_METHOD *meth;
|
SSL_METHOD *meth;
|
||||||
SSL_CTX *ctx = NULL;
|
SSL_CTX *ctx = NULL;
|
||||||
@ -436,17 +434,16 @@ main (argc, argv)
|
|||||||
ext = strstr(plugin_name, ".so");
|
ext = strstr(plugin_name, ".so");
|
||||||
if ((ext == NULL) || (strcmp (ext, ".so") != 0))
|
if ((ext == NULL) || (strcmp (ext, ".so") != 0))
|
||||||
sprintf (plugin_name, "%s.so", plugin_name);
|
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);
|
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)
|
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");
|
plugin_init = dlsym (plugin, "init");
|
||||||
dl_result = dlerror ();
|
dl_result = dlerror ();
|
||||||
|
Loading…
Reference in New Issue
Block a user