2 ;;; WL-MK for byte-compile, install, uninstall
4 ;;; Original by OKUNISHI Fujikazu <fuji0924@mbox.kyoto-inet.or.jp>
5 ;;; Modified by Yuuichi Teranishi <teranisi@gohome.org>
7 ;;;;;;;;;;;;;;;;;;;;; DO NOT EDIT THIS FILE ;;;;;;;;;;;;;;;;;;;;;
8 ;;;;;;;;;;;;;;;;;;;;; INTERNAL USE ONLY ;;;;;;;;;;;;;;;;;;;;;
13 (defvar ELMODIR "./elmo")
14 (defvar DOCDIR "./doc")
15 (defvar ICONDIR "./etc/icons")
16 (defvar UTILSDIR "./utils")
17 (defvar SASLDIR "./utils/sasl/lisp")
18 (defvar WL_PREFIX "wl")
19 (defvar ELMO_PREFIX "wl")
21 (defvar COMPRESS-SUFFIX-LIST '("" ".gz" ".Z" ".bz2"))
23 (defvar wl-install-utils nil
24 "if Non-nil, install `wl-utils-modules'.")
25 (defvar wl-install-sasl nil
26 "if Non-nil, install sasl utilities.")
29 (defconst wl-ja-info "wl-ja.info")
30 (defconst wl-ja-texi "wl-ja.texi")
31 (defconst wl-en-info "wl.info")
32 (defconst wl-en-texi "wl.texi")
34 (defvar wl-info-lang "ja"
35 "The language of info file (\"ja\" or \"en\").")
37 ;; for Nemacs (dirty!)
38 (or (fboundp 'file-executable-p)
39 (fset 'file-executable-p 'file-exists-p))
41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46 (condition-case () (require 'custom) (error nil))
48 (unless (and (fboundp 'defgroup)
50 ;; ignore broken module
51 (not (featurep 'tinycustom)))
53 (defmacro defgroup (&rest args))
54 (defmacro defcustom (symbol value &optional doc &rest args)
55 (let ((doc (concat "*" (or doc ""))))
56 (` (defvar (, symbol) (, value) (, doc)))))
59 (setq byte-compile-warnings '(free-vars unresolved callargs redefine))
62 (if (or (boundp 'MULE)
63 (fboundp 'nemacs-version))
64 (setq max-lisp-eval-depth 400))
66 (condition-case () (require 'easymenu) (error nil))
68 (defvar config-wl-package-done nil)
70 (defun config-wl-package-subr ()
71 (unless config-wl-package-done
72 (setq config-wl-package-done t)
73 (setq load-path (cons (expand-file-name ".") load-path))
74 (setq load-path (cons (expand-file-name WLDIR)
75 (cons (expand-file-name ELMODIR) load-path)))
76 (setq wl-icon-dir (expand-file-name ICONDIR))
77 ;;; load custom file if exists.
78 (load "./WL-CFG" t nil t)
81 (setq load-path (cons (expand-file-name UTILSDIR) load-path)))
83 (setq load-path (cons (expand-file-name SASLDIR) load-path)))
88 (error (error "No MIME module was detected. Please install SEMI or tm.")))
90 (princ (concat "\nUse SEMI"
91 (if wl-use-luna " with LUNA\n" " without LUNA\n")))
92 (princ "\nUse tm.\n"))))
94 (defun config-wl-package ()
95 (config-wl-package-subr)
97 (let ((elispdir (car command-line-args-left)))
98 (if (string= elispdir "NONE")
99 (defvar LISPDIR (install-detect-elisp-directory))
100 (defvar LISPDIR elispdir)))
101 (princ (format "LISPDIR is %s\n\n" LISPDIR))
102 (setq command-line-args-left (cdr command-line-args-left)))
105 (defun wl-scan-source (path)
110 (setq ret (append (list y (concat y "c")) ret)))
111 (directory-files x nil "\\(.+\\)\\.el$" t)))
116 (defun wl-uninstall (objs path)
117 ;(message (mapconcat 'identity objs " "))
120 (let ((filename (expand-file-name x path)))
121 (if (and (file-exists-p filename)
122 (file-writable-p filename))
124 (princ (format "%s was uninstalled.\n" filename))
125 (delete-file filename)))))
129 (defun compile-wl-package ()
130 ;; For nemacs byte compiler's strange behavior(?).
132 (if (fboundp 'nemacs-version)
133 (load (expand-file-name "wl.el" WLDIR)))
136 (compile-elisp-modules (cdr x) (car x)))
139 (defun install-wl-package ()
141 (let ((wl-install-dir (expand-file-name WL_PREFIX LISPDIR))
142 (elmo-install-dir (expand-file-name ELMO_PREFIX LISPDIR)))
145 (install-elisp-modules (cdr x) (car x)
146 (if (string= (car x) ELMODIR)
152 (defun uninstall-wl-package ()
154 (let ((wl-install-dir (expand-file-name WL_PREFIX
156 (elmo-install-dir (expand-file-name ELMO_PREFIX
158 (wl-uninstall (wl-scan-source (list WLDIR UTILSDIR SASLDIR))
160 (wl-uninstall (wl-scan-source (list ELMODIR))
165 (defun config-wl-package-xmas ()
166 (if (not (featurep 'xemacs))
167 (error "This directive is only for XEmacs."))
168 (config-wl-package-subr)
171 (and (setq package-dir (car command-line-args-left))
172 (if (string= "NONE" package-dir)
174 (if (boundp 'early-packages)
175 (let ((dirs (append (if early-package-load-path
177 (if late-package-load-path
179 (if last-package-load-path
182 (while (not (file-exists-p
183 (setq dir (car dirs))))
184 (setq dirs (cdr dirs)))
186 (defvar PACKAGEDIR package-dir)))
187 (princ (format "PACKAGEDIR is %s\n\n" PACKAGEDIR))
188 (setq command-line-args-left (cdr command-line-args-left))))
191 (defun compile-wl-package-xmas ()
192 (config-wl-package-xmas)
193 (setq autoload-package-name "wl")
194 (add-to-list 'command-line-args-left WLDIR)
195 (batch-update-directory)
196 (add-to-list 'command-line-args-left WLDIR)
197 (Custom-make-dependencies)
198 ;; WL-AUTOLOAD-MODULES
199 (compile-elisp-modules WL-AUTOLOAD-MODULES WLDIR)
202 (compile-elisp-modules (cdr x) (car x)))
205 (defun install-wl-package-xmas ()
206 (compile-wl-package-xmas)
207 (let ((LISPDIR (expand-file-name "wl"
208 (expand-file-name "lisp"
210 (DATADIR (expand-file-name "wl"
211 (expand-file-name "etc"
213 (INFODIR (expand-file-name "info" PACKAGEDIR)))
214 (or (file-exists-p DATADIR)
215 (make-directory DATADIR t))
216 (or (file-exists-p INFODIR)
217 (make-directory INFODIR t))
220 (let* ((src-file-nondirectory (file-name-nondirectory x))
221 (dst-file (expand-file-name src-file-nondirectory
223 (princ (format "%s->%s\n"
226 (copy-file x dst-file t)))
227 (directory-files "etc/icons" t "xpm"))
229 (install-elisp-modules (cdr x) (car x) LISPDIR))
231 ;; WL-AUTOLOAD-MODULES
232 (install-elisp-modules WL-AUTOLOAD-MODULES WLDIR LISPDIR)
235 (wl-texinfo-install)))
238 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
241 (defun wl-texinfo-format-file (lang)
242 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang))))
243 (texifile (symbol-value (intern (format "wl-%s-texi" lang)))))
244 (require 'wl-vars) ;; for 'wl-cs-local
245 (or (file-newer-than-file-p (expand-file-name infofile DOCDIR)
246 (expand-file-name texifile DOCDIR))
248 ;; Support old texinfmt.el
249 (require 'ptexinfmt (expand-file-name "ptexinfmt.el" UTILSDIR))
250 (find-file (expand-file-name texifile DOCDIR))
251 (setq obuf (current-buffer))
252 ;; We can't know file names if splitted.
253 (texinfo-format-buffer t)
254 ;; Emacs20.2's default is 'raw-text-unix.
255 (and (fboundp 'set-buffer-file-coding-system)
256 (set-buffer-file-coding-system wl-cs-local))
258 (kill-buffer (current-buffer)) ;; info
259 (kill-buffer obuf)) ;; texi
262 (defun wl-texinfo-format ()
264 (setq INFODIR (wl-detect-info-directory)))
265 (cond ((listp wl-info-lang)
266 (mapcar 'wl-texinfo-format-file wl-info-lang))
267 ((stringp wl-info-lang)
268 (wl-texinfo-format-file wl-info-lang))))
270 (defun wl-texinfo-install-file (lang)
271 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang)))))
272 (install-file infofile DOCDIR INFODIR)))
274 (defun wl-texinfo-install ()
275 (cond ((listp wl-info-lang)
276 (mapcar 'wl-texinfo-install-file wl-info-lang))
277 ((stringp wl-info-lang)
278 (wl-texinfo-install-file wl-info-lang))))
280 (defun wl-primary-info-file ()
281 "Get primary info file (for wl-detect-info-directory)."
283 ((listp wl-info-lang)
284 (let ((wl-info-lang (car wl-info-lang)))
285 (wl-primary-info-file)))
286 ((stringp wl-info-lang)
287 (symbol-value (intern (format "wl-%s-info" wl-info-lang))))))
289 (defun wl-detect-info-directory ()
290 (config-wl-package-subr)
291 (if (fboundp 'nemacs-version)
292 (error "Cannot format info on Nemacs. Please use another formatter."))
295 (let ((infodir (car command-line-args-left))
296 (info (wl-primary-info-file))
299 (if (string= infodir "NONE")
301 (exec-installed-p info Info-directory-list
302 COMPRESS-SUFFIX-LIST))
304 ;;(condition-case nil (delete-file previous))
305 (directory-file-name (file-name-directory previous));)
306 (car Info-directory-list))
308 (setq command-line-args-left (cdr command-line-args-left))
309 (princ (format "INFODIR is %s\n\n" INFODIR))
312 (defun install-wl-info ()
314 (wl-texinfo-install))
318 ;;; * MORE refine code (^_^;