#!/bin/csh -f
#!/bin/csh -fvx
echo `date`
#
# the installation directory.
#
set trg_dir=`pwd`
#
#
# 1. Check that the compressed files are here.
#
set tcl_gzfile=`ls tcl7.3*gz`
if ( $status ) exit
set tk_gzfile=`ls tk3.6*gz`
if ( $status ) exit
set itcl_gzfile=`ls itcl-1.5*gz`
if ( $status ) exit
set pix_gzfile=`ls TkPixmap*gz`
if ( $status ) exit
set blt_gzfile=`ls BLT-1.7*gz`
if ( $status ) exit
set icon_gzfile=`ls TkIcon*gz`
if ( $status ) exit
set steal_gzfile=`ls TkSteal*gz`
if ( $status ) exit
echo "Tcl compressed file:      $tcl_gzfile"
echo "Tk compressed file:       $tk_gzfile"
echo "iTcl compressed file:     $itcl_gzfile"
echo "TkPixmap compressed file: $pix_gzfile"
echo "blt compressed file:      $blt_gzfile"
echo "TkIcon compressed file:   $icon_gzfile"
echo "TkSteal compressed file:  $steal_gzfile"
echo "Compressed files OK"
#
# 2. Open all the gz files.
#
foreach gzf ( ${tcl_gzfile} ${tk_gzfile} ${itcl_gzfile} ${pix_gzfile} ${blt_gzfile} ${icon_gzfile} ${steal_gzfile} )
    echo "open file: $gzf"
	gzip -dc < $gzf | tar xf -
	# if ( ${status} ) exit
end
#
#
# mv TkSteal/wish/Makefile TkSteal/wish/Makefile.orig
# sed '/TKMEGA[^=]*=/s/^([^=]*)=.*$///\1=/' < TkSteal/wish/Makefile.orig > TkSteal/wish/Makefile
#
# 3. configure and make all.
#
# Configure each directory
#
( cd tcl7.3 ; configure --prefix=$trg_dir --exec-prefix=$trg_dir ; make ; make install )
( cd tk3.6 ; configure --prefix=$trg_dir --exec-prefix=$trg_dir ; make ; make install )
( cd itcl-1.5 ; configure --prefix=$trg_dir --exec-prefix=$trg_dir ; make ; make install )
( cd TkPixmap ; configure --prefix=$trg_dir --exec-prefix=$trg_dir ; make ; make install )
( cd blt-1.7 ; configure --prefix=$trg_dir --exec-prefix=$trg_dir ; make ; make install )
( cd TkIcon ; configure --prefix=$trg_dir --exec-prefix=$trg_dir ; make ; make install )
( cd TkSteal ; \
  configure --prefix=$trg_dir --exec-prefix=$trg_dir --with-itcl --with-tkpixmap --with-tkpixmap-xpm --with-tkpixmap-gif --with-tkpixmap-localxpm --with-tkpixmap-pinfo --with-tkpixmap-uxpm --with-blt --with-tkicon ; \
  make -k ; \
  make -k install )
#
# 4. Update the TkSteal/wish/Makefile and final make.
#
( cd TkSteal/wish ; mv Makefile Makefile.orig ; \
  sed -e '/TKMEGA[^=]*=/s/^\([^=]*\)=.*$/\1=/' < Makefile.orig > Makefile ; \
  make )
#
# 5. Move the TkSteal/wish/steal-wish to here '.'
#
mv TkSteal/wish/steal-wish ./op-wish
mv bin/tclsh .
#
# 6. Update the tclIndex in the lib/tk directory.
#
./tclsh <<'EOF'
cd lib/tk
auto_mkindex . *.tcl
exit
'EOF'
#
echo `date`
# End build-all
