#
# This is a Wafe script to build the initial indices for the tcl
# libraries provided with wafe and to achive backward compatibility
#
puts stderr "building aliases for backward compatibility ..."
source mkAlias.tcl
catch {exec rm bc/tclIndex}
mkAliasIndex bc *.tcl

puts stderr "building index in Wafe tcl library..."
if [string match "" [info proc auto_mkindex]] {
    puts stderr ""
    puts stderr "Problem:" 

    puts stderr "   'auto_mk_index' is not defined, probably since the"
    puts stderr "   standard (not Wafe specific) Tcl library is not installed"
    puts stderr "   on your system. According to libtcl.a I expect to find "
    puts stderr "   this procedure in [info library]/init.tcl."
    puts stderr ""

    if [info exists env(TCL_HOME)] { 

      puts stderr "   If the standard Tcl library is not (yet) installed on"
      puts stderr "   your system; i suggest to install it by issuing the"
      puts stderr "   following commands as root:"

      puts stderr ""
      puts stderr "        cd $env(TCL_HOME)"
      puts stderr "        make install-libraries"
      puts stderr ""
    }

    puts stderr "   If the standard Tcl library is installed on a"
    puts stderr "   different place on your system you should"
    puts stderr "      a) specify the directory when you compile tcl"
    puts stderr "         (see TCL_LIBRARY in the Makefile of tcl), or" 
    puts stderr "      b) use the TCL_LIBRARY environment variable at runtime."
    if [info exists env(TCL_HOME)] {
      if [string match ".*" $env(TCL_HOME)] {
	set newenv ../$env(TCL_HOME)
      } else {
	set newenv $env(TCL_HOME)
      }
      puts stderr ""
      puts stderr "   In a c-shell you can use for example:"
      puts stderr "        setenv TCL_LIBRARY $newenv/library"
      puts stderr "   and try 'make' again (only as a temporary fix)"
    }
    puts stderr ""
    quit
} 

catch {exec rm tclIndex}
auto_mkindex . *.tcl
puts stderr "Indices build"
quit
