Index: README ================================================================== --- README +++ README @@ -81,16 +81,25 @@ action on most platforms is to dynamically link to Tk. When building KitDLL, STATICTK is "1" by default. If you want to enable dynamic linking of Tk with KitDLL you will have to specify this as "-1". - 5. STRIP + 5. STATICMK4 + Specify this as "0" to attempt to create create the "mk4tcl" + project as a shared object. If this fails, it will fall back + to building statically. Specify it as "-1" to force building + it as a shared object. Any other value, including being unset + results in "mk4tcl" being built and linked statically. KitDILL + sets this to variable to "0". If Metakit4 is built shared, it + cannot be used for the kit storage for Tclkit. + + 6. STRIP Specifies the tool you wish to be called to strip object files, archives, and shared objects. The default is "strip". You should probably set this if you are cross-compiling. - 6. KITCREATOR_PKGS + 7. KITCREATOR_PKGS Specify which non-required packages to build. The default list is: tk itcl mk4tcl If mk4tcl is not present a Zip-based storage mechanism will be @@ -100,26 +109,26 @@ contains only white space. If "kitdll" is specified in the list the target becomes KitDLL and no Tclkit will built, but instead libtclkit. - 7. KITCREATOR_MINENCODINGS + 8. KITCREATOR_MINENCODINGS Set this variable to a non-empty string to generate a Tclkit without all encodings, only including the following: ascii.enc cp1252.enc iso8859-1.enc iso8859-15.enc iso8859-2.enc koi8-r.enc macRoman.enc - 8. KITCREATOR_MINBUILD + 9. KITCREATOR_MINBUILD Set this variable to a non-empty string to exclude unnecessary packages from Tcl build. This excludes the following packages: tcltest Kitsh Configure Options: 1. --enable-kit-storage={zip|mk4|auto} Specify which type of storage to use with the Tclkit. The default is to auto-detect. Auto-detection uses Mk4 if - available, otherwise it falls back to Zip. + available and built statically, otherwise it falls back to Zip. ------------------- Method of Operation ------------------- Summary: Index: kitcreator ================================================================== --- kitcreator +++ kitcreator @@ -72,10 +72,18 @@ echo ' Set STATICTK to -1 if you really want to link Tk dynamically.' >&2 STATICTK="1" export STATICTK fi + + if [ -z "${STATICMK4}" ]; then + echo 'Warning: Linking Mk4tcl dynamically because you are building KitDLL' 2>&1 + echo ' Set STATICMK4 to 1 if you really want to link Mk4tcl statically.' >&2 + + STATICMK4="0" + export STATICMK4 + fi fi fi failedpkgs="" buildfailed="0" Index: kitdll/buildsrc/kitdll-0.0/aclocal.m4 ================================================================== --- kitdll/buildsrc/kitdll-0.0/aclocal.m4 +++ kitdll/buildsrc/kitdll-0.0/aclocal.m4 @@ -237,20 +237,64 @@ $3 ] ) ]) + +AC_DEFUN(DC_DO_STATIC_LINK_LIB, [ + AC_MSG_CHECKING([for how to statically link to $1]) + + SAVELIBS="${LIBS}" + staticlib="" + found="0" + dnl HP/UX uses -Wl,-a,archive -lstdc++ -Wl,-a,shared_archive + dnl Linux and Solaris us -Wl,-Bstatic ... -Wl,-Bdynamic + for trylink in "-Wl,-a,archive $2 -Wl,-a,shared_archive" "-Wl,-Bstatic $2 -Wl,-Bdynamic" "$2"; do + LIBS="${SAVELIBS} ${trylink}" + + AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), [ + staticlib="${trylink}" + found="1" + + break + ]) + done + + if test "${found}" = "1"; then + SAVELIBS=`echo "$SAVELIBS" | sed 's@ $2 @ @'` + LIBS="${SAVELIBS} ${staticlib}" + + AC_MSG_RESULT([${staticlib}]) + + AC_SUBST(LIBS) + + $3 + else + LIBS="${SAVELIBS}" + + AC_MSG_RESULT([cant]) + + $4 + fi +]) + +AC_DEFUN(DC_DO_STATIC_LINK_LIBCXX, [ + dnl Sun Studio uses -lCstd -lCrun, most platforms use -lstdc++ + DC_DO_STATIC_LINK_LIB([C++ Library (Sun Studio)], [-lCstd -lCrun],, [ + DC_DO_STATIC_LINK_LIB([C++ Library (UNIX)], [-lstdc++]) + ]) +]) AC_DEFUN(DC_FIND_TCLKIT_LIBS, [ DC_SETUP_TCL_PLAT_DEFS WISH_CFLAGS="" dnl We will need this for the Tcl project, which we will always have DC_CHECK_FOR_WHOLE_ARCHIVE - for proj in tcl tclvfs tk; do + for proj in tcl tclvfs tk mk4tcl; 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" ' '`" @@ -268,12 +312,13 @@ ]) ]) fi if test "${proj}" = "mk4tcl"; then - if test -n "$libfilesnostub"; then + if test -n "$libfiles"; then AC_DEFINE(KIT_INCLUDES_MK4TCL, [1], [Specify this if you link against mkt4tcl]) + DC_DO_STATIC_LINK_LIBCXX fi fi if test "$proj" = "tk"; then if test -n "$libfilesnostub"; then Index: mk4tcl/build.sh ================================================================== --- mk4tcl/build.sh +++ mk4tcl/build.sh @@ -64,38 +64,69 @@ # work BUILDTYPE="$(basename "${TCLCONFIGDIR}")" if [ "${BUILDTYPE}" = "win" ]; then CPPFLAGS="${CPPFLAGS} -DBUILD_tcl=1" export CPPFLAGS - fi - - - # If we are building for KitDLL, compile as shared - isshared="0" - if [ "${KITTARGET}" = "kitdll" ]; then - isshared="1" - - echo "Running: ./configure --enable-shared --prefix=\"${INSTDIR}\" --exec-prefix=\"${INSTDIR}\" --with-tcl=\"${TCLCONFIGDIR}/../generic\" ${CONFIGUREEXTRA}" - ./configure --enable-shared --prefix="${INSTDIR}" --exec-prefix="${INSTDIR}" --with-tcl="${TCLCONFIGDIR}/../generic" ${CONFIGUREEXTRA} - else - echo "Running: ./configure --disable-shared --prefix=\"${INSTDIR}\" --exec-prefix=\"${INSTDIR}\" --with-tcl=\"${TCLCONFIGDIR}/../generic\" ${CONFIGUREEXTRA}" - ./configure --disable-shared --prefix="${INSTDIR}" --exec-prefix="${INSTDIR}" --with-tcl="${TCLCONFIGDIR}/../generic" ${CONFIGUREEXTRA} - fi - - echo "Running: ${MAKE:-make} tcllibdir=\"${INSTDIR}/lib\" AR=\"${AR:-ar}\" RANLIB=\"${RANLIB:-ranlib}\"" - ${MAKE:-make} tcllibdir="${INSTDIR}/lib" AR="${AR:-ar}" RANLIB="${RANLIB:-ranlib}" && \ - ${MAKE:-make} tcllibdir="${INSTDIR}/lib" AR="${AR:-ar}" RANLIB="${RANLIB:-ranlib}" install || ( + + if [ "${STATICMK4}" != "-1" ]; then + if [ "${STATICMK4}" = "0" ]; then + echo 'Warning: Metakit4 fails to build shared on Win32, converting to static linking' + + STATICMK4="1" + fi + else + STATICMK4="0" + fi + export STATICMK4 + fi + + # Try to build as a shared object if requested + if [ "${STATICMK4}" = "0" ]; then + tryopts="--enable-shared --disable-shared" + elif [ "${STATICMK4}" = "-1" ]; then + tryopts="--enable-shared" + else + tryopts="--disable-shared" + fi + + for tryopt in $tryopts __fail__; do + # Clean up, if needed + make distclean >/dev/null 2>/dev/null rm -rf "${INSTDIR}" mkdir "${INSTDIR}" - exit 1 - ) || exit 1 + if [ "${tryopt}" = "__fail__" ]; then + exit 1 + fi + + if [ "${tryopt}" == "--enable-shared" ]; then + isshared="1" + else + isshared="0" + fi + + ( + echo "Running: ./configure $tryopt --prefix=\"${INSTDIR}\" --exec-prefix=\"${INSTDIR}\" --with-tcl=\"${TCLCONFIGDIR}/../generic\" ${CONFIGUREEXTRA}" + ./configure $tryopt --prefix="${INSTDIR}" --exec-prefix="${INSTDIR}" --with-tcl="${TCLCONFIGDIR}/../generic" ${CONFIGUREEXTRA} + + echo "Running: ${MAKE:-make} tcllibdir=\"${INSTDIR}/lib\" AR=\"${AR:-ar}\" RANLIB=\"${RANLIB:-ranlib}\"" + ${MAKE:-make} tcllibdir="${INSTDIR}/lib" AR="${AR:-ar}" RANLIB="${RANLIB:-ranlib}" || exit 1 + + echo "Running: ${MAKE:-make} tcllibdir=\"${INSTDIR}/lib\" AR=\"${AR:-ar}\" RANLIB=\"${RANLIB:-ranlib}\" install" + ${MAKE:-make} tcllibdir="${INSTDIR}/lib" AR="${AR:-ar}" RANLIB="${RANLIB:-ranlib}" install || exit 1 + ) || continue + + break + done + + # Clean up "libmk4.*", it's not needed + rm -f "${INSTDIR}/lib"/libmk4.* + # If we are building a shared version of Mk4tcl, put it in the VFS directory if [ "${isshared}" = "1" ]; then - # If we are building a shared version of Mk4tcl, put it in the VFS directory cp -r "${INSTDIR}/lib" "${OUTDIR}" fi exit 0 ) || exit 1 exit 0