(in-package :common-lisp-user)

(pushnew :logon *features*)

;;
;; in a run-time image loading this file as its `-L' argument, we need to call
;; *restart-init-function* ourselves, as slave() below never returns.
;;
#+(and :allegro :runtime-standard)
(when (functionp excl:*restart-init-function*)
  (funcall excl:*restart-init-function*))
  
(let* ((logon (system:getenv "LOGONROOT"))
       (lingo (namestring (parse-namestring (format nil "~a/lingo" logon)))))
  ;;
  ;; load MK defsystem() and LinGO load-up library first
  ;;
  (load (format nil "~a/lingo/lkb/src/general/loadup" logon))

  ;;
  ;; for generation, we need (close to) the full scoop
  ;;
  (pushnew :lkb *features*)
  (pushnew :slave *features*)
  (excl:tenuring 
   (funcall (intern "COMPILE-SYSTEM" :make) "tsdb"))

  (funcall (symbol-function (find-symbol "INITIALIZE-TSDB" :tsdb))
           nil :rc (format nil "~a/dot.tsdbrc" logon))
  
  ;;
  ;; activate duplicate result elimination for analysis and generation
  ;;
  (set (intern "*PROCESS-SUPPRESS-DUPLICATES*" :tsdb) '(:surface))
  
  ;;
  ;; activate duplicate result elimination for analysis and generation
  ;;
  (set (intern "*MT-ENGINE*" :tsdb) (pairlis '(:engine :delay) '(:oa 30)))
       
  ;;
  ;; finally, make ourselves known to our creator and wait for orders
  ;;
  (funcall (symbol-function (find-symbol "SLAVE" :tsdb))))