;;; -*- Mode: lisp; Package: CL-USER -*-

;;; Defsystem to convert the colnew Fortran code to Lisp
;;;
;;; Convert Fortran code to Lisp via
;;;
;;; (mk:oos "colnew-lisp" :compile :force t)

(in-package #-gcl #:cl-user #+gcl "CL-USER")

(require :f2cl)


(mk:define-language :f2cl-lisp
    :compiler #'f2cl:f2cl
    :loader #'identity
    :source-extension "f"
    :binary-extension "lisp")

(defparameter *colnew-root* (maxima::maxima-load-pathname-directory))

(mk:defsystem colnew-lisp
  :source-pathname *colnew-root*
  :components
  ((:module fortran
	    :source-extension "f"
	    :binary-pathname "lisp/"
	    :language :f2cl-lisp
	    :compiler-options (:common-as-array t :package :colnew)
	    :compile-only t
	    :components
	    (
	     ;; Linpack routines needed by colnew
	     (:file "dgesl"
		    :depends-on ("daxpy" "ddot"))
	     (:file "dgefa"
		    :depends-on ("idamax" "dscal" "daxpy"))
	     ;; BLAS routines needed by above
	     (:file "daxpy")
	     (:file "ddot")
	     (:file "dscal")
	     (:file "idamax")
	     ;; Simple compatibility to define all of the needed
	     ;; common blocks in one place.
	     (:file "compat"
		    :compiler-options (:declare-common t :common-as-array t
						       :package :colnew))
	     ;; COLNEW itself, broken down into one subroutine per
	     ;; file.
	     (:file "colnew"
		    :depends-on ("compat" "consts" "newmsh" "contrl"))
	     (:file "contrl"
		    :depends-on ("compat" "lsyslv" "skale" "errchk" "newmsh"))
	     (:file "skale"
		    :depends-on ("compat"))
	     (:file "newmsh"
		    :depends-on ("compat" "approx" "horder"))
	     (:file "consts"
		    :depends-on ("compat" "vmonde" "rkbas"))
	     (:file "errchk")
	     (:file "lsyslv"
		    :depends-on ("compat" "vwblok" "gblock" "gderiv" "fcblok"
					  "sbblok" "dmzsol"))
	     (:file "gderiv")
	     (:file "vwblok"
		    :depends-on ("compat" "dgesl" "dgefa"))
	     (:file "gblock"
		    :depends-on ("compat" "dgesl"))
	     (:file "appsln")
	     (:file "approx"
		    :depends-on ("compat"))
	     (:file "rkbas"
		    :depends-on ("compat"))
	     (:file "vmonde"
		    :depends-on ("compat"))
	     (:file "horder")
	     (:file "dmzsol"
		    :depends-on ("factrb" "shiftb"))
	     (:file "fcblok"
		    :depends-on ("factrb" "shiftb"))
	     (:file "factrb")
	     (:file "shiftb")
	     (:file "sbblok"
		    :depends-on ("subfor" "subbak"))
	     (:file "subfor")
	     (:file "subbak")))))

(mk:defsystem colnew-ex-lisp
  :source-pathname *colnew-root*
  :language :f2cl-lisp
  :compiler-options (:package :colnew)
  :compile-only t
  :components
  ((:module ex1
	    :components
	    ((:file "prob1"
		    :compiler-options (:common-as-array t :package :colnew)
		    :depends-on ("fsub" "dfsub" "gsub" "dgsub" "exact"))
	     (:file "fsub")
	     (:file "gsub")
	     (:file "dfsub")
	     (:file "dgsub")
	     (:file "exact")))
   (:module ex2
	    :components
	    ((:file "prob2"
		    :compiler-options (:declare-common t :package :colnew)
		    :depends-on ("fsub" "dfsub" "gsub" "dgsub" "solutn"))
	     (:file "fsub")
	     (:file "gsub")
	     (:file "dfsub")
	     (:file "dgsub")
	     (:file "solutn")))
   (:module ex3
	    :components
	    ((:file "prob3"
		    :compiler-options (:declare-common t :package :colnew)
		    :depends-on ("fsub" "dfsub" "gsub" "dgsub" "solutn"))
	     (:file "fsub")
	     (:file "gsub")
	     (:file "dfsub")
	     (:file "dgsub")
	     (:file "solutn")))))
