Index: README ================================================================== --- README +++ README @@ -59,11 +59,14 @@ c. ./kitcreator 9. Create a Tclkit with Metakit4 support, but using Zip for storage: a. $ ./kitcreator --enable-kit-storage=zip - 10. Create a KitDLL without Metakit support (will not create a Tclkit + 10. Create a Tclkit with Metakit4 support, but using C-VFS for storage + a. $ ./kitcreator --enable-kit-storage=cvfs + + 11. Create a KitDLL without Metakit support (will not create a Tclkit binary, just the library): a. $ KITCREATOR_PKGS='tk itcl kitdll' b. $ export KITCREATOR_PKGS c. $ ./kitcreator Index: kitcreator ================================================================== --- kitcreator +++ kitcreator @@ -20,11 +20,11 @@ mode="distclean" fi # Define the list of all packages, for cleaning purposes -KITCREATOR_ALLPKGS="kitsh tcl tclvfs zlib tk itcl mk4tcl thread kitdll" +KITCREATOR_ALLPKGS="kitsh tcl tclvfs zlib tk itcl mk4tcl thread" for pkg in ${KITCREATOR_ALLPKGS}; do rm -f "${pkg}/build.log" rm -rf "${pkg}/out" "${pkg}/inst" "${pkg}/build" rm -rf "${pkg}/src"/tmp-* @@ -100,11 +100,11 @@ fi export KITCREATOR_ICON KITCREATOR_RC failedpkgs="" buildfailed="0" -for pkg in tcl tclvfs zlib ${KITCREATOR_PKGS} "${KITTARGET}"; do +for pkg in tcl tclvfs zlib ${KITCREATOR_PKGS} kitsh; do echo -n "Building ${pkg} ..." failed="0" ( cd "${pkg}" >/dev/null 2>/dev/null || exit 1 @@ -137,9 +137,9 @@ if [ "${buildfailed}" != "0" ]; then echo 'WARNING: Build is likely incomplete or failed.' >&2 fi -cp 'kitdll/build'/kitdll-*/libtclkit* . >/dev/null 2>/dev/null +cp 'kitsh/build'/kitsh-*/libtclkit* . >/dev/null 2>/dev/null cp 'kitsh/build'/kitsh-*/kit "tclkit-${TCLVERS}" >/dev/null 2>/dev/null exit "${buildfailed}" DELETED kitdll/build.sh Index: kitdll/build.sh ================================================================== --- kitdll/build.sh +++ /dev/null @@ -1,142 +0,0 @@ -#! /bin/bash - -if [ ! -f 'build.sh' ]; then - echo 'ERROR: This script must be run from the directory it is in' >&2 - - exit 1 -fi -if [ -z "${TCLVERS}" ]; then - echo 'ERROR: The TCLVERS environment variable is not set' >&2 - - exit 1 -fi - -KITDLLVERS="0.0" -BUILDDIR="$(pwd)/build/kitdll-${KITDLLVERS}" -OUTDIR="$(pwd)/out" -INSTDIR="$(pwd)/inst" -OTHERPKGSDIR="$(pwd)/../" -export KITDLLVERS BUILDDIR OUTDIR INSTDIR OTHERPKGSDIR - -rm -rf 'build' 'out' 'inst' -mkdir 'out' 'inst' || exit 1 - -( - cp -r 'buildsrc' 'build' - cd "${BUILDDIR}" || exit 1 - - # Fix up archives that Tcl gets wrong - for archive in ../../../tcl/inst/lib/dde*/tcldde*.a ../../../tcl/inst/lib/reg*/tclreg*.a; do - if [ ! -f "${archive}" ]; then - continue - fi - - rm -rf __TEMP__ - ( - mkdir __TEMP__ || exit 1 - cd __TEMP__ - - ## Patch archive name - archive="../${archive}" - - "${AR:-ar}" x "${archive}" || exit 1 - - rm -f "${archive}" - - "${AR:-ar}" cr "${archive}" *.o || exit 1 - "${RANLIB:-ranlib}" "${archive}" || true - ) - done - - # Determine how we invoke a Tcl interpreter - for testsh in "${TCLSH_NATIVE:-false}" "${TCLKIT:-tclkit}"; do - if echo 'exit 0' | "${testsh}" >/dev/null 2>/dev/null; then - TCLSH_NATIVE="${testsh}" - - break - fi - done - - # Cleanup, just incase the incoming directory was not pre-cleaned - ${MAKE:-make} distclean >/dev/null 2>/dev/null - rm -rf "starpack.vfs" - - # Create VFS directory - mkdir "starpack.vfs" - mkdir "starpack.vfs/lib" - - ## Copy in required built directories - cp -r "${OTHERPKGSDIR}"/*/out/* 'starpack.vfs/' - - ## Rename the "vfs" package directory to what "boot.tcl" expects - mv 'starpack.vfs/lib'/vfs* 'starpack.vfs/lib/vfs' - - ## Install "boot.tcl" - cp 'boot.tcl' 'starpack.vfs/' - - # Include extra objects as required - ## Initialize list of extra objects - EXTRA_OBJS="" - - ## Figure out if zlib compiled (if not, the system zlib will be used and we - ## will need to have that present) - ZLIBDIR="$(cd "${OTHERPKGSDIR}/zlib/inst" 2>/dev/null && pwd)" - export ZLIBDIR - if [ -n "${ZLIBDIR}" -a -f "${ZLIBDIR}/lib/libz.a" ]; then - EXTRA_OBJS="${EXTRA_OBJS} ${ZLIBDIR}/lib/libz.a" - - ### Add lib directory for zlib - LDFLAGS="${LDFLAGS} -L${ZLIBDIR}/lib" - export LDFLAGS - - ### Add include directory for zlib - CFLAGS="${CFLAGS} -I${ZLIBDIR}/include" - CPPFLAGS="${CPPFLAGS} -I${ZLIBDIR}/include" - export CFLAGS CPPFLAGS - fi - - ## Tk Resources (needed for Win32 support) - TKDIR="$(cd "${OTHERPKGSDIR}/tk/inst" && pwd)" - TKRSRC="${TKDIR}/lib/tkbase.res.o" - if [ -n "${TKDIR}" -a -f "${TKRSRC}" ]; then - EXTRA_OBJS="${EXTRA_OBJS} ${TKRSRC}" - fi - - ## Export to the environment, to be picked up by the "configure" script - export EXTRA_OBJS - - # Build KitDLL - echo "Running: ./configure --with-tcl=\"${TCLCONFIGDIR}\" ${CONFIGUREEXTRA}" - ./configure --with-tcl="${TCLCONFIGDIR}" ${CONFIGUREEXTRA} - - echo "Running: ${MAKE:-make}" - ${MAKE:-make} TCLSH_NATIVE="${TCLSH_NATIVE}" || exit 1 - - # Strip the KitDLL of debugging symbols, if possible - "${STRIP:-strip}" -g libtclkit* >/dev/null 2>/dev/null - - # Fix up Win32 DLL names - ## .DLL.A -> .LIB - for file in libtclkit*.dll.a; do - if [ ! -f "${file}" ]; then - continue - fi - - newfile="$(basename "${file}" .dll.a).lib" - mv "${file}" "${newfile}" - done - - ## .DLL.DEF -> .DEF - for file in libtclkit*.dll.def; do - if [ ! -f "${file}" ]; then - continue - fi - - newfile="$(basename "${file}" .dll.def).def" - mv "${file}" "${newfile}" - done - - exit 0 -) || exit 1 - -exit 0 DELETED kitdll/buildsrc/kitdll-0.0/boot.tcl Index: kitdll/buildsrc/kitdll-0.0/boot.tcl ================================================================== --- kitdll/buildsrc/kitdll-0.0/boot.tcl +++ /dev/null @@ -1,112 +0,0 @@ -proc tclInit {} { - rename tclInit {} - - global auto_path tcl_library tcl_libPath - global tcl_version - - # Set path where to mount VFS - set tcl_mountpoint "/.KITDLL_TCL" - - set tcl_library [file join $tcl_mountpoint lib tcl$tcl_version] - set tcl_libPath [list $tcl_library [file join $tcl_mountpoint lib]] - - # get rid of a build residue - unset -nocomplain ::tclDefaultLibrary - - # the following code only gets executed once on startup - if {[info exists ::initVFS]} { - set vfsHandler [list ::vfs::kitdll::vfshandler tcl] - - # alter path to find encodings - if {[info tclversion] eq "8.4"} { - load {} pwb - librarypath [info library] - } else { - encoding dirs [list [file join [info library] encoding]] ;# TIP 258 - } - - # fix system encoding, if it wasn't properly set up (200207.004 bug) - if {[encoding system] eq "identity"} { - if {[info exists ::tclkit_system_encoding] && $::tclkit_system_encoding != ""} { - catch { - encoding system $::tclkit_system_encoding - } - } - unset -nocomplain ::tclkit_system_encoding - } - - # If we've still not been able to set the encoding, revert to Tclkit defaults - if {[encoding system] eq "identity"} { - catch { - switch $::tcl_platform(platform) { - windows { encoding system cp1252 } - macintosh { encoding system macRoman } - default { encoding system iso8859-1 } - } - } - } - - # now remount the executable with the correct encoding - vfs::filesystem unmount [lindex [::vfs::filesystem info] 0] - - # Resolve symlinks - set tcl_mountpoint [file dirname [file normalize [file join $tcl_mountpoint __dummy__]]] - - set tcl_library [file join $tcl_mountpoint lib tcl$tcl_version] - set tcl_libPath [list $tcl_library [file join $tcl_mountpoint lib]] - - vfs::filesystem mount $tcl_mountpoint $vfsHandler - - } - - # load config settings file if present - namespace eval ::vfs { variable tclkit_version 1 } - catch { uplevel #0 [list source [file join $tcl_mountpoint config.tcl]] } - - uplevel #0 [list source [file join $tcl_library init.tcl]] - - # reset auto_path, so that init.tcl's search outside of tclkit is cancelled - set auto_path $tcl_libPath - - # This loads everything needed for "clock scan" to work - # "clock scan" is used within "vfs::zip", which may be - # loaded before this is run causing the root VFS to break - catch { clock scan } - - # Load these, the original Tclkit does so it should be safe. - foreach vfsfile [list vfsUtils vfslib] { - uplevel #0 [list source [file join $tcl_mountpoint lib vfs ${vfsfile}.tcl]] - } - - # Set a maximum seek to avoid reading the entire DLL looking for a - # zip header - catch { - package require vfs::zip - set ::zip::max_header_seek 8192 - } - - # Now that the initialization is complete, mount the user VFS if needed - ## Mount the VFS from the Shared Object - if {[info exists ::initVFS] && [info exists ::tclKitFilename]} { - catch { - vfs::zip::Mount $::tclKitFilename "/.KITDLL_USER" - - lappend auto_path [file normalize "/.KITDLL_USER/lib"] - } - } - - ## Mount the VFS from executable - if {[info exists ::initVFS]} { - catch { - vfs::zip::Mount [info nameofexecutable] "/.KITDLL_APP" - - lappend auto_path [file normalize "/.KITDLL_APP/lib"] - } - } - - # Clean up - unset -nocomplain ::zip::max_header_seek - - # Clean up after the kitInit.c:preInitCmd - unset -nocomplain ::initVFS ::tclKitFilename -} DELETED kitdll/buildsrc/kitdll-0.0/kitInit.c Index: kitdll/buildsrc/kitdll-0.0/kitInit.c ================================================================== --- kitdll/buildsrc/kitdll-0.0/kitInit.c +++ /dev/null @@ -1,305 +0,0 @@ -#ifdef KIT_INCLUDES_TK -# include -#else -# include -#endif /* KIT_INCLUDES_TK */ - -#ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN -# include -# undef WIN32_LEAN_AND_MEAN -#endif /* _WIN32 */ - -#ifdef HAVE_STRING_H -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_DLFCN_H -# include -#endif - -#include "tclInt.h" - -#if defined(HAVE_TCL_GETENCODINGNAMEFROMENVIRONMENT) && defined(HAVE_TCL_SETSYSTEMENCODING) -# define TCLKIT_CAN_SET_ENCODING 1 -#endif -#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 -# define TCLKIT_REQUIRE_TCLEXECUTABLENAME 1 -#endif -#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 -# define KIT_INCLUDES_PWB 1 -#endif -#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86 -# define KIT_INCLUDES_ZLIB 1 -#endif - -Tcl_AppInitProc Vfs_Init, Rechan_Init; -Tcl_AppInitProc Vfs_kitdll_data_tcl_Init; -#ifdef KIT_INCLUDES_MK4TCL -Tcl_AppInitProc Mk4tcl_Init; -#endif -#ifdef KIT_INCLUDES_PWB -Tcl_AppInitProc Pwb_Init; -#endif -#ifdef KIT_INCLUDES_ZLIB -Tcl_AppInitProc Zlib_Init; -#endif -#ifdef TCL_THREADS -Tcl_AppInitProc Thread_Init; -#endif -#ifdef _WIN32 -Tcl_AppInitProc Dde_Init, Registry_Init; -#endif - -/* - * This Tcl code is invoked whenever Tcl_Init() is called on an - * interpreter. It should mount up the VFS and make everything ready for - * that interpreter to do its job. - */ -static char *preInitCmd = -"proc tclKitInit {} {\n" - "rename tclKitInit {}\n" -#ifdef KIT_INCLUDES_ZLIB - "catch { load {} zlib }\n" -#endif - "load {} tclkit::init\n" - "load {} rechan\n" - "load {} vfs\n" - "load {} vfs_kitdll_data_tcl\n" -#ifdef KIT_INCLUDES_MK4TCL - "catch { load {} Mk4tcl }\n" -#endif -#include "vfs_kitdll.tcl.h" - "if {![file exists \"/.KITDLL_TCL/boot.tcl\"]} {\n" - "vfs::kitdll::Mount tcl /.KITDLL_TCL\n" - "set ::initVFS 1\n" - "}\n" - "set f [open \"/.KITDLL_TCL/boot.tcl\"]\n" - "set s [read $f]\n" - "close $f\n" - "::tclkit::init::initInterp\n" - "rename ::tclkit::init::initInterp {}\n" - "uplevel #0 $s\n" -#if defined(KIT_INCLUDES_TK) && defined(KIT_TK_VERSION) - "package ifneeded Tk " KIT_TK_VERSION " {\n" - "load {} Tk\n" - "}\n" -#endif -#ifdef _WIN32 - "catch {load {} dde}\n" - "catch {load {} registry}\n" -#endif /* _WIN32 */ -"}\n" -"tclKitInit"; - -#ifdef HAVE_ACCEPTABLE_DLADDR -/* Symbol to resolve against dladdr() */ -static void _tclkit_dummy_func(void) { - return; -} - -int main(int argc, char **argv); -#endif /* HAVE_ACCEPTABLE_DLADDR */ - -/* - * This function will return a pathname we can open() to treat as a VFS, - * hopefully - */ -static char *find_tclkit_dll_path(void) { -#ifdef HAVE_ACCEPTABLE_DLADDR - Dl_info syminfo; - int dladdr_ret; -#endif /* HAVE_ACCEPTABLE_DLADDR */ -#ifdef _WIN32 - TCHAR modulename[8192]; - DWORD gmfn_ret; -#endif /* _WIN32 */ - -#ifdef HAVE_ACCEPTABLE_DLADDR - dladdr_ret = dladdr(&_tclkit_dummy_func, &syminfo); - if (dladdr_ret != 0) { - if (syminfo.dli_fname && syminfo.dli_fname[0] != '\0') { - return(strdup(syminfo.dli_fname)); - } - } -#endif /* HAVE_ACCEPTABLE_DLADDR */ - -#ifdef _WIN32 - gmfn_ret = GetModuleFileName(TclWinGetTclInstance(), modulename, sizeof(modulename) / sizeof(modulename[0]) - 1); - - if (gmfn_ret != 0) { - return(strdup(modulename)); - } -#endif /* _WIN32 */ - - return(NULL); -} - -/* SetExecName -- - - Hack to get around Tcl bug 1224888. -*/ -static void SetExecName(Tcl_Interp *interp, const char *path) { -#ifdef TCLKIT_REQUIRE_TCLEXECUTABLENAME - tclExecutableName = strdup(path); -#endif - Tcl_FindExecutable(path); - - return; -} - -static void FindAndSetExecName(Tcl_Interp *interp) { - int len = 0; - Tcl_Obj *execNameObj; - Tcl_Obj *lobjv[1]; -#ifdef HAVE_READLINK - ssize_t readlink_ret; - char exe_buf[4096]; -#endif /* HAVE_READLINK */ -#ifdef HAVE_ACCEPTABLE_DLADDR - Dl_info syminfo; - int dladdr_ret; -#endif /* HAVE_ACCEPTABLE_DLADDR */ - -#ifdef HAVE_READLINK - if (Tcl_GetNameOfExecutable() == NULL) { - readlink_ret = readlink("/proc/self/exe", exe_buf, sizeof(exe_buf) - 1); - - if (readlink_ret > 0 && readlink_ret < (sizeof(exe_buf) - 1)) { - exe_buf[readlink_ret] = '\0'; - - SetExecName(interp, exe_buf); - - return; - } - } - - if (Tcl_GetNameOfExecutable() == NULL) { - readlink_ret = readlink("/proc/curproc/file", exe_buf, sizeof(exe_buf) - 1); - - if (readlink_ret > 0 && readlink_ret < (sizeof(exe_buf) - 1)) { - exe_buf[readlink_ret] = '\0'; - - if (strcmp(exe_buf, "unknown") != 0) { - SetExecName(interp, exe_buf); - - return; - } - } - } -#endif /* HAVE_READLINK */ - -#ifdef HAVE_ACCEPTABLE_DLADDR - if (Tcl_GetNameOfExecutable() == NULL) { - dladdr_ret = dladdr(&main, &syminfo); - if (dladdr_ret != 0) { - SetExecName(interp, syminfo.dli_fname); - } - } -#endif /* HAVE_ACCEPTABLE_DLADDR */ - - if (Tcl_GetNameOfExecutable() == NULL) { - lobjv[0] = Tcl_GetVar2Ex(interp, "argv0", NULL, TCL_GLOBAL_ONLY); - execNameObj = Tcl_FSJoinToPath(Tcl_FSGetCwd(interp), 1, lobjv); - - SetExecName(interp, Tcl_GetStringFromObj(execNameObj, &len)); - - return; - } - - return; -} - - -/* - * This function exists to allow C code to initialize a particular - * interpreter. - */ -static int tclkit_init_initinterp(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { - char *kitdll_path; -#ifdef TCLKIT_CAN_SET_ENCODING - Tcl_DString encodingName; -#endif /* TCLKIT_CAN_SET_ENCODING */ - - -#ifdef _WIN32 - Tcl_SetVar(interp, "tcl_rcFileName", "~/tclkitrc.tcl", TCL_GLOBAL_ONLY); -#else - Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclkitrc", TCL_GLOBAL_ONLY); -#endif - - kitdll_path = find_tclkit_dll_path(); - if (kitdll_path != NULL) { - Tcl_SetVar(interp, "tclKitFilename", kitdll_path, TCL_GLOBAL_ONLY); - - free(kitdll_path); - } - - FindAndSetExecName(interp); - -#ifdef TCLKIT_CAN_SET_ENCODING - /* Set the encoding from the Environment */ - Tcl_GetEncodingNameFromEnvironment(&encodingName); - Tcl_SetSystemEncoding(NULL, Tcl_DStringValue(&encodingName)); - Tcl_SetVar(interp, "tclkit_system_encoding", Tcl_DStringValue(&encodingName), TCL_GLOBAL_ONLY); - Tcl_DStringFree(&encodingName); -#endif - - return(TCL_OK); -} - -/* - * Create a package for initializing a particular interpreter. This is - * our hook to have Tcl invoke C commands when creating an interpreter. - * The preInitCmd will load the package in the new interpreter and invoke - * this function. - */ -int Tclkit_init_Init(Tcl_Interp *interp) { - Tcl_Command tclCreatComm_ret; - int tclPkgProv_ret; - - tclCreatComm_ret = Tcl_CreateObjCommand(interp, "::tclkit::init::initInterp", tclkit_init_initinterp, NULL, NULL); - if (!tclCreatComm_ret) { - return(TCL_ERROR); - } - - tclPkgProv_ret = Tcl_PkgProvide(interp, "tclkit::init", "1.0"); - - return(tclPkgProv_ret); -} - -/* - * Initialize the Tcl system when we are loaded, that way Tcl functions - * are ready to be used when invoked. - */ -void __attribute__((constructor)) _Tclkit_Init(void) { - Tcl_StaticPackage(0, "tclkit::init", Tclkit_init_Init, NULL); - Tcl_StaticPackage(0, "rechan", Rechan_Init, NULL); - Tcl_StaticPackage(0, "vfs", Vfs_Init, NULL); - Tcl_StaticPackage(0, "vfs_kitdll_data_tcl", Vfs_kitdll_data_tcl_Init, NULL); -#ifdef KIT_INCLUDES_ZLIB - Tcl_StaticPackage(0, "zlib", Zlib_Init, NULL); -#endif -#ifdef KIT_INCLUDES_MK4TCL - Tcl_StaticPackage(0, "Mk4tcl", Mk4tcl_Init, NULL); -#endif -#ifdef KIT_INCLUDES_PWB - Tcl_StaticPackage(0, "pwb", Pwb_Init, NULL); -#endif -#ifdef TCL_THREADS - Tcl_StaticPackage(0, "Thread", Thread_Init, NULL); -#endif -#ifdef _WIN32 - Tcl_StaticPackage(0, "dde", Dde_Init, NULL); - Tcl_StaticPackage(0, "registry", Registry_Init, NULL); -#endif -#ifdef KIT_INCLUDES_TK - Tcl_StaticPackage(0, "Tk", Tk_Init, Tk_SafeInit); -#endif - - TclSetPreInitScript(preInitCmd); - - return; -} Index: kitsh/build.sh ================================================================== --- kitsh/build.sh +++ kitsh/build.sh @@ -28,13 +28,46 @@ ( cp -r 'buildsrc' 'build' cd "${BUILDDIR}" || exit 1 + + # Fix up archives that Tcl gets wrong + for archive in ../../../tcl/inst/lib/dde*/tcldde*.a ../../../tcl/inst/lib/reg*/tclreg*.a; do + if [ ! -f "${archive}" ]; then + continue + fi + + rm -rf __TEMP__ + ( + mkdir __TEMP__ || exit 1 + cd __TEMP__ + + ## Patch archive name + archive="../${archive}" + + "${AR:-ar}" x "${archive}" || exit 1 + + rm -f "${archive}" + + "${AR:-ar}" cr "${archive}" *.o || exit 1 + "${RANLIB:-ranlib}" "${archive}" || true + ) + done + + # Determine how we invoke a Tcl interpreter + for testsh in "${TCLSH_NATIVE:-false}" tclsh tclsh8.4 tclsh8.5 tclsh8.6 "${TCLKIT:-tclkit}"; do + if echo 'exit 0' | "${testsh}" >/dev/null 2>/dev/null; then + TCLSH_NATIVE="${testsh}" + + break + fi + done # Cleanup, just incase the incoming directory was not pre-cleaned ${MAKE:-make} distclean >/dev/null 2>/dev/null + rm -rf 'starpack.vfs' # Create VFS directory mkdir "starpack.vfs" mkdir "starpack.vfs/lib" @@ -60,10 +93,11 @@ cp "${KITCREATOR_RC}" "${BUILDDIR}/kit.rc" # Include extra objects as required ## Initialize list of extra objects EXTRA_OBJS="" + export EXTRA_OBJS ## Tk Resources (needed for Win32 support) -- remove kit-found resources to prevent the symbols from being in conflict TKDIR="$(cd "${OTHERPKGSDIR}/tk/inst" && pwd)" TKRSRC="${TKDIR}/lib/tkbase.res.o" if [ -n "${TKDIR}" -a -f "${TKRSRC}" ]; then @@ -72,14 +106,16 @@ echo ' *** Removing "kit.rc" since we have Tk with its own resource file' rm -f "${BUILDDIR}/kit.rc" fi - ## Export to the environment, to be picked up by the "configure" script - export EXTRA_OBJS + # Determine if target is KitDLL or KitSH + if [ "${KITTARGET}" = "kitdll" ]; then + CONFIGUREEXTRA="${CONFIGUREEXTRA} --enable-kitdll" + fi - # Compile Kitsh + # Compile Kit if [ -z "${ZLIBDIR}" ]; then echo "Running: ./configure --with-tcl=\"${TCLCONFIGDIR}\" ${CONFIGUREEXTRA}" ./configure --with-tcl="${TCLCONFIGDIR}" ${CONFIGUREEXTRA} else @@ -86,35 +122,90 @@ echo "Running: ./configure --with-tcl=\"${TCLCONFIGDIR}\" --with-zlib=\"${ZLIBDIR}\" ${CONFIGUREEXTRA}" ./configure --with-tcl="${TCLCONFIGDIR}" --with-zlib="${ZLIBDIR}" ${CONFIGUREEXTRA} fi - echo "Running: ${MAKE:-make}" - ${MAKE:-make} || exit 1 + echo "Running: ${MAKE:-make} TCLSH_NATIVE=\"${TCLSH_NATIVE}\"" + ${MAKE:-make} TCLSH_NATIVE="${TCLSH_NATIVE}" || exit 1 # Strip the kit of all symbols, if possible "${STRIP:-strip}" kit >/dev/null 2>/dev/null + "${STRIP:-strip}" -g libtclkit* >/dev/null 2>/dev/null + + # Fix up Win32 DLL names + ## .DLL.A -> .LIB + for file in libtclkit*.dll.a; do + if [ ! -f "${file}" ]; then + continue + fi + + newfile="$(basename "${file}" .dll.a).lib" + mv "${file}" "${newfile}" + done + + ## .DLL.DEF -> .DEF + for file in libtclkit*.dll.def; do + if [ ! -f "${file}" ]; then + continue + fi + + newfile="$(basename "${file}" .dll.def).def" + mv "${file}" "${newfile}" + done + + # Determine name of created kit + KITTARGET_NAME='__error__' + if [ "${KITTARGET}" = "kitdll" ]; then + ## Find the library created + for chkkittarget in libtclkit*.*; do + if [ ! -f "${chkkittarget}" ]; then + continue + fi + + if echo "${chkkittarget}" | egrep '\.(lib|def|a)$'; then + continue + fi + + KITTARGET_NAME="${chkkittarget}" + + break + done + + ## Also create an executable named "kit" so that we can run it later + ${MAKE:-make} tclsh + mv tclsh kit + else + ## The executable is always named "kit" + KITTARGET_NAME='kit' + fi + export KITTARGET_NAME + + if [ "x${KITTARGET_NAME}" = 'x__error__' ]; then + echo "Failed to locate kit target!" >&2 + + exit 1 + fi # Intall VFS onto kit ## Determine if we have a Tclkit to do this work TCLKIT="${TCLKIT:-tclkit}" if echo 'exit 0' | "${TCLKIT}" >/dev/null 2>/dev/null; then ## Install using existing Tclkit ### Call installer - echo "Running: \"${TCLKIT}\" installvfs.tcl kit starpack.vfs \"${ENABLECOMPRESSION}\"" - "${TCLKIT}" installvfs.tcl kit starpack.vfs "${ENABLECOMPRESSION}" + echo "Running: \"${TCLKIT}\" installvfs.tcl \"${KITTARGET_NAME}\" starpack.vfs \"${ENABLECOMPRESSION}\"" + "${TCLKIT}" installvfs.tcl "${KITTARGET_NAME}" starpack.vfs "${ENABLECOMPRESSION}" else ## Bootstrap (cannot cross-compile) ### Call installer cp kit runkit - echo "set argv [list kit starpack.vfs {${ENABLECOMPRESSION}}]" > setup.tcl + echo "set argv [list {${KITTARGET_NAME}} starpack.vfs {${ENABLECOMPRESSION}}]" > setup.tcl echo 'if {[catch { clock seconds }]} { proc clock args { return 0 } }' >> setup.tcl echo 'source installvfs.tcl' >> setup.tcl echo 'Running: echo | ./runkit' - echo | ./runkit + echo | ./runkit setup.tcl fi exit 0 ) || exit 1 exit 0 Index: kitsh/buildsrc/kitsh-0.0/Makefile.common.in ================================================================== --- kitsh/buildsrc/kitsh-0.0/Makefile.common.in +++ kitsh/buildsrc/kitsh-0.0/Makefile.common.in @@ -8,11 +8,13 @@ SHOBJLDFLAGS = @SHOBJLDFLAGS@ LIBS = @LIBS@ ARCHS = @ARCHS@ STRIPLIBS = @STRIPLIBS@ @EXTRA_OBJS@ EXTRA_OBJS = @EXTRA_OBJS@ +LDRUNPATH = @LDRUNPATH@ EXTRA_KIT_DEPS = @EXTRA_KIT_DEPS@ +EXTRA_VFS_OBJS = @EXTRA_VFS_OBJS@ TCLSH_NATIVE = tclsh # Build targets ## VFS Build vfs_kitdll_data_tcl.o: vfs_kitdll_data_tcl.c @@ -41,11 +43,11 @@ # Cleanup routines clean: rm -f kit kit.res.o rm -f libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ - rm -f $(OBJS) + rm -f $(OBJS) $(EXTRA_OBJS) $(EXTRA_VFS_OBJS) rm -f vfs_kitdll_data_tcl.c rm -f vfs_kitdll.tcl.h rm -f tclsh.o tclsh tclsh.exe rm -f wish.o wish wish.exe Index: kitsh/buildsrc/kitsh-0.0/Makefile.kitdll.in ================================================================== --- kitsh/buildsrc/kitsh-0.0/Makefile.kitdll.in +++ kitsh/buildsrc/kitsh-0.0/Makefile.kitdll.in @@ -1,20 +1,20 @@ -OBJS = vfs_kitdll_data_tcl.o kitInit.o rechan.o pwb.o zlib.o +OBJS = kitInit.o rechan.o pwb.o zlib.o # Default target all: libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ -include Makefile.common ## DLL Build -libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@: $(OBJS) $(EXTRA_KIT_DEPS) $(EXTRA_OBJS) +libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@: $(OBJS) $(EXTRA_KIT_DEPS) $(EXTRA_OBJS) $(EXTRA_VFS_OBJS) -for striplib in $(STRIPLIBS); do $(OBJCOPY) --weaken "$${striplib}"; done - $(CC) $(CPPFLAGS) $(CFLAGS) -o libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ $(OBJS) $(EXTRA_OBJS) $(LDFLAGS) $(SHOBJLDFLAGS) @WHOLEARCHIVE@ $(ARCHS) @NOWHOLEARCHIVE@ $(LIBS) + $(CC) $(CPPFLAGS) $(CFLAGS) -o libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ $(OBJS) $(EXTRA_OBJS) $(EXTRA_VFS_OBJS) $(LDFLAGS) $(SHOBJLDFLAGS) @WHOLEARCHIVE@ $(ARCHS) @NOWHOLEARCHIVE@ $(LIBS) # Test driver tclsh.o: tclsh.c tclsh: tclsh.o $(EXTRA_OBJS) libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ - $(CC) $(CPPFLAGS) $(CFLAGS) -o tclsh tclsh.o $(EXTRA_OBJS) -L. -ltclkit@KITDLL_LIB_VERSION@ -Wl,-rpath,. + $(CC) $(CPPFLAGS) $(CFLAGS) -o tclsh tclsh.o $(EXTRA_OBJS) -L. -ltclkit@KITDLL_LIB_VERSION@ $(LDRUNPATH) wish.o: wish.c wish: wish.o $(EXTRA_OBJS) libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ - $(CC) $(CPPFLAGS) $(CFLAGS) $(WISH_CFLAGS) -o wish wish.o $(EXTRA_OBJS) -L. -ltclkit@KITDLL_LIB_VERSION@ -Wl,-rpath,. + $(CC) $(CPPFLAGS) $(CFLAGS) $(WISH_CFLAGS) -o wish wish.o $(EXTRA_OBJS) -L. -ltclkit@KITDLL_LIB_VERSION@ $(LDRUNPATH) Index: kitsh/buildsrc/kitsh-0.0/Makefile.tclkit.in ================================================================== --- kitsh/buildsrc/kitsh-0.0/Makefile.tclkit.in +++ kitsh/buildsrc/kitsh-0.0/Makefile.tclkit.in @@ -2,7 +2,7 @@ all: kit -include Makefile.common -kit: $(OBJS) $(EXTRA_OBJS) $(EXTRA_KIT_DEPS) $(ARCHS) - $(CC) $(CPPFLAGS) $(CFLAGS) -o kit $(OBJS) $(EXTRA_OBJS) $(ARCHS) $(LDFLAGS) $(LIBS) +kit: $(OBJS) $(EXTRA_OBJS) $(EXTRA_KIT_DEPS) $(EXTRA_VFS_OBJS) $(ARCHS) + $(CC) $(CPPFLAGS) $(CFLAGS) -o kit $(OBJS) $(EXTRA_OBJS $(EXTRA_VFS_OBJS)) $(ARCHS) $(LDFLAGS) $(LIBS) Index: kitsh/buildsrc/kitsh-0.0/aclocal.m4 ================================================================== --- kitsh/buildsrc/kitsh-0.0/aclocal.m4 +++ kitsh/buildsrc/kitsh-0.0/aclocal.m4 @@ -35,15 +35,18 @@ . "${tclconfigsh}" CFLAGS="${CFLAGS} ${TCL_INCLUDE_SPEC} -I${TCL_SRC_DIR}/generic -I${tclconfigshdir}" CPPFLAGS="${CPPFLAGS} ${TCL_INCLUDE_SPEC} -I${TCL_SRC_DIR}/generic -I${tclconfigshdir}" LIBS="${LIBS} ${TCL_LIBS}" + + KITDLL_LIB_VERSION=`echo "${TCL_VERSION}${TCL_PATCH_LEVEL}" | sed 's@\.@@g'` fi AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LIBS) + AC_SUBST(KITDLL_LIB_VERSION) AC_MSG_RESULT([$tclconfigsh]) ]) AC_DEFUN(DC_DO_TK, [ @@ -151,31 +154,49 @@ ]) ]) AC_DEFUN(DC_FIND_TCLKIT_LIBS, [ DC_SETUP_TCL_PLAT_DEFS + + dnl We will need this for the Tcl project, which we will always have + DC_CHECK_FOR_WHOLE_ARCHIVE for proj in mk4tcl tcl tclvfs tk; do AC_MSG_CHECKING([for libraries required for ${proj}]) - libdir="../../../${proj}/inst" - libfiles="`find "${libdir}" -name '*.a' 2>/dev/null | tr "\n" ' '`" - libfilesnostub="`find "${libdir}" -name '*.a' 2>/dev/null | grep -v 'stub' | tr "\n" ' '`" - - ARCHS="${ARCHS} ${libfiles}" - - AC_MSG_RESULT([${libfiles}]) - - if test "${libfilesnostub}" != ""; then - if test "${proj}" = "mk4tcl"; then + projlibdir="../../../${proj}/inst" + projlibfiles="`find "${projlibdir}" -name '*.a' 2>/dev/null | tr "\n" ' '`" + projlibfilesnostub="`find "${projlibdir}" -name '*.a' 2>/dev/null | grep -v 'stub' | tr "\n" ' '`" + + AC_MSG_RESULT([${projlibfilesnostub}]) + + hide_symbols="1" + + if test "${proj}" = "tcl"; then + DC_TEST_WHOLE_ARCHIVE_SHARED_LIB([$ARCHS $projlibfilesnostub], [ + projlibfiles="${projlibfilesnostub}" + ], [ + DC_TEST_WHOLE_ARCHIVE_SHARED_LIB([$ARCHS $projlibfiles], [ + projlibfiles="${projlibfiles}" + ]) + ]) + + hide_symbols="0" + fi + + if test "${proj}" = "mk4tcl"; then + if test -n "${projlibfiles}"; then AC_DEFINE(KIT_INCLUDES_MK4TCL, [1], [Specify this if you link against mkt4tcl]) kc_cv_feature_kit_includes_mk4tcl='1' DC_DO_STATIC_LINK_LIBCXX fi - if test "${proj}" = "tk"; then + fi + + if test "${proj}" = "tk"; then + if test "${projlibfilesnostub}" != ""; then DC_DO_TK AC_DEFINE(KIT_INCLUDES_TK, [1], [Specify this if we link statically to Tk]) if test -n "${TK_VERSION}"; then AC_DEFINE_UNQUOTED(KIT_TK_VERSION, "${TK_VERSION}${TK_PATCH_LEVEL}", [Specify the version of Tk]) fi @@ -182,15 +203,24 @@ if test "$host_os" = "mingw32msvc" -o "$host_os" = "mingw32"; then AC_DEFINE(KITSH_NEED_WINMAIN, [1], [Define if you need WinMain (Windows)]) CFLAGS="${CFLAGS} -mwindows" fi + + hide_symbols="0" fi fi + + ARCHS="${ARCHS} ${projlibfiles}" + + if test "${hide_symbols}" = "1"; then + STRIPLIBS="${STRIPLIBS} ${projlibfiles}" + fi done AC_SUBST(ARCHS) + AC_SUBST(STRIPLIBS) ]) AC_DEFUN(DC_SETUP_TCL_PLAT_DEFS, [ AC_CANONICAL_BUILD AC_CANONICAL_HOST @@ -199,21 +229,25 @@ AC_MSG_RESULT($host_os) case $host_os in mingw32*) CFLAGS="${CFLAGS} -mno-cygwin -mms-bitfields" + WISH_CFLAGS="-mwindows" dnl If we are building for Win32, we need to define "BUILD_tcl" so that dnl TCL_STORAGE_CLASS gets defined as DLLEXPORT, to make static linking dnl work AC_DEFINE(BUILD_tcl, [1], [Define if you need to pretend to be building Tcl (Windows)]) AC_DEFINE(BUILD_tk, [1], [Define if you need to pretend to be building Tk (Windows)]) ;; cygwin*) CFLAGS="${CFLAGS} -mms-bitfields" + WISH_CFLAGS="-mwindows" ;; esac + + AC_SUBST(WISH_CFLAGS) ]) AC_DEFUN(DC_STATIC_LIBGCC, [ AC_MSG_CHECKING([how to link statically against libgcc]) @@ -406,5 +440,22 @@ fi AC_SUBST(WHOLEARCHIVE) AC_SUBST(NOWHOLEARCHIVE) ]) + +AC_DEFUN(DC_SETLDRUNPATH, [ + OLD_LDFLAGS="${LDFLAGS}" + + for testldflags in "-Wl,-rpath -Wl,$1" "-Wl,-R -Wl,$1"; do + LDFLAGS="${OLD_LDFLAGS} ${testldflags}" + AC_TRY_LINK([#include ], [ return(0); ], [ + LDRUNPATH="$LDRUNPATH $testldflags" + + break + ]) + done + + LDFLAGS="${OLD_LDFLAGS}" + + AC_SUBST(LDRUNPATH) +]) Index: kitsh/buildsrc/kitsh-0.0/boot.tcl ================================================================== --- kitsh/buildsrc/kitsh-0.0/boot.tcl +++ kitsh/buildsrc/kitsh-0.0/boot.tcl @@ -2,28 +2,27 @@ rename tclInit {} global auto_path tcl_library tcl_libPath global tcl_version tcl_rcFileName - set noe [info nameofexecutable] + set mountpoint [subst "$::TCLKIT_MOUNTPOINT_VAR"] # Resolve symlinks - set noe [file dirname [file normalize [file join $noe __dummy__]]] + set mountpoint [file dirname [file normalize [file join $mountpoint __dummy__]]] - set tcl_library [file join $noe lib tcl$tcl_version] - set tcl_libPath [list $tcl_library [file join $noe lib]] - - # get rid of a build residue - unset -nocomplain ::tclDefaultLibrary + set tcl_library [file join $mountpoint lib tcl$tcl_version] + set tcl_libPath [list $tcl_library [file join $mountpoint lib]] # the following code only gets executed once on startup - if {[info exists tcl_rcFileName]} { + if {[info exists ::TCLKIT_INITVFS]} { + catch { + load {} vfs + } + # lookup and emulate "source" of lib/vfs/{vfs*.tcl,mk4vfs.tcl} switch -- $::tclKitStorage { "mk4" { - load {} vfs - # must use raw MetaKit calls because VFS is not yet in place set d [mk::select exe.dirs parent 0 name lib] set d [mk::select exe.dirs parent $d name vfs] foreach x {vfsUtils vfslib mk4vfs} { @@ -78,11 +77,11 @@ set vfsHandler [list ::vfs::kitdll::vfshandler tcl] } } # mount the executable, i.e. make all runtime files available - vfs::filesystem mount $noe $vfsHandler + vfs::filesystem mount $mountpoint $vfsHandler # alter path to find encodings if {[info tclversion] eq "8.4"} { load {} pwb librarypath [info library] @@ -95,11 +94,10 @@ if {[info exists ::tclkit_system_encoding] && $::tclkit_system_encoding != ""} { catch { encoding system $::tclkit_system_encoding } } - unset -nocomplain ::tclkit_system_encoding } # If we've still not been able to set the encoding, revert to Tclkit defaults if {[encoding system] eq "identity"} { catch { @@ -108,29 +106,31 @@ macintosh { encoding system macRoman } default { encoding system iso8859-1 } } } } + + # Re-evaluate mountpoint with correct encoding set + set mountpoint [subst "$::TCLKIT_MOUNTPOINT_VAR"] # now remount the executable with the correct encoding vfs::filesystem unmount [lindex [::vfs::filesystem info] 0] - set noe [info nameofexecutable] - # Resolve symlinks - set noe [file dirname [file normalize [file join $noe __dummy__]]] + set mountpoint [file dirname [file normalize [file join $mountpoint __dummy__]]] - set tcl_library [file join $noe lib tcl$tcl_version] - set tcl_libPath [list $tcl_library [file join $noe lib]] + set tcl_library [file join $mountpoint lib tcl$tcl_version] + set tcl_libPath [list $tcl_library [file join $mountpoint lib]] - vfs::filesystem mount $noe $vfsHandler + vfs::filesystem mount $mountpoint $vfsHandler } # load config settings file if present namespace eval ::vfs { variable tclkit_version 1 } - catch { uplevel #0 [list source [file join $noe config.tcl]] } + catch { uplevel #0 [list source [file join $mountpoint config.tcl]] } + # Perform expected initialization uplevel #0 [list source [file join $tcl_library init.tcl]] # reset auto_path, so that init.tcl's search outside of tclkit is cancelled set auto_path $tcl_libPath @@ -137,9 +137,41 @@ # This loads everything needed for "clock scan" to work # "clock scan" is used within "vfs::zip", which may be # loaded before this is run causing the root VFS to break catch { clock scan } - # Cleanup - unset ::tclKitStorage - unset -nocomplain ::tclKitStorage_fd + if {$::TCLKIT_TYPE == "kitdll"} { + # Set a maximum seek to avoid reading the entire file looking for a + # zip header + catch { + package require vfs::zip + set ::zip::max_header_seek 8192 + } + + # Now that the initialization is complete, mount the user VFS if needed + ## Mount the VFS from the Shared Object + if {[info exists ::TCLKIT_INITVFS] && [info exists ::tclKitFilename]} { + catch { + vfs::zip::Mount $::tclKitFilename "/.KITDLL_USER" + + lappend auto_path [file normalize "/.KITDLL_USER/lib"] + } + } + + ## Mount the VFS from executable + if {[info exists ::TCLKIT_INITVFS]} { + catch { + vfs::zip::Mount [info nameofexecutable] "/.KITDLL_APP" + + lappend auto_path [file normalize "/.KITDLL_APP/lib"] + } + } + + } + + # Clean up + unset -nocomplain ::zip::max_header_seek + unset -nocomplain ::TCLKIT_TYPE ::TCLKIT_INITVFS + unset -nocomplain ::TCLKIT_MOUNTPOINT ::TCLKIT_VFSSOURCE ::TCLKIT_MOUNTPOINT_VAR ::TCLKIT_VFSSOURCE_VAR + unset -nocomplain ::tclKitStorage ::tclKitStorage_fd ::tclKitFilename + unset -nocomplain ::tclkit_system_encoding } Index: kitsh/buildsrc/kitsh-0.0/configure.ac ================================================================== --- kitsh/buildsrc/kitsh-0.0/configure.ac +++ kitsh/buildsrc/kitsh-0.0/configure.ac @@ -31,10 +31,12 @@ dnl Find the appropriate libraries to link to AC_SEARCH_LIBS(acos, m,, [ AC_MSG_WARN([Couldn't find acos (normally in libm)!]) ]) AC_SEARCH_LIBS(dlsym, dl,, [ AC_MSG_WARN([Couldn't find dlsym (normally in libdl)!]) ]) AS_IF([test "$TARGET" = "tclkit"], [ + dnl We have Tclkit + dnl Figure out how to statically link to libgcc, if needed DC_STATIC_LIBGCC dnl Specify local Appinit function AC_DEFINE(DTK_LOCAL_APPINIT, [TclKit_AppInit], [Tclkit appinit function]) @@ -45,25 +47,29 @@ DC_CHK_OS_INFO dnl Determine how to create a shared object DC_GET_SHOBJFLAGS - dnl KitDLL always uses C-VFS - AC_DEFINE([KIT_STORAGE_CVFS], [1], [Define if you are going to use C-VFS for kit storage]) + dnl Determine if we have "objcopy" available to weaken non-Tcl/Tk symbols + AC_CHECK_TOOL(OBJCOPY, objcopy, [:]) dnl Define KitDLL usage AC_DEFINE([TCLKIT_DLL], [1], [Define if you are using a KitDLL rather than a Tclkit]) ]) + +dnl Set linker rpath for tclsh/wish +DC_SETLDRUNPATH([.]) dnl Find the appropriate Tcl headers and libraries DC_DO_TCL dnl Find archives we need to link to DC_FIND_TCLKIT_LIBS dnl Find extra objects we need to link as a part of "kit" AC_SUBST(EXTRA_OBJS) +AC_SUBST(EXTRA_VFS_OBJS) dnl Check for Windows Resource Compiler AC_CHECK_TOOL([RC], [windres], [false]) dnl If we found the resource compiler, add "kit.res.o" to our list of objects to build @@ -101,16 +107,14 @@ CFLAGS="${CFLAGS} -I${with_zlib}/include -I${with_zlib}" LDFLAGS="${LDFLAGS} -L${with_zlib}/lib -L${with_zlib}" ]) dnl Only needed for Tclkit -AS_IF([test "$TARGET" = "tclkit"], [ - DC_DO_STATIC_LINK_LIB(zlib, -lz,, [ - DC_DO_STATIC_LINK_LIB(zlib, -lzlib,, [ - AC_SEARCH_LIBS(inflate, z zlib,, [ - AC_MSG_WARN([Couldn't find inflate (normally in zlib)!]) - ]) +DC_DO_STATIC_LINK_LIB(zlib, -lz,, [ + DC_DO_STATIC_LINK_LIB(zlib, -lzlib,, [ + AC_SEARCH_LIBS(inflate, z zlib,, [ + AC_MSG_WARN([Couldn't find inflate (normally in zlib)!]) ]) ]) ]) dnl Determine which storage mechanism to use @@ -181,10 +185,11 @@ dnl Define that C-VFS should be make [load]-able AC_DEFINE([KITDLL_MAKE_LOADABLE], [1], [Specify that the C-VFS should be able to be loaded]) dnl Add appropriate dependencies EXTRA_KIT_DEPS="vfs_kitdll.tcl.h" + EXTRA_VFS_OBJS="${EXTRA_VFS_OBJS} vfs_kitdll_data_tcl.o" ] ) AC_SUBST(EXTRA_KIT_DEPS) Index: kitsh/buildsrc/kitsh-0.0/installvfs.tcl ================================================================== --- kitsh/buildsrc/kitsh-0.0/installvfs.tcl +++ kitsh/buildsrc/kitsh-0.0/installvfs.tcl @@ -13,11 +13,11 @@ if {[lindex $argv 2] != ""} { set opt_compression [lindex $argv 2] } # Determine what storage mechanism is being used -set fd [open Makefile r] +set fd [open Makefile.common r] set data [read $fd] close $fd if {[string match "*KIT_STORAGE_ZIP*" $data]} { set tclKitStorage zip Index: kitsh/buildsrc/kitsh-0.0/kitInit.c ================================================================== --- kitsh/buildsrc/kitsh-0.0/kitInit.c +++ kitsh/buildsrc/kitsh-0.0/kitInit.c @@ -84,12 +84,14 @@ Tcl_AppInitProc Dde_Init, Registry_Init; #endif #ifdef TCLKIT_DLL # define TCLKIT_MOUNTPOINT "/.KITDLL_TCL" +# define TCLKIT_VFSSOURCE "$::tclKitFilename" #else # define TCLKIT_MOUNTPOINT "[info nameofexecutable]" +# define TCLKIT_VFSSOURCE "[info nameofexecutable]" #endif /* TCLKIT_DLL */ #ifdef HAVE_ACCEPTABLE_DLADDR # ifdef KITSH_NEED_WINMAIN # ifdef _WIN32_WCE @@ -141,11 +143,13 @@ #ifdef KIT_INCLUDES_MK4TCL "catch { load {} Mk4tcl }\n" #endif #ifdef TCLKIT_DLL "load {} tclkit::init\n" -#endif + "::tclkit::init::initInterp\n" + "rename ::tclkit::init::initInterp {}\n" +#endif /* TCLKIT_DLL */ "set bootfile [file join " TCLKIT_MOUNTPOINT " boot.tcl]\n" "if {[file exists $bootfile]} {\n" "catch {\n" "set f [open $bootfile]\n" "set s [read $f]\n" @@ -153,11 +157,11 @@ "}\n" "}\n" #ifdef KIT_STORAGE_MK4 "set ::tclKitStorage \"mk4\"\n" "if {![info exists s]} {\n" - "mk::file open exe [info nameofexecutable] -readonly\n" + "mk::file open exe " TCLKIT_VFSSOURCE " -readonly\n" "set n [mk::select exe.dirs!0.files name boot.tcl]\n" "if {$n != \"\"} {\n" "set s [mk::get exe.dirs!0.files!$n contents]\n" "if {![string length $s]} { error \"empty boot.tcl\" }\n" "catch {load {} zlib}\n" @@ -171,11 +175,11 @@ "set ::tclKitStorage \"zip\"\n" "catch { load {} vfs }\n" "if {![info exists s]} {\n" # include "zipvfs.tcl.h" "catch {\n" - "set ::tclKitStorage_fd [::zip::open [info nameofexecutable]]\n" + "set ::tclKitStorage_fd [::zip::open " TCLKIT_VFSSOURCE "]\n" "::zip::stat $::tclKitStorage_fd boot.tcl sb\n" "seek $::tclKitStorage_fd $sb(ino)\n" "::zip::Data $::tclKitStorage_fd sb s\n" "}\n" "}\n" @@ -190,20 +194,26 @@ "catch {\n" "set s [::vfs::kitdll::data::getData tcl boot.tcl]\n" "}\n" "}\n" #endif /* KIT_STORAGE_CVFS */ -#ifdef TCLKIT_DLL - "::tclkit::init::initInterp\n" - "rename ::tclkit::init::initInterp {}\n" -#else +#ifndef TCLKIT_DLL "if {![info exists s]} {\n" "set f [open setup.tcl]\n" "set s [read $f]\n" "close $f\n" "}\n" +#endif /* !TCLKIT_DLL */ +#ifdef TCLKIT_DLL + "set ::TCLKIT_TYPE \"kitdll\"\n" +#else + "set ::TCLKIT_TYPE \"tclkit\"\n" #endif /* TCLKIT_DLL */ + "set ::TCLKIT_MOUNTPOINT " TCLKIT_MOUNTPOINT "\n" + "set ::TCLKIT_VFSSOURCE " TCLKIT_VFSSOURCE "\n" + "set ::TCLKIT_MOUNTPOINT_VAR {" TCLKIT_MOUNTPOINT "}\n" + "set ::TCLKIT_VFSSOURCE_VAR {" TCLKIT_VFSSOURCE "}\n" "uplevel #0 $s\n" #if defined(KIT_INCLUDES_TK) && defined(KIT_TK_VERSION) "package ifneeded Tk " KIT_TK_VERSION " {\n" "load {} Tk\n" "}\n" @@ -366,33 +376,37 @@ static void _Tclkit_Interp_Init(Tcl_Interp *interp) { #ifdef TCLKIT_CAN_SET_ENCODING Tcl_DString encodingName; #endif /* TCLKIT_CAN_SET_ENCODING */ +#ifndef TCLKIT_DLL /* the tcl_rcFileName variable only exists in the initial interpreter */ -#ifdef _WIN32 +# ifdef _WIN32 Tcl_SetVar(interp, "tcl_rcFileName", "~/tclkitrc.tcl", TCL_GLOBAL_ONLY); -#else +# else Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclkitrc", TCL_GLOBAL_ONLY); -#endif +# endif /* _WIN32 */ +#endif /* !TCLKIT_DLL */ + Tcl_SetVar(interp, "TCLKIT_INITVFS", "1", TCL_GLOBAL_ONLY); #ifdef TCLKIT_CAN_SET_ENCODING /* Set the encoding from the Environment */ Tcl_GetEncodingNameFromEnvironment(&encodingName); Tcl_SetSystemEncoding(NULL, Tcl_DStringValue(&encodingName)); Tcl_SetVar(interp, "tclkit_system_encoding", Tcl_DStringValue(&encodingName), 0); Tcl_DStringFree(&encodingName); -#endif +#endif /* TCLKIT_CAN_SET_ENCODING */ /* Hack to get around Tcl bug 1224888. This must be run here and * in LibraryPathObjCmd because this information is needed both * before and after that command is run. */ FindAndSetExecName(interp); return; } +#ifndef TCLKIT_DLL int TclKit_AppInit(Tcl_Interp *interp) { #ifdef KIT_INCLUDES_TK # ifdef _WIN32 # ifndef _WIN32_WCE char msgBuf[2049]; @@ -459,10 +473,11 @@ # endif /* _WIN32 */ #endif /* KIT_INCLUDES_TK */ return TCL_ERROR; } +#endif /* !TCLKIT_DLL */ #ifdef TCLKIT_DLL # ifdef HAVE_ACCEPTABLE_DLADDR /* Symbol to resolve against dladdr() */