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