;;; When loaded, this file compiles the entire kernel Spice Lisp system and
;;; the compiler.

(unless (eq *package* *lisp-package*)
  (error "You lose!  Set *package* to *lisp-package* first."))

(setq *maximum-interpreter-error-checking* nil)
(setq *load-set-default-pathname* nil)

(fresh-line)

;;; For the cold load, random top-level forms must be compiled as functions.

(setq *compile-random-forms-as-functions* t)

;;; To speed compilation and create a single log file, we redirect output
;;; to >sys>user>code>compile-slisp.log.

(setq *log-file* (open ">sys>user>compile-slisp.log"
		       :direction :output
		       :if-exists :supersede))

(defun comf (name)
  (maybe-gc)
  (write-line name)
  (let ((*standard-output* *log-file*))
    (compile-file name)))

;;; These guys need to be first.

(comf ">sys>slisp>code>Nspdefs.Slisp")
(comf ">sys>slisp>code>Perqinit.Slisp")
(comf ">sys>slisp>code>Kernel.Slisp")
(comf ">sys>slisp>code>Keyword.Slisp")
(comf ">sys>slisp>code>Defstream.Slisp")

;;; These guys can supposedly come in any order.
;;; Some are put at the end so macros don't run interpreted and stuff.

(comf ">sys>slisp>code>Arith.Slisp")
(comf ">sys>slisp>code>Array.Slisp")
(comf ">sys>slisp>code>Backq.Slisp")
(comf ">sys>slisp>code>Char.Slisp")
(comf ">sys>slisp>code>Choose.Slisp")
(comf ">sys>slisp>code>Debug.Slisp")
(comf ">sys>slisp>code>Disassemble.Slisp")
(comf ">sys>slisp>code>Envmgr.Slisp")
(comf ">sys>slisp>code>Error.Slisp")
(comf ">sys>slisp>code>Errorm.Slisp")
(comf ">sys>slisp>code>Eval.Slisp")
(comf ">sys>slisp>code>Filesys.Slisp")
(comf ">sys>slisp>code>Format.Slisp")
(comf ">sys>slisp>code>Frames.Slisp")
(comf ">sys>slisp>code>Hash.Slisp")
(comf ">sys>slisp>code>Lfloat-consts.Slisp")
(comf ">sys>slisp>code>List.Slisp")
(comf ">sys>slisp>code>Load.Slisp")
(comf ">sys>slisp>code>Macromemo.Slisp")
(comf ">sys>slisp>code>Misc.Slisp")
(comf ">sys>slisp>code>Package.Slisp")
(comf ">sys>slisp>code>Perqstrops.Slisp")
(comf ">sys>slisp>code>Pred.Slisp")
(comf ">sys>slisp>code>Print.Slisp")
(comf ">sys>slisp>code>Query.Slisp")
(comf ">sys>slisp>code>Rand.Slisp")
(comf ">sys>slisp>code>Reader.Slisp")
(comf ">sys>slisp>code>Sapphire.Slisp")
(comf ">sys>slisp>code>Save.Slisp")
(comf ">sys>slisp>code>Save-Aux.Slisp")
(comf ">sys>slisp>code>Seq.Slisp")
(comf ">sys>slisp>code>Sesame.Slisp")
(comf ">sys>slisp>code>Sharpm.Slisp")
(comf ">sys>slisp>code>Sort.Slisp")
(comf ">sys>slisp>code>Spbug.Slisp")
(comf ">sys>slisp>code>Spio.Slisp")
(comf ">sys>slisp>code>Spirrat.Slisp")
(comf ">sys>slisp>code>Spnum.Slisp")
(comf ">sys>slisp>code>Step.Slisp")
(comf ">sys>slisp>code>Stream.Slisp")
(comf ">sys>slisp>code>Pprint.Slisp")
(comf ">sys>slisp>code>String.Slisp")
(comf ">sys>slisp>code>Subtypep.Slisp")
(comf ">sys>slisp>code>Symbol.Slisp")
(comf ">sys>slisp>code>Trace.Slisp")
(comf ">sys>slisp>code>Typescript.Slisp")
(comf ">sys>slisp>code>Viewport.Slisp")

(comf ">sys>slisp>code>Genesis.Slisp")
(comf ">sys>slisp>code>Purify.Slisp")

(comf ">sys>slisp>compiler>Clc.Slisp")
(comf ">sys>slisp>compiler>Fndefs.Slisp")
(comf ">sys>slisp>compiler>Trans.Slisp")
(comf ">sys>slisp>compiler>Typetran.Slisp")
(comf ">sys>slisp>compiler>Seqtran.Slisp")
(comf ">sys>slisp>compiler>Peep.Slisp")
(comf ">sys>slisp>compiler>Assem.Slisp")
(comf ">sys>slisp>compiler>Instrdefs.Slisp")

(comf ">sys>slisp>code>Alien.Slisp")
(comf ">sys>slisp>code>Defstruct.Slisp")
(comf ">sys>slisp>code>Macros.Slisp")
(comf ">sys>slisp>code>Defmacro.Slisp")

(close *log-file*)

(setq *load-verbose* nil)