XEmacs 21.2.41 "Polyhymnia".
[chise/xemacs-chise.git.1] / lisp / setup-paths.el
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
6
7 ;; Author: Mike Sperber <sperber@informatik.uni-tuebingen.de>
8 ;; Maintainer: XEmacs Development Team
9 ;; Keywords: internal, dumped
10
11 ;; This file is part of XEmacs.
12
13 ;; XEmacs is free software; you can redistribute it and/or modify it
14 ;; under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; XEmacs is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ;; General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with XEmacs; see the file COPYING.  If not, write to the 
25 ;; Free Software Foundation, 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Synched up with: Not in FSF.
29
30 ;;; Commentary:
31
32 ;; This file is dumped with XEmacs.
33
34 ;; This file describes and constructs the various paths into the
35 ;; XEmacs hierarchy from a global viewpoint.
36
37 ;; It requires find-paths.el and packages.el.
38 \f
39 ;;; Code:
40
41 (defvar paths-core-load-path-depth 1
42   "Depth of load-path searches in core Lisp paths.")
43
44 (defvar paths-site-load-path-depth 1
45   "Depth of load-path searches in site Lisp paths.")
46
47 (defvar paths-default-info-directories
48   (mapcar (function
49            (lambda (dirlist)
50              (paths-construct-path
51               dirlist (char-to-string directory-sep-char))))
52           '(("usr" "local" "info")
53             ("usr" "info")
54             ("usr" "local" "share" "info")
55             ("usr" "share" "info")))
56   "Directories appended to the end of the info path by default.")
57
58 (defun paths-find-site-lisp-directory (roots)
59   "Find the site Lisp directory of the XEmacs hierarchy."
60   (paths-find-site-directory roots "site-lisp"
61                              nil
62                              configure-site-directory))
63
64 (defun paths-find-site-module-directory (roots)
65   "Find the site modules directory of the XEmacs hierarchy."
66   (paths-find-site-directory roots "site-modules"
67                              nil
68                              configure-site-module-directory))
69
70 (defun paths-find-lisp-directory (roots)
71   "Find the main Lisp directory of the XEmacs hierarchy."
72   (paths-find-version-directory roots "lisp"
73                                 nil
74                                 configure-lisp-directory))
75
76 (defun paths-find-module-directory (roots)
77   "Find the main modules directory of the XEmacs hierarchy."
78   (paths-find-architecture-directory roots "modules"
79                                      nil configure-module-directory))
80
81 (defun paths-construct-load-path
82   (roots early-package-load-path late-package-load-path last-package-load-path
83          lisp-directory
84          &optional site-lisp-directory)
85   "Construct the load path."
86   (let* ((envvar-value (getenv "EMACSLOADPATH"))
87          (env-load-path
88           (and envvar-value
89                (paths-decode-directory-path envvar-value 'drop-empties)))
90          (site-lisp-load-path
91           (and site-lisp-directory
92                (paths-find-recursive-load-path (list site-lisp-directory)
93                                                paths-site-load-path-depth)))
94          (lisp-load-path
95           (and lisp-directory
96                (paths-find-recursive-load-path (list lisp-directory)
97                                                paths-core-load-path-depth))))
98     (append env-load-path
99             early-package-load-path
100             site-lisp-load-path
101             late-package-load-path
102             lisp-load-path
103             last-package-load-path)))
104
105 (defun paths-construct-module-load-path
106   (root module-directory &optional site-module-directory)
107   "Construct the modules load path."
108   (let* ((envvar-value (getenv "EMACSMODULEPATH"))
109          (env-module-path
110           (and envvar-value
111                (paths-decode-directory-path envvar-value 'drop-empties)))
112          (site-module-load-path
113           (and site-module-directory
114                (paths-find-recursive-load-path (list site-module-directory)
115                                                paths-site-load-path-depth)))
116          (module-load-path
117           (and module-directory
118                (paths-find-recursive-load-path (list module-directory)
119                                                paths-core-load-path-depth))))
120      (append env-module-path
121             site-module-load-path
122             module-load-path)))
123
124 (defun paths-construct-info-path (roots early-packages late-packages last-packages)
125   "Construct the info path."
126   (let ((info-path-envval (getenv "INFOPATH")))
127     (paths-uniq-append
128      (append
129       (let ((info-directory
130              (paths-find-version-directory roots "info"
131                                            nil
132                                            configure-info-directory)))
133         (and info-directory
134              (list info-directory)))
135       (packages-find-package-info-path early-packages)
136       (packages-find-package-info-path late-packages)
137       (packages-find-package-info-path last-packages)
138       (and info-path-envval
139            (paths-decode-directory-path info-path-envval 'drop-empties)))
140      (and (null info-path-envval)
141           (paths-uniq-append
142            (paths-directories-which-exist configure-info-path)
143            (paths-directories-which-exist paths-default-info-directories))))))
144
145 (defun paths-find-doc-directory (roots)
146   "Find the documentation directory."
147   (paths-find-architecture-directory roots "lib-src" nil configure-doc-directory))
148
149 (defun paths-find-exec-directory (roots)
150   "Find the binary directory."
151   (paths-find-architecture-directory roots "lib-src"
152                                      nil configure-exec-directory))
153
154 (defun paths-construct-exec-path (roots exec-directory
155                                   early-packages late-packages last-packages)
156   "Find the binary path."
157   (append
158    (let ((path-envval (getenv "PATH")))
159      (if path-envval
160          (paths-decode-directory-path path-envval 'drop-empties)))
161    (packages-find-package-exec-path early-packages)
162    (packages-find-package-exec-path late-packages)
163    (let ((emacspath-envval (getenv "EMACSPATH")))
164      (and emacspath-envval
165           (split-path emacspath-envval)))
166    (and exec-directory
167         (list exec-directory))
168    (packages-find-package-exec-path last-packages)))
169
170 (defun paths-find-data-directory (roots)
171   "Find the data directory."
172   (paths-find-version-directory roots "etc" "EMACSDATA" configure-data-directory))
173
174 (defun paths-construct-data-directory-list (data-directory
175                                             early-packages late-packages last-packages)
176   "Find the data path."
177   (append
178    (packages-find-package-data-path early-packages)
179    (packages-find-package-data-path late-packages)
180    (list data-directory)
181    (packages-find-package-data-path last-packages)))
182
183 ;;; setup-paths.el ends here