-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.lisp
More file actions
165 lines (136 loc) · 5.08 KB
/
Copy pathbootstrap.lisp
File metadata and controls
165 lines (136 loc) · 5.08 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
161
162
163
164
165
;; Lisp code to build a REDUCE image for bootstrapping on Common Lisp
;; FJW -- Time-stamp: <2026-01-03 16:42:37 franc>
(load (concatenate 'string "fasl."
#+SBCL "sbcl"
#+CLISP "clisp"
#+ABCL "abcl"
#+CCL "ccl"
#+ECLP "eclp"
#+ECLN "ecln"
"/sl-on-cl")) ; could probably make this more elegant!
;; (unless (sl:getenv "reduce")
;; ;; No easy way to support setenv in ABCL, so $reduce must be set explicitly!
;; (cond #-ABCL ((probe-file "./packages") (sl:setenv "reduce" "."))
;; #-ABCL ((probe-file "../packages") (sl:setenv "reduce" ".."))
;; (t (format t "~%Error: cannot find packages directory. Please set $reduce.~2%")
;; (sl:exit 1))))
#-DEBUG (declaim (optimize speed))
#+DEBUG (declaim (optimize debug safety))
#+SBCL (declaim (sb-ext:muffle-conditions sb-ext:compiler-note style-warning))
#+CLISP (setq custom:*suppress-check-redefinition* t
custom:*compile-warnings* nil)
#+ABCL (progn
(require :abcl-contrib)
(require :asdf-jar) ;; seems to imply (require "asdf")
;; Process .asd files in the current directory only.
(asdf:initialize-source-registry
`(:source-registry (:directory ,*default-pathname-defaults*)
:ignore-inherited-configuration)))
#+CCL
;; (progn
;; (require :asdf)
(setq ccl:*warn-if-redefine* nil
ccl::*suppress-compiler-warnings* t)
;; )
(standard-lisp)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% STANDARD LISP SYNTAX FROM NOW ON! %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
(setq !*verboseload t)
(setq !*redefmsg nil) % Just duplicates CL warnings!
(cl:defparameter !*init!-time!* (time))
(cl:defvar !*backtrace nil) % used in "boot.sl"
(cl:defvar !*argnochk t)
(cl:defvar !*int nil) % Prevents input buffer being saved.
(cl:defvar !*msg nil)
% Do not use fasl version of "boot.sl": the CL compiler may optimize
% away (i.e. discard) uses of fluid variables that are needed later in
% the build process!
(cond ((filep "boot.sl") (load "boot.sl"))
((filep "../psl/boot.sl") (load "../psl/boot.sl"))
(t (error 0 "Cannot find boot file.") (exit 1)))
% It's faster in some lisps if we compile.
(setq !*comp (not (memq 'ecl lispsystem!*)))
%%%%%%%%%%%%%%%%%%%%%%%
%% Start of build.sl %%
%%%%%%%%%%%%%%%%%%%%%%%
% The following code is essentially a Standard Lisp version
% of "packages/support/build.red". It primarily defines the function
% load!-package!-sources, which is required for bootstrapping.
(global '(loaded!-packages!*))
% Since some of the early modules may have tabs in them, we must redefine
% seprp. Note that there is a TAB in this definition and that may not be
% readily visible when merely editing the file.
(de seprp (u) (or (eq u '! ) (eq u '! ) (eq u !$eol!$)))
(de mkfil (u)
(cond
((stringp u) u)
((not (idp u)) (typerr u "file name"))
(t (string!-downcase u))))
% Convert the module u in package directory v, or the current
% directory if v is nil, to a (lower-case) file name relative to the
% directory containing packages. Also defined in remake.red!
(de module2!-to!-file (u v)
(progn
(setq u (concat2 (mkfil u) ".red"))
(cond
(v
(concat2
"$reduce/packages/"
(concat2 (mkfil v) (concat2 "/" u))))
(t u))))
(de inmodule (u v)
(prog (file)
(terpri)
(terpri)
(prin2 "+++ Reading file: ")
(prin2 (setq file (module2!-to!-file u v)))
(terpri)
(setq u (open file 'input))
(setq v (rds u))
(setq cursym!* '!*semicol!*)
(prog nil
whilelabel
(cond ((not (not (eq cursym!* 'end))) (return nil)))
(progn (prin2 (eval (form (xread nil)))) (prin2 " "))
(go whilelabel))
(rds v)
(close u)))
(de load!-package!-sources (u v)
(prog (!*int !*echo w)
(inmodule u v)
(cond ((setq w (get u 'package)) (setq w (cdr w))))
(prog nil
whilelabel
(cond ((not w) (return nil)))
(progn (inmodule (car w) v) (setq w (cdr w)))
(go whilelabel))
(setq loaded!-packages!* (cons u loaded!-packages!*))))
%%%%%%%%%%%%%%%%%%%%%
%% End of build.sl %%
%%%%%%%%%%%%%%%%%%%%%
(load!-package!-sources 'clprolo nil)
(load!-package!-sources 'rlisp 'rlisp)
(load!-package!-sources 'smacros 'support)
(load!-package!-sources 'clrend nil)
(load!-package!-sources 'poly 'poly)
(load!-package!-sources 'alg 'alg)
(load!-package!-sources 'rtools 'rtools) % https://sourceforge.net/p/reduce-algebra/code/5845/
(load!-package!-sources 'arith 'arith)
(load!-package!-sources 'entry 'support)
(load!-package!-sources 'remake nil)
(setq !*comp nil)
% (load "compiler")
(prog nil
(terpri)
(prin2 "Time to build bootstrap REDUCE: ")
(prin2 (quotient (difference (time) !*init!-time!*) 1000.0))
(prin2t " secs")
(prin2 "Heap left: ")
(prin2 (gtheap))
(prin2t " bytes")
)
(initreduce)
(setq date!* (date))
(setq version!* "Bootstrap REDUCE")
(save!-reduce!-image "bootstrap") % doesn't save or stop ECL