##################################################
##### LOAD LUC(IOLE) DYNAMIC LIB #################
##################################################
# THIS SCRIPT MUST BE source'd in the preamble of
# tools using luc (for now luc(iole), rp2luc)
#
# 2026/02 -> check version compat beteen tclsh and lustubs.so
# - only major version is taken into account, maybe not a good idea ...
# - 
# Load c-stubs, import commands (machine dep.):
# - for loading/running the 'dro' appli
# - misc utilities (e.g. timer)

if { [catch {load $::env(LUSTRE_INSTALL)/tcl/lustubs.so} fid] } {
   global tcl_version
   puts stderr "Can't not open standard lustubs\n$fid"
   puts stderr "tcl_version=$tcl_version"
   set major [lindex [split $tcl_version "."] 0]
   puts "major=$major"
   set alt_so "$::env(LUSTRE_INSTALL)/tcl/lustubs.$major.so"
   if { [file exist $alt_so] } {
      puts stderr "Try to open $alt_so"
      load $alt_so
   } else {
      puts stderr "No stubs arre available for this version of tclsh ($major)"
      exit 1
   }
}

