Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 313 lines (268 sloc) 9.61 kb
e4619ab Initial revision
morioka authored
1 ;;; install.el --- Emacs Lisp package install utility
2
ad6c730 (install-get-default-package-directory): New function.
tomo authored
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2006
4 ;; Free Software Foundation, Inc.
e4619ab Initial revision
morioka authored
5
ad6c730 (install-get-default-package-directory): New function.
tomo authored
6 ;; Author: MORIOKA Tomohiko <tomo@m17n.org>
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
7 ;; Created: 1996/08/18
8 ;; Keywords: install, byte-compile, directory detection
e4619ab Initial revision
morioka authored
9
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
10 ;; This file is part of APEL (A Portable Emacs Library).
e4619ab Initial revision
morioka authored
11
12 ;; This program is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 2, or (at
15 ;; your option) any later version.
16
17 ;; This program is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
23 ;; along with GNU Emacs; see the file COPYING. If not, write to
eefe87e Update FSF's address in GPL notices.
yamaoka authored
24 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
e4619ab Initial revision
morioka authored
26
27 ;;; Code:
28
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
29 (require 'poe) ; make-directory for v18
30 (require 'path-util) ; default-load-path
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
31
32
33 ;;; @ compile Emacs Lisp files
34 ;;;
35
e4619ab Initial revision
morioka authored
36 (defun compile-elisp-module (module &optional path every-time)
37 (setq module (expand-file-name (symbol-name module) path))
38 (let ((el-file (concat module ".el"))
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
39 (elc-file (concat module ".elc")))
e4619ab Initial revision
morioka authored
40 (if (or every-time
41 (file-newer-than-file-p el-file elc-file))
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
42 (byte-compile-file el-file))))
e4619ab Initial revision
morioka authored
43
44 (defun compile-elisp-modules (modules &optional path every-time)
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
45 (mapcar
46 (function
47 (lambda (module)
48 (compile-elisp-module module path every-time)))
49 modules))
e4619ab Initial revision
morioka authored
50
51
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
52 ;;; @ install files
53 ;;;
54
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
55 (defvar install-overwritten-file-modes (+ (* 64 6)(* 8 4) 4)) ; 0644
e4619ab Initial revision
morioka authored
56
2073495 Merge apel-mcs-2-9_12_2.
morioka authored
57 (defun install-file (file src dest &optional move overwrite just-print)
58 (if just-print
59 (princ (format "%s -> %s\n" file dest))
60 (let ((src-file (expand-file-name file src)))
61 (if (file-exists-p src-file)
62 (let ((full-path (expand-file-name file dest)))
63 (if (and (file-exists-p full-path) overwrite)
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
64 (delete-file full-path))
2073495 Merge apel-mcs-2-9_12_2.
morioka authored
65 (copy-file src-file full-path t t)
8ef115e * install.el (install-file, install-elisp-module): Set file modes
minakaji authored
66 (set-file-modes full-path install-overwritten-file-modes)
2073495 Merge apel-mcs-2-9_12_2.
morioka authored
67 (if move
68 (catch 'tag
69 (while (and (file-exists-p src-file)
70 (file-writable-p src-file))
71 (condition-case err
72 (progn
73 (delete-file src-file)
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
74 (throw 'tag nil))
75 (error (princ (format "%s\n" (nth 1 err))))))))
76 (princ (format "%s -> %s\n" file dest)))))))
e4619ab Initial revision
morioka authored
77
2073495 Merge apel-mcs-2-9_12_2.
morioka authored
78 (defun install-files (files src dest &optional move overwrite just-print)
f73e279 * install.el (install-files): Do not make DEST directory when
minakaji authored
79 (or just-print
80 (file-exists-p dest)
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
81 (make-directory dest t))
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
82 (mapcar
83 (function
84 (lambda (file)
85 (install-file file src dest move overwrite just-print)))
86 files))
e4619ab Initial revision
morioka authored
87
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
88
89 ;;; @@ install Emacs Lisp files
90 ;;;
91
ec576d5 * install.el (install-elisp-module): Delete an elc file if the optional ...
yamaoka authored
92 (defun install-elisp-module (module src dest &optional just-print del-elc)
e4619ab Initial revision
morioka authored
93 (let (el-file elc-file)
94 (let ((name (symbol-name module)))
95 (setq el-file (concat name ".el"))
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
96 (setq elc-file (concat name ".elc")))
e4619ab Initial revision
morioka authored
97 (let ((src-file (expand-file-name el-file src)))
2073495 Merge apel-mcs-2-9_12_2.
morioka authored
98 (if (not (file-exists-p src-file))
99 nil
100 (if just-print
101 (princ (format "%s -> %s\n" el-file dest))
e4619ab Initial revision
morioka authored
102 (let ((full-path (expand-file-name el-file dest)))
103 (if (file-exists-p full-path)
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
104 (delete-file full-path))
e4619ab Initial revision
morioka authored
105 (copy-file src-file full-path t t)
8ef115e * install.el (install-file, install-elisp-module): Set file modes
minakaji authored
106 (set-file-modes full-path install-overwritten-file-modes)
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
107 (princ (format "%s -> %s\n" el-file dest)))))
e4619ab Initial revision
morioka authored
108 (setq src-file (expand-file-name elc-file src))
2073495 Merge apel-mcs-2-9_12_2.
morioka authored
109 (if (not (file-exists-p src-file))
ec576d5 * install.el (install-elisp-module): Delete an elc file if the optional ...
yamaoka authored
110 (let ((full-path (expand-file-name elc-file dest)))
111 (if (and del-elc (file-exists-p full-path))
112 (if just-print
113 (princ (format "%s -> to be deleted\n" full-path))
114 (delete-file full-path)
115 (princ (format "%s -> deleted\n" full-path)))))
2073495 Merge apel-mcs-2-9_12_2.
morioka authored
116 (if just-print
117 (princ (format "%s -> %s\n" elc-file dest))
e4619ab Initial revision
morioka authored
118 (let ((full-path (expand-file-name elc-file dest)))
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
119 (if (file-exists-p full-path)
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
120 (delete-file full-path))
e4619ab Initial revision
morioka authored
121 (copy-file src-file full-path t t)
8ef115e * install.el (install-file, install-elisp-module): Set file modes
minakaji authored
122 (set-file-modes full-path install-overwritten-file-modes)
e4619ab Initial revision
morioka authored
123 (catch 'tag
124 (while (file-exists-p src-file)
125 (condition-case err
126 (progn
127 (delete-file src-file)
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
128 (throw 'tag nil))
129 (error (princ (format "%s\n" (nth 1 err)))))))
130 (princ (format "%s -> %s\n" elc-file dest))))))))
e4619ab Initial revision
morioka authored
131
ec576d5 * install.el (install-elisp-module): Delete an elc file if the optional ...
yamaoka authored
132 (defun install-elisp-modules (modules src dest &optional just-print del-elc)
96932b2 * install.el (install-elisp-modules): Do not make DEST directory
minakaji authored
133 (or just-print
134 (file-exists-p dest)
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
135 (make-directory dest t))
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
136 (mapcar
137 (function
138 (lambda (module)
ec576d5 * install.el (install-elisp-module): Delete an elc file if the optional ...
yamaoka authored
139 (install-elisp-module module src dest just-print del-elc)))
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
140 modules))
e4619ab Initial revision
morioka authored
141
142
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
143 ;;; @ detect install path
144 ;;;
145
7660cee (install-prefix): Check whether `system-configuration-options' is
shuhei-k authored
146 ;; install to shared directory (maybe "/usr/local")
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
147 (defvar install-prefix
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
148 (if (or (<= emacs-major-version 18)
149 (featurep 'xemacs)
cc7a836 * install.el (install-prefix): Change value for Meadow2 and NTEmacs.
teranisi authored
150 (featurep 'meadow) ; for Meadow
151 (and (eq system-type 'windows-nt) ; for NTEmacs
e609b91 @ikazuhiro install.el (install-prefix): Minor refactoring.
ikazuhiro authored
152 (>= emacs-major-version 20)
153 ;; Exclude the case that built by running the same
154 ;; configure script as on all other platforms.
155 (equal (file-name-nondirectory
156 (expand-file-name "." exec-directory))
157 "bin")
158 ))
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
159 (expand-file-name "../../.." exec-directory)
7660cee (install-prefix): Check whether `system-configuration-options' is
shuhei-k authored
160 (expand-file-name "../../../.." data-directory)))
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
161
162 (defvar install-elisp-prefix
163 (if (>= emacs-major-version 19)
164 "site-lisp"
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
165 ;; v18 does not have standard site directory.
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
166 "local.lisp"))
167
e7259bc Synch with APEL XEmacs package 1.32.
yamaoka authored
168 ;; Avoid compile warning.
169 (eval-when-compile (autoload 'replace-in-string "subr"))
170
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
171 (defun install-detect-elisp-directory (&optional prefix elisp-prefix
172 allow-version-specific)
173 (or prefix
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
174 (setq prefix install-prefix))
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
175 (or elisp-prefix
81e81fc Require 'poe instead of 'emu.
shuhei-k authored
176 (setq elisp-prefix install-elisp-prefix))
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
177 (or (catch 'tag
e7259bc Synch with APEL XEmacs package 1.32.
yamaoka authored
178 (let ((rest (delq nil (copy-sequence default-load-path)))
179 (regexp
180 (concat "^"
181 (regexp-quote (if (featurep 'xemacs)
182 ;; Handle backslashes (Windows)
183 (replace-in-string
184 (file-name-as-directory
185 (expand-file-name prefix))
186 "\\\\" "/")
187 (file-name-as-directory
188 (expand-file-name prefix))))
189 ".*/"
190 (regexp-quote
191 (if (featurep 'xemacs)
192 ;; Handle backslashes (Windows)
193 (replace-in-string elisp-prefix "\\\\" "/")
194 elisp-prefix))
195 "/?$"))
196 dir)
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
197 (while rest
e7259bc Synch with APEL XEmacs package 1.32.
yamaoka authored
198 (setq dir (if (featurep 'xemacs)
199 ;; Handle backslashes (Windows)
200 (replace-in-string (car rest) "\\\\" "/")
201 (car rest)))
202 (if (string-match regexp dir)
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
203 (if (or allow-version-specific
204 (not (string-match (format "/%d\\.%d"
205 emacs-major-version
206 emacs-minor-version)
e7259bc Synch with APEL XEmacs package 1.32.
yamaoka authored
207 dir)))
8a6c2da Removed v18 stuff; now we require 'poe.
shuhei authored
208 (throw 'tag (car rest))))
209 (setq rest (cdr rest)))))
210 (expand-file-name (concat (if (and (not (featurep 'xemacs))
211 (or (>= emacs-major-version 20)
212 (and (= emacs-major-version 19)
213 (> emacs-minor-version 28))))
214 "share/"
215 "lib/")
216 (cond
217 ((featurep 'xemacs)
218 (if (featurep 'mule)
219 "xmule/"
220 "xemacs/"))
221 ;; unfortunately, unofficial mule based on
222 ;; 19.29 and later use "emacs/" by default.
223 ((boundp 'MULE) "mule/")
224 ((boundp 'NEMACS) "nemacs/")
225 (t "emacs/"))
226 elisp-prefix)
227 prefix)))
2390124 (install-detect-elisp-directory): Modify regexp to allow trailing `/'.
morioka authored
228
229 (defvar install-default-elisp-directory
230 (install-detect-elisp-directory))
231
232
da7b296 (install-update-package-files): New function [moved from APEL-MK].
tomo authored
233 ;;; @ for XEmacs package system
234 ;;;
235
ad6c730 (install-get-default-package-directory): New function.
tomo authored
236 (defun install-get-default-package-directory ()
237 (let ((dirs (append
238 (cond
239 ((boundp 'early-package-hierarchies)
240 (append (if early-package-load-path
241 early-package-hierarchies)
242 (if late-package-load-path
243 late-package-hierarchies)
244 (if last-package-load-path
245 last-package-hierarchies)) )
246 ((boundp 'early-packages)
247 (append (if early-package-load-path
248 early-packages)
249 (if late-package-load-path
250 late-packages)
251 (if last-package-load-path
252 last-packages)) ))
253 (if (and (boundp 'configure-package-path)
254 (listp configure-package-path))
255 (delete "" configure-package-path))))
256 dir)
257 (while (and (setq dir (car dirs))
258 (not (file-exists-p dir)))
259 (setq dirs (cdr dirs)))
260 dir))
261
da7b296 (install-update-package-files): New function [moved from APEL-MK].
tomo authored
262 (defun install-update-package-files (package dir &optional just-print)
263 (cond
264 (just-print
265 (princ (format "Updating autoloads in directory %s..\n\n" dir))
266
267 (princ (format "Processing %s\n" dir))
268 (princ "Generating custom-load.el...\n\n")
269
270 (princ (format "Compiling %s...\n"
271 (expand-file-name "auto-autoloads.el" dir)))
272 (princ (format "Wrote %s\n"
273 (expand-file-name "auto-autoloads.elc" dir)))
274
275 (princ (format "Compiling %s...\n"
276 (expand-file-name "custom-load.el" dir)))
277 (princ (format "Wrote %s\n"
278 (expand-file-name "custom-load.elc" dir))))
279 (t
604f9f3 (install-update-package-files): Use batch-update-directory-autoloads if ...
yamaoka authored
280 (if (fboundp 'batch-update-directory-autoloads)
281 ;; XEmacs 21.5.19 and newer.
282 (let ((command-line-args-left (list package dir)))
283 (batch-update-directory-autoloads))
284 (setq autoload-package-name package)
285 (let ((command-line-args-left (list dir)))
286 (batch-update-directory)))
da7b296 (install-update-package-files): New function [moved from APEL-MK].
tomo authored
287
288 (let ((command-line-args-left (list dir)))
289 (Custom-make-dependencies))
290
291 (byte-compile-file (expand-file-name "auto-autoloads.el" dir))
292 (byte-compile-file (expand-file-name "custom-load.el" dir)))))
293
294
295 ;;; @ Other Utilities
296 ;;;
297
298 (defun install-just-print-p ()
299 (let ((flag (getenv "MAKEFLAGS"))
300 (case-fold-search nil))
301 (princ (format "%s\n" flag))
302 (if flag
303 (string-match "^\\(\\(--[^ ]+ \\)+-\\|[^ =-]\\)*n" flag))))
304
305
e4619ab Initial revision
morioka authored
306 ;;; @ end
307 ;;;
308
d52455a Add product information.
keiichi authored
309 (require 'product)
310 (product-provide (provide 'install) (require 'apel-ver))
e4619ab Initial revision
morioka authored
311
312 ;;; install.el ends here
Something went wrong with that request. Please try again.