428
+ − 1 ;; loadup.el --- load up standardly loaded Lisp files for XEmacs.
+ − 2
+ − 3 ;; Copyright (C) 1985, 1986, 1992, 1994, 1997 Free Software Foundation, Inc.
+ − 4 ;; Copyright (C) 1996 Richard Mlynarik.
1261
+ − 5 ;; Copyright (C) 1995, 1996, 2003 Ben Wing.
428
+ − 6
+ − 7 ;; Maintainer: XEmacs Development Team
+ − 8 ;; Keywords: internal, dumped
+ − 9
+ − 10 ;; This file is part of XEmacs.
+ − 11
+ − 12 ;; XEmacs is free software; you can redistribute it and/or modify it
+ − 13 ;; under the terms of the GNU General Public License as published by
+ − 14 ;; the Free Software Foundation; either version 2, or (at your option)
+ − 15 ;; any later version.
+ − 16
+ − 17 ;; XEmacs is distributed in the hope that it will be useful, but
+ − 18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
+ − 19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ − 20 ;; General Public License for more details.
+ − 21
+ − 22 ;; You should have received a copy of the GNU General Public License
+ − 23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
+ − 24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ − 25 ;; 02111-1307, USA.
+ − 26
+ − 27 ;;; Synched up with: Last synched with FSF 19.30, with wild divergence since.
+ − 28
+ − 29 ;;; Commentary:
+ − 30
1261
+ − 31 ;; If you are wanting to add files to be dumped into your local version of
+ − 32 ;; XEmacs, DO NOT add them here. Use site-init.el or site-load.el instead.
428
+ − 33
+ − 34 ;; This is loaded into a bare XEmacs to make a dumpable one.
+ − 35
+ − 36 ;;; Code:
+ − 37
1261
+ − 38 ;; Help debug problems.
+ − 39 (setq stack-trace-on-error t
+ − 40 load-always-display-messages t)
+ − 41
1330
+ − 42 ;(princ (format "command-line-args: %s\n" command-line-args))
+ − 43 ;(princ (format "configure-lisp-directory: %S\n" configure-lisp-directory))
+ − 44 ;(princ (format "configure-data-directory: %S\n" configure-data-directory))
+ − 45 ;(princ (format "lisp-directory: %S\n" lisp-directory))
+ − 46
428
+ − 47 (when (fboundp 'error)
+ − 48 (error "loadup.el already loaded!"))
+ − 49
+ − 50 (defvar running-xemacs t
+ − 51 "Non-nil when the current emacs is XEmacs.")
+ − 52 (defvar preloaded-file-list nil
+ − 53 "List of files preloaded into the XEmacs binary image.")
+ − 54
+ − 55 (defvar Installation-string nil
+ − 56 "Description of XEmacs installation.")
+ − 57
1330
+ − 58 (defvar build-root (expand-file-name ".." invocation-directory))
+ − 59 (defvar source-lisp (file-name-directory (expand-file-name
+ − 60 (nth 2 command-line-args))))
+ − 61 (defvar source-root (expand-file-name ".." source-lisp))
+ − 62 ;(defvar build-lib-src (expand-file-name "lib-src" build-root))
+ − 63
442
+ − 64 ;(start-profiling)
+ − 65
+ − 66 (let ((gc-cons-threshold
+ − 67 ;; setting it low makes loadup incredibly fucking slow.
+ − 68 ;; no need to do it when not dumping.
+ − 69 (if (and purify-flag
+ − 70 (not (memq 'quick-build internal-error-checking)))
+ − 71 30000 3000000)))
1261
+ − 72
+ − 73 ;; really-early-error-handler outputs a stack trace so let's not do it
+ − 74 ;; twice.
+ − 75 (let ((stack-trace-on-error nil))
428
+ − 76
+ − 77 ;; This is awfully damn early to be getting an error, right?
+ − 78 (call-with-condition-handler 'really-early-error-handler
+ − 79 #'(lambda ()
+ − 80
440
+ − 81 ;; Initialize Installation-string. We do it before loading
428
+ − 82 ;; anything so that dumped code can make use of its value.
+ − 83 (setq Installation-string
+ − 84 (save-current-buffer
+ − 85 (set-buffer (get-buffer-create (generate-new-buffer-name
+ − 86 " *temp*")))
+ − 87 ;; insert-file-contents-internal bogusly calls
+ − 88 ;; format-decode without checking if it's defined.
+ − 89 (fset 'format-decode #'(lambda (f l &optional v) l))
1330
+ − 90 (insert-file-contents-internal
+ − 91 (expand-file-name "Installation" build-root))
428
+ − 92 (fmakunbound 'format-decode)
+ − 93 (prog1 (buffer-substring)
+ − 94 (kill-buffer (current-buffer)))))
+ − 95
1330
+ − 96 (setq load-path (list source-lisp))
+ − 97 (setq module-load-path (list (expand-file-name "modules" build-root)))
428
+ − 98
+ − 99 ;; message not defined yet ...
+ − 100 (external-debugging-output (format "\nUsing load-path %s" load-path))
+ − 101 (external-debugging-output (format "\nUsing module-load-path %s"
+ − 102 module-load-path))
+ − 103
+ − 104 ;; We don't want to have any undo records in the dumped XEmacs.
+ − 105 (buffer-disable-undo (get-buffer "*scratch*"))
+ − 106
+ − 107 ;; lread.c (or src/Makefile.in.in) has prepended
+ − 108 ;; "${srcdir}/../lisp/" to load-path, which is how this file
+ − 109 ;; has been found. At this point, enough of XEmacs has been
+ − 110 ;; initialized that we can start dumping "standard" lisp.
+ − 111 ;; Dumped lisp from external packages is added when we search
+ − 112 ;; the package path.
+ − 113 ;; #### This code is duplicated in two other places.
+ − 114 (let ((temp-path (expand-file-name "." (car load-path))))
+ − 115 (setq load-path (nconc (mapcar
+ − 116 #'(lambda (i) (concat i "/"))
+ − 117 (directory-files temp-path t "^[^-.]"
+ − 118 nil 'dirs-only))
+ − 119 (cons (file-name-as-directory temp-path)
+ − 120 load-path))))
+ − 121
1261
+ − 122 (setq load-warn-when-source-only t) ; Set to nil at the end
428
+ − 123
+ − 124 ;; garbage collect after loading every file in an attempt to
+ − 125 ;; minimize the size of the dumped image (if we don't do this,
+ − 126 ;; there will be lots of extra space in the data segment filled
+ − 127 ;; with garbage-collected junk)
+ − 128 (defun pureload (file)
+ − 129 (let ((full-path
+ − 130 (locate-file file load-path
+ − 131 (if load-ignore-elc-files
+ − 132 '(".el" "") '(".elc" ".el" "")))))
+ − 133 (if full-path
+ − 134 (prog1
+ − 135 (load full-path)
442
+ − 136 ;; but garbage collection really slows down loading.
+ − 137 (unless (memq 'quick-build internal-error-checking)
+ − 138 (garbage-collect)))
428
+ − 139 (external-debugging-output (format "\nLoad file %s: not found\n"
+ − 140 file))
+ − 141 ;; Uncomment in case of trouble
2456
+ − 142 ;;(print (format "late-package-hierarchies: %S" late-package-hierarchies))
1227
+ − 143 ;;(print (format "guessed-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-root-p)))
+ − 144 ;;(print (format "guessed-data-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-data-root-p)))
428
+ − 145 nil)))
+ − 146
1330
+ − 147 (load (expand-file-name "dumped-lisp.el" source-lisp))
428
+ − 148
+ − 149 (let ((files preloaded-file-list)
+ − 150 file)
+ − 151 (while (setq file (car files))
+ − 152 (unless (pureload file)
+ − 153 (external-debugging-output "Fatal error during load, aborting")
+ − 154 (kill-emacs 1))
+ − 155 (setq files (cdr files)))
+ − 156 (when (not (featurep 'toolbar))
+ − 157 ;; else still define a few functions.
+ − 158 (defun toolbar-button-p (obj) "No toolbar support." nil)
+ − 159 (defun toolbar-specifier-p (obj) "No toolbar support." nil))
+ − 160 (fmakunbound 'pureload))
+ − 161
2367
+ − 162 ;; We cannot do this in mule-cmds.el because not all the
+ − 163 ;; appropriate charsets are loaded yet.
+ − 164 (when (and (featurep 'mule)
+ − 165 load-unicode-tables-at-dump-time)
+ − 166 (let ((data-directory (expand-file-name "etc" source-root)))
+ − 167 (load-unicode-tables)))
+ − 168
428
+ − 169 (packages-load-package-dumped-lisps late-package-load-path)
+ − 170
+ − 171 )) ;; end of call-with-condition-handler
1261
+ − 172
+ − 173 ) ; (let ((stack-trace-on-error nil)))
428
+ − 174
+ − 175 ;; Fix up the preloaded file list
+ − 176 (setq preloaded-file-list (mapcar #'file-name-sans-extension
+ − 177 preloaded-file-list))
+ − 178
1261
+ − 179 (setq load-warn-when-source-only nil)
428
+ − 180
+ − 181 (setq debugger 'debug)
+ − 182
+ − 183 (when (member "no-site-file" command-line-args)
+ − 184 (setq site-start-file nil))
+ − 185
+ − 186 ;; If you want additional libraries to be preloaded and their
+ − 187 ;; doc strings kept in the DOC file rather than in core,
+ − 188 ;; you may load them with a "site-load.el" file.
+ − 189 ;; But you must also cause them to be scanned when the DOC file
1261
+ − 190 ;; is generated. For MS Windows, you must edit ../nt/xemacs.mak.
+ − 191 ;; For other systems, you must edit ../src/Makefile.in.in.
428
+ − 192 (when (load "site-load" t)
442
+ − 193 (garbage-collect)
+ − 194 )
428
+ − 195
+ − 196 ;;FSFmacs randomness
+ − 197 ;;(if (fboundp 'x-popup-menu)
+ − 198 ;; (precompute-menubar-bindings))
+ − 199 ;;; Turn on recording of which commands get rebound,
+ − 200 ;;; for the sake of the next call to precompute-menubar-bindings.
+ − 201 ;(setq define-key-rebound-commands nil)
+ − 202
+ − 203 ;; Note: all compiled Lisp files loaded above this point
+ − 204 ;; must be among the ones parsed by make-docfile
+ − 205 ;; to construct DOC. Any that are not processed
+ − 206 ;; for DOC will not have doc strings in the dumped XEmacs.
+ − 207
+ − 208 ;; Don't bother with these if we're running temacs, i.e. if we're
+ − 209 ;; just debugging don't waste time finding doc strings.
+ − 210
+ − 211 ;; purify-flag is nil if called from loadup-el.el.
+ − 212 (when purify-flag
+ − 213 (message "Finding pointers to doc strings...")
+ − 214 (Snarf-documentation "DOC")
+ − 215 (message "Finding pointers to doc strings...done")
+ − 216 (Verify-documentation))
+ − 217
+ − 218 ;; Note: You can cause additional libraries to be preloaded
+ − 219 ;; by writing a site-init.el that loads them.
+ − 220 ;; See also "site-load" above.
+ − 221 (when (stringp site-start-file)
+ − 222 (load "site-init" t))
+ − 223 (setq current-load-list nil)
+ − 224 (garbage-collect)
+ − 225
+ − 226 ;;; At this point, we're ready to resume undo recording for scratch.
+ − 227 (buffer-enable-undo "*scratch*")
+ − 228
1261
+ − 229 ) ;; (let ((gc-cons-threshold [frequent garbage collection when dumping])))
428
+ − 230
442
+ − 231 ;(stop-profiling)
+ − 232
428
+ − 233 ;; Dump into the name `xemacs' (only)
+ − 234 (when (member "dump" command-line-args)
+ − 235 (message "Dumping under the name xemacs")
+ − 236 ;; This is handled earlier in the build process.
+ − 237 ;; (condition-case () (delete-file "xemacs") (file-error nil))
+ − 238 (when (fboundp 'really-free)
+ − 239 (really-free))
1261
+ − 240 ;; Make sure we don't dump with debugging messages turned on.
+ − 241 (setq stack-trace-on-error nil
+ − 242 load-always-display-messages nil)
462
+ − 243 (dump-emacs
+ − 244 (cond
+ − 245 ((featurep 'infodock) "infodock")
+ − 246 ;; #### BILL!!!
+ − 247 ;; If we want to dump under a name other than `xemacs', do that here!
+ − 248 ;; ((featurep 'gtk) "xemacs-gtk")
+ − 249 (t "xemacs"))
+ − 250 "temacs")
428
+ − 251 (kill-emacs))
+ − 252
+ − 253 ;; Avoid error if user loads some more libraries now.
+ − 254 (setq purify-flag nil)
+ − 255
+ − 256 (when (member "run-temacs" command-line-args)
+ − 257 (message "\nBootstrapping from temacs...")
+ − 258 ;; Remove all args up to and including "run-temacs"
+ − 259 (apply #'run-emacs-from-temacs (cdr (member "run-temacs" command-line-args)))
+ − 260 ;; run-emacs-from-temacs doesn't actually return anyway.
+ − 261 (kill-emacs))
+ − 262
+ − 263 ;; XEmacs change
+ − 264 ;; If you are using 'recompile', then you should have used -l loadup-el.el
+ − 265 ;; so that the .el files always get loaded (the .elc files may be out-of-
+ − 266 ;; date or bad).
+ − 267 (when (member "recompile" command-line-args)
+ − 268 (setq command-line-args-left (cdr (member "recompile" command-line-args)))
+ − 269 (batch-byte-recompile-directory)
+ − 270 (kill-emacs))
+ − 271
+ − 272 ;; For machines with CANNOT_DUMP defined in config.h,
+ − 273 ;; this file must be loaded each time Emacs is run.
+ − 274 ;; So run the startup code now.
+ − 275
+ − 276 (when (not (fboundp 'dump-emacs))
+ − 277 ;; Avoid loading loadup.el a second time!
+ − 278 (setq command-line-args (cdr (cdr command-line-args)))
+ − 279 (eval top-level))
+ − 280
+ − 281 ;;; loadup.el ends here