;; Matlab-interface ;; Copyright (c) 2002 Sebastian Seidel ;; This library is free software; you can redistribute it and/or ;; modify it under the terms of the GNU Lesser General Public ;; License as published by the Free Software Foundation; either ;; version 2.1 of the License, or (at your option) any later version. ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. ;; You should have received a copy of the GNU Lesser General Public ;; License along with this library; if not, write to the Free Software ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ;; Contact me by mail: Sebastian.H.Seidel@med.uni-giessen.de ;; -------------------------------------------------------------------- ;; This file - installer.ss - provides procedures that compile and ;; link 'primitive.c' to produce a mzscheme-extension-file. ;; -------------------------------------------------------------------- ;; Use matlab-interface to control matlab (www.mathworks.com) via ;; interprocess-communication from within the fantastic open-source ;; scheme-interpreters/compilers mzscheme and drscheme that are ;; distributed by plt (www.plt-scheme.org). ;; -------------------------------------------------------------------- ;; installer.ss ;; ============ ;; First-edition: 2002-05-27 SSeidel ;; New-from-scratch: 2002-10-27 SSeidel ;; Latest-revision: 2002-11-07 SSeidel ;; Exports ;; ------- ;; (install) Compile and link 'primitive.c'. ;; Needs information about the location of some files ;; and directories inside the matlab-directory-tree. ;; Reads that information from 'info.ss'. ;; Please, consult 'doc.txt' for additional ;; information about the installation-process. ;; (installer) Evoked automatically by 'Setup PLT'. Displays some ;; text. ;; -------------------------------------------------------------------- (module installer mzscheme (provide installer install) (require (lib "compile.ss" "dynext") (lib "link.ss" "dynext") (lib "file.ss" "dynext") (lib "getinfo.ss" "setup")) (define step-0:workdir #f) ;; path to directory .../collects/matlab-interface/ which contains 'step-1:srcfile' (define step-1:srcfile #f) ;; path to 'primitive.c' in directory step-0:workdir (define step-2:binsdir #f) ;; path to binary directory, a subdirectory of .../collects/matlab-interface/compiled/ (define step-3:incldir #f) ;; path to matlab-include-directory which contains 'engine.h' (define step-4:objfile #f) ;; path to object-file - result of compiling 'primitive.c' - in directory 'step-2:binsdir' (define step-5:lnklibs #f) ;; list of matlab-link-libraries-paths (define step-6:extfile #f) ;; path to extension-file - result of linking step-4:objfile with step-5:lnklibs - in directory 'step-2:binsdir' (define explode-path ;; -> ( ...) ;; Split path-string into list of path-strings ;; ( ...) ;; similar functionality: 'explode-path' in mzlib/file.ss (lambda (base) (letrec ((P (lambda (ls base name) (cond ((or (eq? base 'relative) (eq? base #f)) (cons name ls)) ((string? base) (call-with-values (lambda () (split-path base)) (lambda (new-base new-name dummy) (P (cons name ls) new-base new-name)))) (#t (error 'explode-path:unexpected-condition)))))) (call-with-values (lambda () (split-path base)) (lambda (base name dummy) (P '() base name)))))) (define make-directory-layers ;; ( ...) ;; Make those directories: ;; base-path/ ;; base-path/relative-path1 ;; base-path/relative-path1/... (lambda (ls) (if (pair? ls) (let P ((ls (cdr ls)) (path (car ls))) (begin (or (directory-exists? path) (make-directory path)) (if (pair? ls) (P (cdr ls) (build-path path (car ls))) path))) (error 'make-directory-layers:empty-list)))) (define get-info-value ;; -> ;; definition of in module ;; collects/matlab-interface/info.ss ;; The namespace-hack is neccessary to get the _actual_ value. (lambda (sym) (let ((ns (make-namespace))) (parameterize ((current-namespace ns)) ((get-info '("matlab-interface")) sym))))) (define init-setup-params (lambda () (set! step-0:workdir (collection-path "matlab-interface")) (display `(step-0:workdir ,step-0:workdir)) (newline) (set! step-1:srcfile (build-path step-0:workdir "primitive.c")) (display `(step-1:srcfile ,step-1:srcfile)) (newline) (set! step-2:binsdir (build-path step-0:workdir "compiled" "native" (system-library-subpath))) (display `(step-2:binsdir ,step-2:binsdir)) (newline) (set! step-3:incldir (get-info-value 'matlab-include-directory)) (display `(step-3:incldir ,step-3:incldir)) (newline) (set! step-4:objfile (build-path step-2:binsdir (append-object-suffix "primitive"))) (display `(step-4:objfile ,step-4:objfile)) (newline) (set! step-5:lnklibs (get-info-value 'matlab-link-libraries)) (display `(step-5:lnklibs ,step-5:lnklibs)) (newline) (set! step-6:extfile (build-path step-2:binsdir (append-extension-suffix "primitive"))) (display `(step-6:extfile ,step-6:extfile)) (newline))) (define install (lambda () (newline) (display '(a set-paths)) (newline) (init-setup-params) (newline) (display '(b (make-binary-directory step-2:binsdir))) (newline) (make-directory-layers (explode-path step-2:binsdir)) (newline) (display '(c (delete-old-objectfile step-4:objfile))) (newline) (and (file-exists? step-4:objfile) (delete-file step-4:objfile)) (newline) (display '(d (compile-extension (input (sourcefile step-1:srcfile) (includefile "engine.h" (in-directory step-3:incldir))) (output (objectfile step-4:objfile))))) (newline) (compile-extension #f step-1:srcfile step-4:objfile (list step-3:incldir)) (newline) (display '(e (delete-old-extensionfile step-6:extfile))) (newline) (and (file-exists? step-6:extfile) (delete-file step-6:extfile)) (newline) (display '(f (link-extension (input (objectfile step-4:objfile) (matlab-libraries step-5:lnklibs)) (output (extensionfile step-6:extfile))))) (newline) (link-extension #f (cons step-4:objfile step-5:lnklibs) step-6:extfile) (newline) (display '(g installation-successful)) (newline))) (define installer (lambda (plt-home) (display " +------------------------------------------+ | <<<<<< Matlab - Interface >>>>>> | +------------------------------------------+ All files are in place now. The only remaining task is to install - compile and link - the extension-program. ATTENTION: The documentation of the matlab-interface describes how to go on. Please procede with step (2) of the installation. Look for the documentation at those locations: - matlab-interface/doc.txt - plt-help-desk - www.biont.org Good luck! For questions, proposals, laudatio and critisism mail to: Sebastian.H.Seidel@med.uni-giessen.de "))) )