Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / lisp / cedet / ede / proj.el
blobe3c2ea4b91479511a7c8dca5b72ad8e18c6f9906
1 ;;; ede/proj.el --- EDE Generic Project file driver
3 ;; Copyright (C) 1998-2003, 2007-2014 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; Keywords: project, make
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/>.
23 ;;; Commentary:
25 ;; EDE defines a method for managing a project. EDE-PROJ aims to be a
26 ;; generic project file format based on the EIEIO object stream
27 ;; methods. Changes in the project structure will require Makefile
28 ;; rebuild. The targets provided in ede-proj can be augmented with
29 ;; additional target types inherited directly from `ede-proj-target'.
31 (require 'ede/proj-comp)
32 (require 'ede/make)
34 (declare-function ede-proj-makefile-create "ede/pmake")
35 (declare-function ede-proj-configure-synchronize "ede/pconf")
37 (autoload 'ede-proj-target-aux "ede/proj-aux"
38 "Target class for a group of lisp files." nil nil)
39 (autoload 'ede-proj-target-elisp "ede/proj-elisp"
40 "Target class for a group of lisp files." nil nil)
41 (autoload 'ede-proj-target-elisp-autoloads "ede/proj-elisp"
42 "Target class for generating autoload files." nil nil)
43 (autoload 'ede-proj-target-scheme "ede/proj-scheme"
44 "Target class for a group of lisp files." nil nil)
45 (autoload 'ede-proj-target-makefile-miscelaneous "ede/proj-misc"
46 "Target class for a group of miscellaneous w/ a special makefile." nil nil)
47 (autoload 'ede-proj-target-makefile-program "ede/proj-prog"
48 "Target class for building a program." nil nil)
49 (autoload 'ede-proj-target-makefile-archive "ede/proj-archive"
50 "Target class for building an archive of object code." nil nil)
51 (autoload 'ede-proj-target-makefile-shared-object "ede/proj-shared"
52 "Target class for building a shared object." nil nil)
53 (autoload 'ede-proj-target-makefile-info "ede/proj-info"
54 "Target class for info files." nil nil)
56 (eieio-defclass-autoload 'ede-proj-target-aux '(ede-proj-target)
57 "ede/proj-aux"
58 "Target class for a group of lisp files.")
59 (eieio-defclass-autoload 'ede-proj-target-elisp '(ede-proj-target-makefile)
60 "ede/proj-elisp"
61 "Target class for a group of lisp files.")
62 (eieio-defclass-autoload 'ede-proj-target-elisp-autoloads '(ede-proj-target-elisp)
63 "ede/proj-elisp"
64 "Target class for generating autoload files.")
65 (eieio-defclass-autoload 'ede-proj-target-scheme '(ede-proj-target)
66 "ede/proj-scheme"
67 "Target class for a group of lisp files.")
68 (eieio-defclass-autoload 'ede-proj-target-makefile-miscelaneous '(ede-proj-target-makefile)
69 "ede/proj-misc"
70 "Target class for a group of miscellaneous w/ a special makefile.")
71 (eieio-defclass-autoload 'ede-proj-target-makefile-program '(ede-proj-target-makefile-objectcode)
72 "ede/proj-prog"
73 "Target class for building a program.")
74 (eieio-defclass-autoload 'ede-proj-target-makefile-archive '(ede-proj-target-makefile-objectcode)
75 "ede/proj-archive"
76 "Target class for building an archive of object code.")
77 (eieio-defclass-autoload 'ede-proj-target-makefile-shared-object '(ede-proj-target-makefile-program)
78 "ede/proj-shared"
79 "Target class for building a shared object.")
80 (eieio-defclass-autoload 'ede-proj-target-makefile-info '(ede-proj-target-makefile)
81 "ede/proj-info"
82 "Target class for info files.")
84 ;; Not in ede/ , but part of semantic.
85 (eieio-defclass-autoload 'semantic-ede-proj-target-grammar '(ede-proj-target-elisp)
86 "semantic/ede-grammar"
87 "Target classfor Semantic grammar files.")
89 ;;; Class Definitions:
90 (defclass ede-proj-target (ede-target)
91 ((auxsource :initarg :auxsource
92 :initform nil
93 :type list
94 :custom (repeat (string :tag "File"))
95 :label "Auxiliary Source Files"
96 :group (default source)
97 :documentation "Auxiliary source files included in this target.
98 Each of these is considered equivalent to a source file, but it is not
99 distributed, and each should have a corresponding rule to build it.")
100 (dirty :initform nil
101 :type boolean
102 :documentation "Non-nil when generated files needs updating.")
103 (compiler :initarg :compiler
104 :initform nil
105 :type (or null symbol)
106 :custom (choice (const :tag "None" nil)
107 (symbol :tag "Custom Compiler Symbol")
108 :slotofchoices availablecompilers)
109 :label "Compiler for building sources"
110 :group make
111 :documentation
112 "The compiler to be used to compile this object.
113 This should be a symbol, which contains the object defining the compiler.
114 This enables save/restore to do so by name, permitting the sharing
115 of these compiler resources, and global customization thereof.")
116 (linker :initarg :linker
117 :initform nil
118 :type (or null symbol)
119 :custom (choice (const :tag "None" nil)
120 (symbol :tag "Custom Linker Symbol")
121 :slotofchoices availablelinkers)
122 :label "Linker for combining intermediate object files."
123 :group make
124 :documentation
125 "The linker to be used to link compiled sources for this object.
126 This should be a symbol, which contains the object defining the linker.
127 This enables save/restore to do so by name, permitting the sharing
128 of these linker resources, and global customization thereof.")
129 ;; Class allocated slots
130 (phony :allocation :class
131 :initform nil
132 :type boolean
133 :documentation
134 "A phony target is one where the build target does not relate to a file.
135 Such targets are always built, but make knows how to deal with them..")
136 (availablecompilers :allocation :class
137 :initform nil
138 :type (or null list)
139 :documentation
140 "A list of `ede-compiler' objects.
141 These are the compilers the user can choose from when setting the
142 `compiler' slot.")
143 (availablelinkers :allocation :class
144 :initform nil
145 :type (or null list)
146 :documentation
147 "A list of `ede-linker' objects.
148 These are the linkers the user can choose from when setting the
149 `linker' slot.")
151 "Abstract class for ede-proj targets.")
153 (defclass ede-proj-target-makefile (ede-proj-target)
154 ((makefile :initarg :makefile
155 :initform "Makefile"
156 :type string
157 :custom string
158 :label "Parent Makefile"
159 :group make
160 :documentation "File name of generated Makefile.")
161 (partofall :initarg :partofall
162 :initform t
163 :type boolean
164 :custom boolean
165 :label "Part of `all:' target"
166 :group make
167 :documentation
168 "Non nil means the rule created is part of the all target.
169 Setting this to nil creates the rule to build this item, but does not
170 include it in the ALL`all:' rule.")
171 (configuration-variables
172 :initarg :configuration-variables
173 :initform nil
174 :type list
175 :custom (repeat (cons (string :tag "Configuration")
176 (repeat
177 (cons (string :tag "Name")
178 (string :tag "Value")))))
179 :label "Environment Variables for configurations"
180 :group make
181 :documentation "Makefile variables appended to use in different configurations.
182 These variables are used in the makefile when a configuration becomes active.
183 Target variables are always renamed such as foo_CFLAGS, then included into
184 commands where the variable would usually appear.")
185 (rules :initarg :rules
186 :initform nil
187 :type list
188 :custom (repeat (object :objecttype ede-makefile-rule))
189 :label "Additional Rules"
190 :group (make)
191 :documentation
192 "Arbitrary rules and dependencies needed to make this target.
193 It is safe to leave this blank.")
195 "Abstract class for Makefile based targets.")
197 (defvar ede-proj-target-alist
198 '(("program" . ede-proj-target-makefile-program)
199 ("archive" . ede-proj-target-makefile-archive)
200 ("sharedobject" . ede-proj-target-makefile-shared-object)
201 ("emacs lisp" . ede-proj-target-elisp)
202 ("emacs lisp autoloads" . ede-proj-target-elisp-autoloads)
203 ("info" . ede-proj-target-makefile-info)
204 ("auxiliary" . ede-proj-target-aux)
205 ("scheme" . ede-proj-target-scheme)
206 ("miscellaneous" . ede-proj-target-makefile-miscelaneous)
208 "Alist of names to class types for available project target classes.")
210 (defun ede-proj-register-target (name class)
211 "Register a new target class with NAME and class symbol CLASS.
212 This enables the creation of your target type."
213 (let ((a (assoc name ede-proj-target-alist)))
214 (if a
215 (setcdr a class)
216 (setq ede-proj-target-alist
217 (cons (cons name class) ede-proj-target-alist)))))
219 (defclass ede-proj-project (eieio-persistent ede-project)
220 ((extension :initform ".ede")
221 (file-header-line :initform ";; EDE Project Files are auto generated: Do Not Edit")
222 (makefile-type :initarg :makefile-type
223 :initform Makefile
224 :type symbol
225 :custom (choice (const Makefile)
226 ;(const Makefile.in)
227 (const Makefile.am)
228 ;(const cook)
230 :documentation "The type of Makefile to generate.
231 Can be one of 'Makefile, 'Makefile.in, or 'Makefile.am.
232 If this value is NOT 'Makefile, then that overrides the :makefile slot
233 in targets.")
234 (variables :initarg :variables
235 :initform nil
236 :type list
237 :custom (repeat (cons (string :tag "Name")
238 (string :tag "Value")))
239 :group (settings)
240 :documentation "Variables to set in this Makefile.")
241 (configuration-variables
242 :initarg :configuration-variables
243 :initform ("debug" (("DEBUG" . "1")))
244 :type list
245 :custom (repeat (cons (string :tag "Configuration")
246 (repeat
247 (cons (string :tag "Name")
248 (string :tag "Value")))))
249 :group (settings)
250 :documentation "Makefile variables to use in different configurations.
251 These variables are used in the makefile when a configuration becomes active.")
252 (inference-rules :initarg :inference-rules
253 :initform nil
254 :custom (repeat
255 (object :objecttype ede-makefile-rule))
256 :documentation "Inference rules to add to the makefile.")
257 (include-file :initarg :include-file
258 :initform nil
259 :custom (repeat
260 (string :tag "Include File"))
261 :documentation "Additional files to include.
262 These files can contain additional rules, variables, and customizations.")
263 (automatic-dependencies
264 :initarg :automatic-dependencies
265 :initform t
266 :type boolean
267 :custom boolean
268 :group (default settings)
269 :documentation
270 "Non-nil to do implement automatic dependencies in the Makefile.")
271 (menu :initform
273 [ "Regenerate Makefiles" ede-proj-regenerate t ]
274 [ "Upload Distribution" ede-upload-distribution t ]
277 (metasubproject
278 :initarg :metasubproject
279 :initform nil
280 :type boolean
281 :custom boolean
282 :group (default settings)
283 :documentation
284 "Non-nil if this is a metasubproject.
285 Usually, a subproject is determined by a parent project. If multiple top level
286 projects are grouped into a large project not maintained by EDE, then you need
287 to set this to non-nil. The only effect is that the `dist' rule will then avoid
288 making a tar file.")
290 "The EDE-PROJ project definition class.")
292 ;;; Code:
293 (defun ede-proj-load (project &optional rootproj)
294 "Load a project file from PROJECT directory.
295 If optional ROOTPROJ is provided then ROOTPROJ is the root project
296 for the tree being read in. If ROOTPROJ is nil, then assume that
297 the PROJECT being read in is the root project."
298 (save-excursion
299 (let ((ret (eieio-persistent-read (concat project "Project.ede")
300 ede-proj-project))
301 (subdirs (directory-files project nil "[^.].*" nil)))
302 (if (not (object-of-class-p ret 'ede-proj-project))
303 (error "Corrupt project file"))
304 (oset ret directory project)
305 (oset ret rootproject rootproj)
307 ;; Load the project file of each subdirectory containing a
308 ;; loadable Project.ede.
309 (while subdirs
310 (let ((sd (file-name-as-directory
311 (expand-file-name (car subdirs) project))))
312 (if (and (file-directory-p sd)
313 (ede-directory-project-p sd))
314 (oset ret subproj
315 (cons (ede-proj-load sd (or rootproj ret))
316 (oref ret subproj))))
317 (setq subdirs (cdr subdirs))))
318 ret)))
320 (defun ede-proj-save (&optional project)
321 "Write out object PROJECT into its file."
322 (save-excursion
323 (if (not project) (setq project (ede-current-project)))
324 (let ((cdir (oref project directory)))
325 (unwind-protect
326 (progn
327 (slot-makeunbound project :directory)
328 (eieio-persistent-save project))
329 ;; Restore the directory slot
330 (oset project directory cdir))) ))
332 (defmethod ede-commit-local-variables ((proj ede-proj-project))
333 "Commit change to local variables in PROJ."
334 (ede-proj-save proj))
336 (defmethod eieio-done-customizing ((proj ede-proj-project))
337 "Call this when a user finishes customizing this object.
338 Argument PROJ is the project to save."
339 (call-next-method)
340 (ede-proj-save proj))
342 (defmethod eieio-done-customizing ((target ede-proj-target))
343 "Call this when a user finishes customizing this object.
344 Argument TARGET is the project we are completing customization on."
345 (call-next-method)
346 (ede-proj-save (ede-current-project)))
348 (defmethod ede-commit-project ((proj ede-proj-project))
349 "Commit any change to PROJ to its file."
350 (ede-proj-save proj))
352 (defmethod ede-buffer-mine ((this ede-proj-project) buffer)
353 "Return t if object THIS lays claim to the file in BUFFER."
354 (let ((f (ede-convert-path this (buffer-file-name buffer))))
355 (or (string= (file-name-nondirectory (oref this file)) f)
356 (string= (ede-proj-dist-makefile this) f)
357 (string-match "Makefile\\(\\.\\(in\\|am\\)\\)?$" f)
358 (string-match "config\\(ure\\.\\(in\\|ac\\)\\|\\.status\\)?$" f)
359 (string-match "config.h\\(\\.in\\)?" f)
360 (member f '("AUTHORS" "NEWS" "COPYING" "INSTALL" "README"))
363 (defmethod ede-buffer-mine ((this ede-proj-target) buffer)
364 "Return t if object THIS lays claim to the file in BUFFER."
365 (or (call-next-method)
366 (ede-target-buffer-in-sourcelist this buffer (oref this auxsource))))
369 ;;; EDE command functions
371 (defvar ede-proj-target-history nil
372 "History when querying for a target type.")
374 (defmethod project-new-target ((this ede-proj-project)
375 &optional name type autoadd)
376 "Create a new target in THIS based on the current buffer."
377 (let* ((name (or name (read-string "Name: " "")))
378 (type (or type
379 (completing-read "Type: " ede-proj-target-alist
380 nil t nil '(ede-proj-target-history . 1))))
381 (ot nil)
382 (src (if (and (buffer-file-name)
383 (if (and autoadd (stringp autoadd))
384 (string= autoadd "y")
385 (y-or-n-p (format "Add %s to %s? " (buffer-name) name))))
386 (buffer-file-name)))
387 (fcn (cdr (assoc type ede-proj-target-alist)))
390 (when (not fcn)
391 (error "Unknown target type %s for EDE Project" type))
393 (setq ot (funcall fcn name :name name
394 :path (ede-convert-path this default-directory)
395 :source (if src
396 (list (file-name-nondirectory src))
397 nil)))
398 ;; If we added it, set the local buffer's object.
399 (if src (progn
400 (setq ede-object ot)
401 (ede-apply-object-keymap)))
402 ;; Add it to the project object
403 ;;(oset this targets (cons ot (oref this targets)))
404 ;; New form: Add to the end using fancy eieio function.
405 ;; @todone - Some targets probably want to be in the front.
406 ;; How to do that?
407 ;; @ans - See elisp autoloads for answer
408 (object-add-to-list this 'targets ot t)
409 ;; And save
410 (ede-proj-save this)))
412 (defmethod project-new-target-custom ((this ede-proj-project))
413 "Create a new target in THIS for custom."
414 (let* ((name (read-string "Name: " ""))
415 (type (completing-read "Type: " ede-proj-target-alist
416 nil t nil '(ede-proj-target-history . 1))))
417 (funcall (cdr (assoc type ede-proj-target-alist)) name :name name
418 :path (ede-convert-path this default-directory)
419 :source nil)))
421 (defmethod project-delete-target ((this ede-proj-target))
422 "Delete the current target THIS from its parent project."
423 (let ((p (ede-current-project))
424 (ts (oref this source)))
425 ;; Loop across all sources. If it exists in a buffer,
426 ;; clear its object.
427 (while ts
428 (let* ((default-directory (oref this path))
429 (b (get-file-buffer (car ts))))
430 (if b
431 (with-current-buffer b
432 (if (eq ede-object this)
433 (progn
434 (setq ede-object nil)
435 (ede-apply-object-keymap))))))
436 (setq ts (cdr ts)))
437 ;; Remove THIS from its parent.
438 ;; The two vectors should be pointer equivalent.
439 (oset p targets (delq this (oref p targets)))
440 (ede-proj-save (ede-current-project))))
442 (defmethod project-add-file ((this ede-proj-target) file)
443 "Add to target THIS the current buffer represented as FILE."
444 (let ((file (ede-convert-path this file))
445 (src (ede-target-sourcecode this)))
446 (while (and src (not (ede-want-file-p (car src) file)))
447 (setq src (cdr src)))
448 (when src
449 (setq src (car src))
450 (cond ((ede-want-file-source-p this file)
451 (object-add-to-list this 'source file t))
452 ((ede-want-file-auxiliary-p this file)
453 (object-add-to-list this 'auxsource file t))
454 (t (error "`project-add-file(ede-target)' source mismatch error")))
455 (ede-proj-save))))
457 (defmethod project-remove-file ((target ede-proj-target) file)
458 "For TARGET, remove FILE.
459 FILE must be massaged by `ede-convert-path'."
460 ;; Speedy delete should be safe.
461 (object-remove-from-list target 'source (ede-convert-path target file))
462 (object-remove-from-list target 'auxsource (ede-convert-path target file))
463 (ede-proj-save))
465 (defmethod project-update-version ((this ede-proj-project))
466 "The :version of project THIS has changed."
467 (ede-proj-save))
469 (defmethod project-make-dist ((this ede-proj-project))
470 "Build a distribution for the project based on THIS target."
471 (let ((pm (ede-proj-dist-makefile this))
472 (df (project-dist-files this)))
473 (if (and (file-exists-p (car df))
474 (not (y-or-n-p "Dist file already exists. Rebuild? ")))
475 (error "Try `ede-update-version' before making a distribution"))
476 (ede-proj-setup-buildenvironment this)
477 (if (ede-proj-automake-p this)
478 (setq pm (expand-file-name "Makefile"
479 (file-name-directory pm))))
480 (compile (concat ede-make-command " -f " pm " dist"))))
482 (defmethod project-dist-files ((this ede-proj-project))
483 "Return a list of files that constitutes a distribution of THIS project."
484 (list
485 ;; Note to self, keep this first for the above fn to check against.
486 (concat (oref this name) "-" (oref this version) ".tar.gz")
489 (defmethod project-compile-project ((proj ede-proj-project) &optional command)
490 "Compile the entire current project PROJ.
491 Argument COMMAND is the command to use when compiling."
492 (let ((pm (ede-proj-dist-makefile proj))
493 (default-directory (file-name-directory (oref proj file))))
494 (ede-proj-setup-buildenvironment proj)
495 (if (ede-proj-automake-p proj)
496 (setq pm (expand-file-name "Makefile"
497 (file-name-directory pm))))
498 (compile (concat ede-make-command" -f " pm " all"))))
500 ;;; Target type specific compilations/debug
502 (defmethod project-compile-target ((obj ede-proj-target) &optional command)
503 "Compile the current target OBJ.
504 Argument COMMAND is the command to use for compiling the target."
505 (project-compile-project (ede-current-project) command))
507 (defmethod project-compile-target ((obj ede-proj-target-makefile)
508 &optional command)
509 "Compile the current target program OBJ.
510 Optional argument COMMAND is the s the alternate command to use."
511 (ede-proj-setup-buildenvironment (ede-current-project))
512 (compile (concat ede-make-command " -f " (oref obj makefile) " "
513 (ede-proj-makefile-target-name obj))))
515 (defmethod project-debug-target ((obj ede-proj-target))
516 "Run the current project target OBJ in a debugger."
517 (error "Debug-target not supported by %s" (eieio-object-name obj)))
519 (defmethod project-run-target ((obj ede-proj-target))
520 "Run the current project target OBJ."
521 (error "Run-target not supported by %s" (eieio-object-name obj)))
523 (defmethod ede-proj-makefile-target-name ((this ede-proj-target))
524 "Return the name of the main target for THIS target."
525 (ede-name this))
527 ;;; Compiler and source code generators
529 (defmethod ede-want-file-auxiliary-p ((this ede-target) file)
530 "Return non-nil if THIS target wants FILE."
531 ;; By default, all targets reference the source object, and let it decide.
532 (let ((src (ede-target-sourcecode this)))
533 (while (and src (not (ede-want-file-auxiliary-p (car src) file)))
534 (setq src (cdr src)))
535 src))
537 (defmethod ede-proj-compilers ((obj ede-proj-target))
538 "List of compilers being used by OBJ.
539 If the `compiler' slot is empty, concoct one on a first match found
540 basis for any given type from the `availablecompilers' slot.
541 Otherwise, return the `compiler' slot.
542 Converts all symbols into the objects to be used."
543 (when (slot-exists-p obj 'compiler)
544 (let ((comp (oref obj compiler)))
545 (if comp
546 ;; Now that we have a pre-set compilers to use, convert tye symbols
547 ;; into objects for ease of use
548 (if (listp comp)
549 (setq comp (mapcar 'symbol-value comp))
550 (setq comp (list (symbol-value comp))))
551 (let* ((acomp (oref obj availablecompilers))
552 (avail (mapcar 'symbol-value acomp))
553 (st (oref obj sourcetype))
554 (sources (oref obj source)))
555 ;; COMP is not specified, so generate a list from the available
556 ;; compilers list.
557 (while st
558 (if (ede-want-any-source-files-p (symbol-value (car st)) sources)
559 (let ((c (ede-proj-find-compiler avail (car st))))
560 (if c (setq comp (cons c comp)))))
561 (setq st (cdr st)))
562 ;; Provide a good error msg.
563 (unless comp
564 (error "Could not find compiler match for source code extension \"%s\".
565 You may need to add support for this type of file."
566 (if sources
567 (file-name-extension (car sources))
568 "")))
570 ;; Return the discovered compilers.
571 comp)))
573 (defmethod ede-proj-linkers ((obj ede-proj-target))
574 "List of linkers being used by OBJ.
575 If the `linker' slot is empty, concoct one on a first match found
576 basis for any given type from the `availablelinkers' slot.
577 Otherwise, return the `linker' slot.
578 Converts all symbols into the objects to be used."
579 (when (slot-exists-p obj 'linker)
580 (let ((link (oref obj linker)))
581 (if link
582 ;; Now that we have a pre-set linkers to use, convert type symbols
583 ;; into objects for ease of use
584 (if (symbolp link)
585 (setq link (list (symbol-value link)))
586 (error ":linker is not a symbol. Howd you do that?"))
587 (let* ((alink (oref obj availablelinkers))
588 (avail (mapcar 'symbol-value alink))
589 (st (oref obj sourcetype))
590 (sources (oref obj source)))
591 ;; LINKER is not specified, so generate a list from the available
592 ;; compilers list.
593 (while st
594 (if (ede-want-any-source-files-p (symbol-value (car st)) sources)
595 (let ((c (ede-proj-find-linker avail (car st))))
596 (if c (setq link (cons c link)))))
597 (setq st (cdr st)))
598 (unless link
599 ;; No linker stands out! Loop over our linkers and pull out
600 ;; the first that has no source type requirement.
601 (while (and avail (not (eieio-instance-inheritor-slot-boundp (car avail) 'sourcetype)))
602 (setq avail (cdr avail)))
603 (setq link (cdr avail)))))
604 ;; Return the discovered linkers.
605 link)))
608 ;;; Target type specific autogenerating gobbledygook.
611 (defun ede-proj-makefile-type (&optional proj)
612 "Makefile type of the current project PROJ."
613 (oref (or proj (ede-current-project)) makefile-type))
615 (defun ede-proj-automake-p (&optional proj)
616 "Return non-nil if the current project PROJ is automake mode."
617 (eq (ede-proj-makefile-type proj) 'Makefile.am))
619 (defun ede-proj-autoconf-p (&optional proj)
620 "Return non-nil if the current project PROJ is automake mode."
621 (eq (ede-proj-makefile-type proj) 'Makefile.in))
623 (defun ede-proj-make-p (&optional proj)
624 "Return non-nil if the current project PROJ is automake mode."
625 (eq (ede-proj-makefile-type proj) 'Makefile))
627 (defmethod ede-proj-dist-makefile ((this ede-proj-project))
628 "Return the name of the Makefile with the DIST target in it for THIS."
629 (cond ((eq (oref this makefile-type) 'Makefile.am)
630 (concat (file-name-directory (oref this file))
631 "Makefile.am"))
632 ((eq (oref this makefile-type) 'Makefile.in)
633 (expand-file-name "Makefile.in"
634 (file-name-directory (oref this file))))
635 ((object-assoc "Makefile" 'makefile (oref this targets))
636 (expand-file-name "Makefile"
637 (file-name-directory (oref this file))))
639 (let ((targets (oref this targets)))
640 (while (and targets
641 (not (obj-of-class-p
642 (car targets)
643 'ede-proj-target-makefile)))
644 (setq targets (cdr targets)))
645 (if targets (oref (car targets) makefile)
646 (expand-file-name "Makefile"
647 (file-name-directory (oref this file))))))))
649 (defun ede-proj-regenerate ()
650 "Regenerate Makefiles for and edeproject project."
651 (interactive)
652 (ede-proj-setup-buildenvironment (ede-current-project) t))
654 (defmethod ede-proj-makefile-create-maybe ((this ede-proj-project) mfilename)
655 "Create a Makefile for all Makefile targets in THIS if needed.
656 MFILENAME is the makefile to generate."
657 ;; For now, pass through until dirty is implemented.
658 (require 'ede/pmake)
659 (if (or (not (file-exists-p mfilename))
660 (file-newer-than-file-p (oref this file) mfilename))
661 (ede-proj-makefile-create this mfilename)))
663 (defmethod ede-proj-setup-buildenvironment ((this ede-proj-project)
664 &optional force)
665 "Setup the build environment for project THIS.
666 Handles the Makefile, or a Makefile.am configure.ac combination.
667 Optional argument FORCE will force items to be regenerated."
668 (if (not force)
669 (ede-proj-makefile-create-maybe this (ede-proj-dist-makefile this))
670 (require 'ede/pmake)
671 (ede-proj-makefile-create this (ede-proj-dist-makefile this)))
672 ;; Rebuild all subprojects
673 (ede-map-subprojects
674 this (lambda (sproj) (ede-proj-setup-buildenvironment sproj force)))
675 ;; Autoconf projects need to do other kinds of initializations.
676 (when (and (ede-proj-automake-p this)
677 (eq this (ede-toplevel this)))
678 (require 'ede/pconf)
679 ;; If the user wants to force this, do it some other way?
680 (ede-proj-configure-synchronize this)
681 ;; Now run automake to fill in the blanks, autoconf, and other
682 ;; auto thingies so that we can just say "make" when done.
687 ;;; Lower level overloads
689 (defmethod project-rescan ((this ede-proj-project))
690 "Rescan the EDE proj project THIS."
691 (let ((root (or (ede-project-root this) this))
693 (setq ede-projects (delq root ede-projects))
694 ;; NOTE : parent function double-checks that this dir was
695 ;; already in memory once.
696 (ede-load-project-file (ede-project-root-directory root))
699 (provide 'ede/proj)
701 ;;; ede/proj.el ends here