*** import.c-dist Wed Oct 13 16:45:54 1993
--- import.c Wed Oct 13 17:40:27 1993
***************
*** 47,53 ****
--- 47,58 ----
#endif
#ifdef USE_DL
+ #ifdef SUN_SHLIB
+ #include <dlfcn.h>
+ typedef void (*dl_funcptr)();
+ #else
#include "dl.h"
+ #endif /* SUN_SHLIB */
extern char *argv0;
#endif
***************
*** 98,104 ****
--- 103,113 ----
#define PY_SUFFIX ".py"
#ifdef USE_DL
+ #ifdef SUN_SHLIB
+ #define O_SUFFIX "module.so"
+ #else
#define O_SUFFIX "module.o"
+ #endif /* SUN_SHLIB */
#endif
/* Find and open a module file, using sys.path.
***************
*** 183,189 ****
--- 192,205 ----
dl_funcptr p;
D(fprintf(stderr, "Found %s\n", namebuf));
sprintf(funcname, "init%s", name);
+ #ifdef SUN_SHLIB
+ {
+ void *handle = dlopen (namebuf, 1);
+ p = (dl_funcptr) dlsym(handle, funcname);
+ }
+ #else
p = dl_loadmod(argv0, namebuf, funcname);
+ #endif /* SUN_SHLIB */
if (p == NULL) {
D(fprintf(stderr, "dl_loadmod failed\n"));
}
To link python dynamically under SunOS, just remove the -Bstatic flag
when linking, and define the SUN_SHLIB flag when compiling import.c.
To create a new object module that is capable of being dynamically
loaded, type "ld -o foomodule.so foomodule.c". Note the ".so" suffix.
I'd really like to be able to move stdwin to a dynamically loaded object
module, but there is stdwin-specific code in config.c which makes some
initialization and finalization calls to the STDWIN library. Could that
code be moved/replaced?
Bill