Properly determine the name of preceeding directory
[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 (mapfam
69                                #'(lambda (e)
70                                    (replace-in-string e "\\." ""))
71                                :initiator "\\.\\("
72                                :terminator "\\)$"
73                                :separator "\\|"
74                                :result-type #'concat module-extensions)
75                  'list t 1))
76          (dir-bloom (make-bloom))
77          directories)
78     (mapfam
79      #'(lambda (f)
80          (let ((d (file-basename (file-dirname f))))
81            (unless (bloom-owns-p dir-bloom d)
82              (bloom-add dir-bloom d)
83              (setq directories (cons d directories)))))
84      :result-type 'void files)
85     directories))
86
87 (when (featurep 'modules)
88   (let* ((modsrc "../.sxemacs.source.tree/modules/")
89          (mods (mapfam
90                 #'(lambda (d) (concat modsrc d))
91                 :result-type #'list (find-emod-directories)))
92          (feat "modules")
93          (autofile (expand-file-name "auto-autoloads.el" "../modules/")))
94     (update-autoload-files mods feat autofile t)))
95
96 ;; indicate success
97 (kill-emacs 0)
98
99 ;;; build-autoloads.el ends here