(in-package "COMMON-LISP-USER")

;;; File: selected-kpml-kr.lisp
;;;
;;; This should contain all that is necessary to load/compile the
;;; selected knowledge representation system to be used with KPML.
;;; For illustration, the current contents as released are usually
;;; for Loom. An alternative KR based on CLOS can be seen in the
;;; file kpml-kr-agile.lisp.
;;;
;;; Note:
;;; KPML can be persuaded to take some other file rather than this file
;;; by presetting the variable common-lisp-user::*kpml-kr-loader* to 
;;; the pathname locating that file.
;;; ----------------------------------------------------------------------

;;***************************************************************************
;;*                                                                         *
;;*  IMPORTANT NOTE:                                                        *
;;*     EXTERNAL USERS MUST CHANGE THE FOLLOWING DEFVAR OR ALREADY          *
;;*     HAVE DEFINED IT IN A FILE LOADED BEFORE THIS ONE.                   *
;;*                                                                         *
;;*  It may be that different versions of the KR system are kept in various *
;;*  placed depending on what operating system and Lisp version is being    *
;;*  used. So examples of conditionalization are given here, showing quite  *
;;*  a wide variation. You don't have to have this if it not necessary      *
;;*  for your local configuration.                                          *
;;*                                                                         *
;;***************************************************************************
;;
;;; Make a pathname pointing to the top of the Loom directories hierarchy:
;;; (the settings as released can be taken as examples...)

(defvar *loom-pathname-default*
    
    ;; The ACL binaries were kept on forth.stir.ac.uk in the directory BIN
    ;; for a while...
    #+(and acl3.0 (not runtime-system))
    (pathname "\\\\FORTH\\jab4\\Systems\\loom2.1\\")

    ;; apart from the ACL runtime binaries, which are a bit different...
    #+(and acl3.0 runtime-system)
    (pathname "\\\\FORTH\\jab4\\Systems\\loom2.1r\\")

    ;; The Lispworks binaries are kept locally since LWW4.0 did not like
    ;; going across file systems... Although this is not an issue
    ;; in LWW4.1 and KPML4 and above... Although you still have to 
    ;; be sure that Loom can cope as the release defsystem with Loom
    ;; does not manage under LWW4.1.... Need to use the KPML version
    ;; instead.
    #+lispworks
    (pathname "C:\\Programme\\loom3.0\\")
    
    ;; The non-PC version was here for a while...
    #+unix(pathname "/projects/gnome/annotation/anno-tools/RAX/loom2.1/")
    
    #+(and allegro mswindows)
    (pathname "C:/Systems/loom2.1/")
    )

;;; ----------------------------------------------------------------------
;;; NO FURTHER CHANGES REQUIRED IN THIS FILE!
;;; ----------------------------------------------------------------------


;;; ----------------------------------------------------------------------
;;; installation proceeds with comments...

#+(and acl3.0 runtime-system)
(format *trace-output* "~%N.B., Using runtime Loom2.1 for ACL3.0!")

;;; ----------------------------------------------------------------------
;;; If Loom does not already exist (i.e., it has not been loaded into
;;; the current image), then do so... (this puts :isi onto *features*
;;; just in case Loom likes it being there... (homesickness?))
;;; ----------------------------------------------------------------------

(unless (find-package 'LOOM)
  (push :isi *features*)
  (load (merge-pathnames "load-loom.lisp" user::*loom-pathname-default*)))

#-loom
(format t "%;;; Loom system was NOT successfully loaded!!! Do this first.")

;;; ----------------------------------------------------------------------
;;; Loom3.0 added (Feb98: from Knut)
;;; Open Lisp versioning introduced (Apr99).
;;; Loom4.0 added (Jan03: John)
;;; ----------------------------------------------------------------------

#+loom
(:version-message
 (t ":LOOM") 
 ((- "2.0")     "~%;;; This loom is too old! It will probably crash.")
 (("2.0" "2.1") "~%;;; Configuring KPML for LOOM 2.0 or 2.1")
 (("3.0" "3.0") "~%;;; Configuring KPML for LOOM 3.0")
 (("4.0" "4.0") "~%;;; Configuring KPML for LOOM 4.0")
 ((+ "4.0")     
  "~%;;; Some Loom newer than 4.0 being used (which is odd!!). Configuring KPML as for Loom 4.0"))

#+loom
(:version-case (":LOOM")
	       ((+ "2.1")
		(unless (loom::find-context 'ideation-base-0)
		  (loom::defcontext ideation-base-0 :theory nil))))

;;; ----------------------------------------------------------------------
;;; System definitions for interfacing with LOOM.
;;; ----------------------------------------------------------------------

(defparameter *kpml-kr-system-name* 'kpml-loom)

(make:defsystem KPML-LOOM
  :source-pathname *root-of-kpml*
  :source-extension "lisp"
  :binary-pathname *kpml-binaries-root*
  :components 
  ((:module CORE
	    :source-pathname "Processes"
	    :components 
	    (
	     (:module LOOM-PACKAGE
		      :source-pathname "kr-interfaces/loom"
		      :components ((:file loom-kpml-package.lisp)))
	     (:module KR-INTERFACES
		      :source-pathname "kr-interfaces/loom"
		      :components (
				   ;; KPML4 followiing unused...
				   ;;    (:file loom-kb-utilities)
				   ;;
				   (:file penman-loom-kb-interface)
				   ))))))

;;; ----------------------------------------------------------------------
;;; LOOM does stuff to set, so we change it back before continuing...
;;; ----------------------------------------------------------------------

(in-package "LOOM")
(defun set (a b)(common-lisp::set a b))
(compile 'set)


(format t "~%;;; LOOM and KPML-LOOM interface loaded.")

