428
+ − 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
1330
+ − 6 ;; Copyright (C) 2003 Ben Wing.
428
+ − 7
2456
+ − 8 ;; Author: Mike Sperber <mike@xemacs.orgx>
428
+ − 9 ;; Maintainer: XEmacs Development Team
+ − 10 ;; Keywords: internal, dumped
+ − 11
+ − 12 ;; This file is part of XEmacs.
+ − 13
+ − 14 ;; XEmacs is free software; you can redistribute it and/or modify it
+ − 15 ;; under the terms of the GNU General Public License as published by
+ − 16 ;; the Free Software Foundation; either version 2, or (at your option)
+ − 17 ;; any later version.
+ − 18
+ − 19 ;; XEmacs is distributed in the hope that it will be useful, but
+ − 20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
+ − 21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ − 22 ;; General Public License for more details.
+ − 23
+ − 24 ;; You should have received a copy of the GNU General Public License
+ − 25 ;; along with XEmacs; see the file COPYING. If not, write to the
+ − 26 ;; Free Software Foundation, 59 Temple Place - Suite 330,
+ − 27 ;; Boston, MA 02111-1307, USA.
+ − 28
+ − 29 ;;; Synched up with: Not in FSF.
+ − 30
+ − 31 ;;; Commentary:
+ − 32
+ − 33 ;; This file is dumped with XEmacs.
+ − 34
776
+ − 35 ;; This file contains functions and variables that describe and construct
+ − 36 ;; the various paths into the XEmacs hierarchy from a global viewpoint.
2456
+ − 37
+ − 38 ;; This file doesn't actually set any global variable, and doesn't
+ − 39 ;; contain any state---it just contains the functionality for
+ − 40 ;; searching directories and constructing paths.
428
+ − 41
+ − 42 ;; It requires find-paths.el and packages.el.
1330
+ − 43
+ − 44 ;;; Code:
+ − 45
+ − 46 ;(setq debug-paths t)
+ − 47
428
+ − 48
460
+ − 49 (defvar paths-core-load-path-depth 0
428
+ − 50 "Depth of load-path searches in core Lisp paths.")
+ − 51
452
+ − 52 (defvar paths-site-load-path-depth 1
+ − 53 "Depth of load-path searches in site Lisp paths.")
+ − 54
460
+ − 55 (defvar paths-mule-load-path-depth 0
+ − 56 "Depth of load-path searches in Mule Lisp paths.")
+ − 57
428
+ − 58 (defvar paths-default-info-directories
+ − 59 (mapcar (function
+ − 60 (lambda (dirlist)
+ − 61 (paths-construct-path
+ − 62 dirlist (char-to-string directory-sep-char))))
+ − 63 '(("usr" "local" "info")
+ − 64 ("usr" "info")
+ − 65 ("usr" "local" "share" "info")
+ − 66 ("usr" "share" "info")))
+ − 67 "Directories appended to the end of the info path by default.")
+ − 68
1330
+ − 69
+ − 70 ;;; Basic utility functions.
+ − 71
+ − 72 (defun paths-emacs-root-p (directory)
+ − 73 "Check if DIRECTORY is a plausible installation root."
+ − 74 (or
+ − 75 ;; installed
+ − 76 (paths-file-readable-directory-p (paths-construct-path (list directory
+ − 77 "lib"
+ − 78 (construct-emacs-version-name))))
+ − 79 ;; in-place or windows-nt. windows-nt equivalent of --srcdir is
+ − 80 ;; BUILD_DIR in config.inc, and has no lisp/ or etc/ since symlinks
+ − 81 ;; don't exist. instead, xemacs.mak points configure-lisp-directory and
+ − 82 ;; configure-data-directory at the right places.
+ − 83 (and
1526
+ − 84 (or configure-exec-directory (paths-file-readable-directory-p (paths-construct-path (list directory "lib-src"))) (eq system-type 'windows-nt))
1330
+ − 85 (or configure-lisp-directory (paths-file-readable-directory-p (paths-construct-path (list directory "lisp"))))
+ − 86 (or configure-data-directory (paths-file-readable-directory-p (paths-construct-path (list directory "etc")))))))
+ − 87
+ − 88 (defun paths-emacs-data-root-p (directory)
+ − 89 "Check if DIRECTORY is a plausible data installation root.
+ − 90 A data installation root is one containing data files that may be shared
2456
+ − 91 among multiple different versions of XEmacs, the packages in particular.
+ − 92 This serves as an additional filter to narrow down the list of plausible
+ − 93 installation roots."
1330
+ − 94 (or
+ − 95 ;; installed
+ − 96 (paths-file-readable-directory-p (paths-construct-path (list directory
+ − 97 "lib"
+ − 98 emacs-program-name)))
+ − 99 (paths-file-readable-directory-p (paths-construct-path (list directory
+ − 100 "lib"
+ − 101 (construct-emacs-version-name))))
+ − 102 ;; in-place or windows-nt
+ − 103 (and
+ − 104 (paths-file-readable-directory-p (paths-construct-path (list directory "lisp")))
+ − 105 (paths-file-readable-directory-p (paths-construct-path (list directory "etc"))))))
+ − 106
+ − 107 (defun paths-find-emacs-root (invocation-directory invocation-name)
2456
+ − 108 "Find the run-time root of XEmacs.
+ − 109 INVOCATION-DIRECTORY is a directory containing the XEmacs executable.
+ − 110 INVOCATION-NAME is the name of the executable itself."
1330
+ − 111 (let* ((executable-file-name (paths-chase-symlink
+ − 112 (concat invocation-directory
+ − 113 invocation-name)))
+ − 114 (executable-directory (file-name-directory executable-file-name))
+ − 115 (maybe-root-1 (file-name-as-directory
+ − 116 (paths-construct-path '("..") executable-directory)))
+ − 117 (maybe-root-2 (file-name-as-directory
+ − 118 (paths-construct-path '(".." "..") executable-directory))))
+ − 119 (or (and (paths-emacs-root-p maybe-root-1)
+ − 120 maybe-root-1)
+ − 121 (and (paths-emacs-root-p maybe-root-2)
+ − 122 maybe-root-2))))
+ − 123
2456
+ − 124 (defun paths-find-emacs-roots (invocation-directory
+ − 125 invocation-name
+ − 126 root-p)
1330
+ − 127 "Find all plausible installation roots for XEmacs.
+ − 128 This is a list of plausible directories in which to search for the important
+ − 129 directories used by XEmacs at run-time, for example `exec-directory',
+ − 130 `data-directory' and `lisp-directory'.
+ − 131 ROOT-P is a function that tests whether a root is plausible."
+ − 132 (let* ((potential-invocation-root
+ − 133 (paths-find-emacs-root invocation-directory invocation-name))
+ − 134 (invocation-roots
+ − 135 (and potential-invocation-root
+ − 136 (list potential-invocation-root)))
+ − 137 (potential-installation-roots
+ − 138 (paths-uniq-append
+ − 139 (and configure-exec-prefix-directory
+ − 140 (list (file-name-as-directory
+ − 141 configure-exec-prefix-directory)))
+ − 142 (and configure-prefix-directory
+ − 143 (list (file-name-as-directory
+ − 144 configure-prefix-directory)))))
+ − 145 (installation-roots
+ − 146 (paths-filter root-p potential-installation-roots)))
+ − 147 (paths-uniq-append invocation-roots
+ − 148 installation-roots)))
+ − 149
428
+ − 150 (defun paths-find-site-lisp-directory (roots)
2456
+ − 151 "Find the site Lisp directory of the XEmacs hierarchy.
+ − 152 ROOTS is a list of installation roots."
428
+ − 153 (paths-find-site-directory roots "site-lisp"
+ − 154 nil
+ − 155 configure-site-directory))
+ − 156
+ − 157 (defun paths-find-site-module-directory (roots)
2456
+ − 158 "Find the site modules directory of the XEmacs hierarchy.
+ − 159 ROOTS is a list of installation roots."
428
+ − 160 (paths-find-site-directory roots "site-modules"
+ − 161 nil
+ − 162 configure-site-module-directory))
+ − 163
+ − 164 (defun paths-find-lisp-directory (roots)
2456
+ − 165 "Find the main Lisp directory of the XEmacs hierarchy.
+ − 166 ROOTS is a list of installation roots."
428
+ − 167 (paths-find-version-directory roots "lisp"
+ − 168 nil
+ − 169 configure-lisp-directory))
+ − 170
460
+ − 171 (defun paths-find-mule-lisp-directory (roots &optional lisp-directory)
2456
+ − 172 "Find the Mule Lisp directory of the XEmacs hierarchy.
+ − 173 ROOTS is a list of installation roots."
460
+ − 174 ;; #### kludge
+ − 175 (if lisp-directory
+ − 176 (let ((guess
+ − 177 (file-name-as-directory
+ − 178 (paths-construct-path (list lisp-directory "mule")))))
+ − 179 (if (paths-file-readable-directory-p guess)
+ − 180 guess
+ − 181 (paths-find-version-directory roots "mule-lisp"
+ − 182 nil
+ − 183 configure-mule-lisp-directory)))))
+ − 184
428
+ − 185 (defun paths-find-module-directory (roots)
2456
+ − 186 "Find the main modules directory of the XEmacs hierarchy.
+ − 187 ROOTS is a list of installation roots."
428
+ − 188 (paths-find-architecture-directory roots "modules"
+ − 189 nil configure-module-directory))
+ − 190
+ − 191 (defun paths-construct-load-path
+ − 192 (roots early-package-load-path late-package-load-path last-package-load-path
+ − 193 lisp-directory
460
+ − 194 &optional site-lisp-directory mule-lisp-directory)
2456
+ − 195 "Construct the complete load path.
+ − 196 ROOTS is the list of installation roots.
+ − 197 EARLY-PACKAGE-LOAD-PATH, LATE-PACKAGE-LOAD-PATH, and LAST-PACKAGE-LOAD-PATH
+ − 198 are the load paths for the package hierarchies.
+ − 199 SITE-LISP-DIRECTORY and MULE-LISP-DIRECTORY are optional directories to be
+ − 200 included in the load path---SITE-LISP-DIRECTORY for the obsolete site-specific
+ − 201 Lisp files, and MULE-LISP-DIRECTORY for the Mule Lisp files, which exist
+ − 202 only in Mule installations."
428
+ − 203 (let* ((envvar-value (getenv "EMACSLOADPATH"))
+ − 204 (env-load-path
+ − 205 (and envvar-value
+ − 206 (paths-decode-directory-path envvar-value 'drop-empties)))
+ − 207 (site-lisp-load-path
+ − 208 (and site-lisp-directory
+ − 209 (paths-find-recursive-load-path (list site-lisp-directory)
452
+ − 210 paths-site-load-path-depth)))
460
+ − 211 (mule-lisp-load-path
+ − 212 (and mule-lisp-directory
+ − 213 (paths-find-recursive-load-path (list mule-lisp-directory)
+ − 214 paths-mule-load-path-depth)))
428
+ − 215 (lisp-load-path
+ − 216 (and lisp-directory
+ − 217 (paths-find-recursive-load-path (list lisp-directory)
452
+ − 218 paths-core-load-path-depth))))
428
+ − 219 (append env-load-path
+ − 220 early-package-load-path
+ − 221 site-lisp-load-path
+ − 222 late-package-load-path
460
+ − 223 mule-lisp-load-path
428
+ − 224 lisp-load-path
+ − 225 last-package-load-path)))
+ − 226
+ − 227 (defun paths-construct-module-load-path
+ − 228 (root module-directory &optional site-module-directory)
+ − 229 "Construct the modules load path."
+ − 230 (let* ((envvar-value (getenv "EMACSMODULEPATH"))
+ − 231 (env-module-path
+ − 232 (and envvar-value
+ − 233 (paths-decode-directory-path envvar-value 'drop-empties)))
+ − 234 (site-module-load-path
+ − 235 (and site-module-directory
+ − 236 (paths-find-recursive-load-path (list site-module-directory)
452
+ − 237 paths-site-load-path-depth)))
428
+ − 238 (module-load-path
+ − 239 (and module-directory
+ − 240 (paths-find-recursive-load-path (list module-directory)
452
+ − 241 paths-core-load-path-depth))))
2456
+ − 242 (append env-module-path
428
+ − 243 site-module-load-path
+ − 244 module-load-path)))
+ − 245
2456
+ − 246 (defun paths-construct-info-path (roots
+ − 247 early-package-hierarchies
+ − 248 late-package-hierarchies
+ − 249 last-package-hierarchies)
+ − 250 "Construct the info path.
+ − 251 ROOTS is the list of installation roots.
+ − 252 EARLY-PACKAGE-HIERARCHIES, LATE-PACKAGE-HIERARCHIES, and
+ − 253 LAST-PACKAGE-HIERARCHIES are lists of package hierarchy roots,
+ − 254 respectively."
428
+ − 255 (let ((info-path-envval (getenv "INFOPATH")))
+ − 256 (paths-uniq-append
+ − 257 (append
+ − 258 (let ((info-directory
+ − 259 (paths-find-version-directory roots "info"
+ − 260 nil
+ − 261 configure-info-directory)))
+ − 262 (and info-directory
+ − 263 (list info-directory)))
2456
+ − 264 (packages-find-package-info-path early-package-hierarchies)
+ − 265 (packages-find-package-info-path late-package-hierarchies)
+ − 266 (packages-find-package-info-path last-package-hierarchies)
428
+ − 267 (and info-path-envval
+ − 268 (paths-decode-directory-path info-path-envval 'drop-empties)))
+ − 269 (and (null info-path-envval)
+ − 270 (paths-uniq-append
+ − 271 (paths-directories-which-exist configure-info-path)
+ − 272 (paths-directories-which-exist paths-default-info-directories))))))
+ − 273
+ − 274 (defun paths-find-doc-directory (roots)
2456
+ − 275 "Find the documentation directory.
+ − 276 ROOTS is the list of installation roots."
428
+ − 277 (paths-find-architecture-directory roots "lib-src" nil configure-doc-directory))
+ − 278
+ − 279 (defun paths-find-exec-directory (roots)
2456
+ − 280 "Find the binary directory.
+ − 281 ROOTS is the list of installation roots."
428
+ − 282 (paths-find-architecture-directory roots "lib-src"
+ − 283 nil configure-exec-directory))
+ − 284
+ − 285 (defun paths-construct-exec-path (roots exec-directory
2456
+ − 286 early-package-hierarchies
+ − 287 late-package-hierarchies
+ − 288 last-package-hierarchies)
+ − 289 "Find the binary path.
+ − 290 ROOTS is the list of installation roots.
+ − 291 EARLY-PACKAGE-HIERARCHIES, LATE-PACKAGE-HIERARCHIES, and
+ − 292 LAST-PACKAGE-HIERARCHIES are lists of package hierarchy roots,
+ − 293 respectively.
+ − 294 EXEC-DIRECTORY is the directory of architecture-dependent files that
+ − 295 come with XEmacs.
+ − 296 EARLY-PACKAGES, LATE-PACKAGES, and LAST-PACKAGES are lists of
+ − 297 package hierarchy roots, respectively."
428
+ − 298 (append
+ − 299 (let ((path-envval (getenv "PATH")))
+ − 300 (if path-envval
+ − 301 (paths-decode-directory-path path-envval 'drop-empties)))
2456
+ − 302 (packages-find-package-exec-path early-package-hierarchies)
+ − 303 (packages-find-package-exec-path late-package-hierarchies)
428
+ − 304 (let ((emacspath-envval (getenv "EMACSPATH")))
+ − 305 (and emacspath-envval
+ − 306 (split-path emacspath-envval)))
+ − 307 (and exec-directory
+ − 308 (list exec-directory))
2456
+ − 309 (packages-find-package-exec-path last-package-hierarchies)))
428
+ − 310
+ − 311 (defun paths-find-data-directory (roots)
2456
+ − 312 "Find the data directory.
+ − 313 ROOTS is the list of installation roots."
428
+ − 314 (paths-find-version-directory roots "etc" "EMACSDATA" configure-data-directory))
+ − 315
+ − 316 (defun paths-construct-data-directory-list (data-directory
2456
+ − 317 early-package-hierarchies
+ − 318 late-package-hierarchies
+ − 319 last-package-hierarchies)
+ − 320 "Construct the data path.
+ − 321 DATA-DIRECTORY is the data directory of the XEmacs installation.
+ − 322 EARLY-PACKAGE-HIERARCHIES, LATE-PACKAGE-HIERARCHIES, and
+ − 323 LAST-PACKAGE-HIERARCHIES are lists of package hierarchy roots,
+ − 324 respectively."
428
+ − 325 (append
2456
+ − 326 (packages-find-package-data-path early-package-hierarchies)
+ − 327 (packages-find-package-data-path late-package-hierarchies)
428
+ − 328 (list data-directory)
2456
+ − 329 (packages-find-package-data-path last-package-hierarchies)))
1330
+ − 330
428
+ − 331 ;;; setup-paths.el ends here