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