1 (defun replace-substring (in-string old new
)
4 (end (search old in-string
)
5 (search old in-string
:start2 begin
)))
6 ((>= begin
(length in-string
)) 'done
)
8 (progn (setf result
(concatenate 'string result
9 (subseq in-string begin end
)
11 (setf begin
(+ end
(length old
))))
12 (progn (setf result
(concatenate 'string result
13 (subseq in-string begin
15 (setf begin
(length in-string
)))))
18 (defun process-file (in-filename out-filename substitutions
)
19 (with-open-file (in in-filename
:direction
:input
)
20 (with-open-file (out out-filename
:direction
:output
21 :if-exists
:supersede
)
22 (do ((line (read-line in nil
'eof
)
23 (read-line in nil
'eof
)))
25 (mapc #'(lambda (pair)
26 (setf line
(replace-substring line
30 (format out
"~a~%" line
)))))
32 (defun read-with-default (prompt default
)
33 (format t
"~a [~a]: " prompt default
)
35 (let ((response (string-right-trim '(#\Return
) (read-line))))
36 (if (string= response
"") default response
)))
39 ;;; This function (only) modified from CLOCC http://clocc.sourceforge.net
40 (defun default-directory-string ()
42 "\\" (string-right-trim
45 #+allegro
(excl:current-directory
)
46 #+clisp
(#+lisp
=cl ext
:default-directory
47 #-lisp
=cl lisp
:default-directory
)
48 #+cmu
(ext:default-directory
)
49 #+scl
(unix-namestring (ext:default-directory
))
50 #+cormanlisp
(ccl:get-current-directory
)
51 #+lispworks
(hcl:get-working-directory
)
52 #+lucid
(lcl:working-directory
)
53 #-
(or allegro clisp cmu scl cormanlisp lispworks lucid
)
57 (with-open-file (in "configure.ac" :direction
:input
)
58 (do ((line (read-line in nil
'eof
)
59 (read-line in nil
'eof
))
63 (when (string= version
"")
64 (format t
"Warning: No version information found.~%~%"))
66 (when (search "AC_INIT([maxima]," line
)
67 (setq line
(string-trim '(#\Return
) line
))
69 (replace-substring line
"AC_INIT([maxima], [" ""))
71 (replace-substring temp
"])" ""))
72 (when (or (string= temp line
)
73 (string= temp version
))
75 (format t
"Warning: Problem parsing version information. ")
76 (format t
"Found: \"~a\"~%~%" version
))))))
78 (defvar *maxima-lispname
* #+clisp
"clisp"
84 #+(and openmcl
(not 64-bit-target
)) "openmcl"
85 #+(and openmcl
64-bit-target
) "ccl64"
88 #-
(or clisp cmu scl sbcl gcl allegro ccl abcl ecl
) "unknownlisp")
90 (defun configure (&key
(interactive t
) (verbose nil
)
103 (let ((prefix (if maxima-directory
105 (default-directory-string)))
106 (win32-string (if is-win32
"true" "false"))
107 (shell (if posix-shell posix-shell
"/bin/sh"))
108 (clisp (if clisp-name clisp-name
"clisp"))
109 (cmucl (if cmucl-name cmucl-name
"lisp"))
110 (scl (if scl-name scl-name
"lisp"))
111 (acl (if acl-name acl-name
"acl"))
112 (openmcl (if openmcl-name openmcl-name
"mcl"))
113 (ccl64 (if ccl64-name ccl64-name
"ccl64"))
114 (sbcl (if sbcl-name sbcl-name
"sbcl"))
115 (ecl (if ecl-name ecl-name
"ecl"))
116 (gcl (if gcl-name gcl-name
"gcl"))
117 (files (list "maxima-local.in" "src/maxima.in" "src/maxima.bat.in"
118 "src/autoconf-variables.lisp.in"))
122 (setf prefix
(read-with-default "Enter the Maxima directory" prefix
))
124 (read-with-default "Is this a Windows system? (true/false)"
126 (setf shell
(read-with-default "Posix shell (optional)" shell
))
128 (read-with-default "Name of the Clisp executable (optional)"
131 (read-with-default "Name of the CMUCL executable (optional)"
134 (read-with-default "Name of the SCL executable (optional)"
137 (read-with-default "Name of the Allegro executable (optional)"
140 (read-with-default "Name of the OpenMCL executable (optional)"
143 (read-with-default "Name of the OpenMCL (64-bit) executable (optional)"
146 (read-with-default "Name of the ECL executable (optional)"
149 (read-with-default "Name of the GCL executable (optional)"
152 (read-with-default "Name of the SBCL executable (optional)"
154 (setf substitutions
(list (cons "@prefix@"
155 (replace-substring prefix
"\\" "\\\\"))
156 (cons "@PACKAGE@" "maxima")
157 (cons "@VERSION@" (get-version))
158 (cons "@host@" "unknown")
159 (cons "@win32@" win32-string
)
160 (cons "@default_layout_autotools@" "false")
161 (cons "@POSIX_SHELL@" shell
)
162 (cons "@expanded_top_srcdir@"
163 (replace-substring prefix
"\\" "\\\\"))
164 (cons "@lisp_only_build@" "t")
165 (cons "@DEFAULTLISP@" *maxima-lispname
*)
166 (cons "@CLISP_NAME@" clisp
)
167 (cons "@CMUCL_NAME@" cmucl
)
168 (cons "@SCL_NAME@" scl
)
169 (cons "@ACL_NAME@" acl
)
170 (cons "@OPENMCL_NAME@" openmcl
)
171 (cons "@CCL64_NAME@" ccl64
)
172 (cons "@ECL_NAME@" ecl
)
173 (cons "@GCL_NAME@" gcl
)
174 (cons "@SBCL_NAME@" sbcl
)))
176 (mapc #'(lambda (pair) (format t
"~a=~a~%" (first pair
) (rest pair
)))
178 (mapc #'(lambda (filename)
179 (let ((out-filename (replace-substring filename
".in" "")))
180 (process-file filename out-filename substitutions
)
181 (format t
"Created ~a~%" out-filename
)))