さくらんぼのlambda日記

lambdaちっくなことからゲーム開発までいろいろ書きます。

SBCLのインストール

公式から1.0.29のインストーラをダウンロードしてくる。
http://jaist.dl.sourceforge.net/project/sbcl/sbcl/1.0.29/sbcl-1.0.29-x86-windows-binary.msi


インストールするときは"C:\SBCL"のようにスペースを含まない場所にインストールする必要がある。

~/.sbclrcを下の内容で作成する。

(require :asdf)

(in-package :asdf)

(defun win-sysdef-search (system)
  (let ((home (MERGE-PATHNAMES ".sbcl/site/" (USER-HOMEDIR-PATHNAME))))
    (let* ((name (coerce-name system))
           (home (truename home))
           (files (directory
                   (merge-pathnames
                    (make-pathname :directory `(:relative :wild)
                                   :name name
                                   :type "asd"
                                   :case :local
                                         :version :newest)
                    home))))
      (dolist (file files)
        (when (probe-file file)
          (return-from win-sysdef-search file))))))

(pushnew 'win-sysdef-search asdf:*system-definition-search-functions*)

(require :asdf-install)

(in-package :asdf-install)

(labels ((cyg-path (win-path)
   (cl:concatenate 'string "/cygdrive/c/" (cl:substitute #\/ #\\ (cl:subseq (namestring win-path) 2))))

         (tar (args)
           (with-output-to-string (o)
             (let ((process (sb-ext:run-program *tar-program*
                                                args
                                                :search t
                                                :wait nil
                                                :output :stream)))
               (prog1 (loop for l = (read-line (process-output process) nil nil)
                         while l
                         do (write-line l o))
                 (process-wait process)
                 (process-close process))))))

  (defun get-tar-directory (packagename)
    (let* ((tar (tar (list "-tzf" (cyg-path packagename))))
           (first-line (subseq tar 0 (position #\newline tar))))
      (if (find #\/ first-line)
          (subseq first-line 0 (position #\/ first-line))
          first-line)))

  (defun untar-package (source packagename)
    (tar (list "-C" (cyg-path source)
               "-xzvf" (cyg-path packagename)))))


(in-package :cl-user)