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