Index: README ================================================================== --- README +++ README @@ -144,10 +144,15 @@ 10. KC_TCL_STATICPKGS Set this variable to the value "1" to attempt to force the packages included in the "pkgs" directory of Tcl 8.6+ to be compiled statically + 11. KITCREATOR_STATIC_KITDLL + Set this variable to the value "1" to build a static KitDLL. + This only has an affect when KITCREATOR_PKGS specifies that + "kitdll" is to be built (e.g., KITCREATOR_PKGS='kitdll') + Cross compiling Environment Variables: 1. CC C compiler e.g. i686-pc-mingw32-gcc Index: kitsh/build.sh ================================================================== --- kitsh/build.sh +++ kitsh/build.sh @@ -113,11 +113,15 @@ # Cleanup rm -f kit kit.exe tclsh tclsh.exe # Determine if target is KitDLL or KitSH if [ "${KITTARGET}" = "kitdll" ]; then - CONFIGUREEXTRA="${CONFIGUREEXTRA} --enable-kitdll" + if [ "${KITCREATOR_STATIC_KITDLL}" = '1' ]; then + CONFIGUREEXTRA="${CONFIGUREEXTRA} --enable-kitdll=static" + else + CONFIGUREEXTRA="${CONFIGUREEXTRA} --enable-kitdll" + fi fi # Compile Kit if [ -z "${ZLIBDIR}" ]; then echo "Running: ./configure --with-tcl=\"${TCLCONFIGDIR}\" ${CONFIGUREEXTRA}" @@ -166,11 +170,11 @@ for chkkittarget in libtclkit*.*; do if [ ! -f "${chkkittarget}" ]; then continue fi - if echo "${chkkittarget}" | egrep '\.(lib|def|a)$'; then + if echo "${chkkittarget}" | egrep '\..*\.(lib|def|a)$'; then continue fi KITTARGET_NAME="./${chkkittarget}" 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 @@ -14,10 +14,12 @@ EXTRA_KIT_DEPS = @EXTRA_KIT_DEPS@ EXTRA_VFS_OBJS = @EXTRA_VFS_OBJS@ TCLSH_NATIVE = tclsh LDFLAGS_ADD = @LDFLAGS_ADD@ DIR2C_FLAGS = @DIR2C_FLAGS@ +AR = @AR@ +RANLIB = @RANLIB@ # Build targets ## VFS Build cvfs_data_tcl.o: cvfs_data_tcl.c cvfs_data_tcl.c: dir2c.tcl starpack.vfs cvfs_data.c @@ -43,10 +45,11 @@ kit.res.o: kit.rc tclkit.ico $(RC) -o kit.res.o $(CPPFLAGS) kit.rc # Cleanup routines clean: + rm -rf __TMP__ rm -f kit kit.res.o rm -f libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ rm -f $(OBJS) $(EXTRA_OBJS) $(EXTRA_VFS_OBJS) rm -f cvfs_data_tcl.c cvfs_data_tcl.o rm -f cvfs.tcl.h 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,11 +1,14 @@ OBJS = kitInit.o rechan.o pwb.o zlib.o # Default target -all: libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ +all: @TARGET@ -include Makefile.common + +kitdll: libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ +kitdll-static: libtclkit@KITDLL_LIB_VERSION@.a ## DLL Build libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@: $(OBJS) $(EXTRA_KIT_DEPS) $(EXTRA_OBJS) $(EXTRA_VFS_OBJS) $(CC) $(CPPFLAGS) $(CFLAGS) -o libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ $(OBJS) $(EXTRA_OBJS) $(EXTRA_VFS_OBJS) $(LDFLAGS) $(SHOBJLDFLAGS) @WHOLEARCHIVE@ $(ARCHS) @NOWHOLEARCHIVE@ $(LIBS) $(LDFLAGS_ADD) -for striplib in $(STRIPLIBS); do $(OBJCOPY) --weaken "$${striplib}"; done @@ -12,13 +15,27 @@ -mv libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@.safe; \ $(CC) $(CPPFLAGS) $(CFLAGS) -o libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ $(OBJS) $(EXTRA_OBJS) $(EXTRA_VFS_OBJS) $(LDFLAGS) $(SHOBJLDFLAGS) @WHOLEARCHIVE@ $(ARCHS) @NOWHOLEARCHIVE@ $(LIBS) || \ mv libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@.safe libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ -rm -f libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@.safe +## Static archive build +libtclkit@KITDLL_LIB_VERSION@.a: $(OBJS) $(EXTRA_KIT_DEPS) $(EXTRA_OBJS) $(EXTRA_VFS_OBJS) + rm -f libtclkit@KITDLL_LIB_VERSION@.a.new + rm -rf __TMP__ + mkdir __TMP__ + for arch in $(ARCHS); do ( cd __TMP__ && ar x ../$${arch} ); done + $(OBJCOPY) --redefine-sym Tcl_Init=Tcl_InitReal __TMP__/tclInterp.o + $(AR) cr libtclkit@KITDLL_LIB_VERSION@.a.new $(OBJS) $(EXTRA_OBJS) $(EXTRA_VFS_OBJS) __TMP__/*.o + rm -rf __TMP__ + $(RANLIB) libtclkit@KITDLL_LIB_VERSION@.a.new + mv libtclkit@KITDLL_LIB_VERSION@.a.new libtclkit@KITDLL_LIB_VERSION@.a + # Test driver tclsh.o: tclsh.c -tclsh: tclsh.o $(EXTRA_OBJS) libtclkit@KITDLL_LIB_VERSION@.@SHOBJEXT@ +tclsh: tclsh.o $(EXTRA_OBJS) @TARGET@ $(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@ $(LDRUNPATH) + +.PHONY: kitdll kitdll-static Index: kitsh/buildsrc/kitsh-0.0/configure.ac ================================================================== --- kitsh/buildsrc/kitsh-0.0/configure.ac +++ kitsh/buildsrc/kitsh-0.0/configure.ac @@ -15,10 +15,13 @@ AC_ARG_ENABLE(kitdll, AC_HELP_STRING([--enable-kitdll], [Enable building KitDLL instead of Tclkit (default: no)]), [ AS_CASE([$enableval], [yes|kitdll], [ TARGET="kitdll" ], + static, [ + TARGET="kitdll-static" + ], no, [ true ], [ AC_MSG_RESULT([unknown]) @@ -25,22 +28,26 @@ AC_MSG_ERROR([Invalid option: $enableval]) ] ) ]) AC_MSG_RESULT([$TARGET]) +AC_SUBST(TARGET) 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 + TARGET_BASE='tclkit' dnl Specify local Appinit function AC_DEFINE(TK_LOCAL_APPINIT, [TclKit_AppInit], [Tclkit appinit function]) + ], [ dnl We have KitDLL + TARGET_BASE='kitdll' dnl Determine system information DC_CHK_OS_INFO dnl Determine how to create a shared object @@ -49,10 +56,18 @@ 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 Define a static KitDLL + AS_IF([test "$TARGET" = "kitdll-static"], [ + AC_CHECK_TOOL(RANLIB, [ranlib], [:]) + AC_CHECK_TOOL(AR, [ar], [false MISSING AR]) + + AC_DEFINE([TCLKIT_DLL_STATIC], [1], [Define if you are building a static KitDLL]) + ]) ]) dnl Figure out how to statically link to libgcc, if needed DC_STATIC_LIBGCC @@ -199,9 +214,9 @@ AC_SUBST(EXTRA_KIT_DEPS) AC_SUBST(LDFLAGS_ADD) dnl Put correct Makefile template in place rm -f Makefile.in -cp Makefile.${TARGET}.in Makefile.in +cp Makefile.${TARGET_BASE}.in Makefile.in dnl Produce output AC_OUTPUT(Makefile Makefile.common) Index: kitsh/buildsrc/kitsh-0.0/kitInit.c ================================================================== --- kitsh/buildsrc/kitsh-0.0/kitInit.c +++ kitsh/buildsrc/kitsh-0.0/kitInit.c @@ -569,11 +569,29 @@ #ifdef TCLKIT_DLL void __attribute__((constructor)) _Tclkit_Init(void) { #else static void _Tclkit_Init(void) { #endif + static int called = 0; + + if (called) { + return; + } + + called = 1; + Tcl_StaticPackage(0, "tclkit::init", Tclkit_init_Init, NULL); _Tclkit_Generic_Init(); return; } + +#if defined(TCLKIT_DLL) && defined(TCLKIT_DLL_STATIC) +int Tcl_InitReal(Tcl_Interp *interp); + +int Tcl_Init(Tcl_Interp *interp) { + _Tclkit_Init(); + + return(Tcl_InitReal(interp)); +} +#endif