anmd fix dlopen link detection , actually check for dladdr as it's a gnu

extension etc.


SVN revision: 19777
This commit is contained in:
Carsten Haitzler 2006-01-14 12:36:25 +00:00
parent f435375b19
commit 55172140f9
3 changed files with 42 additions and 15 deletions

View File

@ -124,6 +124,21 @@ AC_PATH_GENERIC(freetype, 9.5.0,
[ AC_MSG_ERROR(Freetype isn't installed) ] [ AC_MSG_ERROR(Freetype isn't installed) ]
) )
dlopen_libs=""
AC_CHECK_FUNCS(dlopen, res=yes, res=no)
if test "x$res" = "xyes"; then
AC_CHECK_FUNCS(dladdr, AC_DEFINE(HAVE_DLADDR))
else
AC_CHECK_LIB(dl, dlopen, res=yes, res=no)
if test "x$res" = "xyes"; then
AC_CHECK_LIB(dl, dladdr, AC_DEFINE(HAVE_DLADDR))
dlopen_libs=-ldl
else
AC_MSG_ERROR(Cannot find dlopen)
fi
fi
AC_SUBST(dlopen_libs)
##################################################################### #####################################################################
## Engines ## Engines

View File

@ -24,7 +24,7 @@ libevas_la_LIBADD = \
imaging/libevas_imaging.la \ imaging/libevas_imaging.la \
engines/common/libevas_engine_common.la \ engines/common/libevas_engine_common.la \
-lm \ -lm \
-ldl \ @dlopen_libs@ \
@FREETYPE_LIBS@ \ @FREETYPE_LIBS@ \
@png_libs@ @jpeg_libs@ @eet_libs@ @edb_libs@ @png_libs@ @jpeg_libs@ @eet_libs@ @edb_libs@

View File

@ -53,7 +53,6 @@ evas_module_paths_init(void)
char *path; char *path;
int i; int i;
Evas_List *paths = NULL; Evas_List *paths = NULL;
Dl_info evas_dl;
/* 1. ~/.evas/modules/ */ /* 1. ~/.evas/modules/ */
prefix = getenv("HOME"); prefix = getenv("HOME");
@ -65,23 +64,36 @@ evas_module_paths_init(void)
paths = evas_list_append(paths,path); paths = evas_list_append(paths,path);
else else
free(path); free(path);
#ifdef HAVE_DLADDR #ifdef HAVE_DLADDR
if (dladdr(evas_module_paths_init, &evas_dl))
{ {
int length; Dl_info evas_dl;
/* 3. libevas.so/../evas/modules/ */
length = strlen(rindex(evas_dl.dli_fname, '/')); if (dladdr(evas_module_paths_init, &evas_dl))
path = malloc(strlen(evas_dl.dli_fname) - length + strlen("/evas/modules") + 1); {
strncpy(path, evas_dl.dli_fname, strlen(evas_dl.dli_fname) - length); int length;
strcat(path, "/evas/modules");
if (evas_file_path_exists(path)) if (strrchr(evas_dl.dli_fname, '/'))
paths = evas_list_append(paths, path); {
else length = strlen(strrchr(evas_dl.dli_fname, '/'));
free(path); path = malloc(strlen(evas_dl.dli_fname) - length +
strlen("/evas/modules") + 1);
if (path)
{
strncpy(path, evas_dl.dli_fname,
strlen(evas_dl.dli_fname) - length);
path[strlen(evas_dl.dli_fname) - length] = 0;
strcat(path, "/evas/modules");
if (evas_file_path_exists(path))
paths = evas_list_append(paths, path);
else
free(path);
}
}
}
} }
#else #else
/* 2. PREFIX/evas/modules/ */ /* 3. PREFIX/evas/modules/ */
prefix = PACKAGE_LIB_DIR; prefix = PACKAGE_LIB_DIR;
path = malloc(strlen(prefix) + 1 + strlen("/evas/modules")); path = malloc(strlen(prefix) + 1 + strlen("/evas/modules"));
strcpy(path, prefix); strcpy(path, prefix);