Initial Commit
[packages] / xemacs-packages / easypg / COMPILE
1 ;;; -*- Emacs-Lisp -*-
2
3 (defvar epg-modules
4   '(epg-package-info epg-config epg epa epa-dired epa-file epa-mail epa-setup))
5
6 (defun epg-compile-modules (modules)
7   (let ((load-path (cons nil load-path))
8         error-modules)
9     (while modules
10       (let ((source (expand-file-name
11                      (concat (symbol-name (car modules)) ".el"))))
12         (if (file-newer-than-file-p source (concat source "c"))
13             (condition-case error
14                 (byte-compile-file source)
15               (error
16                (setq error-modules (cons (car modules) error-modules))))))
17       (setq modules (cdr modules)))
18     (if error-modules
19         (princ (concat "\n\
20   WARNING: ---------------------------------------------------------
21   WARNING: Couldn't compile following modules:
22   WARNING: 
23   WARNING:   " (mapconcat #'symbol-name error-modules ", ") "\n\
24   WARNING: 
25   WARNING: You should probably stop here, try \"make distclean\" to clear
26   WARNING: the last build, and then reconfigure.
27   WARNING: ---------------------------------------------------------\n\n")))))
28
29 (defun epg-compile-module ()
30   (let ((load-path (cons nil load-path)))
31     (let ((source (expand-file-name
32                    (concat (car command-line-args-left) ".el"))))
33       (if (file-newer-than-file-p source (concat source "c"))
34           (byte-compile-file source)))))
35
36 (defun epg-install-modules (modules dest just-print)
37   (unless (or just-print (file-exists-p dest))
38     (make-directory dest t))
39   (while modules
40     (let ((name (symbol-name (car modules))))
41       (princ (format "%s.el -> %s\n" name dest))
42       (unless just-print
43         (copy-file (expand-file-name (concat name ".el"))
44                    (expand-file-name (concat name ".el") dest)
45                    t t))
46       (princ (format "%s.elc -> %s\n" name dest))
47       (unless just-print
48         (if (file-exists-p (expand-file-name (concat name ".elc")))
49             (copy-file (expand-file-name (concat name ".elc"))
50                        (expand-file-name (concat name ".elc") dest)
51                        t t)
52           (princ (format "(%s was not successfully compiled, ignored)\n"
53                          name)))))
54     (setq modules (cdr modules))))
55
56 (defun epg-install-just-print-p ()
57   (let ((flag (getenv "MAKEFLAGS"))
58         case-fold-search)
59     (if flag
60         (string-match "^\\(\\(--[^ ]+ \\)+-\\|[^ =-]\\)*n" flag))))
61
62 (defun epg-examine ()
63   (princ (mapconcat #'symbol-name epg-modules " ")))
64
65 (defun epg-compile ()
66   (epg-compile-modules epg-modules))
67
68 (defun epg-install ()
69   (epg-install-modules
70    epg-modules
71    (expand-file-name "epg" (car command-line-args-left))
72    (epg-install-just-print-p)))
73
74 (defun epg-compile-package ()
75   (setq autoload-package-name "epg")
76   (add-to-list 'command-line-args-left ".")
77   (batch-update-directory)
78   (add-to-list 'command-line-args-left ".")
79   (Custom-make-dependencies)
80   (epg-compile-modules
81    (append epg-modules
82            '(auto-autoloads custom-load))))
83
84 (defun epg-install-package ()
85   (epg-install-modules
86    (append epg-modules
87            '(auto-autoloads custom-load))
88    (expand-file-name "lisp/epg" (car command-line-args-left))
89    (epg-install-just-print-p)))