1 ;;; ede/pconf.el --- configure.ac maintenance for EDE
3 ;;; Copyright (C) 1998-2000, 2005, 2008-2012 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
8 ;; This file is part of GNU Emacs.
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.
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.
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/>.
25 ;; Code generator for autoconf configure.ac, and support files.
28 (require 'ede
/autoconf-edit
)
29 (defvar compilation-in-progress
)
31 (defvar ede-pconf-create-file-query
'ask
32 "Controls if queries are made while creating project files.
33 A value of 'ask means to always ask the user before creating
34 a file, such as AUTHORS. A value of 'never means don't ask, and
35 don't do it. A value of nil means to just do it.")
38 (defmethod ede-proj-configure-file ((this ede-proj-project
))
39 "The configure.ac script used by project THIS."
40 (ede-expand-filename (ede-toplevel this
) "configure.ac" t
))
42 (defmethod ede-proj-configure-test-required-file ((this ede-proj-project
) file
)
43 "For project THIS, test that the file FILE exists, or create it."
44 (let ((f (ede-expand-filename (ede-toplevel this
) file t
)))
45 (when (not (file-exists-p f
))
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
)))
55 (and (eq ede-pconf-create-file-query
'ask
)
56 (not (eq ede-pconf-create-file-query
'never
))
58 (format "I had to create the %s file for you. Ok? " file
)))
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
))
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"))
73 ;; Next, verify all targets of all subobjects.
74 (autoconf-set-version (oref this version
))
75 (let ((top-level-project-local this
))
77 (ede-map-all-subprojects
80 ;; NOTE: don't put in ./Makefile - configure complains.
81 (let ((dir (file-name-as-directory
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 relativity.
86 (concat dir
"Makefile") )))))
88 ;; NOTE TO SELF. TURN THIS INTO THE OFFICIAL LIST
90 (ede-proj-dist-makefile this
)
91 ;; Loop over all targets to clean and then add themselves in.
92 (ede-map-all-subprojects
95 (ede-map-targets sp
'ede-proj-flush-autoconf
)))
96 (ede-map-all-subprojects
99 (ede-map-targets this
'ede-proj-tweak-autoconf
)))
102 (setq postcmd
"autoreconf -i;")
104 ;; Verify a bunch of files that are required by automake.
105 (ede-proj-configure-test-required-file this
"AUTHORS")
106 (ede-proj-configure-test-required-file this
"NEWS")
107 (ede-proj-configure-test-required-file this
"README")
108 (ede-proj-configure-test-required-file this
"ChangeLog")
109 ;; Let specific targets get missing files.
110 (mapc 'ede-proj-configure-create-missing targs
)
111 ;; Verify that we have a make system.
112 (if (or (not (ede-expand-filename (ede-toplevel this
) "Makefile"))
113 ;; Now is this one of our old Makefiles?
116 (ede-expand-filename (ede-toplevel this
)
118 (goto-char (point-min))
119 ;; Here is the unique piece for our makefiles.
120 (re-search-forward "For use with: make" nil t
)))
121 (setq postcmd
(concat postcmd
"./configure;")))
122 (if (not (string= "" postcmd
))
126 (while compilation-in-progress
127 (accept-process-output)
128 ;; If sit for indicates that input is waiting, then
129 ;; read and discard whatever it is that is going on.
130 (when (not (sit-for 1))
131 (read-event nil nil
.1)
134 (with-current-buffer "*compilation*"
135 (goto-char (point-max))
137 (when (not (string= mode-line-process
":exit [0]"))
138 (error "Configure failed!"))
140 ;; The Makefile is now recreated by configure?
141 (let ((b (get-file-buffer
142 (ede-expand-filename (ede-toplevel this
)
143 "Makefile" 'newfile
))))
144 ;; This makes sure that if Makefile was loaded, and old,
145 ;; that it gets flushed so we don't keep rebuilding
146 ;; the autoconf system.
147 (if b
(kill-buffer b
))))
151 (defmethod ede-proj-configure-recreate ((this ede-proj-project
))
152 "Delete project THIS's configure script and start over."
153 (if (not (ede-proj-configure-file this
))
154 (error "Could not determine configure.ac for %S" (object-name this
)))
155 (let ((b (get-file-buffer (ede-proj-configure-file this
))))
156 ;; Destroy all evidence of the old configure.ac
157 (delete-file (ede-proj-configure-file this
))
158 (if b
(kill-buffer b
)))
159 (ede-proj-configure-synchronize this
))
161 (defmethod ede-proj-tweak-autoconf ((this ede-proj-target
))
162 "Tweak the configure file (current buffer) to accommodate THIS."
163 ;; Check the compilers belonging to THIS, and call the autoconf
164 ;; setup for those compilers.
165 (mapc 'ede-proj-tweak-autoconf
(ede-proj-compilers this
))
166 (mapc 'ede-proj-tweak-autoconf
(ede-proj-linkers this
))
169 (defmethod ede-proj-flush-autoconf ((this ede-proj-target
))
170 "Flush the configure file (current buffer) to accommodate THIS.
171 By flushing, remove any cruft that may be in the file. Subsequent
172 calls to `ede-proj-tweak-autoconf' can restore items removed by flush."
175 (defmethod ede-proj-configure-add-missing ((this ede-proj-target
))
176 "Query if any files needed by THIS provided by automake are missing.
177 Results in --add-missing being passed to automake."
180 (defmethod ede-proj-configure-create-missing ((this ede-proj-target
))
181 "Add any missing files for THIS by creating them."
186 ;;; ede/pconf.el ends here