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
3511
+ − 50 (defconst running-xemacs t
428
+ − 51 "Non-nil when the current emacs is XEmacs.")
3511
+ − 52
+ − 53 ;; Can't make this constant for now because it causes an error in
+ − 54 ;; update-elc.el.
+ − 55 (defvar source-lisp (file-name-directory (expand-file-name
+ − 56 (nth 2 command-line-args)))
+ − 57 "Root of tree containing the Lisp source code for the current build.
+ − 58 Differs from `lisp-directory' if this XEmacs has been installed. ")
+ − 59
+ − 60 (defconst build-directory (expand-file-name ".." invocation-directory)
+ − 61 "Root of tree containing object files and executables produced by build.
+ − 62 Differs from `source-directory' if configured with --srcdir option, a practice
+ − 63 recommended for developers.")
+ − 64
+ − 65 (defconst source-directory (expand-file-name ".." source-lisp)
+ − 66 "Root of tree containing source code for the current build.
+ − 67 Used during loadup and for documenting source of symbols defined in C.")
+ − 68
428
+ − 69 (defvar preloaded-file-list nil
+ − 70 "List of files preloaded into the XEmacs binary image.")
+ − 71
442
+ − 72 ;(start-profiling)
+ − 73
+ − 74 (let ((gc-cons-threshold
+ − 75 ;; setting it low makes loadup incredibly fucking slow.
+ − 76 ;; no need to do it when not dumping.
+ − 77 (if (and purify-flag
+ − 78 (not (memq 'quick-build internal-error-checking)))
+ − 79 30000 3000000)))
1261
+ − 80
+ − 81 ;; really-early-error-handler outputs a stack trace so let's not do it
+ − 82 ;; twice.
+ − 83 (let ((stack-trace-on-error nil))
428
+ − 84
+ − 85 ;; This is awfully damn early to be getting an error, right?
+ − 86 (call-with-condition-handler 'really-early-error-handler
+ − 87 #'(lambda ()
1330
+ − 88 (setq load-path (list source-lisp))
3511
+ − 89 (setq module-load-path (list
+ − 90 (expand-file-name "modules" build-directory)))
428
+ − 91
+ − 92 ;; message not defined yet ...
+ − 93 (external-debugging-output (format "\nUsing load-path %s" load-path))
+ − 94 (external-debugging-output (format "\nUsing module-load-path %s"
+ − 95 module-load-path))
+ − 96
+ − 97 ;; We don't want to have any undo records in the dumped XEmacs.
+ − 98 (buffer-disable-undo (get-buffer "*scratch*"))
+ − 99
+ − 100 ;; lread.c (or src/Makefile.in.in) has prepended
+ − 101 ;; "${srcdir}/../lisp/" to load-path, which is how this file
+ − 102 ;; has been found. At this point, enough of XEmacs has been
+ − 103 ;; initialized that we can start dumping "standard" lisp.
+ − 104 ;; Dumped lisp from external packages is added when we search
+ − 105 ;; the package path.
+ − 106 ;; #### This code is duplicated in two other places.
+ − 107 (let ((temp-path (expand-file-name "." (car load-path))))
+ − 108 (setq load-path (nconc (mapcar
+ − 109 #'(lambda (i) (concat i "/"))
+ − 110 (directory-files temp-path t "^[^-.]"
+ − 111 nil 'dirs-only))
+ − 112 (cons (file-name-as-directory temp-path)
+ − 113 load-path))))
+ − 114
1261
+ − 115 (setq load-warn-when-source-only t) ; Set to nil at the end
428
+ − 116
+ − 117 ;; garbage collect after loading every file in an attempt to
+ − 118 ;; minimize the size of the dumped image (if we don't do this,
+ − 119 ;; there will be lots of extra space in the data segment filled
+ − 120 ;; with garbage-collected junk)
+ − 121 (defun pureload (file)
+ − 122 (let ((full-path
+ − 123 (locate-file file load-path
+ − 124 (if load-ignore-elc-files
+ − 125 '(".el" "") '(".elc" ".el" "")))))
+ − 126 (if full-path
+ − 127 (prog1
+ − 128 (load full-path)
442
+ − 129 ;; but garbage collection really slows down loading.
+ − 130 (unless (memq 'quick-build internal-error-checking)
+ − 131 (garbage-collect)))
428
+ − 132 (external-debugging-output (format "\nLoad file %s: not found\n"
+ − 133 file))
+ − 134 ;; Uncomment in case of trouble
2456
+ − 135 ;;(print (format "late-package-hierarchies: %S" late-package-hierarchies))
1227
+ − 136 ;;(print (format "guessed-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-root-p)))
+ − 137 ;;(print (format "guessed-data-roots: %S" (paths-find-emacs-roots invocation-directory invocation-name #'paths-emacs-data-root-p)))
428
+ − 138 nil)))
+ − 139
1330
+ − 140 (load (expand-file-name "dumped-lisp.el" source-lisp))
428
+ − 141
+ − 142 (let ((files preloaded-file-list)
+ − 143 file)
+ − 144 (while (setq file (car files))
+ − 145 (unless (pureload file)
+ − 146 (external-debugging-output "Fatal error during load, aborting")
+ − 147 (kill-emacs 1))
+ − 148 (setq files (cdr files)))
+ − 149 (when (not (featurep 'toolbar))
+ − 150 ;; else still define a few functions.
+ − 151 (defun toolbar-button-p (obj) "No toolbar support." nil)
+ − 152 (defun toolbar-specifier-p (obj) "No toolbar support." nil))
+ − 153 (fmakunbound 'pureload))
+ − 154
+ − 155 (packages-load-package-dumped-lisps late-package-load-path)
+ − 156
+ − 157 )) ;; end of call-with-condition-handler
1261
+ − 158
+ − 159 ) ; (let ((stack-trace-on-error nil)))
428
+ − 160
+ − 161 ;; Fix up the preloaded file list
+ − 162 (setq preloaded-file-list (mapcar #'file-name-sans-extension
+ − 163 preloaded-file-list))
+ − 164
1261
+ − 165 (setq load-warn-when-source-only nil)
428
+ − 166
+ − 167 (setq debugger 'debug)
+ − 168
+ − 169 (when (member "no-site-file" command-line-args)
+ − 170 (setq site-start-file nil))
+ − 171
+ − 172 ;; If you want additional libraries to be preloaded and their
+ − 173 ;; doc strings kept in the DOC file rather than in core,
+ − 174 ;; you may load them with a "site-load.el" file.
+ − 175 ;; But you must also cause them to be scanned when the DOC file
1261
+ − 176 ;; is generated. For MS Windows, you must edit ../nt/xemacs.mak.
+ − 177 ;; For other systems, you must edit ../src/Makefile.in.in.
428
+ − 178 (when (load "site-load" t)
442
+ − 179 (garbage-collect)
+ − 180 )
428
+ − 181
+ − 182 ;;FSFmacs randomness
+ − 183 ;;(if (fboundp 'x-popup-menu)
+ − 184 ;; (precompute-menubar-bindings))
+ − 185 ;;; Turn on recording of which commands get rebound,
+ − 186 ;;; for the sake of the next call to precompute-menubar-bindings.
+ − 187 ;(setq define-key-rebound-commands nil)
+ − 188
+ − 189 ;; Note: all compiled Lisp files loaded above this point
+ − 190 ;; must be among the ones parsed by make-docfile
+ − 191 ;; to construct DOC. Any that are not processed
+ − 192 ;; for DOC will not have doc strings in the dumped XEmacs.
+ − 193
+ − 194 ;; Don't bother with these if we're running temacs, i.e. if we're
+ − 195 ;; just debugging don't waste time finding doc strings.
+ − 196
+ − 197 ;; purify-flag is nil if called from loadup-el.el.
+ − 198 (when purify-flag
+ − 199 (message "Finding pointers to doc strings...")
+ − 200 (Snarf-documentation "DOC")
+ − 201 (message "Finding pointers to doc strings...done")
+ − 202 (Verify-documentation))
+ − 203
+ − 204 ;; Note: You can cause additional libraries to be preloaded
+ − 205 ;; by writing a site-init.el that loads them.
+ − 206 ;; See also "site-load" above.
+ − 207 (when (stringp site-start-file)
+ − 208 (load "site-init" t))
+ − 209 (setq current-load-list nil)
+ − 210 (garbage-collect)
+ − 211
+ − 212 ;;; At this point, we're ready to resume undo recording for scratch.
+ − 213 (buffer-enable-undo "*scratch*")
+ − 214
1261
+ − 215 ) ;; (let ((gc-cons-threshold [frequent garbage collection when dumping])))
428
+ − 216
442
+ − 217 ;(stop-profiling)
+ − 218
428
+ − 219 ;; Dump into the name `xemacs' (only)
+ − 220 (when (member "dump" command-line-args)
+ − 221 (message "Dumping under the name xemacs")
+ − 222 ;; This is handled earlier in the build process.
+ − 223 ;; (condition-case () (delete-file "xemacs") (file-error nil))
+ − 224 (when (fboundp 'really-free)
+ − 225 (really-free))
1261
+ − 226 ;; Make sure we don't dump with debugging messages turned on.
+ − 227 (setq stack-trace-on-error nil
+ − 228 load-always-display-messages nil)
462
+ − 229 (dump-emacs
+ − 230 (cond
+ − 231 ((featurep 'infodock) "infodock")
+ − 232 ;; #### BILL!!!
+ − 233 ;; If we want to dump under a name other than `xemacs', do that here!
+ − 234 ;; ((featurep 'gtk) "xemacs-gtk")
+ − 235 (t "xemacs"))
+ − 236 "temacs")
428
+ − 237 (kill-emacs))
+ − 238
+ − 239 ;; Avoid error if user loads some more libraries now.
+ − 240 (setq purify-flag nil)
+ − 241
+ − 242 (when (member "run-temacs" command-line-args)
+ − 243 (message "\nBootstrapping from temacs...")
+ − 244 ;; Remove all args up to and including "run-temacs"
+ − 245 (apply #'run-emacs-from-temacs (cdr (member "run-temacs" command-line-args)))
+ − 246 ;; run-emacs-from-temacs doesn't actually return anyway.
+ − 247 (kill-emacs))
+ − 248
+ − 249 ;; XEmacs change
+ − 250 ;; If you are using 'recompile', then you should have used -l loadup-el.el
+ − 251 ;; so that the .el files always get loaded (the .elc files may be out-of-
+ − 252 ;; date or bad).
+ − 253 (when (member "recompile" command-line-args)
+ − 254 (setq command-line-args-left (cdr (member "recompile" command-line-args)))
+ − 255 (batch-byte-recompile-directory)
+ − 256 (kill-emacs))
+ − 257
+ − 258 ;; For machines with CANNOT_DUMP defined in config.h,
+ − 259 ;; this file must be loaded each time Emacs is run.
+ − 260 ;; So run the startup code now.
+ − 261
+ − 262 (when (not (fboundp 'dump-emacs))
+ − 263 ;; Avoid loading loadup.el a second time!
+ − 264 (setq command-line-args (cdr (cdr command-line-args)))
+ − 265 (eval top-level))
+ − 266
+ − 267 ;;; loadup.el ends here