428
|
1 ;;; setup-paths.el --- setup various XEmacs paths
|
|
2
|
|
3 ;; Copyright (C) 1985-1986, 1990, 1992-1997 Free Software Foundation, Inc.
|
|
4 ;; Copyright (c) 1993, 1994 Sun Microsystems, Inc.
|
|
5 ;; Copyright (C) 1995 Board of Trustees, University of Illinois
|
1330
|
6 ;; Copyright (C) 2003 Ben Wing.
|
428
|
7
|
2456
|
8 ;; Author: Mike Sperber <mike@xemacs.orgx>
|
428
|
9 ;; Maintainer: XEmacs Development Team
|
|
10 ;; Keywords: internal, dumped
|
|
11
|
|
12 ;; This file is part of XEmacs.
|
|
13
|
|
14 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
15 ;; under the terms of the GNU General Public License as published by
|
|
16 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
17 ;; any later version.
|
|
18
|
|
19 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
22 ;; General Public License for more details.
|
|
23
|
|
24 ;; You should have received a copy of the GNU General Public License
|
|
25 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
26 ;; Free Software Foundation, 59 Temple Place - Suite 330,
|
|
27 ;; Boston, MA 02111-1307, USA.
|
|
28
|
|
29 ;;; Synched up with: Not in FSF.
|
|
30
|
|
31 ;;; Commentary:
|
|
32
|
|
33 ;; This file is dumped with XEmacs.
|
|
34
|
776
|
35 ;; This file contains functions and variables that describe and construct
|
|
36 ;; the various paths into the XEmacs hierarchy from a global viewpoint.
|
2456
|
37
|
|
38 ;; This file doesn't actually set any global variable, and doesn't
|
|
39 ;; contain any state---it just contains the functionality for
|
|
40 ;; searching directories and constructing paths.
|
428
|
41
|
|
42 ;; It requires find-paths.el and packages.el.
|
1330
|
43
|
|
44 ;;; Code:
|
|
45
|
|
46 ;(setq debug-paths t)
|
|
47
|
428
|
48
|
460
|
49 (defvar paths-core-load-path-depth 0
|
428
|
50 "Depth of load-path searches in core Lisp paths.")
|
|
51
|
452
|
52 (defvar paths-site-load-path-depth 1
|
|
53 "Depth of load-path searches in site Lisp paths.")
|
|
54
|
460
|
55 (defvar paths-mule-load-path-depth 0
|
|
56 "Depth of load-path searches in Mule Lisp paths.")
|
|
57
|
428
|
58 (defvar paths-default-info-directories
|
|
59 (mapcar (function
|
|
60 (lambda (dirlist)
|
|
61 (paths-construct-path
|
|
62 dirlist (char-to-string directory-sep-char))))
|
|
63 '(("usr" "local" "info")
|
|
64 ("usr" "info")
|
|
65 ("usr" "local" "share" "info")
|
|
66 ("usr" "share" "info")))
|
|
67 "Directories appended to the end of the info path by default.")
|
|
68
|
1330
|
69
|
|
70 ;;; Basic utility functions.
|
|
71
|
|
72 (defun paths-emacs-root-p (directory)
|
|
73 "Check if DIRECTORY is a plausible installation root."
|
|
74 (or
|
|
75 ;; installed
|
|
76 (paths-file-readable-directory-p (paths-construct-path (list directory
|
|
77 "lib"
|
|
78 (construct-emacs-version-name))))
|
|
79 ;; in-place or windows-nt. windows-nt equivalent of --srcdir is
|
|
80 ;; BUILD_DIR in config.inc, and has no lisp/ or etc/ since symlinks
|
|
81 ;; don't exist. instead, xemacs.mak points configure-lisp-directory and
|
|
82 ;; configure-data-directory at the right places.
|
|
83 (and
|
1526
|
84 (or configure-exec-directory (paths-file-readable-directory-p (paths-construct-path (list directory "lib-src"))) (eq system-type 'windows-nt))
|
1330
|
85 (or configure-lisp-directory (paths-file-readable-directory-p (paths-construct-path (list directory "lisp"))))
|
|
86 (or configure-data-directory (paths-file-readable-directory-p (paths-construct-path (list directory "etc")))))))
|
|
87
|
|
88 (defun paths-emacs-data-root-p (directory)
|
|
89 "Check if DIRECTORY is a plausible data installation root.
|
|
90 A data installation root is one containing data files that may be shared
|
2456
|
91 among multiple different versions of XEmacs, the packages in particular.
|
|
92 This serves as an additional filter to narrow down the list of plausible
|
|
93 installation roots."
|
1330
|
94 (or
|
|
95 ;; installed
|
|
96 (paths-file-readable-directory-p (paths-construct-path (list directory
|
|
97 "lib"
|
|
98 emacs-program-name)))
|
|
99 (paths-file-readable-directory-p (paths-construct-path (list directory
|
|
100 "lib"
|
|
101 (construct-emacs-version-name))))
|
|
102 ;; in-place or windows-nt
|
|
103 (and
|
|
104 (paths-file-readable-directory-p (paths-construct-path (list directory "lisp")))
|
3281
|
105 (paths-file-readable-directory-p (paths-construct-path (list directory "etc"))))
|
1330
|
106
|
3281
|
107 ;; searching for a package directory
|
|
108 (and
|
|
109 (string-match "win32" system-configuration)
|
|
110 (paths-file-readable-directory-p (paths-construct-path (list directory
|
|
111 "xemacs-packages"))))))
|
|
112
|
|
113 (defun paths-find-invocation-roots (invocation-directory invocation-name root-p)
|
|
114 "Find the list of run-time roots of XEmacs.
|
2456
|
115 INVOCATION-DIRECTORY is a directory containing the XEmacs executable.
|
3281
|
116 INVOCATION-NAME is the name of the executable itself
|
|
117 ROOT-P is a function that tests whether a root is plausible."
|
1330
|
118 (let* ((executable-file-name (paths-chase-symlink
|
|
119 (concat invocation-directory
|
|
120 invocation-name)))
|
|
121 (executable-directory (file-name-directory executable-file-name))
|
|
122 (maybe-root-1 (file-name-as-directory
|
|
123 (paths-construct-path '("..") executable-directory)))
|
|
124 (maybe-root-2 (file-name-as-directory
|
|
125 (paths-construct-path '(".." "..") executable-directory))))
|
3281
|
126
|
|
127 (paths-filter root-p
|
|
128 (list maybe-root-1 maybe-root-2))))
|
1330
|
129
|
2456
|
130 (defun paths-find-emacs-roots (invocation-directory
|
|
131 invocation-name
|
|
132 root-p)
|
1330
|
133 "Find all plausible installation roots for XEmacs.
|
|
134 This is a list of plausible directories in which to search for the important
|
|
135 directories used by XEmacs at run-time, for example `exec-directory',
|
|
136 `data-directory' and `lisp-directory'.
|
|
137 ROOT-P is a function that tests whether a root is plausible."
|
3281
|
138 (let* ((invocation-roots
|
|
139 (paths-find-invocation-roots invocation-directory
|
|
140 invocation-name
|
|
141 root-p))
|
1330
|
142 (potential-installation-roots
|
|
143 (paths-uniq-append
|
|
144 (and configure-exec-prefix-directory
|
|
145 (list (file-name-as-directory
|
|
146 configure-exec-prefix-directory)))
|
|
147 (and configure-prefix-directory
|
|
148 (list (file-name-as-directory
|
|
149 configure-prefix-directory)))))
|
|
150 (installation-roots
|
|
151 (paths-filter root-p potential-installation-roots)))
|
|
152 (paths-uniq-append invocation-roots
|
|
153 installation-roots)))
|
|
154
|
428
|
155 (defun paths-find-site-lisp-directory (roots)
|
2456
|
156 "Find the site Lisp directory of the XEmacs hierarchy.
|
|
157 ROOTS is a list of installation roots."
|
428
|
158 (paths-find-site-directory roots "site-lisp"
|
|
159 nil
|
|
160 configure-site-directory))
|
|
161
|
|
162 (defun paths-find-site-module-directory (roots)
|
2456
|
163 "Find the site modules directory of the XEmacs hierarchy.
|
|
164 ROOTS is a list of installation roots."
|
428
|
165 (paths-find-site-directory roots "site-modules"
|
|
166 nil
|
|
167 configure-site-module-directory))
|
|
168
|
|
169 (defun paths-find-lisp-directory (roots)
|
2456
|
170 "Find the main Lisp directory of the XEmacs hierarchy.
|
|
171 ROOTS is a list of installation roots."
|
428
|
172 (paths-find-version-directory roots "lisp"
|
|
173 nil
|
|
174 configure-lisp-directory))
|
|
175
|
460
|
176 (defun paths-find-mule-lisp-directory (roots &optional lisp-directory)
|
2456
|
177 "Find the Mule Lisp directory of the XEmacs hierarchy.
|
|
178 ROOTS is a list of installation roots."
|
460
|
179 ;; #### kludge
|
|
180 (if lisp-directory
|
|
181 (let ((guess
|
|
182 (file-name-as-directory
|
|
183 (paths-construct-path (list lisp-directory "mule")))))
|
|
184 (if (paths-file-readable-directory-p guess)
|
|
185 guess
|
|
186 (paths-find-version-directory roots "mule-lisp"
|
|
187 nil
|
|
188 configure-mule-lisp-directory)))))
|
|
189
|
428
|
190 (defun paths-find-module-directory (roots)
|
2456
|
191 "Find the main modules directory of the XEmacs hierarchy.
|
|
192 ROOTS is a list of installation roots."
|
428
|
193 (paths-find-architecture-directory roots "modules"
|
|
194 nil configure-module-directory))
|
|
195
|
|
196 (defun paths-construct-load-path
|
|
197 (roots early-package-load-path late-package-load-path last-package-load-path
|
|
198 lisp-directory
|
460
|
199 &optional site-lisp-directory mule-lisp-directory)
|
2456
|
200 "Construct the complete load path.
|
|
201 ROOTS is the list of installation roots.
|
|
202 EARLY-PACKAGE-LOAD-PATH, LATE-PACKAGE-LOAD-PATH, and LAST-PACKAGE-LOAD-PATH
|
|
203 are the load paths for the package hierarchies.
|
|
204 SITE-LISP-DIRECTORY and MULE-LISP-DIRECTORY are optional directories to be
|
|
205 included in the load path---SITE-LISP-DIRECTORY for the obsolete site-specific
|
|
206 Lisp files, and MULE-LISP-DIRECTORY for the Mule Lisp files, which exist
|
|
207 only in Mule installations."
|
428
|
208 (let* ((envvar-value (getenv "EMACSLOADPATH"))
|
|
209 (env-load-path
|
|
210 (and envvar-value
|
|
211 (paths-decode-directory-path envvar-value 'drop-empties)))
|
|
212 (site-lisp-load-path
|
|
213 (and site-lisp-directory
|
|
214 (paths-find-recursive-load-path (list site-lisp-directory)
|
452
|
215 paths-site-load-path-depth)))
|
460
|
216 (mule-lisp-load-path
|
|
217 (and mule-lisp-directory
|
|
218 (paths-find-recursive-load-path (list mule-lisp-directory)
|
|
219 paths-mule-load-path-depth)))
|
428
|
220 (lisp-load-path
|
|
221 (and lisp-directory
|
|
222 (paths-find-recursive-load-path (list lisp-directory)
|
452
|
223 paths-core-load-path-depth))))
|
428
|
224 (append env-load-path
|
|
225 early-package-load-path
|
|
226 site-lisp-load-path
|
|
227 late-package-load-path
|
460
|
228 mule-lisp-load-path
|
428
|
229 lisp-load-path
|
|
230 last-package-load-path)))
|
|
231
|
|
232 (defun paths-construct-module-load-path
|
|
233 (root module-directory &optional site-module-directory)
|
|
234 "Construct the modules load path."
|
|
235 (let* ((envvar-value (getenv "EMACSMODULEPATH"))
|
|
236 (env-module-path
|
|
237 (and envvar-value
|
|
238 (paths-decode-directory-path envvar-value 'drop-empties)))
|
|
239 (site-module-load-path
|
|
240 (and site-module-directory
|
|
241 (paths-find-recursive-load-path (list site-module-directory)
|
452
|
242 paths-site-load-path-depth)))
|
428
|
243 (module-load-path
|
|
244 (and module-directory
|
|
245 (paths-find-recursive-load-path (list module-directory)
|
452
|
246 paths-core-load-path-depth))))
|
2456
|
247 (append env-module-path
|
428
|
248 site-module-load-path
|
|
249 module-load-path)))
|
|
250
|
2456
|
251 (defun paths-construct-info-path (roots
|
|
252 early-package-hierarchies
|
|
253 late-package-hierarchies
|
|
254 last-package-hierarchies)
|
|
255 "Construct the info path.
|
|
256 ROOTS is the list of installation roots.
|
|
257 EARLY-PACKAGE-HIERARCHIES, LATE-PACKAGE-HIERARCHIES, and
|
|
258 LAST-PACKAGE-HIERARCHIES are lists of package hierarchy roots,
|
|
259 respectively."
|
428
|
260 (let ((info-path-envval (getenv "INFOPATH")))
|
|
261 (paths-uniq-append
|
|
262 (append
|
|
263 (let ((info-directory
|
|
264 (paths-find-version-directory roots "info"
|
|
265 nil
|
|
266 configure-info-directory)))
|
|
267 (and info-directory
|
|
268 (list info-directory)))
|
2456
|
269 (packages-find-package-info-path early-package-hierarchies)
|
|
270 (packages-find-package-info-path late-package-hierarchies)
|
|
271 (packages-find-package-info-path last-package-hierarchies)
|
428
|
272 (and info-path-envval
|
|
273 (paths-decode-directory-path info-path-envval 'drop-empties)))
|
|
274 (and (null info-path-envval)
|
|
275 (paths-uniq-append
|
|
276 (paths-directories-which-exist configure-info-path)
|
|
277 (paths-directories-which-exist paths-default-info-directories))))))
|
|
278
|
|
279 (defun paths-find-doc-directory (roots)
|
2456
|
280 "Find the documentation directory.
|
|
281 ROOTS is the list of installation roots."
|
428
|
282 (paths-find-architecture-directory roots "lib-src" nil configure-doc-directory))
|
|
283
|
|
284 (defun paths-find-exec-directory (roots)
|
2456
|
285 "Find the binary directory.
|
|
286 ROOTS is the list of installation roots."
|
428
|
287 (paths-find-architecture-directory roots "lib-src"
|
|
288 nil configure-exec-directory))
|
|
289
|
|
290 (defun paths-construct-exec-path (roots exec-directory
|
2456
|
291 early-package-hierarchies
|
|
292 late-package-hierarchies
|
|
293 last-package-hierarchies)
|
|
294 "Find the binary path.
|
|
295 ROOTS is the list of installation roots.
|
|
296 EARLY-PACKAGE-HIERARCHIES, LATE-PACKAGE-HIERARCHIES, and
|
|
297 LAST-PACKAGE-HIERARCHIES are lists of package hierarchy roots,
|
|
298 respectively.
|
|
299 EXEC-DIRECTORY is the directory of architecture-dependent files that
|
|
300 come with XEmacs.
|
|
301 EARLY-PACKAGES, LATE-PACKAGES, and LAST-PACKAGES are lists of
|
|
302 package hierarchy roots, respectively."
|
428
|
303 (append
|
|
304 (let ((path-envval (getenv "PATH")))
|
|
305 (if path-envval
|
|
306 (paths-decode-directory-path path-envval 'drop-empties)))
|
2456
|
307 (packages-find-package-exec-path early-package-hierarchies)
|
|
308 (packages-find-package-exec-path late-package-hierarchies)
|
428
|
309 (let ((emacspath-envval (getenv "EMACSPATH")))
|
|
310 (and emacspath-envval
|
|
311 (split-path emacspath-envval)))
|
|
312 (and exec-directory
|
|
313 (list exec-directory))
|
2456
|
314 (packages-find-package-exec-path last-package-hierarchies)))
|
428
|
315
|
|
316 (defun paths-find-data-directory (roots)
|
2456
|
317 "Find the data directory.
|
|
318 ROOTS is the list of installation roots."
|
428
|
319 (paths-find-version-directory roots "etc" "EMACSDATA" configure-data-directory))
|
|
320
|
|
321 (defun paths-construct-data-directory-list (data-directory
|
2456
|
322 early-package-hierarchies
|
|
323 late-package-hierarchies
|
|
324 last-package-hierarchies)
|
|
325 "Construct the data path.
|
|
326 DATA-DIRECTORY is the data directory of the XEmacs installation.
|
|
327 EARLY-PACKAGE-HIERARCHIES, LATE-PACKAGE-HIERARCHIES, and
|
|
328 LAST-PACKAGE-HIERARCHIES are lists of package hierarchy roots,
|
|
329 respectively."
|
428
|
330 (append
|
2456
|
331 (packages-find-package-data-path early-package-hierarchies)
|
|
332 (packages-find-package-data-path late-package-hierarchies)
|
428
|
333 (list data-directory)
|
2456
|
334 (packages-find-package-data-path last-package-hierarchies)))
|
1330
|
335
|
428
|
336 ;;; setup-paths.el ends here
|