f843c6bcf537d0bd01c41237d5d5f73fa24315ec
[elisp/tm.git] / mk-tm
1 ;;; -*-Emacs-Lisp-*-
2 ;;;
3 ;;; $Id: mk-tm,v 7.4 1995/12/03 15:46:37 morioka Exp morioka $
4 ;;;
5
6 (setq load-path (append
7                  (mapcar (function
8                           (lambda (path)
9                             (expand-file-name path (getenv "PWD"))
10                             ))
11                          '("." "../tl/" "../mel/")
12                          )
13                  load-path))
14
15 (require 'tl-misc)
16
17 ;; Please specify VM path.
18 (add-path "vm-5.95beta/")
19
20 ;; Please specify Mailcrypt path.
21 (add-path "mailcrypt-3.4beta/")
22
23 (setq tm-modules
24       (cons
25        (cond ((boundp 'NEMACS)
26               "tm-nemacs"
27               )
28              ((boundp 'MULE)
29               "tm-mule"
30               )
31              (t
32               "tm-orig"
33               ))
34        '("signature"
35          "tm-def"
36          "tm-ew-d" "tm-parse" "tm-view" "tm-play" "tm-partial"
37          "tm-rich"
38          "tm-latex" "tm-html" "tm-tar" "tm-file"
39          "tm-ew-e"
40          "tm-edit"
41          "tm-rmail" "tm-mail"
42          "tm-setup" "mime-setup"
43          )))
44
45 (setq tm-uncompile-el-files '("sc-setup.el"))
46
47 (if (catch 'tag
48       (let ((paths load-path) path)
49         (while paths
50           (setq path (expand-file-name "ange-ftp.el" (car paths)))
51           (if (file-exists-p path)
52               (throw 'tag path)
53             )
54           (setq paths (cdr paths))
55           )))
56     (setq tm-modules (append tm-modules '("tm-ftp")))
57   (setq tm-uncompile-el-files
58         (append tm-uncompile-el-files '("tm-ftp.el")))
59   )
60
61 (if (catch 'tag
62       (let ((paths load-path) path)
63         (while paths
64           (setq path (expand-file-name "vm.elc" (car paths)))
65           (if (file-exists-p path)
66               (throw 'tag path)
67             )
68           (setq paths (cdr paths))
69           )))
70     (setq tm-modules (append tm-modules '("tm-vm")))
71   (setq tm-uncompile-el-files
72         (append tm-uncompile-el-files '("tm-vm.el")))
73   )
74
75 (if (catch 'tag
76       (let ((paths load-path) path)
77         (while paths
78           (setq path (expand-file-name "mailcrypt.el" (car paths)))
79           (if (file-exists-p path)
80               (throw 'tag path)
81             )
82           (setq paths (cdr paths))
83           )))
84     (setq tm-modules (append tm-modules '("tm-pgp")))
85   (setq tm-uncompile-el-files
86         (append tm-uncompile-el-files '("tm-pgp.el")))
87   )
88
89 (if (and (file-exists-p "tm-evs.el")
90          (or (boundp 'MULE)
91              (boundp 'NEMACS))
92          )
93     (setq tm-modules (append tm-modules '("tm-evs")))
94   )
95
96 (setq tm-el-files
97       (mapcar (function (lambda (module)
98                           (concat module ".el")
99                           ))
100               tm-modules))
101
102 (setq tm-elc-files
103       (mapcar (function (lambda (module)
104                           (concat module ".elc")
105                           ))
106               tm-modules))
107
108 (defun compile-tm ()
109   ;; (require 'gnus)
110   (require 'tm-rich)
111   (require 'mel-u)
112   (require 'tm-edit)
113   (mapcar (function
114            (lambda (module)
115              (let ((el-file (concat module ".el"))
116                    (elc-file (concat module ".elc"))
117                    )
118                (if (file-newer-than-file-p el-file elc-file)
119                    (byte-compile-file el-file)
120                  )
121                )))
122           tm-modules)
123   )
124
125 (defconst el-file-mode (+ (* 64 6)(* 8 4) 4))
126
127 (defun install-el (path file)
128   (let ((full-path (expand-file-name file path)))
129     (if (file-exists-p full-path)
130         (set-file-modes full-path el-file-mode)
131       )
132     (copy-file file full-path t t)
133     (princ (format "%s -> %s\n" file path))
134     ))
135
136 (defun install-el-files (path &rest files)
137   (mapcar (function (lambda (file)
138                       (if (file-exists-p file)
139                           (install-el path file)
140                         )))
141           files))
142
143 (defun install-elc (path file)
144   (let ((full-path (expand-file-name file path)))
145     (copy-file file full-path t t)
146     (delete-file file)
147     (princ (format "%s -> %s\n" file path))
148     ))
149
150 (defun install-elc-files (path &rest files)
151   (mapcar (function (lambda (file)
152                       (if (file-exists-p file)
153                           (install-elc path file)
154                         )))
155           files))
156
157 (defun install-tm ()
158   (let ((path (car command-line-args-left)))
159     (princ (format "%s\n" emacs-version))
160     (if (not (file-exists-p path))
161         (make-directory path t)
162       )
163     (apply (function install-el-files) path
164            (append tm-el-files tm-uncompile-el-files)
165            )
166     (apply (function install-elc-files) path tm-elc-files)
167     ))