Debian Codegraph @

src/compile.lsp.in

raw
1 ;;;; -*- Mode: Lisp; Syntax: Common-Lisp; indent-tabs-mode: nil -*-
2 ;;;; vim: set filetype=lisp tabstop=8 shiftwidth=2 expandtab:
3
4 ;;; @configure_input@
5 ;;;
6 ;;; This is the "makefile" file for building ECL. The purpose of this file is
7 ;;; - Compile the core of the Common-Lisp library (lsp, clos)
8 ;;; - Compile the compiler (cmp)
9 ;;; - Build an executable
10 ;;; This can be done in two ways:
11 ;;; - Using interpreted code and the ECL_MIN minimal environment.
12 ;;; - On a second stage, using the final ECL executable, to test it.
13 ;;;
14
15 (progn
16 (setq *package* (find-package "SYSTEM"))
17 (setq *host-features* *features*)
18 (setq *features* '(@LSP_FEATURES@ @COMPILATION_FEATURES@))
19 (when (member :ecl-min *host-features*)
20 (setq *features* (cons :ecl-min *features*)))
21 (when (member :uname *host-features*)
22 (setq *features* (cons :uname *features*)))
23 (when (member :cross *host-features*)
24 (setq *features* (cons :cross *features*))))
25
26 ;;;
27 ;;; * Ensure that we have the whole of Common-Lisp to compile
28 ;;;
29 (load "bare.lsp" :verbose nil)
30
31 ;;;
32 ;;; * External formats. These come at the very beginning since msvc needs
33 ;;; them to compile correctly.
34 ;;;
35 #+UNICODE
36 (load "ext:encodings;generate.lisp")
37
38 ;;;
39 ;;; * Find out what features are supported by the C compiler we are using
40 ;;;
41 (progn
42 (c::update-compiler-features
43 :executable
44 #+(or windows cygwin mingw32) "build:ecl_min.exe"
45 #-(or windows cygwin mingw32) "build:@ECL_MIN@")
46 (format t "~&;;; System features: ~A~%" c::*compiler-features*))
47
48 ;;;
49 ;;; * Complain about functions which are not in the core
50 ;;;
51 #+(or)
52 (let ((wrong-symbols '()))
53 (let ((*standard-output* (make-broadcast-stream)))
54 (dolist (p '("CL" "SI" "EXT" "CLOS"))
55 (do-symbols (s (find-package p))
56 (when (and (fboundp s)
57 (not (typep (fdefinition s) '(or list generic-function)))
58 (si::mangle-name s)
59 (si::bc-disassemble (fdefinition s)))
60 (pushnew s wrong-symbols)))))
61 (format t "~%;;; Functions that can be made into the core:~%")
62 (pprint (set-difference wrong-symbols c::*in-all-symbols-functions*)))
63
64 ;;;
65 ;;; * Force compiler constants only for the core library
66 ;;;
67 (setf *use-static-constants-p* t)
68
69 ;;;
70 ;;; * Dump documentation
71 ;;;
72 #+stage1
73 (progn
74 (load "ext:ecl-cdb;ecl-cdb")
75 (load "ext:ecl-cdb;ecl-help")
76 (load "@true_srcdir@/doc/help.lsp")
77 (si::dump-documentation "@true_builddir@/help.doc"))
78
79 ;;;
80 ;;; * Trick to make names shorter in C files
81 ;;;
82 (si::package-lock "CL" nil)
83 (rename-package "CL" "CL" '("COMMON-LISP"))
84
85 ;;;
86 ;;; * Add include path to not yet installed headers, and remove include flag
87 ;;; (-I) to installed directory, and Notice that we must explicitely mention
88 ;;; libecl.so/ecl.dll instead of using -lecl. This is to avoid interference
89 ;;; with an already installed copy of ECL.
90 ;;;
91 (setq c::*cc-flags*
92 #-msvc "@CPPFLAGS@ @CFLAGS@ @ECL_CFLAGS@ -I\"@true_srcdir@/c\""
93 #+msvc "@CFLAGS@ @ECL_CFLAGS@"
94 c::*ecl-include-directory* "@true_builddir@/"
95 c::*ecl-library-directory* "@true_builddir@/")
96 (setf c::*ld-flags* "@LDFLAGS@")
97 #-:wants-dlopen
98 (setf c::*ld-libs* "@LIBPREFIX@ecl.@LIBEXT@ @CORE_LIBS@ @FASL_LIBS@ @LIBS@")
99 #+(and :wants-dlopen (not nonstop))
100 (setf c::*ld-libs*
101 "@SHAREDPREFIX@ecl.@SHAREDEXT@ @LIBS@"
102 c::*ld-shared-flags*
103 "@SHARED_LDFLAGS@ @LDFLAGS@"
104 c::*ld-bundle-flags*
105 "@BUNDLE_LDFLAGS@ @LDFLAGS@"
106 c::*ld-program-flags*
107 "@PROGRAM_LDFLAGS@ @LDFLAGS@")
108 ;;; FIXME: The nonstop platform does not support soname
109 #+(and :wants-dlopen nonstop)
110 (setf c::*ld-libs*
111 "-Wld=-l@SHAREDPREFIX@ecl.@SHAREDEXT@ @LIBS@"
112 c::*ld-shared-flags*
113 "@SHARED_LDFLAGS@ @LDFLAGS@ -Wld=-l@SHAREDPREFIX@ecl.@SHAREDEXT@"
114 c::*ld-bundle-flags*
115 "@BUNDLE_LDFLAGS@ @LDFLAGS@ -Wld=-l@SHAREDPREFIX@ecl.@SHAREDEXT@")
116
117 ;;;
118 ;;; * Avoid name clashes with user supplied code.
119 ;;;
120 (setq si::*init-function-prefix* "ECL")
121
122 ;;;
123 ;;; * Clean up a little bit before moving on
124 ;;;
125 (mapc #'delete-file (directory "eclinit*.*"))
126
127 ;;;
128 ;;; * Compile and link Common-Lisp base library
129 ;;;
130 (setq si::*keep-documentation* nil)
131 (mapc #'proclaim +ecl-optimization-settings+)
132 (let* ((c::*cc-flags* (concatenate 'string "-DECL_API -I\"@true_builddir@/c\" " c::*cc-flags*))
133 (lsp-objects (compile-if-old "build:lsp;" +lisp-module-files+
134 :system-p t :c-file t :data-file t :h-file t
135 ;;:shared-data-file "build:ecl.sdat"
136 )))
137 #+clos
138 (progn
139 (mapc #'proclaim +ecl-optimization-settings+)
140 (setq lsp-objects (append lsp-objects
141 (compile-if-old "build:clos;" +clos-module-files+
142 :system-p t :c-file t :data-file t
143 :h-file t
144 ;;:shared-data-file "build:ecl.sdat"
145 ))))
146 (let ((extra-lisp-files '(@ECL_EXTRA_LISP_FILES@)))
147 (when extra-lisp-files
148 (setq lsp-objects (append lsp-objects
149 (compile-if-old "build:user;" extra-lisp-files
150 :system-p t :c-file t :data-file t
151 :h-file t
152 ;;:shared-data-file "build:ecl.sdat"
153 )))))
154 (c::build-static-library "lsp"
155 :lisp-files lsp-objects
156 :init-name "init_lib_LSP"
157 ;;:shared-data-file "build:ecl.sdat"
158 ))
159
160 #-:wants-dlopen
161 (c::safe-system
162 (concatenate 'string
163 "sh -c 'rm -rf tmp; mkdir tmp;"
164 "cp @LIBPREFIX@eclmin.@LIBEXT@ @LIBPREFIX@ecl.@LIBEXT@;"
165 "cd tmp; @AR@ -x ../@LIBPREFIX@lsp.@LIBEXT@;"
166 "for i in *.@OBJEXT@; do mv $i lsp_`basename $i`; done;"
167 "@AR@ -r ../@LIBPREFIX@ecl.@LIBEXT@ *.@OBJEXT@ ../c/all_symbols2.@OBJEXT@; rm *.@OBJEXT@;"
168 "@RANLIB@ ../@LIBPREFIX@ecl.@LIBEXT@'"))
169
170 #+:wants-dlopen
171 ;;;
172 ;;; We do not need the -rpath flag for the library, nor -lecl.
173 ;;;
174 (let* ((c::*ld-shared-flags* #-msvc "@SHARED_LDFLAGS@ @LDFLAGS@ @SONAME_LDFLAGS@"
175 #+msvc "@SHARED_LDFLAGS@ @LDFLAGS@")
176 (c::*ld-libs* #-msvc "@CORE_LIBS@ @FASL_LIBS@ @LIBS@"
177 #+msvc "@STATICLIBS@ @CLIBS@")
178 (c::*cc-flags* (concatenate 'string "-DECL_API -I@true_builddir@/c " c::*cc-flags*))
179 (extra-args nil))
180 #+(or mingw32 cygwin)
181 (progn
182 ;; We need these two to force dllwrap to export the symbols
183 ;; in these libraries. Otherwise it will not be possible to
184 ;; call functions from GMP or GC in code that embeds ECL.
185 #+thread
186 (when (probe-file "@LIBPREFIX@atomic_ops.@LIBEXT@")
187 (push "@LIBPREFIX@atomic_ops.@LIBEXT@" extra-args))
188 (when (probe-file "@LIBPREFIX@eclgc.@LIBEXT@")
189 (push "@LIBPREFIX@eclgc.@LIBEXT@" extra-args))
190 (when (probe-file "@LIBPREFIX@eclgmp.@LIBEXT@")
191 (push "@LIBPREFIX@eclgmp.@LIBEXT@" extra-args)))
192 (print extra-args)
193 (c::shared-cc (compile-file-pathname "ecl" :type :dll)
194 (list* #-emscripten "c/main.@OBJEXT@"
195 "c/all_symbols2.@OBJEXT@"
196 "@LIBPREFIX@lsp.@LIBEXT@"
197 "@LIBPREFIX@eclmin.@LIBEXT@"
198 extra-args)))
199
200 ;;;
201 ;;; * Compile and link Common-Lisp to C compiler
202 ;;;
203 (mapc #'proclaim +ecl-optimization-settings+)
204
205 #-mingw32
206 (si::pathname-translations "SYS" '(("**;*.*.*" "@ecldir\@/**/*.*")))
207
208 #+WANTS-CMP
209 (build-module "cmp" +cmp-module-files+
210 :dir "build:@ECL_CMPDIR@;" :prefix "CMP"
211 :builtin #+:BUILTIN-CMP t #-:BUILTIN-CMP nil)
212
213 (build-module "ecl-cdb" '("ext:ecl-cdb;ecl-cdb.lisp")
214 :dir "build:ext;" :prefix "EXT"
215 :builtin #+:WANTS-DLOPEN nil #-:WANTS-DLOPEN t)
216
217 (build-module "ecl-help" '("ext:ecl-cdb;ecl-cdb.lisp"
218 "ext:ecl-cdb;ecl-help.lisp")
219 :dir "build:ext;" :prefix "EXT"
220 :builtin #+:WANTS-DLOPEN nil #-:WANTS-DLOPEN t)
221
222 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
223 ;;;
224 ;;; EXTENSIONS
225 ;;;
226
227 ;;;
228 ;;; * SSE
229 ;;;
230 #+(and WANTS-CMP SSE2)
231 (build-module "cl-simd"
232 '("ext:cl-simd;sse-package.lisp"
233 "ext:cl-simd;ecl-sse-core.lisp"
234 "ext:cl-simd;sse-intrinsics.lisp"
235 "ext:cl-simd;sse-array-defs.lisp"
236 "ext:cl-simd;ecl-sse-utils.lisp"
237 "ext:cl-simd;sse-utils.lisp")
238 :dir "build:ext;"
239 :prefix "EXT"
240 :builtin nil)
241
242 ;;;
243 ;;; * DEFSYSTEM
244 ;;;
245 #+WANTS-DEFSYSTEM
246 (build-module "defsystem"
247 '("ext:defsystem;defsystem.lisp")
248 :dir "build:ext;"
249 :prefix "EXT"
250 :builtin #+:BUILTIN-DEFSYSTEM t #-:BUILTIN-DEFSYSTEM nil)
251
252 ;;;
253 ;;; * ASDF
254 ;;;
255 #+WANTS-ASDF
256 (build-module "asdf"
257 '("ext:asdf;asdf.lisp")
258 :dir "build:ext;"
259 :prefix "EXT"
260 :builtin #+:BUILTIN-ASDF t #-:BUILTIN-ASDF nil)
261
262 ;;;
263 ;;; * PROFILE
264 ;;;
265 #+(and WANTS-PROFILE (not (or cygwin mingw32)))
266 (build-module "profile"
267 '("ext:profile;profile.lisp")
268 :dir "build:ext;"
269 :prefix "EXT"
270 :builtin
271 #+(or (NOT :WANTS-DLOPEN) :BUILTIN-PROFILE) t
272 #-(or (NOT :WANTS-DLOPEN) :BUILTIN-PROFILE) nil)
273
274 ;;;
275 ;;; * Sockets library.
276 ;;;
277
278 #+WANTS-SOCKETS
279 (build-module "sockets"
280 '("ext:sockets;package.lisp"
281 "ext:sockets;sockets.lisp")
282 :dir "build:ext;"
283 :prefix "EXT"
284 :builtin
285 #+(or (NOT :WANTS-DLOPEN) :BUILTIN-SOCKETS) t
286 #-(or (NOT :WANTS-DLOPEN) :BUILTIN-SOCKETS) nil)
287
288 #+WANTS-SOCKETS
289 (build-module "sb-bsd-sockets"
290 '("ext:sockets;sb-bsd-sockets.lisp")
291 :depends-on '("sockets")
292 :dir "build:ext;"
293 :prefix "EXT"
294 :builtin nil)
295
296 #+WANTS-SERVE-EVENT
297 (build-module "serve-event"
298 '("ext:serve-event;serve-event.lisp")
299 :dir "build:ext;"
300 :prefix "EXT"
301 :builtin
302 #+(or (NOT :WANTS-DLOPEN) :BUILTIN-SERVE-EVENT) t
303 #-(or (NOT :WANTS-DLOPEN) :BUILTIN-SERVE-EVENT) nil)
304
305 #+WANTS-SOCKETS
306 (build-module "ecl-curl"
307 '("ext:ecl-curl;ecl-curl.lisp")
308 :dir "build:ext;"
309 :prefix "EXT"
310 :builtin nil)
311
312 #+WANTS-SOCKETS
313 (build-module "ql-minitar"
314 '("ext:quicklisp;minitar.lisp")
315 :dir "build:ext;"
316 :prefix "EXT"
317 :builtin nil)
318
319 #+WANTS-SOCKETS
320 (build-module "deflate"
321 '("ext:deflate;deflate.lisp")
322 :dir "build:ext;"
323 :prefix "EXT"
324 :builtin nil)
325
326 #+WANTS-SOCKETS
327 (build-module "ecl-quicklisp"
328 '("ext:quicklisp;ecl-quicklisp.lisp")
329 :dir "build:ext;"
330 :prefix "EXT"
331 :builtin nil)
332
333 ;;;
334 ;;; * Test suite
335 ;;;
336 #+WANTS-RT
337 (build-module "rt"
338 '("ext:rt;rt.lisp")
339 :dir "build:ext;"
340 :prefix "EXT"
341 :builtin #+:BUILTIN-RT t #-:BUILTIN-RT nil)
342
343 ;;;
344 ;;; * Package locks
345 ;;;
346 (build-module "package-locks"
347 '("ext:package-locks;package-locks.lisp")
348 :dir "build:ext;" :prefix "EXT" :builtin nil)
349
350 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
351 ;;;
352 ;;; THE FINAL EXECUTABLE
353 ;;;
354
355 (setq si::*init-function-prefix* NIL)
356
357 #+windows
358 (progn
359 (with-open-file (s "ecl.rc"
360 :direction :output
361 :if-exists :supersede
362 :if-does-not-exist :create)
363 (write-line "id ICON \"ecl.ico\"" s))
364 (ext:copy-file #p"src:util;ecl.ico" "ecl.ico")
365 #+msvc (ext:system "rc /nologo /r ecl.rc")
366 #-msvc (ext:system "windres ecl.rc -O coff ecl.res"))
367
368 (si::pathname-translations "SYS" '(("**;*.*.*" "@true_builddir@/**/*.*")))
369
370 (compiler::build-program
371 #+:msvc "ecl2"
372 #+(and (or cross stage1) (not msvc)) "bin/ecl"
373 #-(or cross stage1 msvc) "ecl2"
374 :epilogue-code '@ECL_INIT_FORM@
375 :lisp-files *module-symbols*
376 :ld-flags
377 (concatenate 'list #-msvc '("-L./") #+windows '("ecl.res" #+msvc "/F 10485760")))
378
379 (with-open-file (modules-list #P"build:MODULES" :direction :output
380 :if-exists :supersede
381 :if-does-not-exist :create)
382 (print *module-files*)
383 (dolist (module-file *module-files*)
384 (format modules-list "~A~%" module-file)))
385
386 (quit)