1 ;;; package-compile.el --- Bytecompiler wrapper for building packages from source
3 ;; Copyright (C) 1998 by Free Software Foundation, Inc.
4 ;; Copyright (C) 2002 Ben Wing.
6 ;; Author: SL Baur <steve@xemacs.org>
7 ;; Keywords: internal, lisp
9 ;; This file is part of XEmacs.
11 ;; XEmacs is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; XEmacs is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
23 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 ;;; Synched up with: Not in FSF
30 ;; This is meant to be called -batch and handles setting up the loadpath
31 ;; and minimizing what autoloads are imported.
33 ;; This package cannot be used with an XEmacs binary that was built with
34 ;; backwards compatible lisp directories.
38 (setq stack-trace-on-error t)
39 ;; #### We ought to set load-ignore-elc-files here. However, that causes
40 ;; a crash when loading auto-autoload files, for obscure reasons that I
41 ;; haven't yet tracked down. So we set it down below, after all the
42 ;; auto-autoloads have been loaded.
44 ;; Using load-ignore-elc-files is the ONLY way to ensure that compilation
45 ;; of the package tree proceeds properly regardless of the state of .elc
46 ;; files wrt .el files. (Of course, another solution would be to simply
47 ;; erase all .elc files; but this is less drastic.) Using
48 ;; load-ignore-out-of-date-elc-files is a start, but not enough -- it's
49 ;; possible, for example, for a .elc file that gets loaded to be out of
50 ;; date even if its date is later than its .el file. This happens, for
51 ;; example, with a file containing top-level calls to macros located in
52 ;; another file -- if the macros are changed in the other file, the .elc
53 ;; file will be out of date because it will contain the old macros.
54 ;; Loading the .el file (ala `load-ignore-elc-files') works, since the new
55 ;; macros will be retrieved on-the-fly when the macro is first called.
56 (setq load-ignore-out-of-date-elc-files t)
57 (setq load-always-display-messages t)
58 ;; Don't enable this by default, as it clutters up the output so much.
59 ;; Turn it on if you're doubtful that the right files are being loaded.
60 ;; (setq load-show-full-path-in-messages t)
63 (error "package-compile may only be used with -batch"))
65 ;;; Step 1, set the load-path and load the core autoloads.
68 ;; #### All hail Mr. Preprocessor!
69 ;; OK, OK, his code is under development; FIXME when it's done.
70 ((boundp 'paths-load-path-depth) ; XEmacs 21.1
71 paths-load-path-depth)
72 ((boundp 'paths-core-load-path-depth) ; XEmacs > 21.2.41
73 paths-core-load-path-depth)
74 (t (error "Somebody has been messing with paths-find-*!")))))
75 (setq load-path (paths-find-recursive-load-path
77 ;; Only pay attention to mule-lisp-directory if
79 (and mule-lisp-directory (list mule-lisp-directory)))
82 (load (expand-file-name "auto-autoloads" (car load-path)))
85 ;;; Step 2, collect the dependencies into load-path and load the autoloads.
86 (let ((load-ignore-elc-files nil)
87 (load-ignore-out-of-date-elc-files t))
88 ;; Make sure we get the compiled version of the byte compiler, otherwise
89 ;; compilation will be UNGODLY slow.
91 (require 'byte-optimize))
93 (defconst package-directory-map
96 ("Sun" . "xemacs-packages")
97 ("ada" . "xemacs-packages")
98 ("apel" . "xemacs-packages")
99 ("auctex" . "xemacs-packages")
100 ("bbdb" . "xemacs-packages")
101 ("c-support" . "xemacs-packages")
102 ("calc" . "xemacs-packages")
103 ("calendar" . "xemacs-packages")
104 ("cc-mode" . "xemacs-packages")
105 ("cedet-common" . "xemacs-packages")
106 ("clearcase" . "xemacs-packages")
107 ("cogre" . "xemacs-packages")
108 ("cookie" . "xemacs-packages")
109 ("crisp" . "xemacs-packages")
110 ("debug" . "xemacs-packages")
111 ("docbookide" . "xemacs-packages")
112 ("dictionary" . "xemacs-packages")
113 ("dired" . "xemacs-packages")
114 ("ecb" . "xemacs-packages")
115 ("ecrypto" . "xemacs-packages")
116 ("ede" . "xemacs-packages")
117 ("edebug" . "xemacs-packages")
118 ("ediff" . "xemacs-packages")
119 ("edit-utils" . "xemacs-packages")
120 ("edt" . "xemacs-packages")
121 ("efs" . "xemacs-packages")
122 ("eieio" . "xemacs-packages")
123 ("elib" . "xemacs-packages")
124 ("emerge" . "xemacs-packages")
125 ("erc" . "xemacs-packages")
126 ("eshell" . "xemacs-packages")
127 ("eterm" . "xemacs-packages")
128 ("eudc" . "xemacs-packages")
129 ("escreen" . "xemacs-packages")
130 ("footnote" . "xemacs-packages")
131 ("forms" . "xemacs-packages")
132 ("fortran-modes" . "xemacs-packages")
133 ("frame-icon" . "xemacs-packages")
134 ("fsf-compat" . "xemacs-packages")
135 ("games" . "xemacs-packages")
136 ("general-docs" . "xemacs-packages")
137 ("gnats" . "xemacs-packages")
138 ("gnus" . "xemacs-packages")
139 ("guided-tour" . "xemacs-packages")
140 ("haskell-mode" . "xemacs-packages")
141 ("hm--html-menus" . "xemacs-packages")
142 ("hyperbole" . "xemacs-packages")
143 ("ibuffer" . "xemacs-packages")
144 ("idlwave" . "xemacs-packages")
145 ("igrep" . "xemacs-packages")
146 ("ilisp" . "xemacs-packages")
147 ("ispell" . "xemacs-packages")
148 ("jde" . "xemacs-packages")
149 ("mail-lib" . "xemacs-packages")
150 ("mailcrypt" . "xemacs-packages")
151 ("mew" . "xemacs-packages")
152 ("mh-e" . "xemacs-packages")
153 ("mine" . "xemacs-packages")
154 ("misc-games" . "xemacs-packages")
155 ("mmm-mode" . "xemacs-packages")
156 ("net-utils" . "xemacs-packages")
157 ("ocaml" . "xemacs-packages")
158 ("oo-browser" . "xemacs-packages")
159 ("os-utils" . "xemacs-packages")
160 ("pc" . "xemacs-packages")
161 ("pcl-cvs" . "xemacs-packages")
162 ("pcomplete" . "xemacs-packages")
163 ("perl-modes" . "xemacs-packages")
164 ("pgg" . "xemacs-packages")
165 ("prog-modes" . "xemacs-packages")
166 ("ps-print" . "xemacs-packages")
167 ("psgml" . "xemacs-packages")
168 ("psgml-dtds" . "xemacs-packages")
169 ("python-modes" . "xemacs-packages")
170 ("re-builder" . "xemacs-packages")
171 ("reftex" . "xemacs-packages")
172 ("riece" . "xemacs-packages")
173 ("rmail" . "xemacs-packages")
174 ("ruby-modes" . "xemacs-packages")
175 ("sasl" . "xemacs-packages")
176 ("scheme" . "xemacs-packages")
177 ("semantic" . "xemacs-packages")
178 ("sgml" . "xemacs-packages")
179 ("sh-script" . "xemacs-packages")
180 ("sieve" . "xemacs-packages")
181 ("slider" . "xemacs-packages")
182 ("sml-mode" . "xemacs-packages")
183 ("sounds-au" . "xemacs-packages")
184 ("sounds-wav" . "xemacs-packages")
185 ("speedbar" . "xemacs-packages")
186 ("strokes" . "xemacs-packages")
187 ("supercite" . "xemacs-packages")
188 ("texinfo" . "xemacs-packages")
189 ("text-modes" . "xemacs-packages")
190 ("textools" . "xemacs-packages")
191 ("time" . "xemacs-packages")
192 ("tm" . "xemacs-packages")
193 ("tooltalk" . "xemacs-packages")
194 ("tpu" . "xemacs-packages")
195 ("tramp" . "xemacs-packages")
196 ("vc" . "xemacs-packages")
197 ("vc-cc" . "xemacs-packages")
198 ("vhdl" . "xemacs-packages")
199 ("view-process" . "xemacs-packages")
200 ("viper" . "xemacs-packages")
201 ("vm" . "xemacs-packages")
202 ("w3" . "xemacs-packages")
203 ("x-symbol" . "xemacs-packages")
204 ("xemacs-base" . "xemacs-packages")
205 ("xemacs-devel" . "xemacs-packages")
206 ("xetla" . "xemacs-packages")
207 ("xlib" . "xemacs-packages")
208 ("xslide" . "xemacs-packages")
209 ("xslt-process" . "xemacs-packages")
210 ("xwem" . "xemacs-packages")
211 ("zenirc" . "xemacs-packages")
213 ("edict" . "mule-packages")
214 ("egg-its" . "mule-packages")
215 ("latin-euro-standards" . "mule-packages")
216 ("latin-unity" . "mule-packages")
217 ("leim" . "mule-packages")
218 ("locale" . "mule-packages")
219 ("lookup" . "mule-packages")
220 ("mule-base" . "mule-packages")
221 ("mule-ucs" . "mule-packages")
222 ("skk" . "mule-packages")
225 (defvar package-source-root nil)
226 (let ((defdir default-directory))
227 (while (not (file-exists-p (expand-file-name "XEmacs.rules" defdir)))
228 (setq defdir (expand-file-name (concat defdir "/.."))))
229 (setq package-source-root defdir))
231 (defun package-name-to-directories (package)
232 "Map `package' to a source directory."
233 (let* ((area (or (cdr (assoc package package-directory-map))
234 (error (concat "%s is not in `package-directory-map'. "
235 "See: package-compile.el")
237 (dir (expand-file-name
238 package (expand-file-name area package-source-root))))
239 (cond ((or (equal package "bbdb")
240 (equal package "gnus")
241 (equal package "jde")
242 (equal package "lookup")
243 (equal package "mule-ucs")
244 (equal package "tramp")
247 (equal package "x-symbol")
248 (equal package "xlib")
249 (equal package "xwem"))
250 (list (expand-file-name "lisp" (file-name-as-directory dir))))
251 ((equal package "mew")
252 (list (expand-file-name "mew" (file-name-as-directory dir))))
253 ((equal package "zenirc")
254 (list (expand-file-name "src" (file-name-as-directory dir))))
255 ((equal package "semantic")
257 (expand-file-name "bovine" (file-name-as-directory dir))
258 (expand-file-name "wisent" (file-name-as-directory dir))))
262 (defvar command-line-args-left)
264 (while (and command-line-args-left
265 (not (equal "--" (car command-line-args-left))))
266 (push (car command-line-args-left) depends)
267 (pop command-line-args-left))
269 (when command-line-args-left
270 (pop command-line-args-left))
272 ;; Setup load-path, data-directory-list and load necessary auto-autoloads
274 (let ((dirs (package-name-to-directories (car depends))))
276 (error "%s is not in `package-directory-map'. See: package-compile.el"
278 (let* ((dir (car dirs))
279 (etc-dir (expand-file-name "etc" dir)))
281 (push (car dirs) load-path)
282 (setq dirs (cdr dirs)))
283 ;; This assumes package has layout *-packages/package/etc/package
284 ;; This is the case for the only package it matters at the time or writing
286 (if (file-directory-p (expand-file-name (car depends) etc-dir))
287 (push (file-name-as-directory etc-dir) data-directory-list))
288 (load (expand-file-name "auto-autoloads" dir))
291 ;; Lastly, add the current directory
292 (push default-directory load-path)
294 ;; Let it be known we are running under special circomstances
295 (defvar bootstrap-in-progress t)
297 ;;; Step 3, perform the requested bytecompilation
299 ;; (message "datadirs = %s" data-directory-list)
301 ;; (prin1 "Load path = ")
305 ;; Let the caller specify command
306 ;(batch-byte-compile)
308 ;; See comment at top of file.
309 ;; #### Let's see whether we actually need this.
310 ;;(setq load-ignore-elc-files t)
312 (provide 'package-compile)
314 ;;; package-compile.el ends here