Index: kitsh/buildsrc/kitsh-0.0/aclocal.m4 ================================================================== --- kitsh/buildsrc/kitsh-0.0/aclocal.m4 +++ kitsh/buildsrc/kitsh-0.0/aclocal.m4 @@ -41,27 +41,48 @@ ]) AC_DEFUN(DC_DO_STATIC_LINK_LIBCXX, [ AC_MSG_CHECKING([for how to statically link to libstdc++]) - STATICLIBCXX="-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic" - LIBS="${LIBS} ${STATICLIBCXX}" + SAVELIBS="${LIBS}" + staticlibcxx="" + for trylink in "-Wl,-Bstatic -lstdc++ -Wl,-Bdynamic" "-Wl,-Bstatic -lCstd -lCrun -Wl,-Bdynamic" "-lstdc++" "-lCstd -lCrun"; do + LIBS="${SAVELIBS} ${trylink}" + + AC_LINK_IFELSE(, [ + staticlibcxx="${trylink}" + + break + ]) + done + LIBS="${SAVELIBS} ${staticlibcxx}" + + AC_MSG_RESULT([${staticlibcxx}]) AC_SUBST(LIBS) - - AC_MSG_RESULT([${STATICLIBCXX}]) ]) AC_DEFUN(DC_FIND_TCLKIT_LIBS, [ + for proj in mk4tcl tcl tclvfs; do AC_MSG_CHECKING([for libraries required for ${proj}]) libdir="../../../${proj}/inst" libfiles="`find "${libdir}" -name '*.a' | tr "\n" ' '`" ARCHS="${ARCHS} ${libfiles}" AC_MSG_RESULT([${libfiles}]) + + if test "${libfiles}" != ""; then + upperproj=`echo "${proj}" | dd conv=ucase 2>/dev/null` + + AC_DEFINE(KIT_INCLUDES_$upperproj) + + if test "${proj}" = "mk4tcl"; then + DC_DO_STATIC_LINK_LIBCXX + fi + fi done AC_SUBST(ARCHS) ]) Index: kitsh/buildsrc/kitsh-0.0/configure.ac ================================================================== --- kitsh/buildsrc/kitsh-0.0/configure.ac +++ kitsh/buildsrc/kitsh-0.0/configure.ac @@ -7,23 +7,20 @@ AC_PROG_MAKE_SET AC_PROG_INSTALL AC_AIX AC_GNU_SOURCE -dnl Find the appropriate Tcl headers and libraries -DC_DO_TCL - -dnl Find out how to statically link to libstdc++ (for Metakit) -DC_DO_STATIC_LINK_LIBCXX - -dnl Find archives we need to link to -DC_FIND_TCLKIT_LIBS - dnl Find the appropriate libraries to link to AC_SEARCH_LIBS(inflate, z zlib,, [ AC_MSG_WARN([Couldn't find inflate (normally in zlib)!]) ]) 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)!]) ]) + +dnl Find the appropriate Tcl headers and libraries +DC_DO_TCL + +dnl Find archives we need to link to +DC_FIND_TCLKIT_LIBS dnl Determine if we have "Tcl_SetStartupScript" (8.6.x) or "TclSetStartupScriptPath" (8.4.x) SAVE_LIBS="${LIBS}" LIBS="${ARCHS} ${LIBS}" AC_CHECK_FUNCS(Tcl_SetStartupScript TclSetStartupScriptPath) Index: kitsh/buildsrc/kitsh-0.0/kitInit.c ================================================================== --- kitsh/buildsrc/kitsh-0.0/kitInit.c +++ kitsh/buildsrc/kitsh-0.0/kitInit.c @@ -34,11 +34,14 @@ #include "tclInt.h" #ifdef KIT_INCLUDES_ITCL Tcl_AppInitProc Itcl_Init; #endif -Tcl_AppInitProc Mk4tcl_Init, Vfs_Init, Rechan_Init, Zlib_Init; +#ifdef KIT_INCLUDES_MK4TCL +Tcl_AppInitProc Mk4tcl_Init +#endif +Tcl_AppInitProc Vfs_Init, Rechan_Init, Zlib_Init; #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 Tcl_AppInitProc Pwb_Init; #endif #ifdef TCL_THREADS Tcl_AppInitProc Thread_Init; @@ -73,11 +76,11 @@ "return -code $code $res\n" "}\n" #endif "proc tclKitInit {} {\n" "rename tclKitInit {}\n" - "load {} Mk4tcl\n" + "catch { load {} Mk4tcl }\n" "mk::file open exe [info nameofexecutable] -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" @@ -131,11 +134,13 @@ TclKit_AppInit(Tcl_Interp *interp) { #ifdef KIT_INCLUDES_ITCL Tcl_StaticPackage(0, "Itcl", Itcl_Init, NULL); #endif +#ifdef KIT_INCLUDES_MK4TCL Tcl_StaticPackage(0, "Mk4tcl", Mk4tcl_Init, NULL); +#endif #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 Tcl_StaticPackage(0, "pwb", Pwb_Init, NULL); #endif Tcl_StaticPackage(0, "rechan", Rechan_Init, NULL); Tcl_StaticPackage(0, "vfs", Vfs_Init, NULL);