* gnus.el (gnus-revision-number): Increment to 03.
[elisp/gnus.git-] / lisp / dgnushack.el
1 ;;; dgnushack.el --- a hack to set the load path for byte-compiling
2 ;; Copyright (C) 1994,95,96,97,98,99 Free Software Foundation, Inc.
3
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;;      Katsumi Yamaoka <yamaoka@jpl.org>
6 ;; Version: 4.19
7 ;; Keywords: news, path
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (fset 'facep 'ignore)
31
32 (require 'cl)
33 (require 'bytecomp)
34 (push "." load-path)
35 (load "./lpath.el" nil t)
36
37 (defalias 'device-sound-enabled-p 'ignore)
38 (defalias 'play-sound-file 'ignore)
39 (defalias 'nndb-request-article 'ignore)
40 (defalias 'efs-re-read-dir 'ignore)
41 (defalias 'ange-ftp-re-read-dir 'ignore)
42 (defalias 'define-mail-user-agent 'ignore)
43
44 (eval-and-compile
45   (unless (string-match "XEmacs" emacs-version)
46     (fset 'get-popup-menu-response 'ignore)
47     (fset 'event-object 'ignore)
48     (fset 'x-defined-colors 'ignore)
49     (fset 'read-color 'ignore)))
50
51 (defun dgnushack-compile (&optional warn)
52   ;;(setq byte-compile-dynamic t)
53   (unless warn
54     (setq byte-compile-warnings
55           '(free-vars unresolved callargs redefine)))
56   (unless (locate-library "cus-edit")
57     (error "You do not seem to have Custom installed.
58 Fetch it from <URL:http://www.dina.kvl.dk/~abraham/custom/>.
59 You also then need to add the following to the lisp/dgnushack.el file:
60
61      (push \"~/lisp/custom\" load-path)
62
63 Modify to suit your needs."))
64   (let ((files (directory-files "." nil "^[^=].*\\.el$"))
65         (xemacs (string-match "XEmacs" emacs-version))
66         ;;(byte-compile-generate-call-tree t)
67         file elc)
68     (condition-case ()
69         (require 'w3-forms)
70       (error (setq files (delete "nnweb.el" (delete "nnlistserv.el" files)))))
71     (condition-case ()
72         (require 'bbdb)
73       (error (setq files (delete "gnus-bbdb.el" files))))
74     (while (setq file (pop files))
75       (when (or (and (not xemacs)
76                      (not (member file '("gnus-xmas.el" "gnus-picon.el"
77                                          "messagexmas.el" "nnheaderxm.el"
78                                          "smiley.el" "x-overlay.el"))))
79                 (and xemacs
80                      (not (member file '("md5.el")))))
81         (when (or (not (file-exists-p (setq elc (concat file "c"))))
82                   (file-newer-than-file-p file elc))
83           (ignore-errors
84             (byte-compile-file file)))))))
85
86 (defun dgnushack-recompile ()
87   (require 'gnus)
88   (byte-recompile-directory "." 0))
89
90 \f
91 ;; Avoid byte-compile warnings.
92 (defvar gnus-revision-number)
93 (defvar gnus-version-number)
94 (defvar gnus-product-name)
95 (defvar configure-package-path)
96 (defvar package-path)
97
98 (defconst dgnushack-info-file-regexp
99   "^\\(gnus\\|message\\|emacs-mime\\|gnus-ja\\|message-ja\\)\\(-[0-9]+\\)?$")
100
101 (defun dgnushack-make-package ()
102   (require 'gnus)
103   (let* ((product-name (downcase gnus-product-name))
104          (lisp-dir (concat "lisp/" product-name "/"))
105          make-backup-files)
106
107     (message "Updating autoloads for directory %s..." default-directory)
108     (let ((generated-autoload-file "auto-autoloads.el")
109           noninteractive)
110       (update-autoloads-from-directory default-directory))
111     (byte-compile-file "auto-autoloads.el")
112
113     (with-temp-buffer
114       (let ((standard-output (current-buffer)))
115         (Custom-make-dependencies "."))
116       (message (buffer-string)))
117     (require 'cus-load)
118     (byte-compile-file "custom-load.el")
119
120     (message "Generating MANIFEST.%s for the package..." product-name)
121     (with-temp-buffer
122       (insert "pkginfo/MANIFEST." product-name "\n"
123               lisp-dir
124               (mapconcat
125                'identity
126                (sort (directory-files "." nil "\\.elc?$")
127                      'string-lessp)
128                (concat "\n" lisp-dir))
129               "\ninfo/"
130               (mapconcat
131                'identity
132                (sort (directory-files "../texi/"
133                                       nil dgnushack-info-file-regexp)
134                      'string-lessp)
135                "\ninfo/")
136               "\n")
137       (write-file (concat "../MANIFEST." product-name)))))
138
139 (defun dgnushack-install-package ()
140   (let* ((package-dir (file-name-as-directory
141                        (or (car command-line-args-left)
142                            (if (boundp 'configure-package-path)
143                                (car configure-package-path)
144                              (car package-path)))))
145          (info-dir (expand-file-name "info/" package-dir))
146          (pkginfo-dir (expand-file-name "pkginfo/" package-dir))
147          product-name lisp-dir manifest files)
148     (require 'gnus)
149     (setq product-name (downcase gnus-product-name)
150           lisp-dir (expand-file-name (concat "lisp/" product-name "/")
151                                      package-dir)
152           manifest (concat "MANIFEST." product-name))
153
154     (unless (file-directory-p lisp-dir)
155       (make-directory lisp-dir t))
156     (unless (file-directory-p info-dir)
157       (make-directory info-dir))
158     (unless (file-directory-p pkginfo-dir)
159       (make-directory pkginfo-dir))
160
161     (setq files (sort (directory-files "." nil "\\.elc?$") 'string-lessp))
162     (mapcar
163      (lambda (file)
164        (unless (member file files)
165          (setq file (expand-file-name file lisp-dir))
166          (message "Removing %s..." file)
167          (condition-case nil
168              (delete-file file)
169            (error nil))))
170      (directory-files lisp-dir nil nil nil t))
171     (mapcar
172      (lambda (file)
173        (message "Copying %s to %s..." file lisp-dir)
174        (copy-file file (expand-file-name file lisp-dir) t t))
175      files)
176
177     (mapcar
178      (lambda (file)
179        (message "Copying ../texi/%s to %s..." file info-dir)
180        (copy-file (expand-file-name file "../texi/")
181                   (expand-file-name file info-dir)
182                   t t))
183      (sort (directory-files "../texi/" nil dgnushack-info-file-regexp)
184            'string-lessp))
185
186     (message "Copying ../%s to %s..." manifest pkginfo-dir)
187     (copy-file (expand-file-name manifest "../")
188                (expand-file-name manifest pkginfo-dir) t t)
189
190     (message "Done")))
191
192 ;;; dgnushack.el ends here