Index: Makefile.in =================================================================== RCS file: /cvsroot/tcltrf/trf/Makefile.in,v retrieving revision 1.7 diff -u -u -p -r1.7 Makefile.in --- Makefile.in 9 Jan 2003 21:26:58 -0000 1.7 +++ Makefile.in 26 Dec 2003 01:19:45 -0000 @@ -208,6 +208,7 @@ MAKE_STATIC_LIB = @MAKE_STATIC_LIB@ MAKE_STUB_LIB = @MAKE_STUB_LIB@ OBJEXT = @OBJEXT@ RANLIB = @RANLIB@ +RANLIB_STUB = @RANLIB_STUB@ SHLIB_CFLAGS = @SHLIB_CFLAGS@ SHLIB_SUFFIX = @SHLIB_SUFFIX@ SHLIB_LD = @SHLIB_LD@ @@ -232,6 +233,7 @@ TCL_LIBS = @TCL_LIBS@ EXTRA_PATH = $(top_builddir):$(TCL_BIN_DIR) TCLSH_ENV = TCL_LIBRARY=`@CYGPATH@ $(TCL_SRC_DIR)/library` \ LD_LIBRARY_PATH="$(EXTRA_PATH):$(LD_LIBRARY_PATH)" \ + DYLD_LIBRARY_PATH="$(EXTRA_PATH):$(DYLD_LIBRARY_PATH)" \ LIBPATH="$(EXTRA_PATH):${LIBPATH}" \ SHLIB_PATH="$(EXTRA_PATH):${SHLIB_PATH}" \ PATH="$(EXTRA_PATH):$(PATH)" \ @@ -368,7 +370,7 @@ $($(PACKAGE)_LIB_FILE): $($(PACKAGE)_OBJ $($(PACKAGE)stub_LIB_FILE): $($(PACKAGE)stub_OBJECTS) -rm -f $($(PACKAGE)stub_LIB_FILE) ${MAKE_STUB_LIB} - $(RANLIB) $($(PACKAGE)stub_LIB_FILE) + $(RANLIB_STUB) $($(PACKAGE)stub_LIB_FILE) #======================================================================== # MD5 targets - Not anymore, integrated with main library @@ -511,8 +513,14 @@ install-lib-binaries: if test -f $$p; then \ echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkglibdir)/$$p"; \ $(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkglibdir)/$$p; \ + stub=`echo $$p|sed -e "s/.*\(stub\).*/\1/"`; \ + if test "x$$stub" = "xstub"; then \ + echo " $(RANLIB_STUB) $(DESTDIR)$(pkglibdir)/$$p"; \ + $(RANLIB_STUB) $(DESTDIR)$(pkglibdir)/$$p; \ + else \ echo " $(RANLIB) $(DESTDIR)$(pkglibdir)/$$p"; \ $(RANLIB) $(DESTDIR)$(pkglibdir)/$$p; \ + fi; \ ext=`echo $$p|sed -e "s/.*\.//"`; \ if test "x$$ext" = "xdll"; then \ lib=`basename $$p|sed -e 's/.[^.]*$$//'`.lib; \ Index: configure.in =================================================================== RCS file: /cvsroot/tcltrf/trf/configure.in,v retrieving revision 1.9 diff -u -u -p -r1.9 configure.in --- configure.in 9 Jan 2003 21:27:00 -0000 1.9 +++ configure.in 26 Dec 2003 01:19:52 -0000 @@ -258,9 +258,9 @@ TEA_MAKE_LIB if test $HAVE_zlibtcl_PACKAGE -gt 0 ; then if test "${TEA_PLATFORM}" = "windows" -a "$GCC" != "yes" ; then - SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${zlibtcl_STUB_LIB_PATH}`\"" + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} \"`${CYGPATH} ${zlibtcl_BUILD_STUB_LIB_PATH}`\"" else - SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${zlibtcl_STUB_LIB_SPEC}" + SHLIB_LD_LIBS="${SHLIB_LD_LIBS} ${zlibtcl_BUILD_STUB_LIB_SPEC}" fi fi AC_SUBST(SHLIB_SUFFIX) Index: trf.m4 =================================================================== RCS file: /cvsroot/tcltrf/trf/trf.m4,v retrieving revision 1.3 diff -u -u -p -r1.3 trf.m4 --- trf.m4 1 Oct 2002 23:01:46 -0000 1.3 +++ trf.m4 26 Dec 2003 01:19:52 -0000 @@ -159,7 +159,7 @@ AC_CACHE_CHECK(for libz library, break fi - for libsuff in .so ".so.*" .sl .a; do + for libsuff in .so ".so.*" .sl .a .dylib; do if test -n "$trf_cv_lib_ZLIB_LIB_DIR"; then break fi @@ -277,7 +277,7 @@ AC_CACHE_CHECK(for ssl libcrypto library break fi - for libsuff in .so ".so.*" .sl .a; do + for libsuff in .so ".so.*" .sl .a .dylib; do if test -n "$trf_cv_lib_SSL_LIB_DIR"; then break fi @@ -327,7 +327,7 @@ AC_CACHE_CHECK(for bz2 compressor librar break fi - for libsuff in .so ".so.*" .sl .a; do + for libsuff in .so ".so.*" .sl .a .dylib; do if test -n "$trf_cv_lib_BZ2_LIB_DIR"; then break fi Index: compat/tclLoadDyld.c =================================================================== RCS file: compat/tclLoadDyld.c diff -N compat/tclLoadDyld.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ compat/tclLoadDyld.c 26 Dec 2003 01:19:52 -0000 @@ -0,0 +1,166 @@ +/* + * tclLoadDyld.c -- + * + * This procedure provides a version of the TclLoadFile that + * works with Apple's dyld dynamic loading. This file + * provided by Wilfredo Sanchez (wsanchez@apple.com). + * This works on Mac OS X. + * + * Copyright (c) 1995 Apple Computer, Inc. + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * RCS: @(#) $Id: tclLoadDyld.c,v 1.12 2002/07/24 13:51:18 das Exp $ + */ + +#include +#include + +#include "tcl.h" + +typedef struct Tcl_DyldModuleHandle { + struct Tcl_DyldModuleHandle *nextModuleHandle; + NSModule module; +} Tcl_DyldModuleHandle; + +typedef struct Tcl_DyldLoadHandle { + const struct mach_header *dyld_lib; + Tcl_DyldModuleHandle *firstModuleHandle; +} Tcl_DyldLoadHandle; + +/* + *---------------------------------------------------------------------- + * + * TclpDlopen -- + * + * Dynamically loads a binary code file into memory and returns + * a handle to the new code. + * + * Results: + * A standard Tcl completion code. If an error occurs, an error + * message is left in the interpreter's result. + * + * Side effects: + * New code suddenly appears in memory. + * + *---------------------------------------------------------------------- + */ + +VOID * +dlopen(path, flags) + CONST char *path; + int flags; +{ + Tcl_DyldLoadHandle *dyldLoadHandle; + const struct mach_header *dyld_lib; + + dyld_lib = NSAddImage(path, + NSADDIMAGE_OPTION_WITH_SEARCHING | + NSADDIMAGE_OPTION_RETURN_ON_ERROR); + + if (!dyld_lib) { + return NULL; + } + dyldLoadHandle = (Tcl_DyldLoadHandle *) ckalloc(sizeof(Tcl_DyldLoadHandle)); + if (!dyldLoadHandle) return NULL; + dyldLoadHandle->dyld_lib = dyld_lib; + dyldLoadHandle->firstModuleHandle = NULL; + return (Tcl_LoadHandle) dyldLoadHandle; +} + +char * +dlerror() +{ + NSLinkEditErrors editError; + char *name, *msg; + NSLinkEditError(&editError, &errno, &name, &msg); + return msg; +} + +/* + *---------------------------------------------------------------------- + * + * TclpFindSymbol -- + * + * Looks up a symbol, by name, through a handle associated with + * a previously loaded piece of code (shared library). + * + * Results: + * Returns a pointer to the function associated with 'symbol' if + * it is found. Otherwise returns NULL and may leave an error + * message in the interp's result. + * + *---------------------------------------------------------------------- + */ +VOID *dlsym(handle, symbol) + VOID *handle; + CONST char *symbol; +{ + NSSymbol nsSymbol; + CONST char *native; + Tcl_DString newName, ds; + Tcl_PackageInitProc* proc = NULL; + Tcl_DyldLoadHandle *dyldLoadHandle = (Tcl_DyldLoadHandle *) handle; + /* + * dyld adds an underscore to the beginning of symbol names. + */ + + native = Tcl_UtfToExternalDString(NULL, symbol, -1, &ds); + Tcl_DStringInit(&newName); + Tcl_DStringAppend(&newName, "_", 1); + native = Tcl_DStringAppend(&newName, native, -1); + nsSymbol = NSLookupSymbolInImage(dyldLoadHandle->dyld_lib, native, + NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW | + NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); + if(nsSymbol) { + Tcl_DyldModuleHandle *dyldModuleHandle; + proc = NSAddressOfSymbol(nsSymbol); + dyldModuleHandle = (Tcl_DyldModuleHandle *) ckalloc(sizeof(Tcl_DyldModuleHandle)); + if (dyldModuleHandle) { + dyldModuleHandle->module = NSModuleForSymbol(nsSymbol); + dyldModuleHandle->nextModuleHandle = dyldLoadHandle->firstModuleHandle; + dyldLoadHandle->firstModuleHandle = dyldModuleHandle; + } + } + Tcl_DStringFree(&newName); + Tcl_DStringFree(&ds); + + return proc; +} + +/* + *---------------------------------------------------------------------- + * + * TclpUnloadFile -- + * + * Unloads a dynamically loaded binary code file from memory. + * Code pointers in the formerly loaded file are no longer valid + * after calling this function. + * + * Results: + * None. + * + * Side effects: + * Code dissapears from memory. + * Note that this is a no-op on older (OpenStep) versions of dyld. + * + *---------------------------------------------------------------------- + */ + +int +dlclose(handle) + VOID *handle; +{ + Tcl_DyldLoadHandle *dyldLoadHandle = (Tcl_DyldLoadHandle *) handle; + Tcl_DyldModuleHandle *dyldModuleHandle = dyldLoadHandle->firstModuleHandle; + void *ptr; + + while (dyldModuleHandle) { + NSUnLinkModule(dyldModuleHandle->module, NSUNLINKMODULE_OPTION_NONE); + ptr = dyldModuleHandle; + dyldModuleHandle = dyldModuleHandle->nextModuleHandle; + ckfree(ptr); + } + ckfree(dyldLoadHandle); +} Index: tclconfig/tcl.m4 =================================================================== RCS file: /cvsroot/tcltrf/trf/tclconfig/tcl.m4,v retrieving revision 1.6 diff -u -u -p -r1.6 tcl.m4 --- tclconfig/tcl.m4 4 Apr 2003 21:27:36 -0000 1.6 +++ tclconfig/tcl.m4 26 Dec 2003 01:19:57 -0000 @@ -2591,6 +2591,7 @@ AC_DEFUN(TEA_MAKE_LIB, [ # substituted. #-------------------------------------------------------------------- + RANLIB_STUB="${RANLIB}" if test "${TEA_PLATFORM}" = "windows" ; then if test "${SHARED_BUILD}" = "1" ; then # We force the unresolved linking of symbols that are really in @@ -2632,6 +2633,7 @@ AC_DEFUN(TEA_MAKE_LIB, [ AC_SUBST(MAKE_SHARED_LIB) AC_SUBST(MAKE_STATIC_LIB) AC_SUBST(MAKE_STUB_LIB) + AC_SUBST(RANLIB_STUB) ]) #------------------------------------------------------------------------