==============================================================================
                  How to create prebuilt Tcl/Tk binaries
==============================================================================

Please look further down in this text for Windows instructions...

Unixish OS
----------

For commercial releases we use a prebuilt binary release of Tcl/Tk 8.X
where X >= 2. This release is placed into "gs-VSN/priv/tcl" and the
'gstk_port_handler' module searches this directory first to find the
"wish" executable program.

It is possible to pack the files from a standard installation on a
machine into a TAR file but it is preferable to build Tcl/Tk from
sources. The steps are

  0. Set some environment variables

       % setenv BUILDDIR /tmp/build
       % setenv GNUTAR gtar

  1. Download unpack the sources from http://sourceforge.net/projects/tcl.
     Use the latest stable release. When this README was written
     the latest stable version was 8.3.4.

       % mkdir -p $BUILDDIR/tcl
       % cd $BUILDDIR
       % $GNUTAR -xzf /my/src/path/tcl8.3.4.tar.gz
       % $GNUTAR -xzf /my/src/path/tk8.3.4.tar.gz

       % cd tcl8.3.4/unix
       % ./configure --enable-gcc --enable-threads --disable-load \
                --disable-shared --prefix=$BUILDDIR/tcl
       % make
       % make install

       % cd ../../tk8.3.4/unix
       % ./configure --enable-gcc --enable-threads --disable-load \
                --disable-shared --prefix=$BUILDDIR/tcl \
                --with-tcl=$BUILDDIR/tcl/lib
       % make
       % make install

  2. Check that the executable wish program don't depend on libtcl
     or libtk. If it does we have to redo this or keep them
     where they are, else we can remove the libraries

       % cd $BUILDDIR
       % ldd tcl/bin/wish8.3

     and if the executables doesn't depend on libtcl or libtk we remove them

       % rm -f tcl/lib/libt*

  3. Remove other things we don't need. There may be other things in
     later releases but only remove the obvious things

       % rm -fr tcl/include tcl/man
       % rm -f  tcl/bin/tclsh*
       % rm -f  tcl/lib/*.sh
       % rm -fr tcl/lib/tcl*/http*
       % rm -fr tcl/lib/tcl*/tcltest*
       % rm -fr tcl/lib/tk*/demos
       % rm -fr tcl/lib/tk*/images
       % rm -f  tcl/lib/*/*.c

  4. Some releases of Tcl/Tk contains soft links that make the directory
     structure circular making it impossible to use 'cp' to copy the
     tcl directory. You can find them with

       % find tcl -type l

  5. Find out the name of the resulting TAR archive. Run the GS configure
     script on the target platform to view the name 

       % cd $ERL_TOP/lib/gs
       % rm -f config.cache
       % autoconf
       % ./configure
  
  6. Use the TAR program on the system to pack the resulting Tcl/Tk
     distribution. Keep the top "tcl" library

       % tar -cf - tcl | gzip > xxxxxxxx.tar.gz

  7. Copy and check in this TAR archive into the directory

       /clearcase/otp/erts/lib/gs/tcl/binaries

  8. We are done........


Windows
-------

These instructions are aimed at the 8.5.7 release of both tcl and tk,
but should work for 8.4 as well as 8.6 releases with appropriate
modifications.

0. Download the source tar files for both tcl and tk and unpack the
tar files from the same root.

1. Start with tcl. Open a command prompt with the appropriate Visual
C++ command environment (there is usually a shortcut under VC++ tools
or something in the start menu. With this command prompt, cd to the
tcl<version>/win directory and issue the following commands:

dos_prompt> nmake -f makefile.vc OPTS=static INSTALLDIR=<some temp dir>\tcl
...
dos_prompt> nmake -f makefile.vc OPTS=static INSTALLDIR=<some temp dir>\tcl install

2. Move further to tk. Using the same command prompt, cd
..\..\tk<version>\win and build there:

dos_prompt> nmake -f makefile.vc OPTS=static TCLDIR=<top dir of sources>\tcl<version> INSTALLDIR=<some temp dir>\tcl
...
dos_prompt> nmake -f makefile.vc OPTS=static TCLDIR=<top dir of sources>\tcl<version> INSTALLDIR=<some temp dir>\tcl install

3. Now you will need to strip the installation you put in <some temp
dir>\tcl. To do this, you will want a more appropriate command
shell. Start cygwin bash and cd to the cygwin equivalent of <some temp
dir>, i.e. where tcl/tk was installed. Now clean away what's not
needed (this is not optional, gs won't work with a full version...)

       % rm -fr tcl/include tcl/man
       % rm -f  tcl/bin/tclsh*
       % rm -f  tcl/lib/*.sh
       % rm -fr tcl/lib/tcl*/http*
       % rm -fr tcl/lib/tcl*/tcltest*
       % rm -fr tcl/lib/tcl*/tzdata
       % rm -fr tcl/lib/tcl*/msgs
       % rm -fr tcl/lib/tk*/demos
       % rm -fr tcl/lib/tk*/images
       % rm -fr tcl/lib/tk*/tzdata
       % rm -f  tcl/lib/*/*.c
       % rm -f  tcl/lib/*.lib
       % rm -fr tcl/lib/tcl8

(The last line is especially important, gs will crash otherwise...)

4. Now copy license.terms from the sources, otherwise you may break the redistribution policy.

       % cp <top of sources/tcl<version>/license.terms tcl/

5. Pack the tar file:

       % tar zcf win32.tar.gz tcl

6. Put it in $ERL_TOP/lib/gs/tcl/binaries (as described for Unixes)

7. You are done!



