
TCLV=8.5.14
TCLSH=tclsh8.5
TCLLIB=1.15

cd /opt/local/share/macports

#
# 1) Fetch Tcl sources from sourceforge
# 2) Unpack the tar file
# 3) configure, build, install Tcl as private copy of MacPorts
#    under /opt/local/share/macports
#

if [ ! -f tcl${TCLV}-src.tar.gz ]; then 
   curl -L -o tcl${TCLV}-src.tar.gz http://sourceforge.net/projects/tcl/files/Tcl/${TCLV}/tcl${TCLV}-src.tar.gz/download
fi

if [ ! -d tcl${TCLV} ]; then 
   tar zxvf tcl${TCLV}-src.tar.gz
fi

if [ ! -x bin/${TCLSH} ]; then 
    cd tcl${TCLV}/unix
    ./configure --prefix=/opt/local/share/macports --enable-threads
    make
    make install
    cd /opt/local/share/macports
fi

#
# Fetch Tcllib, can make several things in macports easier, e.g. using the
# 8.6 compatible "try" package
#
if [ ! -f tcllib-${TCLLIB}.tar.gz ]; then 
    curl -L -o tcllib-${TCLLIB}.tar.gz http://sourceforge.net/projects/tcllib/files/tcllib/${TCLLIB}/tcllib-${TCLLIB}.tar.gz/download
fi

if [ ! -d tcllib-${TCLLIB} ]; then 
   tar zxvf tcllib-${TCLLIB}.tar.gz
   cd tcllib-${TCLLIB}
   ./configure --prefix=/opt/local/share/macports
   make install
   cd /opt/local/share/macports
fi

echo "\nUse Tcl $TCLV and tcllib-${TCLLIB}"
echo "tclsh is /opt/local/share/macports/bin/${TCLSH}"
echo "You might want to use this shell in /opt/local/bin/port"
echo "(change in the script /usr/bin/tclsh to /opt/local/share/macports/bin/${TCLSH})"
echo ""

