Refill some long/short copyright headers.
[bpt/emacs.git] / lisp / cedet / ede / proj-info.el
CommitLineData
acc33231
CY
1;;; ede-proj-info.el --- EDE Generic Project texinfo support
2
95df8112 3;;; Copyright (C) 1998-2001, 2004, 2007-2011 Free Software Foundation, Inc.
acc33231
CY
4
5;; Author: Eric M. Ludlam <zappo@gnu.org>
6;; Keywords: project, make
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software: you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22
23;;; Commentary:
24;;
25;; Handle texinfo in and EDE Project file.
26
27(require 'ede/pmake)
28
29;;; Code:
30(defclass ede-proj-target-makefile-info (ede-proj-target-makefile)
31 ((menu :initform nil)
32 (keybindings :initform nil)
cb85c0d8
EL
33 (availablecompilers :initform '(ede-makeinfo-compiler
34 ede-texi2html-compiler))
35 (sourcetype :initform '(ede-makeinfo-source))
acc33231
CY
36 (mainmenu :initarg :mainmenu
37 :initform ""
38 :type string
39 :custom string
40 :documentation "The main menu resides in this file.
41All other sources should be included independently."))
42 "Target for a single info file.")
43
44(defvar ede-makeinfo-source
45 (ede-sourcecode "ede-makeinfo-source"
46 :name "Texinfo"
47 :sourcepattern "\\.texi?$"
48 :garbagepattern '("*.info*" "*.html"))
49 "Texinfo source code definition.")
50
51(defvar ede-makeinfo-compiler
52 (ede-compiler
53 "ede-makeinfo-compiler"
54 :name "makeinfo"
55 :variables '(("MAKEINFO" . "makeinfo"))
56 :commands '("$(MAKEINFO) $<")
57 :autoconf '(("AC_CHECK_PROG" . "MAKEINFO, makeinfo"))
58 :sourcetype '(ede-makeinfo-source)
59 )
60 "Compile texinfo files into info files.")
61
62(defvar ede-texi2html-compiler
63 (ede-compiler
64 "ede-texi2html-compiler"
65 :name "texi2html"
66 :variables '(("TEXI2HTML" . "makeinfo -html"))
67 :commands '("makeinfo -o $@ $<")
68 :sourcetype '(ede-makeinfo-source)
69 )
70 "Compile texinfo files into html files.")
71
72;;; Makefile generation
73;;
74(defmethod ede-proj-configure-add-missing
75 ((this ede-proj-target-makefile-info))
76 "Query if any files needed by THIS provided by automake are missing.
77Results in --add-missing being passed to automake."
78 (not (ede-expand-filename (ede-toplevel) "texinfo.tex")))
79
80(defmethod ede-proj-makefile-sourcevar ((this ede-proj-target-makefile-info))
81 "Return the variable name for THIS's sources."
82 (concat (ede-pmake-varname this) "_TEXINFOS"))
83
84(defmethod ede-proj-makefile-insert-source-variables
85 ((this ede-proj-target-makefile-info) &optional moresource)
86 "Insert the source variables needed by THIS info target.
87Optional argument MORESOURCE is a list of additional sources to add to the
88sources variable.
89Does the usual for Makefile mode, but splits source into two variables
90when working in Automake mode."
91 (if (not (ede-proj-automake-p))
92 (call-next-method)
93 (let* ((sv (ede-proj-makefile-sourcevar this))
94 (src (copy-sequence (oref this source)))
95 (menu (or (oref this menu) (car src))))
96 (setq src (delq menu src))
97 ;; the info_TEXINFOS variable is probably shared
98 (ede-pmake-insert-variable-shared "info_TEXINFOS"
99 (insert menu))
100 ;; Now insert the rest of the source elsewhere
101 (ede-pmake-insert-variable-shared sv
102 (insert (mapconcat 'identity src " ")))
103 (if moresource
104 (error "Texinfo files should not have moresource")))))
105
106(defun ede-makeinfo-find-info-filename (source)
107 "Find the info filename produced by SOURCE texinfo file."
108 (let ((opened (get-file-buffer source))
109 (buffer (or (get-file-buffer source)
110 (find-file-noselect source nil t)))
111 info)
112 (with-current-buffer buffer
113 (save-excursion
114 (goto-char (point-min))
115 (and (re-search-forward "^@setfilename\\s-+\\([^.]+\\).info$" nil t)
116 (setq info (match-string 1)))))
117 (unless (eq buffer opened)
118 (kill-buffer buffer))
119 info))
120
121(defmethod ede-proj-makefile-target-name ((this ede-proj-target-makefile-info))
122 "Return the name of the main target for THIS target."
123 ;; The target should be the main-menu file name translated to .info.
124 (let* ((source (if (not (string= (oref this mainmenu) ""))
125 (oref this mainmenu)
126 (car (oref this source))))
127 (info (ede-makeinfo-find-info-filename source)))
128 (concat (or info (file-name-sans-extension source)) ".info")))
129
130(defmethod ede-proj-makefile-insert-dist-dependencies ((this ede-proj-target-makefile-info))
131 "Insert any symbols that the DIST rule should depend on.
132Texinfo files want to insert generated `.info' files.
133Argument THIS is the target which needs to insert an info file."
134 ;; In some cases, this is ONLY the index file. That should generally
135 ;; be ok.
136 (insert " " (ede-proj-makefile-target-name this))
137 )
138
139(defmethod ede-proj-makefile-insert-dist-filepatterns ((this ede-proj-target-makefile-info))
140 "Insert any symbols that the DIST rule should depend on.
141Texinfo files want to insert generated `.info' files.
142Argument THIS is the target which needs to insert an info file."
143 ;; In some cases, this is ONLY the index file. That should generally
144 ;; be ok.
145 (insert " " (ede-proj-makefile-target-name this) "*")
146 )
147
148; (let ((n (ede-name this)))
149; (if (string-match "\\.info$" n)
150; n
151; (concat n ".info"))))
152
153(defmethod object-write ((this ede-proj-target-makefile-info))
154 "Before committing any change to THIS, make sure the mainmenu is first."
155 (let ((mm (oref this mainmenu))
156 (s (oref this source))
157 (nl nil))
158 (if (or (string= mm "") (not mm) (string= mm (car s)))
159 nil
160 ;; Make sure that MM is first in the list of items.
161 (setq nl (cons mm (delq mm s)))
162 (oset this source nl)))
163 (call-next-method))
164
165(defmethod ede-documentation ((this ede-proj-target-makefile-info))
166 "Return a list of files that provides documentation.
167Documentation is not for object THIS, but is provided by THIS for other
168files in the project."
169 (let* ((src (oref this source))
170 (proj (ede-target-parent this))
171 (dir (oref proj directory))
172 (out nil)
173 )
174 ;; convert src to full file names.
175 (while src
176 (setq out (cons
177 (expand-file-name (car src) dir)
178 out))
179 (setq src (cdr src)))
180 ;; Return it
181 out))
182
183(provide 'ede/proj-info)
184
185;;; ede/proj-info.el ends here