From: Thomas Tanner Date: Thu, 18 Mar 1999 17:40:51 +0000 (+0000) Subject: * NEWS: improved support for BeOS and Cygwin X-Git-Tag: release-1-3~116 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d8cbe02c4069fdf0a94d3bd9fe2fdf83b280b137;p=thirdparty%2Flibtool.git * NEWS: improved support for BeOS and Cygwin * libltdl/ltdl.c: added two new error messages (cannot_open_error, cannot_close_error), use them where approriate, BeOS support (thanks to Xavier Pianet), on BeOS search modules additionally in ADDON_PATH * libtool.m4: rewrote AC_CHECK_LIBM: BeOS and Cygwin don't have libm and *-ncr-sysv4.3* requires libmw * ltconfig.in: don't check for LoadLibrary, hardcode dlopen configuration for BeOS and Cygwin * ltmain.in: ignore -lm on BeOS and Cygwin, always ignore -lc --- diff --git a/ChangeLog b/ChangeLog index 04b5ff7ee..be7645292 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +1999-03-18 Thomas Tanner + + * NEWS: improved support for BeOS and Cygwin + * libltdl/ltdl.c: added two new error messages (cannot_open_error, + cannot_close_error), use them where approriate, + BeOS support (thanks to Xavier Pianet), on BeOS search modules + additionally in ADDON_PATH + * libtool.m4: rewrote AC_CHECK_LIBM: BeOS and Cygwin don't have + libm and *-ncr-sysv4.3* requires libmw + * ltconfig.in: don't check for LoadLibrary, hardcode dlopen + configuration for BeOS and Cygwin + * ltmain.in: ignore -lm on BeOS and Cygwin, always ignore -lc + 1999-03-17 Alexandre Oliva * ltconfig.in (hpux*, hardcode_minus_L): should be no, we have +b diff --git a/NEWS b/NEWS index caac526a7..0f4f669e4 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,9 @@ NEWS - list of user-visible changes between releases of GNU Libtool New in 1.2g: CVS version, Libtool team: -* Nothing so far - +* dlopen support for BeOS +* Improved support for BeOS and Cygwin + New in 1.2e: CVS version; 1.2f: 1999-03-15, Libtool team: * libtool will correctly link uninstalled libraries into programs and prefer uninstalled libraries to installed ones diff --git a/autogen b/autogen index 2a35dcac5..4cda5fe0e 100644 --- a/autogen +++ b/autogen @@ -14,7 +14,7 @@ aclocal automake --gnits --add-missing autoconf -for sub in demo depdemo libltdl mdemo cdemo; do +for sub in demo libltdl mdemo cdemo; do cd $sub rm -f acinclude.m4 cp ../libtool.m4 acinclude.m4 diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index 571215638..221da1237 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -82,6 +82,8 @@ static const char unknown_error[] = "unknown error"; static const char dlopen_not_supported_error[] = "dlopen support not available"; static const char file_not_found_error[] = "file not found"; static const char no_symbols_error[] = "no symbols defined"; +static const char cannot_open_error[] = "can't open the module"; +static const char cannot_close_error[] = "can't close the module"; static const char symbol_error[] = "symbol not found"; static const char memory_error[] = "not enough memory"; static const char invalid_handle_error[] = "invalid handle"; @@ -204,10 +206,6 @@ strrchr(str, ch) # include #endif -#if ! HAVE_DLERROR /* not all platforms have dlerror() */ -#define dlerror() unknown_error -#endif - #ifdef RTLD_GLOBAL # define LTDL_GLOBAL RTLD_GLOBAL #else @@ -259,7 +257,11 @@ dl_open (handle, filename) { handle->handle = dlopen(filename, LTDL_GLOBAL | LTDL_LAZY_OR_NOW); if (!handle->handle) { +#if HAVE_DLERROR last_error = dlerror(); +#else + last_error = cannot_open_error; +#endif return 1; } return 0; @@ -270,7 +272,11 @@ dl_close (handle) lt_dlhandle handle; { if (dlclose(handle->handle) != 0) { +#if HAVE_DLERROR last_error = dlerror(); +#else + last_error = cannot_close_error; +#endif return 1; } return 0; @@ -284,7 +290,11 @@ dl_sym (handle, symbol) lt_ptr_t address = dlsym(handle->handle, symbol); if (!address) +#if HAVE_DLERROR last_error = dlerror(); +#else + last_error = symbol_error; +#endif return address; } @@ -365,7 +375,7 @@ shl_open (handle, filename) { handle->handle = shl_load(filename, LTDL_BIND_FLAGS, 0L); if (!handle->handle) { - last_error = unknown_error; + last_error = cannot_open_error; return 1; } return 0; @@ -376,7 +386,7 @@ shl_close (handle) lt_dlhandle handle; { if (shl_unload((shl_t) (handle->handle)) != 0) { - last_error = unknown_error; + last_error = cannot_close_error; return 1; } return 0; @@ -391,7 +401,7 @@ shl_sym (handle, symbol) if (shl_findsym((shl_t) (handle->handle), symbol, TYPE_UNDEFINED, &address) != 0 || !(handle->handle) || !address) { - last_error = unknown_error; + last_error = symbol_error; return 0; } return address; @@ -438,7 +448,7 @@ dld_open (handle, filename) return 1; } if (dld_link(filename) != 0) { - last_error = unknown_error; + last_error = cannot_open_error; lt_dlfree(handle->handle); return 1; } @@ -450,7 +460,7 @@ dld_close (handle) lt_dlhandle handle; { if (dld_unlink_by_file((char*)(handle->handle), 1) != 0) { - last_error = unknown_error; + last_error = cannot_close_error; return 1; } lt_dlfree(handle->filename); @@ -465,7 +475,7 @@ dld_sym (handle, symbol) lt_ptr_t address = dld_get_func(symbol); if (!address) - last_error = unknown_error; + last_error = symbol_error; return address; } @@ -504,7 +514,7 @@ wll_open (handle, filename) { handle->handle = LoadLibrary(filename); if (!handle->handle) { - last_error = unknown_error; + last_error = cannot_open_error; return 1; } return 0; @@ -515,7 +525,7 @@ wll_close (handle) lt_dlhandle handle; { if (FreeLibrary(handle->handle) != 0) { - last_error = unknown_error; + last_error = cannot_close_error; return 1; } return 0; @@ -529,7 +539,7 @@ wll_sym (handle, symbol) lt_ptr_t address = GetProcAddress(handle->handle, symbol); if (!address) - last_error = unknown_error; + last_error = symbol_error; return address; } @@ -543,6 +553,84 @@ wll = { LTDL_TYPE_TOP, 0, wll_init, wll_exit, #endif +#ifdef __BEOS__ + +/* dynamic linking for BeOS */ + +#include + +static int +bedl_init () +{ + return 0; +} + +static int +bedl_exit () +{ + return 0; +} + +static int +bedl_open (handle, filename) + lt_dlhandle handle; + const char *filename; +{ + image_id image = 0; + + if (filename) { + image = load_add_on(filename); + } else { + image_info info; + int32 cookie = 0; + if (get_next_image_info(0, &cookie, &info) == B_OK) + image = load_add_on(info.name); + } + if (image <= 0) { + last_error = cannot_open_error; + return 1; + } + handle->handle = (void*) image; + return 0; +} + +static int +bedl_close (handle) + lt_dlhandle handle; +{ + if (unload_add_on((image_id)handle->handle) != B_OK) { + last_error = cannot_close_error; + return 1; + } + return 0; +} + +static lt_ptr_t +bedl_sym (handle, symbol) + lt_dlhandle handle; + const char *symbol; +{ + lt_ptr_t address = 0; + image_id image = (image_id)handle->handle; + + if (get_image_symbol(image, symbol, B_SYMBOL_TYPE_ANY, + &address) != B_OK) { + last_error = symbol_error; + return 0; + } + return address; +} + +static +lt_dltype_t +bedl = { LTDL_TYPE_TOP, 0, bedl_init, bedl_exit, + bedl_open, bedl_close, bedl_sym }; + +#undef LTDL_TYPE_TOP +#define LTDL_TYPE_TOP &bedl + +#endif + /* emulate dynamic linking using preloaded_symbols */ typedef struct lt_dlsymlists_t { @@ -1117,6 +1205,12 @@ lt_dlopen (filename) file = (FILE*) find_file(basename, getenv("LTDL_LIBRARY_PATH"), &dir, 0); +#ifdef __BEOS__ + if (!file) + file = (FILE*) find_file(basename, + getenv("ADDON_PATH"), + &dir, 0); +#endif #ifdef LTDL_SHLIBPATH_VAR if (!file) file = (FILE*) find_file(basename, diff --git a/libtool.m4 b/libtool.m4 index f7661efd2..7b3dd4615 100644 --- a/libtool.m4 +++ b/libtool.m4 @@ -568,9 +568,20 @@ AC_SUBST(USE_SYMBOL_UNDERSCORE)dnl ]) # AC_CHECK_LIBM - check for math library -AC_DEFUN(AC_CHECK_LIBM, [ -AC_CHECK_LIB(mw, _mwvalidcheckl) -AC_CHECK_LIB(m, cos) +AC_DEFUN(AC_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +case "$host" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl) + AC_CHECK_LIB(m, cos) + ;; +*) + AC_CHECK_LIB(m, cos) + ;; +esac ]) # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for diff --git a/ltconfig.in b/ltconfig.in index 1a91d7a31..6766d1b9d 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -1630,6 +1630,9 @@ beos*) library_names_spec='${libname}.so' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes ;; bsdi4*) @@ -1661,6 +1664,8 @@ cygwin* | mingw*) need_lib_prefix=no # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= ;; freebsd1*) @@ -2139,54 +2144,6 @@ if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then lt_cv_dlopen="shl_load" else echo "$ac_t""no" 1>&6 -echo $ac_n "checking for LoadLibrary""... $ac_c" 1>&6 -echo "$progname:@LINENO@: checking for LoadLibrary" >&5 -if eval "test \"`echo '$''{'ac_cv_func_LoadLibrary'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -/* Override any gcc2 internal prototype to avoid an error. */ -/* We use char because int might match the return type of a gcc2 - builtin and then its argument prototype would still apply. */ -char LoadLibrary(); - -int main() { - -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined (__stub_LoadLibrary) || defined (__stub___LoadLibrary) -choke me -#else -LoadLibrary(); -#endif - -; return 0; } -EOF -if { (eval echo $progname:@LINENO@: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then - rm -rf conftest* - eval "ac_cv_func_LoadLibrary=yes" -else - echo "$progname: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_func_LoadLibrary=no" -fi -rm -f conftest* -fi - -if eval "test \"`echo '$ac_cv_func_'LoadLibrary`\" = yes"; then - echo "$ac_t""yes" 1>&6 - lt_cv_dlopen="LoadLibrary" -else - echo "$ac_t""no" 1>&6 -fi - - fi diff --git a/ltmain.in b/ltmain.in index 9411a9083..0294541d5 100644 --- a/ltmain.in +++ b/ltmain.in @@ -1010,6 +1010,17 @@ compiler." ;; -l*) + if test "$arg" = "-lm"; then + case "$host" in + *-*-cygwin* | *-*-beos*) + # Ignore -lm on Cygwin and BeOS + continue + ;; + esac + elif test "$arg" = "-lc"; then + # Always ignore -lc + continue + fi deplibs="$deplibs $arg" ;;