[a88b18]: configure.lisp Maximize Restore History

Download this file

configure.lisp    161 lines (153 with data), 5.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
(defun replace-substring (in-string old new)
(let ((result ""))
(do ((begin 0)
(end (search old in-string)
(search old in-string :start2 begin)))
((>= begin (length in-string)) 'done)
(if end
(progn (setf result (concatenate 'string result
(subseq in-string begin end)
new))
(setf begin (+ end (length old))))
(progn (setf result (concatenate 'string result
(subseq in-string begin
(length in-string))))
(setf begin (length in-string)))))
result))
(defun process-file (in-filename out-filename substitutions)
(with-open-file (in in-filename :direction :input)
(with-open-file (out out-filename :direction :output
:if-exists :supersede)
(do ((line (read-line in nil 'eof)
(read-line in nil 'eof)))
((eql line 'eof))
(mapc #'(lambda (pair)
(setf line (replace-substring line
(first pair)
(rest pair))))
substitutions)
(format out "~a~%" line)))))
(defun read-with-default (prompt default)
(format t "~a [~a]: " prompt default)
(terpri)
(let ((response (read-line)))
(if (string= response "") default response)))
;;; This function (only) modified from CLOCC http://clocc.sourceforge.net
(defun default-directory-string ()
(string-right-trim
"\\" (string-right-trim
"/"
(namestring
#+allegro (excl:current-directory)
#+clisp (#+lisp=cl ext:default-directory
#-lisp=cl lisp:default-directory)
#+cmu (ext:default-directory)
#+scl (unix-namestring (ext:default-directory))
#+cormanlisp (ccl:get-current-directory)
#+lispworks (hcl:get-working-directory)
#+lucid (lcl:working-directory)
#-(or allegro clisp cmu scl cormanlisp lispworks lucid)
(truename ".")))))
(defun get-version ()
(let ((version ""))
(with-open-file (in "configure.in" :direction :input)
(do ((line (read-line in nil 'eof)
(read-line in nil 'eof)))
((eql line 'eof))
(if (search "AM_INIT_AUTOMAKE" line)
(progn
#+openmcl (setq line (string-trim '(#\Return) line))
(setf version
(replace-substring line "AM_INIT_AUTOMAKE(maxima," ""))
(setf version
(replace-substring version ")" ""))))))
version))
(defvar *maxima-lispname* #+clisp "clisp"
#+cmu "cmucl"
#+scl "scl"
#+sbcl "sbcl"
#+gcl "gcl"
#+allegro "acl"
#+openmcl "openmcl"
#+abcl "abcl"
#+ecl "ecl"
#-(or clisp cmu scl sbcl gcl allegro openmcl abcl ecl) "unknownlisp")
(defun configure (&key (interactive t) (verbose nil)
is-win32
maxima-directory
posix-shell
clisp-name
cmucl-name
scl-name
acl-name
openmcl-name
sbcl-name
ecl-name)
(let ((prefix (if maxima-directory
maxima-directory
(default-directory-string)))
(win32-string (if is-win32 "true" "false"))
(shell (if posix-shell posix-shell "/bin/sh"))
(clisp (if clisp-name clisp-name "clisp"))
(cmucl (if cmucl-name cmucl-name "lisp"))
(scl (if scl-name scl-name "lisp"))
(acl (if acl-name acl-name "acl"))
(openmcl (if openmcl-name openmcl-name "mcl"))
(sbcl (if sbcl-name sbcl-name "sbcl"))
(ecl (if ecl-name ecl-name "ecl"))
(files (list "maxima-local.in" "src/maxima.in" "src/maxima.bat.in"
"src/autoconf-variables.lisp.in"))
(substitutions))
(if interactive
(progn
(setf prefix (read-with-default "Enter the Maxima directory" prefix))
(setf win32-string
(read-with-default "Is this a Windows system? (true/false)"
win32-string))
(setf shell (read-with-default "Posix shell (optional)" shell))
(setf clisp
(read-with-default "Name of the Clisp executable (optional)"
clisp))
(setf cmucl
(read-with-default "Name of the CMUCL executable (optional)"
cmucl))
(setf scl
(read-with-default "Name of the SCL executable (optional)"
scl))
(setf acl
(read-with-default "Name of the Allegro executable (optional)"
acl))
(setf openmcl
(read-with-default "Name of the OpenMCL executable (optional)"
openmcl))
(setf ecl
(read-with-default "Name of the ECL executable (optional)"
ecl))
(setf sbcl
(read-with-default "Name of the SBCL executable (optional)"
sbcl))))
(setf substitutions (list (cons "@prefix@"
(replace-substring prefix "\\" "\\\\"))
(cons "@PACKAGE@" "maxima")
(cons "@VERSION@" (get-version))
(cons "@win32@" win32-string)
(cons "@default_layout_autotools@" "false")
(cons "@POSIX_SHELL@" shell)
(cons "@expanded_top_srcdir@"
(replace-substring prefix "\\" "\\\\"))
(cons "@DEFAULTLISP@" *maxima-lispname*)
(cons "@CLISP_NAME@" clisp)
(cons "@CMUCL_NAME@" cmucl)
(cons "@SCL_NAME@" scl)
(cons "@ACL_NAME@" acl)
(cons "@OPENMCL_NAME@" openmcl)
(cons "@ECL_NAME@" ecl)
(cons "@SBCL_NAME@" sbcl)))
(if verbose
(mapc #'(lambda (pair) (format t "~a=~a~%" (first pair) (rest pair)))
substitutions))
(mapc #'(lambda (filename)
(let ((out-filename (replace-substring filename ".in" "")))
(process-file filename out-filename substitutions)
(format t "Created ~a~%" out-filename)))
files)))