1 ;;; setup-paths.el --- setup various SXEmacs paths
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
7 ;; Author: Mike Sperber <sperber@informatik.uni-tuebingen.de>
8 ;; Maintainer: SXEmacs Development Team
9 ;; Keywords: internal, dumped
11 ;; This file is part of SXEmacs.
13 ;; SXEmacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; SXEmacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
26 ;;; Synched up with: Not in FSF.
30 ;; This file is dumped with XEmacs.
32 ;; This file describes and constructs the various paths into the
33 ;; XEmacs hierarchy from a global viewpoint.
35 ;; It requires find-paths.el and packages.el.
39 (defvar paths-core-load-path-depth 0
40 "Depth of load-path searches in core Lisp paths.")
42 (defvar paths-site-load-path-depth 1
43 "Depth of load-path searches in site Lisp paths.")
45 (defvar paths-mule-load-path-depth 0
46 "Depth of load-path searches in Mule Lisp paths.")
48 (defvar paths-ffi-load-path-depth 0
49 "Depth of load-path searches in FFI Lisp paths.")
51 (defvar paths-module-load-path-depth 1
52 "Depth of load-path searches in emodule paths.")
54 (defvar paths-default-info-directories
58 dirlist (char-to-string directory-sep-char))))
59 '(("usr" "local" "info")
61 ("usr" "local" "share" "info")
62 ("usr" "share" "info")))
63 "Directories appended to the end of the info path by default.")
65 (defun paths-find-site-module-directory (roots)
66 "Find the site modules directory of the XEmacs hierarchy."
67 (paths-find-site-archdep-directory roots "site-modules"
69 configure-site-module-directory))
71 (defun paths-find-lisp-directory (roots)
72 "Find the main Lisp directory of the XEmacs hierarchy."
73 (or (paths-find-version-archindep-directory
74 roots "lisp" nil configure-lisp-directory)
75 (paths-find-version-archdep-directory
76 roots "lisp" nil configure-lisp-directory)))
78 (defun paths-find-mule-lisp-directory (roots &optional lisp-directory)
79 "Find the Mule Lisp directory of the XEmacs hierarchy."
83 (file-name-as-directory
84 (paths-construct-path (list lisp-directory "mule")))))
85 (if (paths-file-readable-directory-p guess)
87 (paths-find-version-archindep-directory
88 roots "mule-lisp" nil configure-mule-lisp-directory)))))
90 (defun paths-find-ffi-lisp-directory (roots &optional lisp-directory)
91 "Find the FFI Lisp directory of the SXEmacs hierarchy."
95 (file-name-as-directory
96 (paths-construct-path (list lisp-directory "ffi")))))
97 (if (paths-file-readable-directory-p guess)
99 (or (paths-find-version-archdep-directory
100 roots "ffi-lisp" nil)
101 (paths-find-version-archindep-directory
102 roots "ffi-lisp" nil))))))
104 (defun paths-find-module-directory (roots)
105 "Find the main modules directory of the SXEmacs hierarchy."
108 (paths-find-emacs-directory roots "" "modules"
109 nil configure-module-directory)
110 (paths-find-architecture-directory roots "modules"
111 nil configure-module-directory)))
113 (defun paths-construct-module-load-path
114 (root module-directory &optional site-module-directory)
115 "Construct the modules load path.
117 If the environment variable \"EMACSMODULEPATH\" is set then it is used
118 for `module-load-path' and this function does squat. EMACSMODULEPATH
119 should be a colon delimited list of directory paths.
121 ROOT is `emacs-roots'. If that's nil, this will blow up. But if
122 `emacs-roots' is nil, your SXEmacs will blow up before you get here
125 MODULE-DIRECTORY is the directory containing the emodules distributed
126 with the core SXEmacs. If for some reason it is nil, it'll be skipped
129 If SITE-MODULE-DIRECTORY doesn't exist as a directory on disc, it is
130 skipped. If it does exist but the argument here is nil, it is hunted
132 (if (getenv "EMACSMODULEPATH")
133 (setq module-load-path (paths-decode-directory-path
134 (getenv "EMACSMODULEPATH") 'drop-empties))
136 (and system-configuration
138 (paths-find-recursive-load-path
139 (list (paths-construct-path
140 (list system-configuration "modules") user-init-directory))
141 paths-module-load-path-depth)))
142 (site-dir (paths-find-site-module-directory root))
144 (or (and site-module-directory
145 (paths-find-recursive-load-path (list site-module-directory)
146 paths-module-load-path-depth))
148 (paths-find-recursive-load-path
149 (list site-dir) paths-module-load-path-depth))))
151 (and module-directory
152 (paths-find-recursive-load-path (list module-directory)
153 paths-module-load-path-depth))))
154 (setq module-load-path (append (when user-path user-path)
155 (when site-path site-path)
156 (when module-path module-path))))))
158 (defun paths-construct-load-path
159 (roots early-package-load-path late-package-load-path last-package-load-path
161 &optional unused mule-lisp-directory ffi-lisp-directory)
162 "Construct the load path."
163 (let* ((envvar-value (getenv "EMACSLOADPATH"))
166 (paths-decode-directory-path envvar-value 'drop-empties)))
168 (and mule-lisp-directory
169 (paths-find-recursive-load-path (list mule-lisp-directory)
170 paths-mule-load-path-depth)))
172 (and ffi-lisp-directory
173 (paths-find-recursive-load-path (list ffi-lisp-directory)
174 paths-ffi-load-path-depth)))
177 (paths-find-recursive-load-path (list lisp-directory)
178 paths-core-load-path-depth)))
180 (and module-directory
181 (paths-construct-module-load-path roots module-directory
182 site-module-directory)))
184 (paths-find-recursive-load-path
185 (mapcar #'(lambda (root)
186 (expand-file-name "lisp" root))
189 (append env-load-path
191 early-package-load-path
192 late-package-load-path
197 last-package-load-path)))
199 (defun paths-construct-info-path (roots early-packages late-packages last-packages)
200 "Construct the info path."
201 (let ((info-path-envval (getenv "INFOPATH")))
204 (list (paths-find-emacs-directory roots "share/" "info" nil configure-info-directory))
205 (let ((info-directory
206 (or (paths-find-version-archindep-directory
207 roots "info" nil configure-info-directory)
208 (paths-find-version-archdep-directory
209 roots "info" nil configure-info-directory))))
211 (list info-directory)))
212 (packages-find-package-info-path early-packages)
213 (packages-find-package-info-path late-packages)
214 (packages-find-package-info-path last-packages)
215 (and info-path-envval
216 (paths-decode-directory-path info-path-envval 'drop-empties)))
217 (and (null info-path-envval)
219 (paths-directories-which-exist configure-info-path)
220 (paths-directories-which-exist paths-default-info-directories))))))
222 (defun paths-find-doc-directory (roots)
223 "Find the documentation directory."
225 ;; in-place from $blddir/src/.libs
226 ((file-exists-p (paths-construct-path `(".." ,internal-doc-file-name)
227 (invocation-directory)))
228 (expand-file-name "../" invocation-directory))
229 ;; in-place from $blddir/src
230 ((file-exists-p (expand-file-name internal-doc-file-name
231 (invocation-directory)))
232 (invocation-directory))
235 (paths-find-architecture-directory roots nil nil
236 (or configure-doc-directory
239 (defun paths-find-exec-directory (roots)
240 "Find the binary directory."
241 (paths-find-architecture-directory roots "lib-src"
242 nil configure-exec-directory))
244 (defun paths-construct-exec-path (roots exec-directory
245 early-packages late-packages last-packages)
246 "Find the binary path."
248 (let ((path-envval (getenv "PATH")))
250 (paths-decode-directory-path path-envval 'drop-empties)))
251 (packages-find-package-exec-path early-packages)
252 (packages-find-package-exec-path late-packages)
253 (let ((emacspath-envval (getenv "EMACSPATH")))
254 (and emacspath-envval
255 (split-path emacspath-envval)))
257 (list exec-directory))
258 (packages-find-package-exec-path last-packages)))
260 (defun paths-find-data-directory (roots)
261 "Find the data directory."
262 ;; better approach wanted!!! -hroptatyr
263 ;; for now we're just using the toolbar subdirectory as indicator
264 ;; of a healthy etc/ directory
268 (paths-find-version-archdep-directory
269 roots "etc/toolbar" "EMACSDATA" configure-data-directory)
271 (paths-find-version-archindep-directory
272 roots "etc/toolbar" "EMACSDATA" configure-data-directory))))
274 (defun paths-construct-data-directory-list (data-directory
275 early-packages late-packages last-packages)
276 "Find the data path."
278 (packages-find-package-data-path early-packages)
279 (packages-find-package-data-path late-packages)
280 (list data-directory)
281 (packages-find-package-data-path last-packages)))
283 ;;; setup-paths.el ends here