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