1 ;;; install.el --- Emacs Lisp package install utility
3 ;; Copyright (C) 1996 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Version: $Id: install.el,v 2.1 1996/09/04 13:57:50 morioka Exp $
10 ;; This file is part of tl (Tiny Library).
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.
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.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with this program; see the file COPYING. If not, write to
24 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
30 (require 'file-detect)
32 ;;; @ compile Emacs Lisp files
35 (defun compile-elisp-module (module &optional path every-time)
36 (setq module (expand-file-name (symbol-name module) path))
37 (let ((el-file (concat module ".el"))
38 (elc-file (concat module ".elc"))
41 (file-newer-than-file-p el-file elc-file))
42 (byte-compile-file el-file)
46 (defun compile-elisp-modules (modules &optional path every-time)
49 (compile-elisp-module module path every-time)
57 (defvar install-overwritten-file-modes (+ (* 64 6)(* 8 4) 4))
59 (defun install-file (file src dest &optional move overwrite)
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)
64 (set-file-modes full-path install-overwritten-file-modes)
66 (copy-file src-file full-path t t)
69 (while (and (file-exists-p src-file)
70 (file-writable-p src-file))
73 (delete-file src-file)
76 (error (princ (format "%s\n" (nth 1 err))))
78 (princ (format "%s -> %s\n" file dest))
82 (defun install-files (files src dest &optional move overwrite)
83 (or (file-exists-p dest)
84 (make-directory dest t)
86 (mapcar (function (lambda (file)
87 (install-file file src dest move overwrite)
92 ;;; @@ install Emacs Lisp files
95 (defun install-elisp-module (module src dest)
96 (let (el-file elc-file)
97 (let ((name (symbol-name module)))
98 (setq el-file (concat name ".el"))
99 (setq elc-file (concat name ".elc"))
101 (let ((src-file (expand-file-name el-file src)))
102 (if (file-exists-p src-file)
103 (let ((full-path (expand-file-name el-file dest)))
104 (if (file-exists-p full-path)
105 (set-file-modes full-path install-overwritten-file-modes)
107 (copy-file src-file full-path t t)
108 (princ (format "%s -> %s\n" el-file dest))
110 (setq src-file (expand-file-name elc-file src))
111 (if (file-exists-p src-file)
112 (let ((full-path (expand-file-name elc-file dest)))
113 (copy-file src-file full-path t t)
115 (while (file-exists-p src-file)
118 (delete-file src-file)
121 (error (princ (format "%s\n" (nth 1 err))))
123 (princ (format "%s -> %s\n" elc-file dest))
127 (defun install-elisp-modules (modules src dest)
128 (or (file-exists-p dest)
129 (make-directory dest t)
131 (mapcar (function (lambda (module)
132 (install-elisp-module module src dest)
137 ;;; @ detect install path
140 (defvar install-prefix
141 (if (or running-emacs-18 running-xemacs)
142 (expand-file-name "../../.." exec-directory)
143 (expand-file-name "../../../.." data-directory)
144 )) ; install to shared directory (maybe "/usr/local")
146 (defvar install-elisp-prefix
147 (if (>= emacs-major-version 19)
151 (defun install-detect-elisp-directory (&optional prefix elisp-prefix)
153 (setq prefix install-prefix)
156 (setq elisp-prefix install-elisp-prefix)
160 (let ((rest default-load-path)
162 (while (setq dir (car rest))
165 (expand-file-name (concat ".*/" elisp-prefix) prefix)
168 (or (string-match (format "%d\\.%d"
170 emacs-minor-version) dir)
173 (setq rest (cdr rest))
175 (expand-file-name (concat
176 (if running-emacs-19_29-or-later
179 (cond ((boundp 'NEMACS) "nemacs/")
180 ((boundp 'MULE) "mule/")
186 elisp-prefix) prefix)
189 (defvar install-default-elisp-directory
190 (install-detect-elisp-directory))
198 ;;; install.el ends here