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 WL_PREFIX "wl")
18 (defvar ELMO_PREFIX "wl")
20 (defvar COMPRESS-SUFFIX-LIST '("" ".gz" ".Z" ".bz2"))
22 (defvar wl-install-utils nil
23 "If Non-nil, install `wl-utils-modules'.")
26 (defconst wl-ja-info "wl-ja.info")
27 (defconst wl-ja-texi "wl-ja.texi")
28 (defconst wl-en-info "wl.info")
29 (defconst wl-en-texi "wl.texi")
31 (defvar wl-info-lang '("ja" "en")
32 "The language of info file (\"ja\" or \"en\").")
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
39 (condition-case () (require 'custom) (error nil))
41 (unless (and (fboundp 'defgroup)
43 ;; ignore broken module
44 (not (featurep 'tinycustom)))
45 (when (and (boundp 'emacs-major-version)
46 (= emacs-major-version 19)
47 (>= emacs-minor-version 29))
49 Warning: You don't seem to have \"new custom\" package installed.
50 See README file of APEL package for more information.
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))))))
58 (load "bytecomp" nil t)
60 (unless (fboundp 'byte-compile-file-form-custom-declare-variable)
61 ;; Bind defcustom'ed variables.
62 (put 'custom-declare-variable 'byte-hunk-handler
63 'byte-compile-file-form-custom-declare-variable)
64 (defun byte-compile-file-form-custom-declare-variable (form)
65 (if (memq 'free-vars byte-compile-warnings)
66 (setq byte-compile-bound-variables
67 (cons (nth 1 (nth 1 form)) byte-compile-bound-variables)))
72 (wrong-number-of-arguments
73 ;; Optimize byte code for `char-after'.
74 (put 'char-after 'byte-optimizer 'byte-optimize-char-after)
75 (defun byte-optimize-char-after (form)
80 (setq byte-compile-warnings '(free-vars unresolved callargs redefine))
84 (setq max-lisp-eval-depth 400))
86 ;; FIXME: it is currently needed to byte-compile with Emacs 21.
87 (setq recursive-load-depth-limit nil)
89 (condition-case () (require 'easymenu) (error nil))
91 (defvar config-wl-package-done nil)
93 (defun config-wl-package-subr ()
94 (unless config-wl-package-done
95 (setq config-wl-package-done t)
96 (setq load-path (cons (expand-file-name ".") load-path))
97 (setq load-path (cons (expand-file-name WLDIR)
98 (cons (expand-file-name ELMODIR) load-path)))
99 ;; load custom file if exists. `WL-CFG.el' override for committer.
100 (load "./WL-CFG" t nil nil)
103 (setq load-path (cons (expand-file-name UTILSDIR) load-path)))
105 (load "./WL-ELS" nil nil t)
106 ;; product.el version check
108 (if (not (fboundp 'product-version-as-string))
109 (error "Please install new APEL. See INSTALL or INSTALL.ja"))
110 ;; smtp.el version check.
112 (if (not (fboundp 'smtp-send-buffer))
113 (error "Please install new FLIM. See INSTALL or INSTALL.ja"))
115 (require 'mime-setup)
116 (error (error "Cannot load `mime-setup'. Please install SEMI")))))
118 (defun config-wl-pixmap-dir (&optional packagedir)
119 "Examine pixmap directory where icon files should go."
120 (let ((pixmap-dir (car command-line-args-left)))
122 (if (string= pixmap-dir "NONE")
124 (expand-file-name "etc/wl/" packagedir)
125 (expand-file-name "wl/icons/" data-directory))
128 (princ (format "PIXMAPDIR is %s\n" PIXMAPDIR)))
129 (setq command-line-args-left (cdr command-line-args-left)))
131 (defun config-wl-package ()
132 (config-wl-package-subr)
134 (let ((elispdir (car command-line-args-left)))
135 (if (string= elispdir "NONE")
136 (defvar LISPDIR (install-detect-elisp-directory))
137 (defvar LISPDIR elispdir)))
138 (princ (format "LISPDIR is %s\n" LISPDIR))
139 (setq command-line-args-left (cdr command-line-args-left))
141 (config-wl-pixmap-dir)
144 (defun update-version ()
145 "Update version number of documents."
147 (load-file "elmo/elmo-version.el")
148 (let ((version (mapconcat
150 (product-version (product-find 'elmo-version))
152 (princ (concat "Update version number to " version "\n"))
153 ;; generate version.tex
155 (insert "\\def\\versionnumber{" version "}\n")
156 (write-region (point-min) (point-max) (expand-file-name
157 "version.tex" "doc")))
158 ;; generate version.texi
160 (insert "@set VERSION " version "\n")
161 (write-region (point-min) (point-max) (expand-file-name
162 "version.texi" "doc")))))
165 "Run test suite for developer."
168 (let ((files (directory-files "tests" t "^test-.*\\.el$"))
169 (suite (lunit-make-test-suite)))
171 (if (file-regular-p (car files))
173 (load-file (car files))
174 (lunit-test-suite-add-test
175 suite (lunit-make-test-suite-from-class
176 (intern (file-name-sans-extension
177 (file-name-nondirectory (car files))))))))
178 (setq files (cdr files)))
182 "Check user environment. Not for developer."
185 (let ((files (directory-files "tests" t "^check-.*\\.el$"))
186 (suite (lunit-make-test-suite)))
188 (if (file-regular-p (car files))
190 (load-file (car files))
191 (lunit-test-suite-add-test
192 suite (lunit-make-test-suite-from-class
193 (intern (file-name-sans-extension
194 (file-name-nondirectory (car files))))))))
195 (setq files (cdr files)))
198 (defun wl-scan-source (path)
203 (setq ret (append (list y (concat y "c")) ret)))
204 (directory-files x nil "\\(.+\\)\\.el$" t)))
209 (defun wl-uninstall (objs path)
210 ;(message (mapconcat 'identity objs " "))
213 (let ((filename (expand-file-name x path)))
214 (if (and (file-exists-p filename)
215 (file-writable-p filename))
217 (princ (format "%s was uninstalled.\n" filename))
218 (delete-file filename)))))
222 (defun compile-wl-package ()
226 (compile-elisp-modules (cdr x) (car x)))
229 (defun install-wl-icons ()
230 (if (not (file-directory-p PIXMAPDIR))
231 (make-directory PIXMAPDIR t))
232 (let* ((case-fold-search t)
233 (icons (directory-files ICONDIR t
234 (cond ((featurep 'xemacs)
236 ((and (boundp 'emacs-major-version)
237 (>= emacs-major-version 21))
238 "\\.img$\\|\\.x[bp]m$")
240 "\\.img$\\|\\.xbm$"))))
243 (setq icon (car icons)
245 dest (expand-file-name (file-name-nondirectory icon) PIXMAPDIR))
246 (princ (format "%s -> %s\n"
247 (file-name-nondirectory icon)
248 (substring (file-name-directory dest) 0 -1)))
249 (copy-file icon dest t))))
251 (defun install-wl-package ()
253 (let ((wl-install-dir (expand-file-name WL_PREFIX LISPDIR))
254 (elmo-install-dir (expand-file-name ELMO_PREFIX LISPDIR)))
257 (install-elisp-modules (cdr x) (car x)
258 (if (string= (car x) ELMODIR)
266 (defun uninstall-wl-package ()
268 (let ((wl-install-dir (expand-file-name WL_PREFIX
270 (elmo-install-dir (expand-file-name ELMO_PREFIX
272 (wl-uninstall (wl-scan-source (list WLDIR UTILSDIR))
274 (wl-uninstall (wl-scan-source (list ELMODIR))
277 (let* ((case-fold-search t)
278 (icons (directory-files PIXMAPDIR t "\\.x[bp]m$"))
281 (setq icon (car icons)
283 (if (and (file-exists-p icon)
284 (file-writable-p icon))
286 (princ (format "%s was uninstalled.\n" icon))
287 (delete-file icon)))))))
290 (defun config-wl-package-xmas ()
291 (if (not (featurep 'xemacs))
292 (error "This directive is only for XEmacs"))
293 (config-wl-package-subr)
296 (and (setq package-dir (car command-line-args-left))
297 (if (string= "NONE" package-dir)
299 (if (boundp 'early-packages)
300 (let ((dirs (append (if early-package-load-path
302 (if late-package-load-path
304 (if last-package-load-path
307 (while (not (file-exists-p
308 (setq dir (car dirs))))
309 (setq dirs (cdr dirs)))
311 (defvar PACKAGEDIR package-dir)))
312 (princ (format "PACKAGEDIR is %s\n" PACKAGEDIR))
313 (setq command-line-args-left (cdr command-line-args-left)))
315 (config-wl-pixmap-dir PACKAGEDIR)
319 (defun compile-wl-package-xmas ()
320 (config-wl-package-xmas)
321 (setq autoload-package-name "wl")
322 (add-to-list 'command-line-args-left WLDIR)
323 (batch-update-directory)
324 (add-to-list 'command-line-args-left WLDIR)
325 (Custom-make-dependencies)
326 ;; WL-AUTOLOAD-MODULES
327 (compile-elisp-modules WL-AUTOLOAD-MODULES WLDIR)
330 (compile-elisp-modules (cdr x) (car x)))
333 (defun install-wl-package-xmas ()
334 (compile-wl-package-xmas)
335 (let ((LISPDIR (expand-file-name "wl"
336 (expand-file-name "lisp"
338 (DATADIR (expand-file-name "wl"
339 (expand-file-name "etc"
341 (INFODIR (expand-file-name "info" PACKAGEDIR)))
342 (or (file-exists-p DATADIR)
343 (make-directory DATADIR t))
344 (or (file-exists-p INFODIR)
345 (make-directory INFODIR t))
350 (install-elisp-modules (cdr x) (car x) LISPDIR))
352 ;; WL-AUTOLOAD-MODULES
353 (install-elisp-modules WL-AUTOLOAD-MODULES WLDIR LISPDIR)
356 (wl-texinfo-install)))
359 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
362 (defun wl-texinfo-format-file (lang)
363 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang))))
364 (texifile (symbol-value (intern (format "wl-%s-texi" lang)))))
365 (require 'wl-vars) ;; for 'wl-cs-local
366 (or (file-newer-than-file-p (expand-file-name infofile DOCDIR)
367 (expand-file-name texifile DOCDIR))
369 ;; Support old texinfmt.el
370 (require 'ptexinfmt (expand-file-name "ptexinfmt.el" UTILSDIR))
371 (find-file (expand-file-name texifile DOCDIR))
372 (setq obuf (current-buffer))
373 ;; We can't know file names if splitted.
374 (texinfo-format-buffer t)
375 ;; Emacs20.2's default is 'raw-text-unix.
376 (and (fboundp 'set-buffer-file-coding-system)
377 (set-buffer-file-coding-system wl-cs-local))
379 (kill-buffer (current-buffer)) ;; info
380 (kill-buffer obuf)) ;; texi
383 (defun wl-texinfo-format ()
384 (wl-detect-info-directory)
385 (cond ((listp wl-info-lang)
386 (mapcar 'wl-texinfo-format-file wl-info-lang))
387 ((stringp wl-info-lang)
388 (wl-texinfo-format-file wl-info-lang))))
390 (defun wl-texinfo-install-file (lang)
391 (let ((infofile (symbol-value (intern (format "wl-%s-info" lang)))))
392 (install-file infofile DOCDIR INFODIR nil 'overwrite)))
394 (defun wl-texinfo-install ()
395 (cond ((listp wl-info-lang)
396 (mapcar 'wl-texinfo-install-file wl-info-lang))
397 ((stringp wl-info-lang)
398 (wl-texinfo-install-file wl-info-lang))))
400 (defun wl-primary-info-file ()
401 "Get primary info file (for wl-detect-info-directory)."
403 ((listp wl-info-lang)
404 (let ((wl-info-lang (car wl-info-lang)))
405 (wl-primary-info-file)))
406 ((stringp wl-info-lang)
407 (symbol-value (intern (format "wl-%s-info" wl-info-lang))))))
409 (defun wl-detect-info-directory ()
410 (config-wl-package-subr)
413 (if (fboundp 'info-initialize)
416 (let ((infodir (car command-line-args-left))
417 (info (wl-primary-info-file))
420 (if (string= infodir "NONE")
422 (exec-installed-p info Info-directory-list
423 COMPRESS-SUFFIX-LIST))
425 ;;(condition-case nil (delete-file previous))
426 (directory-file-name (file-name-directory previous));)
427 (car Info-directory-list))
429 (setq command-line-args-left (cdr command-line-args-left))))
430 (princ (format "INFODIR is %s\n\n" INFODIR)))
432 (defun install-wl-info ()
434 (wl-texinfo-install))
438 ;;; * MORE refine code (^_^;