diff --git a/legacy/evas/configure.in b/legacy/evas/configure.in index ecfcc16e9b..96ebf43a30 100644 --- a/legacy/evas/configure.in +++ b/legacy/evas/configure.in @@ -124,6 +124,21 @@ AC_PATH_GENERIC(freetype, 9.5.0, [ 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 diff --git a/legacy/evas/src/lib/Makefile.am b/legacy/evas/src/lib/Makefile.am index fad06dc2db..8b605da1e9 100644 --- a/legacy/evas/src/lib/Makefile.am +++ b/legacy/evas/src/lib/Makefile.am @@ -24,7 +24,7 @@ libevas_la_LIBADD = \ imaging/libevas_imaging.la \ engines/common/libevas_engine_common.la \ -lm \ - -ldl \ + @dlopen_libs@ \ @FREETYPE_LIBS@ \ @png_libs@ @jpeg_libs@ @eet_libs@ @edb_libs@ diff --git a/legacy/evas/src/lib/file/evas_module.c b/legacy/evas/src/lib/file/evas_module.c index 791cab8c7f..2ad2d5c37d 100644 --- a/legacy/evas/src/lib/file/evas_module.c +++ b/legacy/evas/src/lib/file/evas_module.c @@ -53,7 +53,6 @@ evas_module_paths_init(void) char *path; int i; Evas_List *paths = NULL; - Dl_info evas_dl; /* 1. ~/.evas/modules/ */ prefix = getenv("HOME"); @@ -65,23 +64,36 @@ evas_module_paths_init(void) paths = evas_list_append(paths,path); else free(path); - + #ifdef HAVE_DLADDR - if (dladdr(evas_module_paths_init, &evas_dl)) { - int length; - - length = strlen(rindex(evas_dl.dli_fname, '/')); - path = malloc(strlen(evas_dl.dli_fname) - length + strlen("/evas/modules") + 1); - strncpy(path, evas_dl.dli_fname, strlen(evas_dl.dli_fname) - length); - strcat(path, "/evas/modules"); - if (evas_file_path_exists(path)) - paths = evas_list_append(paths, path); - else - free(path); + Dl_info evas_dl; + /* 3. libevas.so/../evas/modules/ */ + if (dladdr(evas_module_paths_init, &evas_dl)) + { + int length; + + if (strrchr(evas_dl.dli_fname, '/')) + { + length = strlen(strrchr(evas_dl.dli_fname, '/')); + 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 - /* 2. PREFIX/evas/modules/ */ + /* 3. PREFIX/evas/modules/ */ prefix = PACKAGE_LIB_DIR; path = malloc(strlen(prefix) + 1 + strlen("/evas/modules")); strcpy(path, prefix);