XEmacs 21.2.5
[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-lisp-directory (roots)
58   "Find the main Lisp directory of the XEmacs hierarchy."
59   (paths-find-version-directory roots "lisp"
60                                 nil
61                                 configure-lisp-directory))
62
63 (defun paths-construct-load-path
64   (roots early-package-load-path late-package-load-path last-package-load-path
65          lisp-directory
66          &optional site-lisp-directory)
67   "Construct the load path."
68   (let* ((envvar-value (getenv "EMACSLOADPATH"))
69          (env-load-path
70           (and envvar-value
71                (paths-decode-directory-path envvar-value 'drop-empties)))
72          (site-lisp-load-path
73           (and site-lisp-directory
74                (paths-find-recursive-load-path (list site-lisp-directory)
75                                                paths-load-path-depth)))
76          (lisp-load-path
77           (and lisp-directory
78                (paths-find-recursive-load-path (list lisp-directory)
79                                                paths-load-path-depth))))
80     (append env-load-path
81             early-package-load-path
82             site-lisp-load-path
83             late-package-load-path
84             lisp-load-path
85             last-package-load-path)))
86
87 (defun paths-construct-info-path (roots early-packages late-packages last-packages)
88   "Construct the info path."
89   (let ((info-path-envval (getenv "INFOPATH")))
90     (paths-uniq-append
91      (append
92       (let ((info-directory
93              (paths-find-version-directory roots "info"
94                                            nil
95                                            configure-info-directory)))
96         (and info-directory
97              (list info-directory)))
98       (packages-find-package-info-path early-packages)
99       (packages-find-package-info-path late-packages)
100       (packages-find-package-info-path last-packages)
101       (and info-path-envval
102            (paths-decode-directory-path info-path-envval 'drop-empties)))
103      (and (null info-path-envval)
104           (paths-uniq-append
105            (paths-directories-which-exist configure-info-path)
106            (paths-directories-which-exist paths-default-info-directories))))))
107
108 (defun paths-find-doc-directory (roots)
109   "Find the documentation directory."
110   (paths-find-architecture-directory roots "lib-src"))
111
112 (defun paths-find-lock-directory (roots)
113   "Find the lock directory."
114   (defvar configure-lock-directory)
115   (paths-find-site-directory roots "lock" "EMACSLOCKDIR" configure-lock-directory))
116
117 (defun paths-find-superlock-file (lock-directory)
118   "Find the superlock file."
119   ;; #### There is no such variable configure-superlock-file!
120   (cond
121    ((null lock-directory)
122     nil)
123    ((and configure-superlock-file
124          (file-directory-p (file-name-directory configure-superlock-file)))
125     configure-superlock-file)
126    (t
127     (expand-file-name "!!!SuperLock!!!" lock-directory))))
128
129 (defun paths-find-exec-directory (roots)
130   "Find the binary directory."
131   (paths-find-architecture-directory roots "lib-src" configure-exec-directory))
132
133 (defun paths-construct-exec-path (roots exec-directory
134                                   early-packages late-packages last-packages)
135   "Find the binary path."
136   (append
137    (let ((path-envval (getenv "PATH")))
138      (if path-envval
139          (paths-decode-directory-path path-envval 'drop-empties)))
140    (packages-find-package-exec-path early-packages)
141    (packages-find-package-exec-path late-packages)
142    (let ((emacspath-envval (getenv "EMACSPATH")))
143      (and emacspath-envval
144           (split-path emacspath-envval)))
145    (and exec-directory
146         (list exec-directory))
147    (packages-find-package-exec-path last-packages)))
148
149 (defun paths-find-data-directory (roots)
150   "Find the data directory."
151   (paths-find-version-directory roots "etc" "EMACSDATA" configure-data-directory))
152
153 (defun paths-construct-data-directory-list (data-directory
154                                             early-packages late-packages last-packages)
155   "Find the data path."
156   (append
157    (packages-find-package-data-path early-packages)
158    (packages-find-package-data-path late-packages)
159    (list data-directory)
160    (packages-find-package-data-path last-packages)))
161
162 ;;; setup-paths.el ends here