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 ("build" . "xemacs-packages")
102 ("c-support" . "xemacs-packages")
103 ("calc" . "xemacs-packages")
104 ("calendar" . "xemacs-packages")
105 ("cc-mode" . "xemacs-packages")
106 ("cedet-common" . "xemacs-packages")
107 ("clearcase" . "xemacs-packages")
108 ("cogre" . "xemacs-packages")
109 ("cookie" . "xemacs-packages")
110 ("crisp" . "xemacs-packages")
111 ("debug" . "xemacs-packages")
112 ("docbookide" . "xemacs-packages")
113 ("dictionary" . "xemacs-packages")
114 ("dired" . "xemacs-packages")
115 ("ecb" . "xemacs-packages")
116 ("ecrypto" . "xemacs-packages")
117 ("ede" . "xemacs-packages")
118 ("edebug" . "xemacs-packages")
119 ("ediff" . "xemacs-packages")
120 ("edit-utils" . "xemacs-packages")
121 ("edt" . "xemacs-packages")
122 ("efs" . "xemacs-packages")
123 ("eieio" . "xemacs-packages")
124 ("elib" . "xemacs-packages")
125 ("emerge" . "xemacs-packages")
126 ("erc" . "xemacs-packages")
127 ("eshell" . "xemacs-packages")
128 ("eterm" . "xemacs-packages")
129 ("eudc" . "xemacs-packages")
130 ("escreen" . "xemacs-packages")
131 ("footnote" . "xemacs-packages")
132 ("forms" . "xemacs-packages")
133 ("fortran-modes" . "xemacs-packages")
134 ("frame-icon" . "xemacs-packages")
135 ("fsf-compat" . "xemacs-packages")
136 ("games" . "xemacs-packages")
137 ("general-docs" . "xemacs-packages")
138 ("gnats" . "xemacs-packages")
139 ("gnus" . "xemacs-packages")
140 ("guided-tour" . "xemacs-packages")
141 ("haskell-mode" . "xemacs-packages")
142 ("hm--html-menus" . "xemacs-packages")
143 ("hyperbole" . "xemacs-packages")
144 ("ibuffer" . "xemacs-packages")
145 ("idlwave" . "xemacs-packages")
146 ("igrep" . "xemacs-packages")
147 ("ilisp" . "xemacs-packages")
148 ("ispell" . "xemacs-packages")
149 ("jde" . "xemacs-packages")
150 ("mail-lib" . "xemacs-packages")
151 ("mailcrypt" . "xemacs-packages")
152 ("mew" . "xemacs-packages")
153 ("mh-e" . "xemacs-packages")
154 ("mine" . "xemacs-packages")
155 ("misc-games" . "xemacs-packages")
156 ("mmm-mode" . "xemacs-packages")
157 ("net-utils" . "xemacs-packages")
158 ("ocaml" . "xemacs-packages")
159 ("oo-browser" . "xemacs-packages")
160 ("os-utils" . "xemacs-packages")
161 ("pc" . "xemacs-packages")
162 ("pcl-cvs" . "xemacs-packages")
163 ("pcomplete" . "xemacs-packages")
164 ("perl-modes" . "xemacs-packages")
165 ("pgg" . "xemacs-packages")
166 ("prog-modes" . "xemacs-packages")
167 ("ps-print" . "xemacs-packages")
168 ("psgml" . "xemacs-packages")
169 ("psgml-dtds" . "xemacs-packages")
170 ("python-modes" . "xemacs-packages")
171 ("re-builder" . "xemacs-packages")
172 ("reftex" . "xemacs-packages")
173 ("riece" . "xemacs-packages")
174 ("rmail" . "xemacs-packages")
175 ("ruby-modes" . "xemacs-packages")
176 ("sasl" . "xemacs-packages")
177 ("scheme" . "xemacs-packages")
178 ("semantic" . "xemacs-packages")
179 ("sgml" . "xemacs-packages")
180 ("sh-script" . "xemacs-packages")
181 ("sieve" . "xemacs-packages")
182 ("slider" . "xemacs-packages")
183 ("sml-mode" . "xemacs-packages")
184 ("sounds-au" . "xemacs-packages")
185 ("sounds-wav" . "xemacs-packages")
186 ("speedbar" . "xemacs-packages")
187 ("strokes" . "xemacs-packages")
188 ("supercite" . "xemacs-packages")
189 ("texinfo" . "xemacs-packages")
190 ("text-modes" . "xemacs-packages")
191 ("textools" . "xemacs-packages")
192 ("time" . "xemacs-packages")
193 ("tm" . "xemacs-packages")
194 ("tooltalk" . "xemacs-packages")
195 ("tpu" . "xemacs-packages")
196 ("tramp" . "xemacs-packages")
197 ("vc" . "xemacs-packages")
198 ("vc-cc" . "xemacs-packages")
199 ("vhdl" . "xemacs-packages")
200 ("view-process" . "xemacs-packages")
201 ("viper" . "xemacs-packages")
202 ("vm" . "xemacs-packages")
203 ("w3" . "xemacs-packages")
204 ("x-symbol" . "xemacs-packages")
205 ("xemacs-base" . "xemacs-packages")
206 ("xemacs-devel" . "xemacs-packages")
207 ("xetla" . "xemacs-packages")
208 ("xlib" . "xemacs-packages")
209 ("xslide" . "xemacs-packages")
210 ("xslt-process" . "xemacs-packages")
211 ("xwem" . "xemacs-packages")
212 ("zenirc" . "xemacs-packages")
214 ("edict" . "mule-packages")
215 ("egg-its" . "mule-packages")
216 ("latin-euro-standards" . "mule-packages")
217 ("latin-unity" . "mule-packages")
218 ("leim" . "mule-packages")
219 ("locale" . "mule-packages")
220 ("lookup" . "mule-packages")
221 ("mule-base" . "mule-packages")
222 ("mule-ucs" . "mule-packages")
223 ("skk" . "mule-packages")
226 (defvar package-source-root nil)
227 (let ((defdir default-directory))
228 (while (not (file-exists-p (expand-file-name "XEmacs.rules" defdir)))
229 (setq defdir (expand-file-name (concat defdir "/.."))))
230 (setq package-source-root defdir))
232 (defun package-name-to-directories (package)
233 "Map `package' to a source directory."
234 (let* ((area (or (cdr (assoc package package-directory-map))
235 (error (concat "%s is not in `package-directory-map'. "
236 "See: package-compile.el")
238 (dir (expand-file-name
239 package (expand-file-name area package-source-root))))
240 (cond ((or (equal package "bbdb")
241 (equal package "gnus")
242 (equal package "jde")
243 (equal package "lookup")
244 (equal package "mule-ucs")
245 (equal package "tramp")
248 (equal package "x-symbol")
249 (equal package "xlib")
250 (equal package "xwem"))
251 (list (expand-file-name "lisp" (file-name-as-directory dir))))
252 ((equal package "mew")
253 (list (expand-file-name "mew" (file-name-as-directory dir))))
254 ((equal package "zenirc")
255 (list (expand-file-name "src" (file-name-as-directory dir))))
256 ((equal package "semantic")
258 (expand-file-name "bovine" (file-name-as-directory dir))
259 (expand-file-name "wisent" (file-name-as-directory dir))))
263 (defvar command-line-args-left)
265 (while (and command-line-args-left
266 (not (equal "--" (car command-line-args-left))))
267 (push (car command-line-args-left) depends)
268 (pop command-line-args-left))
270 (when command-line-args-left
271 (pop command-line-args-left))
273 ;; Setup load-path, data-directory-list and load necessary auto-autoloads
275 (let ((dirs (package-name-to-directories (car depends))))
277 (error "%s is not in `package-directory-map'. See: package-compile.el"
279 (let* ((dir (car dirs))
280 (etc-dir (expand-file-name "etc" dir)))
282 (push (car dirs) load-path)
283 (setq dirs (cdr dirs)))
284 ;; This assumes package has layout *-packages/package/etc/package
285 ;; This is the case for the only package it matters at the time or writing
287 (if (file-directory-p (expand-file-name (car depends) etc-dir))
288 (push (file-name-as-directory etc-dir) data-directory-list))
289 (load (expand-file-name "auto-autoloads" dir))
292 ;; Lastly, add the current directory
293 (push default-directory load-path)
295 ;; Let it be known we are running under special circomstances
296 (defvar bootstrap-in-progress t)
298 ;;; Step 3, perform the requested bytecompilation
300 ;; (message "datadirs = %s" data-directory-list)
302 ;; (prin1 "Load path = ")
306 ;; Let the caller specify command
307 ;(batch-byte-compile)
309 ;; See comment at top of file.
310 ;; #### Let's see whether we actually need this.
311 ;;(setq load-ignore-elc-files t)
313 (provide 'package-compile)
315 ;;; package-compile.el ends here