Temporary work-around for bug 162
[sxemacs] / lisp / build-autoloads.el
1 ;;; build-autoloads.el --- Guess what!
2 ;;
3 ;; Copyright (C) 2006 Sebastian Freundt
4 ;; Copyright (C) 2007 Steve Youngs
5 ;;
6 ;; Author: Sebastian Freundt <hroptatyr@sxemacs.org>
7 ;; Maintainer: SXEmacs Development Team
8 ;; Keywords: internal
9 ;;
10 ;; This file is part of SXEmacs.
11 ;;
12 ;; SXEmacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
16
17 ;; SXEmacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
24 ;;
25 ;;; Synched up with: Not in FSF.
26
27 ;;; Commentary:
28 ;;
29 ;;  This file is only used during SXEmacs builds, it does what the
30 ;;  name implies... builds the auto-autoloads.el files for lisp,
31 ;;  lisp/mule, lisp/ffi, plus it generates the custom-load.el and
32 ;;  custom-define.el files for same.  Emodule autoloads are handled
33 ;;  here too.
34
35 ;;; Code:
36
37 (unless (fboundp #'error)
38   (load "loadup-el.el"))
39 (load "autoload.el")
40 (load "bytecomp.el")
41 (load "byte-optimize.el")
42 (load "cus-dep.el")
43
44 ;; lisp/term is missing, but it currently doesn't have any autoloads
45 ;; or customs. --SY.
46 (defvar autodirs '("."))
47
48 (when (featurep 'mule) (setq autodirs (cons "mule" autodirs)))
49 (when (fboundp #'ffi-defun) (setq autodirs (cons "ffi" autodirs)))
50 (setq autodirs (nreverse autodirs))
51
52 (defvar srcdir "../.sxemacs.source.tree/lisp/")
53
54 (mapcar
55  #'(lambda (dir)
56      (let ((pname (if (string= dir ".") "auto" dir))
57            (adir (concat srcdir dir)))
58        (update-autoload-files adir pname (expand-file-name "auto-autoloads.el" dir) t)
59        (Custom-make-dependencies adir (expand-file-name "custom-load.el" dir))
60        (update-custom-define-files adir pname (expand-file-name "custom-defines.el" dir) t)
61        ))
62  autodirs)
63
64 ;; emods
65 (defun find-emod-directories ()
66   (let* ((objdir "../modules/")
67          (files (directory-files-recur
68                  objdir 'full (concat
69                                "\\.\\("
70                                (mapconcat
71                                 #'(lambda (e)
72                                     (replace-in-string e "\\." ""))
73                                 module-extensions "\\|")
74                                "\\)$")
75                               ;; http://issues.sxemacs.org/show_bug.cgi?id=162
76                               ;; (mapfam
77                               ;;  #'(lambda (e)
78                               ;;      (replace-in-string e "\\." ""))
79                               ;;  :initiator "\\.\\("
80                               ;;  :terminator "\\)$"
81                               ;;  :separator "\\|"
82                               ;;  :result-type #'concat module-extensions)
83                  'list t 1))
84          (dir-bloom (make-bloom))
85          directories)
86     (mapfam
87      #'(lambda (f)
88          (let ((d (car (last (split-string-by-char (file-dirname f) ?/) 2))))
89            (unless (bloom-owns-p dir-bloom d)
90              (bloom-add dir-bloom d)
91              (setq directories (cons d directories)))))
92      :result-type 'void files)
93     directories))
94
95 (when (featurep 'modules)
96   (let* ((modsrc "../.sxemacs.source.tree/modules/")
97          (mods (mapfam
98                 #'(lambda (d) (concat modsrc d))
99                 :result-type #'list (find-emod-directories)))
100          (feat "modules")
101          (autofile (expand-file-name "auto-autoloads.el" "../modules/")))
102     (update-autoload-files mods feat autofile t)))
103
104 ;; indicate success
105 (kill-emacs 0)
106
107 ;;; build-autoloads.el ends here