notice "$MENUTRUE" "Setting up Mod_TCL...\n"

if [ -x /usr/bin/tclsh8.4 ];then export TCLVER=8.4;fi
if [ -x $LOCAL_PATH/bin/tclsh8.4 ];then export TCLVER=8.4;fi
if [ -x /usr/bin/tclsh8.3 ];then export TCLVER=8.3;fi
if [ -x $LOCAL_PATH/bin/tclsh8.3 ];then export TCLVER=8.3;fi
if [ -x /usr/bin/tclsh8.2 ];then export TCLVER=8.2;fi
if [ -x $LOCAL_PATH/bin/tclsh8.2 ];then export TCLVER=8.2;fi
if [ -x /usr/bin/tclsh8.1 ];then export TCLVER=8.1;fi
if [ -x $LOCAL_PATH/bin/tclsh8.1 ];then export TCLVER=8.1;fi
if [ -x /usr/bin/tclsh8.0 ];then export TCLVER=8.0;fi
if [ -x $LOCAL_PATH/bin/tclsh8.0 ];then export TCLVER=8.0;fi


if [ ! -f $root/apache_$APACHE/src/modules/mod_dtcl/mod_dtcl.a ];then
cd $root/src
check_source "mod_dtcl-$MODTCL.tar.gz" "http://tcl.apache.org/mod_dtcl/download/mod_dtcl-$MODTCL.tar.gz"
explode mod_dtcl-$MODTCL.tar.gz
notice "$MENUTRUE" " Untared Mod_TCL...\n"
cd mod_dtcl
$CP -f builddtcl.sh builddtcl.sh~
$SED -e "s|TCLSH=tclsh  ######### CHANGEME ##########|TCLSH=tclsh$TCLVER|" < builddtcl.sh  > builddtcl.sh.tmp
$MV -f builddtcl.sh.tmp builddtcl.sh
$SED -e "s|# APACHE=\$HOME/download/apache-1.3/  ######### CHANGEME ##########|APACHE=$root/apache_$APACHE/|" < builddtcl.sh  > builddtcl.sh.tmp   
$MV -f builddtcl.sh.tmp builddtcl.sh
$SED -e "s|INC=/usr/include/apache-1.3/  ######### CHANGEME ##########|INC=\$APACHE/src/include|" < builddtcl.sh  > builddtcl.sh.tmp
$MV -f builddtcl.sh.tmp builddtcl.sh
 notice "$MENUTRUE" " Modified Mod_TCL build script...\n"
 
 $CP $root/apache_$APACHE/src/os/unix/os.h $root/apache_$APACHE/src/include/
 $CP $root/apache_$APACHE/src/os/unix/os-inline.c $root/apache_$APACHE/src/include/

 chmod a+x builddtcl.sh
 ./builddtcl.sh static &> $logdir/mod_dtcl-static-build.log
 notice "$MENUTRUE" " Compiled Mod_TCL...\n"
 ./builddtcl.sh install &> $logdir/mod_dtcl-install.log
 notice "$MENUTRUE" " Installed Mod_TCL...\n"


echo "

########### Mod TCL ############
# http://tcl.apache.org/mod_dtcl/documentation.ttml
AddType application/x-httpd-tcl .ttml
AddType application/x-dtcl-tcl .tcl
################################

" >> $root/apache_$APACHE/conf/httpd.conf-dist
 notice "$MENUTRUE" " Apache httpd.conf-dist setup for Mod_TCL...\n"
 notice "$MENUTRUE" "Mod_TCL setup!\n"
fi
cd $root

APACHELIBS="$APACHELIBS -ltcl$TCLVER -lm"
APACHECFG="$APACHECFG --activate-module=src/modules/mod_dtcl/mod_dtcl.a $r"
