Mercurial > emacs
comparison lisp/cedet/ede/pconf.el @ 104496:8c4870c15962
* cedet/ede.el, cedet/ede/*.el: New files.
* cedet/cedet.el: Require ede.
* cedet/semantic/symref/filter.el (semantic-symref-hits-in-region):
Require semantic/idle.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 20 Sep 2009 15:06:05 +0000 |
parents | |
children | 7f4c7f5c0eba |
comparison
equal
deleted
inserted
replaced
104495:4659ddbe20bf | 104496:8c4870c15962 |
---|---|
1 ;;; ede/pconf.el --- configure.ac maintenance for EDE | |
2 | |
3 ;;; Copyright (C) 1998, 1999, 2000, 2005, 2008, 2009 | |
4 ;;; Free Software Foundation, Inc. | |
5 | |
6 ;; Author: Eric M. Ludlam <zappo@gnu.org> | |
7 ;; Keywords: project | |
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 ;; Code generator for autoconf configure.ac, and support files. | |
27 | |
28 (require 'ede/proj) | |
29 (require 'ede/autoconf-edit) | |
30 (defvar compilation-in-progress) | |
31 | |
32 (defvar ede-pconf-create-file-query 'ask | |
33 "Controls if queries are made while creating project files. | |
34 A value of 'ask means to always ask the user before creating | |
35 a file, such as AUTHORS. A value of 'never means don't ask, and | |
36 don't do it. A value of nil means to just do it.") | |
37 | |
38 ;;; Code: | |
39 (defmethod ede-proj-configure-file ((this ede-proj-project)) | |
40 "The configure.ac script used by project THIS." | |
41 (ede-expand-filename (ede-toplevel this) "configure.ac" t)) | |
42 | |
43 (defmethod ede-proj-configure-test-required-file ((this ede-proj-project) file) | |
44 "For project THIS, test that the file FILE exists, or create it." | |
45 (when (not (ede-expand-filename (ede-toplevel this) file)) | |
46 (save-excursion | |
47 (find-file (ede-expand-filename (ede-toplevel this) file t)) | |
48 (cond ((string= file "AUTHORS") | |
49 (insert (user-full-name) " <" (user-login-name) ">")) | |
50 ((string= file "NEWS") | |
51 (insert "NEWS file for " (ede-name this))) | |
52 (t (insert "\n"))) | |
53 (save-buffer) | |
54 (when | |
55 (and (eq ede-pconf-create-file-query 'ask) | |
56 (not (eq ede-pconf-create-file-query 'never)) | |
57 (not (y-or-n-p | |
58 (format "I had to create the %s file for you. Ok? " file))) | |
59 (error "Quit")))))) | |
60 | |
61 | |
62 (defmethod ede-proj-configure-synchronize ((this ede-proj-project)) | |
63 "Synchronize what we know about project THIS into configure.ac." | |
64 (let ((b (find-file-noselect (ede-proj-configure-file this))) | |
65 ;;(td (file-name-directory (ede-proj-configure-file this))) | |
66 (targs (oref this targets)) | |
67 (postcmd "") | |
68 (add-missing nil)) | |
69 ;; First, make sure we have a file. | |
70 (if (not (file-exists-p (ede-proj-configure-file this))) | |
71 (autoconf-new-program b (oref this name) "Project.ede")) | |
72 (set-buffer b) | |
73 ;; Next, verify all targets of all subobjects. | |
74 (autoconf-set-version (oref this version)) | |
75 (let ((top-level-project-local this)) | |
76 (autoconf-set-output | |
77 (ede-map-all-subprojects | |
78 this | |
79 (lambda (sp) | |
80 ;; NOTE: don't put in ./Makefile - configure complains. | |
81 (let ((dir (file-name-as-directory | |
82 (directory-file-name | |
83 (ede-subproject-relative-path sp top-level-project-local))))) | |
84 (when (string= dir "./") (setq dir "")) | |
85 ;; Use concat, because expand-file-name removes the relativeness. | |
86 (concat dir "Makefile") ))))) | |
87 ;; | |
88 ;; NOTE TO SELF. TURN THIS INTO THE OFFICIAL LIST | |
89 ;; | |
90 (ede-proj-dist-makefile this) | |
91 ;; Loop over all targets to clean and then add themselves in. | |
92 (ede-map-all-subprojects | |
93 this | |
94 (lambda (sp) | |
95 (ede-map-targets sp 'ede-proj-flush-autoconf))) | |
96 (ede-map-all-subprojects | |
97 this | |
98 (lambda (sp) | |
99 (ede-map-targets this 'ede-proj-tweak-autoconf))) | |
100 ;; Now save | |
101 (save-buffer) | |
102 ;; Verify aclocal | |
103 (setq postcmd "aclocal;") | |
104 ;; Always add missing files as needed. | |
105 (setq postcmd (concat postcmd "automake --add-missing;")) | |
106 | |
107 ;; Always do autoreconf | |
108 (setq postcmd (concat postcmd "autoreconf;")) | |
109 ;; Verify a bunch of files that are required by automake. | |
110 (ede-proj-configure-test-required-file this "AUTHORS") | |
111 (ede-proj-configure-test-required-file this "NEWS") | |
112 (ede-proj-configure-test-required-file this "README") | |
113 (ede-proj-configure-test-required-file this "ChangeLog") | |
114 ;; Let specific targets get missing files. | |
115 (mapc 'ede-proj-configure-create-missing targs) | |
116 ;; Verify that we have a make system. | |
117 (if (or (not (ede-expand-filename (ede-toplevel this) "Makefile")) | |
118 ;; Now is this one of our old Makefiles? | |
119 (save-excursion | |
120 (set-buffer (find-file-noselect | |
121 (ede-expand-filename (ede-toplevel this) | |
122 "Makefile" t) t)) | |
123 (goto-char (point-min)) | |
124 ;; Here is the unique piece for our makefiles. | |
125 (re-search-forward "For use with: make" nil t))) | |
126 (setq postcmd (concat postcmd "./configure;"))) | |
127 (if (not (string= "" postcmd)) | |
128 (progn | |
129 (compile postcmd) | |
130 | |
131 (while compilation-in-progress | |
132 (accept-process-output) | |
133 (sit-for 1)) | |
134 | |
135 (save-excursion | |
136 (set-buffer "*compilation*") | |
137 (goto-char (point-max)) | |
138 | |
139 (when (not (string= mode-line-process ":exit [0]")) | |
140 (error "Configure failed!")) | |
141 | |
142 ;; The Makefile is now recreated by configure? | |
143 (let ((b (get-file-buffer | |
144 (ede-expand-filename (ede-toplevel this) | |
145 "Makefile" 'newfile)))) | |
146 ;; This makes sure that if Makefile was loaded, and old, | |
147 ;; that it gets flushed so we don't keep rebuilding | |
148 ;; the autoconf system. | |
149 (if b (kill-buffer b)))) | |
150 | |
151 )))) | |
152 | |
153 (defmethod ede-proj-configure-recreate ((this ede-proj-project)) | |
154 "Delete project THISes configure script and start over." | |
155 (if (not (ede-proj-configure-file this)) | |
156 (error "Could not determine configure.ac for %S" (object-name this))) | |
157 (let ((b (get-file-buffer (ede-proj-configure-file this)))) | |
158 ;; Destroy all evidence of the old configure.ac | |
159 (delete-file (ede-proj-configure-file this)) | |
160 (if b (kill-buffer b))) | |
161 (ede-proj-configure-synchronize this)) | |
162 | |
163 (defmethod ede-proj-tweak-autoconf ((this ede-proj-target)) | |
164 "Tweak the configure file (current buffer) to accomodate THIS." | |
165 ;; Check the compilers belonging to THIS, and call the autoconf | |
166 ;; setup for those compilers. | |
167 (mapc 'ede-proj-tweak-autoconf (ede-proj-compilers this)) | |
168 (mapc 'ede-proj-tweak-autoconf (ede-proj-linkers this)) | |
169 ) | |
170 | |
171 (defmethod ede-proj-flush-autoconf ((this ede-proj-target)) | |
172 "Flush the configure file (current buffer) to accomodate THIS. | |
173 By flushing, remove any cruft that may be in the file. Subsequent | |
174 calls to `ede-proj-tweak-autoconf' can restore items removed by flush." | |
175 nil) | |
176 | |
177 (defmethod ede-proj-configure-add-missing ((this ede-proj-target)) | |
178 "Query if any files needed by THIS provided by automake are missing. | |
179 Results in --add-missing being passed to automake." | |
180 nil) | |
181 | |
182 (defmethod ede-proj-configure-create-missing ((this ede-proj-target)) | |
183 "Add any missing files for THIS by creating them." | |
184 nil) | |
185 | |
186 (provide 'ede/pconf) | |
187 | |
188 ;;; ede/pconf.el ends here |