Initial Commit
[packages] / xemacs-packages / ede / ede-proj.el
1 ;;; ede-proj.el --- EDE Generic Project file driver
2
3 ;;;  Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2007  Eric M. Ludlam
4
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; Keywords: project, make
7 ;; RCS: $Id: ede-proj.el,v 1.1 2007-11-26 15:22:10 michaels Exp $
8
9 ;; This software is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; This software is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
23
24 ;;; Commentary:
25 ;;
26 ;; EDE defines a method for managing a project.  EDE-PROJ aims to be a
27 ;; generic project file format based on the EIEIO object stream
28 ;; methods.  Changes in the project structure will require Makefile
29 ;; rebuild.  The targets provided in ede-proj can be augmented with
30 ;; additional target types inherited directly from `ede-proj-target'.
31
32 (eval-and-compile '(require 'ede))
33 (require 'ede-proj-comp)
34
35 ;;; Class Definitions:
36 (defclass ede-proj-target (ede-target)
37   ((auxsource :initarg :auxsource
38               :initform nil
39               :type list
40               :custom (repeat (string :tag "File"))
41               :label "Auxiliary Source Files"
42               :group (default source)
43               :documentation "Auxilliary source files included in this target.
44 Each of these is considered equivalent to a source file, but it is not
45 distributed, and each should have a corresponding rule to build it.")
46    (dirty :initform nil
47           :type boolean
48           :documentation "Non-nil when generated files needs updating.")
49    (compiler :initarg :compiler
50              :initform nil
51              :type (or null symbol)
52              :custom (choice (const :tag "None" nil)
53                              :slotofchoices availablecompilers)
54              :label "Compiler for building sources"
55              :group make
56              :documentation
57              "The compiler to be used to compile this object.
58 This should be a symbol, which contains the object defining the compiler.
59 This enables save/restore to do so by name, permitting the sharing
60 of these compiler resources, and global customization thereof.")
61    (linker :initarg :linker
62              :initform nil
63              :type (or null symbol)
64              :custom (choice (const :tag "None" nil)
65                              :slotofchoices availablelinkers)
66              :label "Linker for combining intermediate object files."
67              :group make
68              :documentation
69              "The linker to be used to link compled sources for this object.
70 This should be a symbol, which contains the object defining the linker.
71 This enables save/restore to do so by name, permitting the sharing
72 of these linker resources, and global customization thereof.")
73    ;; Class allocated slots
74    (phony :allocation :class
75           :initform nil
76           :type boolean
77           :documentation
78           "A phony target is one where the build target does not relate to a file.
79 Such targets are always built, but make knows how to deal with them..")
80    (availablecompilers :allocation :class
81                        :initform nil
82                        :type (or null list)
83                        :documentation
84                        "A list of `ede-compiler' objects.
85 These are the compilers the user can choose from when setting the
86 `compiler' slot.")
87    (availablelinkers :allocation :class
88                      :initform nil
89                      :type (or null list)
90                      :documentation
91                      "A list of `ede-linker' objects.
92 These are the linkers the user can choose from when setting the
93 `linker' slot.")
94    )
95   "Abstract class for ede-proj targets.")
96
97 (defclass ede-proj-target-makefile (ede-proj-target)
98   ((makefile :initarg :makefile
99              :initform "Makefile"
100              :type string
101              :custom string
102              :label "Parent Makefile"
103              :group make
104              :documentation "File name of generated Makefile.")
105    (partofall :initarg :partofall
106               :initform t
107               :type boolean
108               :custom boolean
109               :label "Part of `all:' target"
110               :group make
111               :documentation
112               "Non nil means the rule created is part of the all target.
113 Setting this to nil creates the rule to build this item, but does not
114 include it in the ALL`all:' rule.")
115    (configuration-variables
116     :initarg :configuration-variables
117     :initform nil
118     :type list
119     :custom (repeat (cons (string :tag "Configuration")
120                           (repeat
121                            (cons (string :tag "Name")
122                                  (string :tag "Value")))))
123     :label "Environment Variables for configurations"
124     :group make
125     :documentation "Makefile variables appended to use in different configurations.
126 These variables are used in the makefile when a configuration becomes active.
127 Target variables are always renamed such as foo_CFLAGS, then included into
128 commands where the variable would usually appear.")
129    (rules :initarg :rules
130           :initform nil
131           :type list
132           :custom (repeat (object :objecttype ede-makefile-rule))
133           :label "Additional Rules"
134           :group (make)
135           :documentation
136           "Arbitrary rules and dependencies needed to make this target.
137 It is safe to leave this blank.")
138    )
139   "Abstract class for Makefile based targets.")
140
141 (autoload 'ede-proj-target-aux "ede-proj-aux"
142   "Target class for a group of lisp files." nil nil)
143 (autoload 'ede-proj-target-elisp "ede-proj-elisp"
144   "Target class for a group of lisp files." nil nil)
145 (autoload 'ede-proj-target-elisp-autoloads "ede-proj-elisp"
146   "Target class for generating autoload files." nil nil)
147 (autoload 'ede-proj-target-scheme "ede-proj-scheme"
148   "Target class for a group of lisp files." nil nil)
149 (autoload 'ede-proj-target-makefile-miscelaneous "ede-proj-misc"
150   "Target class for a group of miscelaneous w/ a special makefile." nil nil)
151 (autoload 'ede-proj-target-makefile-program "ede-proj-prog"
152   "Target class for building a program." nil nil)
153 (autoload 'ede-proj-target-makefile-archive "ede-proj-archive"
154   "Target class for building an archive of object code." nil nil)
155 (autoload 'ede-proj-target-makefile-shared-object "ede-proj-shared"
156   "Target class for building a shared object." nil nil)
157 (autoload 'ede-proj-target-makefile-info "ede-proj-info"
158   "Target class for info files." nil nil)
159
160 (defvar ede-proj-target-alist
161   '(("program" . ede-proj-target-makefile-program)
162     ("archive" . ede-proj-target-makefile-archive)
163     ("sharedobject" . ede-proj-target-makefile-shared-object)
164     ("emacs lisp" . ede-proj-target-elisp)
165     ("emacs lisp autoloads" . ede-proj-target-elisp-autoloads)
166     ("info" . ede-proj-target-makefile-info)
167     ("auxiliary" . ede-proj-target-aux)
168     ("scheme" . ede-proj-target-scheme)
169     ("miscelaneous" . ede-proj-target-makefile-miscelaneous)
170     )
171   "Alist of names to class types for available project target classes.")
172
173 (defun ede-proj-register-target (name class)
174   "Register a new target class with NAME and class symbol CLASS.
175 This enables the creation of your target type."
176   (let ((a (assoc name ede-proj-target-alist)))
177     (if a
178         (setcdr a class)
179       (setq ede-proj-target-alist
180             (cons (cons name class) ede-proj-target-alist)))))
181
182 (defclass ede-proj-project (ede-project)
183   ((makefile-type :initarg :makefile-type
184                   :initform Makefile
185                   :type symbol
186                   :custom (choice (const Makefile)
187                                   ;(const Makefile.in)
188                                   (const Makefile.am)
189                                   ;(const cook)
190                                   )
191                   :documentation "The type of Makefile to generate.
192 Can be one of 'Makefile, 'Makefile.in, or 'Makefile.am.
193 If this value is NOT 'Makefile, then that overrides the :makefile slot
194 in targets.")
195    (variables :initarg :variables
196               :initform nil
197               :type list
198               :custom (repeat (cons (string :tag "Name")
199                                     (string :tag "Value")))
200               :documentation "Variables to set in this Makefile.")
201    (configuration-variables
202     :initarg :configuration-variables
203     :initform ("debug" (("DEBUG" . "1")))
204     :type list
205     :custom (repeat (cons (string :tag "Configuration")
206                           (repeat
207                            (cons (string :tag "Name")
208                                  (string :tag "Value")))))
209     :documentation "Makefile variables to use in different configurations.
210 These variables are used in the makefile when a configuration becomes active.")
211    (inference-rules :initarg :inference-rules
212                     :initform nil
213                     :custom (repeat
214                              (object :objecttype ede-makefile-rule))
215                     :documentation "Inference rules to add to the makefile.")
216    (include-file :initarg :include-file
217                  :initform nil
218                  :custom (repeat
219                           (string :tag "Include File"))
220                  :documentation "Additional files to include.
221 These files can contain additional rules, variables, and customizations.")
222    (automatic-dependencies
223     :initarg :automatic-dependencies
224     :initform t
225     :type boolean
226     :custom boolean
227     :group (default settings)
228     :documentation
229     "Non-nil to do implement automatic dependencies in the Makefile.")
230    (menu :initform
231          (
232           [ "Regenerate Makefiles" ede-proj-regenerate t ]
233           [ "Upload Distribution" ede-upload-distribution t ]
234           )
235          )
236    (metasubproject
237     :initarg :metasubproject
238     :initform nil
239     :type boolean
240     :custom boolean
241     :group (default settings)
242     :documentation
243     "Non-nil if this is a metasubproject.
244 Usually, a subproject is determined by a parent project.  If multiple top level
245 projects are grouped into a large project not maintained by EDE, then you need
246 to set this to non-nil.  The only effect is that the `dist' rule will then avoid
247 making a tar file.")
248    )
249   "The EDE-PROJ project definition class.")
250
251 ;;; Code:
252 (defun ede-proj-load (project)
253   "Load a project file PROJECT."
254   (save-excursion
255     (let ((ret nil)
256           (subdirs (directory-files project nil "[^.].*" nil)))
257       (set-buffer (get-buffer-create " *tmp proj read*"))
258       (unwind-protect
259           (progn
260             (insert-file-contents (concat project "Project.ede")
261                                   nil nil nil t)
262             (goto-char (point-min))
263             (setq ret (read (current-buffer)))
264             (if (not (eq (car ret) 'ede-proj-project))
265                 (error "Corrupt project file"))
266             (setq ret (eval ret))
267             (oset ret file (concat project "Project.ede")))
268         (kill-buffer " *tmp proj read*"))
269       (while subdirs
270         (let ((sd (concat project (car subdirs))))
271           (if (and (file-directory-p sd)
272                    (ede-directory-project-p (concat sd "/")))
273               (oset ret subproj (cons (ede-proj-load (concat sd "/"))
274                                       (oref ret subproj))))
275           (setq subdirs (cdr subdirs))))
276       ret)))
277
278 (defun ede-proj-save (&optional project)
279   "Write out object PROJECT into its file."
280   (save-excursion
281     (if (not project) (setq project (ede-current-project)))
282     (let ((b (set-buffer (get-buffer-create " *tmp proj write*")))
283           (cfn (oref project file)))
284       (unwind-protect
285           (save-excursion
286             (erase-buffer)
287             (let ((standard-output (current-buffer)))
288               (oset project file (file-name-nondirectory cfn))
289               (object-write project ";; EDE project file."))
290             (write-file cfn nil)
291             )
292         ;; Restore the :file on exit.
293         (oset project file cfn)
294         (kill-buffer b)))))
295
296 (defmethod ede-commit-local-variables ((proj ede-proj-project))
297   "Commit change to local variables in PROJ."
298   (ede-proj-save proj))
299
300 (defmethod eieio-done-customizing ((proj ede-proj-project))
301   "Call this when a user finishes customizing this object.
302 Argument PROJ is the project to save."
303   (call-next-method)
304   (ede-proj-save proj))
305
306 (defmethod eieio-done-customizing ((target ede-proj-target))
307   "Call this when a user finishes customizing this object.
308 Argument TARGET is the project we are completing customization on."
309   (call-next-method)
310   (ede-proj-save (ede-current-project)))
311
312 (defmethod ede-commit-project ((proj ede-proj-project))
313   "Commit any change to PROJ to its file."
314   (ede-proj-save proj))
315
316 (defmethod ede-buffer-mine ((this ede-proj-project) buffer)
317   "Return t if object THIS lays claim to the file in BUFFER."
318   (let ((f (ede-convert-path this (buffer-file-name buffer))))
319     (or (string= (file-name-nondirectory (oref this file)) f)
320         (string= (ede-proj-dist-makefile this) f)
321         (string-match "Makefile\\(\\.\\(in\\|am\\)\\)?" f)
322         (string-match "config\\(ure\\.in\\|\\.stutus\\)?" f)
323         )))
324
325 (defmethod ede-buffer-mine ((this ede-proj-target) buffer)
326   "Return t if object THIS lays claim to the file in BUFFER."
327   (or (call-next-method)
328       (ede-target-buffer-in-sourcelist this buffer (oref this auxsource))))
329
330 \f
331 ;;; EDE command functions
332 ;;
333 (defvar ede-proj-target-history nil
334   "History when querying for a target type.")
335
336 (defmethod project-new-target ((this ede-proj-project))
337   "Create a new target in THIS based on the current buffer."
338   (let* ((name (read-string "Name: " ""))
339          (type (completing-read "Type: " ede-proj-target-alist
340                                 nil t nil '(ede-proj-target-history . 1)))
341          (ot nil)
342          (src (if (and (buffer-file-name)
343                        (y-or-n-p (format "Add %s to %s? " (buffer-name) name)))
344                   (buffer-file-name))))
345     (setq ot (funcall (cdr (assoc type ede-proj-target-alist)) name :name name
346                       :path (ede-convert-path this default-directory)
347                       :source (if src
348                                   (list (file-name-nondirectory src))
349                                 nil)))
350     ;; If we added it, set the local buffer's object.
351     (if src (progn
352               (setq ede-object ot)
353               (ede-apply-object-keymap)))
354     ;; Add it to the project object
355     (oset this targets (cons ot (oref this targets)))
356     ;; And save
357     (ede-proj-save this)))
358
359 (defmethod project-new-target-custom ((this ede-proj-project))
360   "Create a new target in THIS for custom."
361   (let* ((name (read-string "Name: " ""))
362          (type (completing-read "Type: " ede-proj-target-alist
363                                 nil t nil '(ede-proj-target-history . 1))))
364     (funcall (cdr (assoc type ede-proj-target-alist)) name :name name
365              :path (ede-convert-path this default-directory)
366              :source nil)))
367
368 (defmethod project-delete-target ((this ede-proj-target))
369   "Delete the current target THIS from it's parent project."
370   (let ((p (ede-current-project))
371         (ts (oref this source)))
372     ;; Loop across all sources.  If it exists in a buffer,
373     ;; clear it's object.
374     (while ts
375       (let* ((default-directory (oref this path))
376              (b (get-file-buffer (car ts))))
377         (if b
378             (save-excursion
379               (set-buffer b)
380               (if (eq ede-object this)
381                   (progn
382                     (setq ede-object nil)
383                     (ede-apply-object-keymap))))))
384       (setq ts (cdr ts)))
385     ;; Remove THIS from it's parent.
386     ;; The two vectors should be pointer equivalent.
387     (oset p targets (delq this (oref p targets)))
388     (ede-proj-save (ede-current-project))))
389
390 (defmethod project-add-file ((this ede-proj-target) file)
391   "Add to target THIS the current buffer represented as FILE."
392   (let ((file (ede-convert-path this file))
393         (src (ede-target-sourcecode this))
394         (aux nil))
395     (while (and src (not (ede-want-file-p (car src) file)))
396       (setq src (cdr src)))
397     (when src
398       (setq src (car src))
399       (cond ((ede-want-file-source-p this file)
400              (object-add-to-list this 'source file t))
401             ((ede-want-file-auxiliary-p this file)
402              (object-add-to-list this 'auxsource file t))
403             (t (error "`project-add-file(ede-target)' source mismatch error")))
404       (ede-proj-save))))
405
406 (defmethod project-remove-file ((target ede-proj-target) file)
407   "For TARGET, remove FILE.
408 FILE must be massaged by `ede-convert-path'."
409   ;; Speedy delete should be safe.
410   (object-remove-from-list target 'source (ede-convert-path target file))
411   (object-remove-from-list target 'auxsource (ede-convert-path target file))
412   (ede-proj-save))
413
414 (defmethod project-update-version ((this ede-proj-project))
415   "The :version of project THIS has changed."
416   (ede-proj-save))
417
418 (defmethod project-make-dist ((this ede-proj-project))
419   "Build a distribution for the project based on THIS target."
420   ;; I'm a lazy bum, so I'll make a makefile for doing this sort
421   ;; of thing, and rely only on that small section of code.
422   (let ((pm (ede-proj-dist-makefile this))
423         (df (project-dist-files this)))
424     (if (and (file-exists-p (car df))
425              (not (y-or-n-p "Dist file already exists.  Rebuild? ")))
426         (error "Try `ede-update-version' before making a distribution"))
427     (ede-proj-setup-buildenvironment this)
428     (if (string= pm "Makefile.am") (setq pm "Makefile"))
429     (compile (concat "make -f " pm " dist"))
430     ))
431
432 (defmethod project-dist-files ((this ede-proj-project))
433   "Return a list of files that constitutes a distribution of THIS project."
434   (list
435    ;; Note to self, keep this first for the above fn to check against.
436    (concat (oref this name) "-" (oref this version) ".tar.gz")
437    ))
438
439 (defmethod project-compile-project ((proj ede-proj-project) &optional command)
440   "Compile the entire current project PROJ.
441 Argument COMMAND is the command to use when compiling."
442   (let ((pm (ede-proj-dist-makefile proj))
443         (default-directory (file-name-directory (oref proj file))))
444     (ede-proj-setup-buildenvironment proj)
445     (if (string= pm "Makefile.am") (setq pm "Makefile"))
446     (compile (concat "make -f " pm " all"))))
447
448 ;;; Target type specific compilations/debug
449 ;;
450 (defmethod project-compile-target ((obj ede-proj-target) &optional command)
451   "Compile the current target OBJ.
452 Argument COMMAND is the command to use for compiling the target."
453   (project-compile-project (ede-current-project) command))
454
455 (defmethod project-compile-target ((obj ede-proj-target-makefile)
456                                    &optional command)
457   "Compile the current target program OBJ.
458 Optional argument COMMAND is the s the alternate command to use."
459   (ede-proj-setup-buildenvironment (ede-current-project))
460   (compile (concat "make -f " (oref obj makefile) " "
461                    (ede-proj-makefile-target-name obj))))
462
463 (defmethod project-debug-target ((obj ede-proj-target))
464   "Run the current project target OBJ in a debugger."
465   (error "Debug-target not supported by %s" (object-name obj)))
466
467 (defmethod ede-proj-makefile-target-name ((this ede-proj-target))
468   "Return the name of the main target for THIS target."
469   (ede-name this))
470 \f
471 ;;; Compiler and source code generators
472 ;;
473 (defmethod ede-want-file-auxiliary-p ((this ede-target) file)
474   "Return non-nil if THIS target wants FILE."
475   ;; By default, all targets reference the source object, and let it decide.
476   (let ((src (ede-target-sourcecode this)))
477     (while (and src (not (ede-want-file-auxiliary-p (car src) file)))
478       (setq src (cdr src)))
479     src))
480
481 (defmethod ede-proj-compilers ((obj ede-proj-target))
482   "List of compilers being used by OBJ.
483 If the `compiler' slot is empty, concoct one on a first match found
484 basis for any given type from the `availablecompilers' slot.
485 Otherwise, return the `compiler' slot.
486 Converts all symbols into the objects to be used."
487   (when (slot-exists-p obj 'compiler)
488     (let ((comp (oref obj compiler)))
489       (if comp
490           ;; Now that we have a pre-set compilers to use, convert tye symbols
491           ;; into objects for ease of use
492           (if (listp comp)
493               (setq comp (mapcar 'symbol-value comp))
494             (setq comp (list (symbol-value comp))))
495         (let ((avail (mapcar 'symbol-value (oref obj availablecompilers)))
496               (st (oref obj sourcetype))
497               (sources (oref obj source)))
498           ;; COMP is not specified, so generate a list from the available
499           ;; compilers list.
500           (while st
501             (if (ede-want-any-source-files-p (symbol-value (car st)) sources)
502                 (let ((c (ede-proj-find-compiler avail (car st))))
503                   (if c (setq comp (cons c comp)))))
504             (setq st (cdr st)))))
505       ;; Return the disovered compilers
506       comp)))
507
508 (defmethod ede-proj-linkers ((obj ede-proj-target))
509   "List of linkers being used by OBJ.
510 If the `linker' slot is empty, concoct one on a first match found
511 basis for any given type from the `availablelinkers' slot.
512 Otherwise, return the `linker' slot.
513 Converts all symbols into the objects to be used."
514   (when (slot-exists-p obj 'linker)
515     (let ((link (oref obj linker)))
516       (if link
517           ;; Now that we have a pre-set linkers to use, convert type symbols
518           ;; into objects for ease of use
519           (setq link (mapcar 'symbol-value link))
520         (let ((avail (mapcar 'symbol-value (oref obj availablelinkers)))
521               (st (oref obj sourcetype))
522               (sources (oref obj source)))
523           ;; LINKER is not specified, so generate a list from the available
524           ;; compilers list.
525           (while st
526             (if (ede-want-any-source-files-p (symbol-value (car st)) sources)
527                 (let ((c (ede-proj-find-linker avail (car st))))
528                   (if c (setq link (cons c link)))))
529             (setq st (cdr st)))
530           (unless link
531             ;; No linker stands out!  Loop over our linkers and pull out
532             ;; the first that has no source type requirement.
533             (while (and avail (not (slot-boundp (car avail) 'sourcetype)))
534               (setq avail (cdr avail)))
535             (setq link (cdr avail)))))
536       ;; Return the disovered linkers
537       link)))
538     
539 \f
540 ;;; Target type specific autogenerating gobbldegook.
541 ;;
542 (eval-when-compile
543   ;; This provides prevents recursive loading during a compile
544   (provide 'ede-proj)
545   (require 'ede-pmake "ede-pmake.el")
546   (require 'ede-pconf "ede-pconf.el"))
547
548 (defun ede-proj-makefile-type (&optional proj)
549   "Makefile type of the current project PROJ."
550   (oref (or proj (ede-current-project)) makefile-type))
551
552 (defun ede-proj-automake-p (&optional proj)
553   "Return non-nil if the current project PROJ is automake mode."
554   (eq (ede-proj-makefile-type proj) 'Makefile.am))
555
556 (defun ede-proj-autoconf-p (&optional proj)
557   "Return non-nil if the current project PROJ is automake mode."
558   (eq (ede-proj-makefile-type proj) 'Makefile.in))
559
560 (defun ede-proj-make-p (&optional proj)
561   "Return non-nil if the current project PROJ is automake mode."
562   (eq (ede-proj-makefile-type proj) 'Makefile))
563
564 (defmethod ede-proj-dist-makefile ((this ede-proj-project))
565   "Return the name of the Makefile with the DIST target in it for THIS."
566   (cond ((eq (oref this makefile-type) 'Makefile.am)
567          (concat (file-name-directory (oref this file))
568                  "Makefile.am"))
569         ((eq (oref this makefile-type) 'Makefile.in)
570          (concat (file-name-directory (oref this file))
571                  "Makefile.in"))
572         ((object-assoc "Makefile" 'makefile (oref this targets))
573          (concat (file-name-directory (oref this file))
574                  "Makefile"))
575         (t
576          (let ((targets (oref this targets)))
577            (while (and targets
578                        (not (obj-of-class-p
579                              (car targets)
580                              'ede-proj-target-makefile)))
581              (setq targets (cdr targets)))
582            (if targets (oref (car targets) makefile)
583              (concat (file-name-directory (oref this file))
584                      "Makefile"))))))
585
586 (defun ede-proj-regenerate ()
587   "Regenerate Makefiles for and edeproject project."
588   (interactive)
589   (ede-proj-setup-buildenvironment (ede-current-project) t))
590
591 (defmethod ede-proj-makefile-create-maybe ((this ede-proj-project) mfilename)
592   "Create a Makefile for all Makefile targets in THIS if needed.
593 MFILENAME is the makefile to generate."
594   ;; For now, pass through until dirty is implemented.
595   (require 'ede-pmake)
596   (if (or (not (file-exists-p mfilename))
597           (file-newer-than-file-p (oref this file) mfilename))
598       (ede-proj-makefile-create this mfilename)))
599
600 (defmethod ede-proj-setup-buildenvironment ((this ede-proj-project)
601                                             &optional force)
602   "Setup the build environment for project THIS.
603 Handles the Makefile, or a Makefile.am configure.in combination.
604 Optional argument FORCE will force items to be regenerated."
605   (if (not force)
606       (ede-proj-makefile-create-maybe this (ede-proj-dist-makefile this))
607     (require 'ede-pmake)
608     (ede-proj-makefile-create this (ede-proj-dist-makefile this)))
609   (if (ede-proj-automake-p this)
610       (progn
611         (require 'ede-pconf)
612         ;; If the user wants to force this, do it some other way?
613         (ede-proj-configure-synchronize this)
614         ;; Now run automake to fill in the blanks, autoconf, and other
615         ;; auto thingies so that we can just say "make" when done.
616         
617         ))
618   ;; Rebuild all subprojects
619   (ede-map-subprojects
620    this (lambda (sproj) (ede-proj-setup-buildenvironment sproj force)))
621   )
622
623 \f
624 ;;; Lower level overloads
625 ;;  
626 (defmethod project-rescan ((this ede-proj-project))
627   "Rescan the EDE proj project THIS."
628   (ede-with-projectfile this
629     (goto-char (point-min))
630     (let ((l (read (current-buffer)))
631           (fields (object-slots this))
632           (targets (oref this targets)))
633       (setq l (cdr (cdr l))) ;; objtype and name skip
634       (while fields ;  reset to defaults those that dont appear.
635         (if (and (not (assoc (car fields) l))
636                  (not (eq (car fields) 'file)))
637             (let ((eieio-skip-typecheck t))
638               ;; This is a hazardous thing, for some elements
639               ;; might not be bound.  Skip typechecking and duplicate
640               ;; unbound slots along the way.
641               (eieio-oset this (car fields)
642                           (eieio-oref-default this (car fields)))))
643         (setq fields (cdr fields)))
644       (while l
645         (let ((field (car l)) (val (car (cdr l))))
646           (cond ((eq field targets)
647                  (let ((targets (oref this targets))
648                        (newtarg nil))
649                    (setq val (cdr val)) ;; skip the `list'
650                    (while val
651                      (let ((o (object-assoc (car (cdr (car val))) ; name
652                                             'name targets)))
653                        (if o
654                            (project-rescan o (car val))
655                          (setq o (eval (car val))))
656                        (setq newtarg (cons o newtarg)))
657                      (setq val (cdr val)))
658                    (oset this targets newtarg)))
659                 (t
660                  (eieio-oset this field val))))
661         (setq l (cdr (cdr l))))))) ;; field/value
662         
663 (defmethod project-rescan ((this ede-proj-target) readstream)
664   "Rescan target THIS from the read list READSTREAM."
665   (setq readstream (cdr (cdr readstream))) ;; constructor/name
666   (while readstream
667     (let ((tag (car readstream))
668           (val (car (cdr readstream))))
669       (eieio-oset this tag val))
670     (setq readstream (cdr (cdr readstream)))))
671
672 ;;;###autoload
673 (add-to-list 'auto-mode-alist '("Project\\.ede" . emacs-lisp-mode))
674
675 (provide 'ede-proj)
676
677 ;;; ede-proj.el ends here