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