XEmacs 21.2.45 "Thelxepeia".
[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 0
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-mule-load-path-depth 0
48   "Depth of load-path searches in Mule Lisp paths.")
49
50 (defvar paths-default-info-directories
51   (mapcar (function
52            (lambda (dirlist)
53              (paths-construct-path
54               dirlist (char-to-string directory-sep-char))))
55           '(("usr" "local" "info")
56             ("usr" "info")
57             ("usr" "local" "share" "info")
58             ("usr" "share" "info")))
59   "Directories appended to the end of the info path by default.")
60
61 (defun paths-find-site-lisp-directory (roots)
62   "Find the site Lisp directory of the XEmacs hierarchy."
63   (paths-find-site-directory roots "site-lisp"
64                              nil
65                              configure-site-directory))
66
67 (defun paths-find-site-module-directory (roots)
68   "Find the site modules directory of the XEmacs hierarchy."
69   (paths-find-site-directory roots "site-modules"
70                              nil
71                              configure-site-module-directory))
72
73 (defun paths-find-lisp-directory (roots)
74   "Find the main Lisp directory of the XEmacs hierarchy."
75   (paths-find-version-directory roots "lisp"
76                                 nil
77                                 configure-lisp-directory))
78
79 (defun paths-find-mule-lisp-directory (roots &optional lisp-directory)
80   "Find the Mule Lisp directory of the XEmacs hierarchy."
81   ;; #### kludge
82   (if lisp-directory
83       (let ((guess
84              (file-name-as-directory
85               (paths-construct-path (list lisp-directory "mule")))))
86         (if (paths-file-readable-directory-p guess)
87             guess
88           (paths-find-version-directory roots "mule-lisp"
89                                         nil
90                                         configure-mule-lisp-directory)))))
91
92 (defun paths-find-module-directory (roots)
93   "Find the main modules directory of the XEmacs hierarchy."
94   (paths-find-architecture-directory roots "modules"
95                                      nil configure-module-directory))
96
97 (defun paths-construct-load-path
98   (roots early-package-load-path late-package-load-path last-package-load-path
99          lisp-directory
100          &optional site-lisp-directory mule-lisp-directory)
101   "Construct the load path."
102   (let* ((envvar-value (getenv "EMACSLOADPATH"))
103          (env-load-path
104           (and envvar-value
105                (paths-decode-directory-path envvar-value 'drop-empties)))
106          (site-lisp-load-path
107           (and site-lisp-directory
108                (paths-find-recursive-load-path (list site-lisp-directory)
109                                                paths-site-load-path-depth)))
110          (mule-lisp-load-path
111           (and mule-lisp-directory
112                (paths-find-recursive-load-path (list mule-lisp-directory)
113                                                paths-mule-load-path-depth)))
114          (lisp-load-path
115           (and lisp-directory
116                (paths-find-recursive-load-path (list lisp-directory)
117                                                paths-core-load-path-depth))))
118     (append env-load-path
119             early-package-load-path
120             site-lisp-load-path
121             late-package-load-path
122             mule-lisp-load-path
123             lisp-load-path
124             last-package-load-path)))
125
126 (defun paths-construct-module-load-path
127   (root module-directory &optional site-module-directory)
128   "Construct the modules load path."
129   (let* ((envvar-value (getenv "EMACSMODULEPATH"))
130          (env-module-path
131           (and envvar-value
132                (paths-decode-directory-path envvar-value 'drop-empties)))
133          (site-module-load-path
134           (and site-module-directory
135                (paths-find-recursive-load-path (list site-module-directory)
136                                                paths-site-load-path-depth)))
137          (module-load-path
138           (and module-directory
139                (paths-find-recursive-load-path (list module-directory)
140                                                paths-core-load-path-depth))))
141      (append env-module-path
142             site-module-load-path
143             module-load-path)))
144
145 (defun paths-construct-info-path (roots early-packages late-packages last-packages)
146   "Construct the info path."
147   (let ((info-path-envval (getenv "INFOPATH")))
148     (paths-uniq-append
149      (append
150       (let ((info-directory
151              (paths-find-version-directory roots "info"
152                                            nil
153                                            configure-info-directory)))
154         (and info-directory
155              (list info-directory)))
156       (packages-find-package-info-path early-packages)
157       (packages-find-package-info-path late-packages)
158       (packages-find-package-info-path last-packages)
159       (and info-path-envval
160            (paths-decode-directory-path info-path-envval 'drop-empties)))
161      (and (null info-path-envval)
162           (paths-uniq-append
163            (paths-directories-which-exist configure-info-path)
164            (paths-directories-which-exist paths-default-info-directories))))))
165
166 (defun paths-find-doc-directory (roots)
167   "Find the documentation directory."
168   (paths-find-architecture-directory roots "lib-src" nil configure-doc-directory))
169
170 (defun paths-find-exec-directory (roots)
171   "Find the binary directory."
172   (paths-find-architecture-directory roots "lib-src"
173                                      nil configure-exec-directory))
174
175 (defun paths-construct-exec-path (roots exec-directory
176                                   early-packages late-packages last-packages)
177   "Find the binary path."
178   (append
179    (let ((path-envval (getenv "PATH")))
180      (if path-envval
181          (paths-decode-directory-path path-envval 'drop-empties)))
182    (packages-find-package-exec-path early-packages)
183    (packages-find-package-exec-path late-packages)
184    (let ((emacspath-envval (getenv "EMACSPATH")))
185      (and emacspath-envval
186           (split-path emacspath-envval)))
187    (and exec-directory
188         (list exec-directory))
189    (packages-find-package-exec-path last-packages)))
190
191 (defun paths-find-data-directory (roots)
192   "Find the data directory."
193   (paths-find-version-directory roots "etc" "EMACSDATA" configure-data-directory))
194
195 (defun paths-construct-data-directory-list (data-directory
196                                             early-packages late-packages last-packages)
197   "Find the data path."
198   (append
199    (packages-find-package-data-path early-packages)
200    (packages-find-package-data-path late-packages)
201    (list data-directory)
202    (packages-find-package-data-path last-packages)))
203
204 ;;; setup-paths.el ends here