* cedet/srecode/srt-mode.el (srecode-template-mode): Doc fix.
[bpt/emacs.git] / lisp / cedet / ede / pmake.el
1 ;;; ede-pmake.el --- EDE Generic Project Makefile code generator.
2
3 ;;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 ;;; 2007, 2008, 2009 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 ;; Code generator for Makefiles.
27 ;;
28 ;; Here is how it should work:
29 ;; 1) Collect information about the project and targets
30 ;; 2) Insert header into the Makefile
31 ;; 3) Insert basic variables (target/source)
32 ;; 4) Conditional
33 ;; a) Makefile
34 ;; 1) Insert support variables (compiler variables, etc)
35 ;; 2) Insert VERSION and DISTDIR
36 ;; 3) Specify top build dir if necessary
37 ;; 4) Specify compile/link commands (c, etc)
38 ;; 5) Specify dependency files
39 ;; 6) Specify all: target
40 ;; 7) Include dependency files
41 ;; 8) Insert commonized target specify rules
42 ;; 9) Insert clean: and dist: rules
43 ;; b) Automake file
44 ;; 1) Insert distribution source variables for targets
45 ;; 2) Insert user requested rules
46
47 (require 'ede/proj)
48 (require 'ede/proj-obj)
49 (require 'ede/proj-comp)
50
51 (declare-function ede-srecode-setup "ede/srecode")
52 (declare-function ede-srecode-insert "ede/srecode")
53
54 ;;; Code:
55 (defmethod ede-proj-makefile-create ((this ede-proj-project) mfilename)
56 "Create a Makefile for all Makefile targets in THIS.
57 MFILENAME is the makefile to generate."
58 (require 'ede/srecode)
59 (let ((mt nil)
60 (isdist (string= mfilename (ede-proj-dist-makefile this)))
61 (depth 0)
62 (orig-buffer nil)
63 (buff-to-kill nil)
64 )
65 ;; Find out how deep this project is.
66 (let ((tmp this))
67 (while (setq tmp (ede-parent-project tmp))
68 (setq depth (1+ depth))))
69 ;; Collect the targets that belong in a makefile.
70 (mapc
71 (lambda (obj)
72 (if (and (obj-of-class-p obj 'ede-proj-target-makefile)
73 (string= (oref obj makefile) mfilename))
74 (setq mt (cons obj mt))))
75 (oref this targets))
76 ;; Fix the order so things compile in the right direction.
77 (setq mt (nreverse mt))
78 ;; Add in the header part of the Makefile*
79 (save-excursion
80 (setq orig-buffer (get-file-buffer mfilename))
81 (set-buffer (setq buff-to-kill (find-file-noselect mfilename)))
82 (goto-char (point-min))
83 (if (and
84 (not (eobp))
85 (not (looking-at "# Automatically Generated \\w+ by EDE.")))
86 (if (not (y-or-n-p (format "Really replace %s? " mfilename)))
87 (error "Not replacing Makefile"))
88 (message "Replace EDE Makefile"))
89 (erase-buffer)
90 (ede-srecode-setup)
91 ;; Insert a giant pile of stuff that is common between
92 ;; one of our Makefiles, and a Makefile.in
93 (ede-srecode-insert
94 "file:ede-empty"
95 "MAKETYPE"
96 (with-slots (makefile-type) this
97 (cond ((eq makefile-type 'Makefile) "make")
98 ((eq makefile-type 'Makefile.in) "autoconf")
99 ((eq makefile-type 'Makefile.am) "automake")
100 (t (error ":makefile-type in project invalid")))))
101
102 ;; Just this project's variables
103 (ede-proj-makefile-insert-variables this)
104
105 ;; Space
106 (insert "\n")
107
108 (cond
109 ((eq (oref this makefile-type) 'Makefile)
110 ;; Make sure the user has the right kind of make
111 (ede-make-check-version)
112
113 (let* ((targ (if isdist (oref this targets) mt))
114 (sp (oref this subproj))
115 (df (apply 'append
116 (mapcar (lambda (tg)
117 (ede-proj-makefile-dependency-files tg))
118 targ))))
119 ;; Distribution variables
120 (ede-compiler-begin-unique
121 (mapc 'ede-proj-makefile-insert-variables targ))
122 ;; Only add the distribution stuff in when depth != 0
123 (let ((top (ede-toplevel this))
124 (tmp this)
125 (subdir ""))
126 (insert "VERSION=" (oref top version) "\n"
127 "DISTDIR=$(top)" (oref top name) "-$(VERSION)")
128 (while (ede-parent-project tmp)
129 (setq subdir
130 (concat
131 "/"
132 (file-name-nondirectory
133 (directory-file-name
134 (file-name-directory (oref tmp file))))
135 subdir)
136 tmp (ede-parent-project tmp)))
137 (insert subdir "\n"))
138 ;; Some built in variables for C code
139 (if df
140 (let ((tc depth))
141 (insert "top_builddir = ")
142 (while (/= 0 tc)
143 (setq tc (1- tc))
144 (insert "..")
145 (if (/= tc 0) (insert "/")))
146 (insert "\n")))
147 (insert "\n")
148 ;; Create a variable with all the dependency files to include
149 ;; These methods borrowed from automake.
150 (if (and (oref this automatic-dependencies) df)
151 (progn
152 (insert "DEP_FILES="
153 (mapconcat (lambda (f)
154 (concat ".deps/"
155 (file-name-nondirectory
156 (file-name-sans-extension
157 f)) ".P"))
158 df " "))))
159 ;;
160 ;; Insert ALL Rule
161 ;;
162 (insert "\n\nall:")
163 (mapc (lambda (c)
164 (if (and (slot-exists-p c 'partofall) (oref c partofall))
165 ;; Only insert this rule if it is a part of ALL.
166 (insert " " (ede-proj-makefile-target-name c))))
167 targ)
168 (mapc (lambda (c)
169 (insert " " (ede-name c))
170 )
171 sp)
172 (insert "\n\n")
173 ;;
174 ;; Add in the include files
175 ;;
176 (mapc (lambda (c)
177 (insert "include " c "\n\n"))
178 (oref this include-file))
179 ;; Some C inference rules
180 ;; Dependency rules borrowed from automake.
181 ;;
182 ;; NOTE: This is GNU Make specific.
183 (if (and (oref this automatic-dependencies) df)
184 (insert "DEPS_MAGIC := $(shell mkdir .deps > /dev/null "
185 "2>&1 || :)\n"
186 "-include $(DEP_FILES)\n\n"))
187 ;;
188 ;; General makefile rules stored in the individual targets
189 ;;
190 (ede-compiler-begin-unique
191 (ede-proj-makefile-insert-rules this)
192 (mapc 'ede-proj-makefile-insert-rules targ))
193 ;;
194 ;; phony targets for sub projects
195 ;;
196 (mapc 'ede-proj-makefile-insert-subproj-rules sp)
197 ;;
198 ;; Distribution rules such as CLEAN and DIST
199 ;;
200 (when isdist
201 (ede-proj-makefile-tags this mt)
202 (ede-proj-makefile-insert-dist-rules this)))
203 (save-buffer))
204 ((eq (oref this makefile-type) 'Makefile.in)
205 (error "Makefile.in is not supported"))
206 ((eq (oref this makefile-type) 'Makefile.am)
207 (require 'ede/pconf)
208 ;; Distribution variables
209 (let ((targ (if isdist (oref this targets) mt)))
210 (ede-compiler-begin-unique
211 (mapc 'ede-proj-makefile-insert-automake-pre-variables targ))
212 (ede-compiler-begin-unique
213 (mapc 'ede-proj-makefile-insert-source-variables targ))
214 (ede-compiler-begin-unique
215 (mapc 'ede-proj-makefile-insert-automake-post-variables targ))
216 (ede-compiler-begin-unique
217 (ede-proj-makefile-insert-user-rules this))
218 (insert "\n# End of Makefile.am\n")
219 (save-buffer))
220 )
221 (t (error "Unknown makefile type when generating Makefile")))
222 ;; Put the cursor in a nice place
223 (goto-char (point-min)))
224 ;; If we have an original buffer, then don't kill it.
225 (when (not orig-buffer)
226 (kill-buffer buff-to-kill))
227 ))
228
229 ;;; VARIABLE insertion
230 ;;
231 (defun ede-pmake-end-of-variable ()
232 "Move to the end of the variable declaration under point."
233 (end-of-line)
234 (while (= (preceding-char) ?\\)
235 (forward-char 1)
236 (end-of-line))
237 )
238
239 (defmacro ede-pmake-insert-variable-shared (varname &rest body)
240 "Add VARNAME into the current Makefile.
241 Execute BODY in a location where a value can be placed."
242 `(let ((addcr t) (v ,varname))
243 (if (re-search-backward (concat "^" v "\\s-*=") nil t)
244 (progn
245 (ede-pmake-end-of-variable)
246 (if (< (current-column) 40)
247 (if (and (/= (preceding-char) ?=)
248 (/= (preceding-char) ? ))
249 (insert " "))
250 (insert "\\\n "))
251 (setq addcr nil))
252 (insert v "="))
253 ,@body
254 (if addcr (insert "\n"))
255 (goto-char (point-max))))
256 (put 'ede-pmake-insert-variable-shared 'lisp-indent-function 1)
257
258 (defmacro ede-pmake-insert-variable-once (varname &rest body)
259 "Add VARNAME into the current Makefile if it doesn't exist.
260 Execute BODY in a location where a value can be placed."
261 `(let ((addcr t) (v ,varname))
262 (unless (re-search-backward (concat "^" v "\\s-*=") nil t)
263 (insert v "=")
264 ,@body
265 (if addcr (insert "\n"))
266 (goto-char (point-max)))
267 ))
268 (put 'ede-pmake-insert-variable-once 'lisp-indent-function 1)
269
270 ;;; SOURCE VARIABLE NAME CONSTRUCTION
271
272 (defsubst ede-pmake-varname (obj)
273 "Convert OBJ into a variable name name.
274 Change . to _ in the variable name."
275 (let ((name (oref obj name)))
276 (while (string-match "\\." name)
277 (setq name (replace-match "_" nil t name)))
278 name))
279
280 (defmethod ede-proj-makefile-sourcevar ((this ede-proj-target))
281 "Return the variable name for THIS's sources."
282 (concat (ede-pmake-varname this) "_YOU_FOUND_A_BUG"))
283
284 ;;; DEPENDENCY FILE GENERATOR LISTS
285 ;;
286 (defmethod ede-proj-makefile-dependency-files ((this ede-proj-target))
287 "Return a list of source files to convert to dependencies.
288 Argument THIS is the target to get sources from."
289 nil)
290
291 ;;; GENERIC VARIABLES
292 ;;
293 (defmethod ede-proj-makefile-configuration-variables ((this ede-proj-project)
294 configuration)
295 "Return a list of configuration variables from THIS.
296 Use CONFIGURATION as the current configuration to query."
297 (cdr (assoc configuration (oref this configuration-variables))))
298
299 (defmethod ede-proj-makefile-insert-variables-new ((this ede-proj-project))
300 "Insert variables needed by target THIS.
301
302 NOTE: Not yet in use! This is part of an SRecode conversion of
303 EDE that is in progress."
304 ; (let ((conf-table (ede-proj-makefile-configuration-variables
305 ; this (oref this configuration-default)))
306 ; (conf-done nil))
307 ;
308 ; (ede-srecode-insert-with-dictionary
309 ; "declaration:ede-vars"
310 ;
311 ; ;; Insert all variables, and augment them with details from
312 ; ;; the current configuration.
313 ; (mapc (lambda (c)
314 ;
315 ; (let ((ldict (srecode-dictionary-add-section-dictionary
316 ; dict "VARIABLE"))
317 ; )
318 ; (srecode-dictionary-set-value ldict "NAME" (car c))
319 ; (if (assoc (car c) conf-table)
320 ; (let ((vdict (srecode-dictionary-add-section-dictionary
321 ; ldict "VALUE")))
322 ; (srecode-dictionary-set-value
323 ; vdict "VAL" (cdr (assoc (car c) conf-table)))
324 ; (setq conf-done (cons (car c) conf-done))))
325 ; (let ((vdict (srecode-dictionary-add-section-dictionary
326 ; ldict "VALUE")))
327 ; (srecode-dictionary-set-value vdict "VAL" (cdr c))))
328 ; )
329 ;
330 ; (oref this variables))
331 ;
332 ; ;; Add in all variables from the configuration not allready covered.
333 ; (mapc (lambda (c)
334 ;
335 ; (if (member (car c) conf-done)
336 ; nil
337 ; (let* ((ldict (srecode-dictionary-add-section-dictionary
338 ; dict "VARIABLE"))
339 ; (vdict (srecode-dictionary-add-section-dictionary
340 ; ldict "VALUE"))
341 ; )
342 ; (srecode-dictionary-set-value ldict "NAME" (car c))
343 ; (srecode-dictionary-set-value vdict "VAL" (cdr c))))
344 ; )
345 ;
346 ; conf-table)
347 ;
348
349 ;; @TODO - finish off this function, and replace the below fcn
350
351 ; ))
352 )
353
354 (defmethod ede-proj-makefile-insert-variables ((this ede-proj-project))
355 "Insert variables needed by target THIS."
356 (let ((conf-table (ede-proj-makefile-configuration-variables
357 this (oref this configuration-default)))
358 (conf-done nil))
359 ;; Insert all variables, and augment them with details from
360 ;; the current configuration.
361 (mapc (lambda (c)
362 (insert (car c) "=")
363 (if (assoc (car c) conf-table)
364 (progn
365 (insert (cdr (assoc (car c) conf-table)) " ")
366 (setq conf-done (cons (car c) conf-done))))
367 (insert (cdr c) "\n"))
368 (oref this variables))
369 ;; Add in all variables from the configuration not allready covered.
370 (mapc (lambda (c)
371 (if (member (car c) conf-done)
372 nil
373 (insert (car c) "=" (cdr c) "\n")))
374 conf-table))
375 (let* ((top "")
376 (tmp this))
377 (while (ede-parent-project tmp)
378 (setq tmp (ede-parent-project tmp)
379 top (concat "../" top)))
380 (insert "\ntop=" top))
381 (insert "\nede_FILES=" (file-name-nondirectory (oref this file)) " "
382 (file-name-nondirectory (ede-proj-dist-makefile this)) "\n"))
383
384 (defmethod ede-proj-makefile-insert-source-variables ((this ede-proj-target)
385 &optional
386 moresource)
387 "Insert the source variables needed by THIS.
388 Optional argument MORESOURCE is a list of additional sources to add to the
389 sources variable."
390 (let ((sv (ede-proj-makefile-sourcevar this)))
391 ;; This variable may be shared between targets
392 (ede-pmake-insert-variable-shared (cond ((listp sv) (car sv))
393 (t sv))
394 (insert (mapconcat (lambda (a) a) (oref this source) " "))
395 (if moresource
396 (insert " \\\n " (mapconcat (lambda (a) a) moresource " ") "")))))
397
398 (defmethod ede-proj-makefile-insert-variables ((this ede-proj-target) &optional
399 moresource)
400 "Insert variables needed by target THIS.
401 Optional argument MORESOURCE is a list of additional sources to add to the
402 sources variable."
403 (ede-proj-makefile-insert-source-variables this moresource)
404 )
405
406 (defmethod ede-proj-makefile-configuration-variables ((this ede-proj-target-makefile)
407 configuration)
408 "Return a list of configuration variables from THIS.
409 Use CONFIGURATION as the current configuration to query."
410 (cdr (assoc configuration (oref this configuration-variables))))
411
412 (defmethod ede-proj-makefile-insert-variables ((this ede-proj-target-makefile)
413 &optional moresource)
414 "Insert variables needed by target THIS.
415 Optional argument MORESOURCE is a list of additional sources to add to the
416 sources variable."
417 (call-next-method)
418 (let* ((proj (ede-target-parent this))
419 (conf-table (ede-proj-makefile-configuration-variables
420 this (oref proj configuration-default)))
421 (conf-done nil)
422 )
423 ;; Add in all variables from the configuration not allready covered.
424 (mapc (lambda (c)
425 (if (member (car c) conf-done)
426 nil
427 (insert (car c) "=" (cdr c) "\n")))
428 conf-table))
429 (let ((comp (ede-proj-compilers this))
430 (link (ede-proj-linkers this))
431 (name (ede-proj-makefile-target-name this))
432 (src (oref this source)))
433 (while comp
434 (ede-compiler-only-once (car comp)
435 (ede-proj-makefile-insert-object-variables (car comp) name src)
436 (ede-proj-makefile-insert-variables (car comp)))
437 (setq comp (cdr comp)))
438 (while link
439 (ede-linker-only-once (car link)
440 (ede-proj-makefile-insert-variables (car link)))
441 (setq link (cdr link)))))
442
443 (defmethod ede-proj-makefile-insert-automake-pre-variables
444 ((this ede-proj-target))
445 "Insert variables needed by target THIS in Makefile.am before SOURCES."
446 nil)
447
448 (defmethod ede-proj-makefile-insert-automake-post-variables
449 ((this ede-proj-target))
450 "Insert variables needed by target THIS in Makefile.am after SOURCES."
451 nil)
452
453 ;;; GARBAGE PATTERNS
454 ;;
455 (defmethod ede-proj-makefile-garbage-patterns ((this ede-proj-project))
456 "Return a list of patterns that are considered garbage to THIS.
457 These are removed with make clean."
458 (let ((mc (ede-map-targets
459 this (lambda (c) (ede-proj-makefile-garbage-patterns c))))
460 (uniq nil))
461 (setq mc (sort (apply 'append mc) 'string<))
462 ;; Filter out duplicates from the targets.
463 (while mc
464 (if (and (car uniq) (string= (car uniq) (car mc)))
465 nil
466 (setq uniq (cons (car mc) uniq)))
467 (setq mc (cdr mc)))
468 (nreverse uniq)))
469
470 (defmethod ede-proj-makefile-garbage-patterns ((this ede-proj-target))
471 "Return a list of patterns that are considered garbage to THIS.
472 These are removed with make clean."
473 ;; Get the the source object from THIS, and use the specified garbage.
474 (let ((src (ede-target-sourcecode this))
475 (garb nil))
476 (while src
477 (setq garb (append (oref (car src) garbagepattern) garb)
478 src (cdr src)))
479 garb))
480
481
482 ;;; RULES
483 ;;
484 (defmethod ede-proj-makefile-insert-subproj-rules ((this ede-proj-project))
485 "Insert a rule for the project THIS which should be a subproject."
486 (insert ".PHONY:" (ede-name this))
487 (newline)
488 (insert (ede-name this) ":")
489 (newline)
490 (insert "\t$(MAKE) -C " (directory-file-name (ede-subproject-relative-path this)))
491 (newline)
492 (newline)
493 )
494
495 (defmethod ede-proj-makefile-insert-rules ((this ede-proj-project))
496 "Insert rules needed by THIS target."
497 (mapc 'ede-proj-makefile-insert-rules (oref this inference-rules))
498 )
499
500 (defmethod ede-proj-makefile-insert-dist-dependencies ((this ede-proj-project))
501 "Insert any symbols that the DIST rule should depend on.
502 Argument THIS is the project that should insert stuff."
503 (mapc 'ede-proj-makefile-insert-dist-dependencies (oref this targets))
504 )
505
506 (defmethod ede-proj-makefile-insert-dist-dependencies ((this ede-proj-target))
507 "Insert any symbols that the DIST rule should depend on.
508 Argument THIS is the target that should insert stuff."
509 nil)
510
511 (defmethod ede-proj-makefile-insert-dist-filepatterns ((this ede-proj-target))
512 "Insert any symbols that the DIST rule should depend on.
513 Argument THIS is the target that should insert stuff."
514 (ede-proj-makefile-insert-dist-dependencies this)
515 )
516
517 (defmethod ede-proj-makefile-insert-dist-rules ((this ede-proj-project))
518 "Insert distribution rules for THIS in a Makefile, such as CLEAN and DIST."
519 (let ((junk (ede-proj-makefile-garbage-patterns this))
520 tmp)
521 ;; Build CLEAN, DIST, TAG, and other rules here.
522 (if junk
523 (insert "\nclean:\n"
524 "\trm -f "
525 (mapconcat (lambda (c) c) junk " ")
526 "\n\n"))
527 ;; @TODO: ^^^ Clean should also recurse. ^^^
528
529 (insert ".PHONY: dist\n")
530 (insert "\ndist:")
531 (ede-proj-makefile-insert-dist-dependencies this)
532 (insert "\n")
533 (unless (or (ede-subproject-p this)
534 (oref this metasubproject))
535 ;; Only delete if we are the toplevel project.
536 (insert "\trm -rf $(DISTDIR)\n"))
537 (insert "\tmkdir $(DISTDIR)\n") ;We may need a -p, but I think not.
538 (setq tmp (oref this targets))
539 (insert "\tcp")
540 (while tmp
541 (let ((sv (ede-proj-makefile-sourcevar (car tmp))))
542 (if (listp sv)
543 ;; Handle special case variables.
544 (cond ((eq (cdr sv) 'share)
545 ;; This variable may be shared between multiple targets.
546 (if (re-search-backward (concat "\\$(" (car sv) ")")
547 (save-excursion
548 (beginning-of-line)
549 (point))
550 t)
551 ;; If its already in the dist target, then skip it.
552 nil
553 (setq sv (car sv))))
554 (t (setq sv (car sv)))))
555 (if (stringp sv)
556 (insert " $(" sv ")"))
557 (ede-proj-makefile-insert-dist-filepatterns (car tmp))
558 (setq tmp (cdr tmp))))
559 (insert " $(ede_FILES) $(DISTDIR)\n")
560
561 ;; Call our sub projects.
562 (ede-map-subprojects
563 this (lambda (sproj)
564 (let ((rp (directory-file-name (ede-subproject-relative-path sproj))))
565 (insert "\t$(MAKE) -C " rp " $(MFLAGS) DISTDIR=$(DISTDIR)/" rp
566 " dist"
567 "\n"))))
568
569 ;; Tar up the stuff.
570 (unless (or (ede-subproject-p this)
571 (oref this metasubproject))
572 (insert "\ttar -cvzf $(DISTDIR).tar.gz $(DISTDIR)\n"
573 "\trm -rf $(DISTDIR)\n"))
574
575 ;; Make sure the Makefile is ok.
576 (insert "\n"
577 (file-name-nondirectory (buffer-file-name)) ": "
578 (file-name-nondirectory (oref this file)) "\n"
579 ;; "$(EMACS) -batch Project.ede -l ede -f ede-proj-regenerate"
580 "\t@echo Makefile is out of date! "
581 "It needs to be regenerated by EDE.\n"
582 "\t@echo If you have not modified Project.ede, you can"
583 " use 'touch' to update the Makefile time stamp.\n"
584 "\t@false\n\n"
585 "\n\n# End of Makefile\n")))
586
587 (defmethod ede-proj-makefile-insert-rules ((this ede-proj-target))
588 "Insert rules needed by THIS target."
589 nil)
590
591 (defmethod ede-proj-makefile-insert-rules ((this ede-proj-target-makefile))
592 "Insert rules needed by THIS target."
593 (mapc 'ede-proj-makefile-insert-rules (oref this rules))
594 (let ((c (ede-proj-compilers this)))
595 (when c
596 (mapc 'ede-proj-makefile-insert-rules c)
597 (if (oref this phony)
598 (insert ".PHONY: " (ede-proj-makefile-target-name this) "\n"))
599 (insert (ede-proj-makefile-target-name this) ": "
600 (ede-proj-makefile-dependencies this) "\n")
601 (ede-proj-makefile-insert-commands this)
602 )))
603
604 (defmethod ede-proj-makefile-insert-commands ((this ede-proj-target-makefile))
605 "Insert the commands needed by target THIS.
606 For targets, insert the commands needed by the chosen compiler."
607 (mapc 'ede-proj-makefile-insert-commands (ede-proj-compilers this))
608 (when (object-assoc t :uselinker (ede-proj-compilers this))
609 (mapc 'ede-proj-makefile-insert-commands (ede-proj-linkers this))))
610
611
612 (defmethod ede-proj-makefile-insert-user-rules ((this ede-proj-project))
613 "Insert user specified rules needed by THIS target.
614 This is different from `ede-proj-makefile-insert-rules' in that this
615 function won't create the building rules which are auto created with
616 automake."
617 (mapc 'ede-proj-makefile-insert-user-rules (oref this inference-rules)))
618
619 (defmethod ede-proj-makefile-insert-user-rules ((this ede-proj-target))
620 "Insert user specified rules needed by THIS target."
621 (mapc 'ede-proj-makefile-insert-rules (oref this rules)))
622
623 (defmethod ede-proj-makefile-dependencies ((this ede-proj-target-makefile))
624 "Return a string representing the dependencies for THIS.
625 Some compilers only use the first element in the dependencies, others
626 have a list of intermediates (object files), and others don't care.
627 This allows customization of how these elements appear."
628 (let* ((c (ede-proj-compilers this))
629 (io (eval (cons 'or (mapcar 'ede-compiler-intermediate-objects-p c))))
630 (out nil))
631 (if io
632 (progn
633 (while c
634 (setq out
635 (concat out "$(" (ede-compiler-intermediate-object-variable
636 (car c)
637 (ede-proj-makefile-target-name this)) ")")
638 c (cdr c)))
639 out)
640 (let ((sv (ede-proj-makefile-sourcevar this))
641 (aux (oref this auxsource)))
642 (setq out
643 (if (and (stringp sv) (not (string= sv "")))
644 (concat "$(" sv ")")
645 ""))
646 (while aux
647 (setq out (concat out " " (car aux)))
648 (setq aux (cdr aux)))
649 out))))
650
651 ;; Tags
652 (defmethod ede-proj-makefile-tags ((this ede-proj-project) targets)
653 "Insert into the current location rules to make recursive TAGS files.
654 Argument THIS is the project to create tags for.
655 Argument TARGETS are the targets we should depend on for TAGS."
656 (insert "tags: ")
657 (let ((tg targets))
658 ;; Loop over all source variables and insert them
659 (while tg
660 (insert "$(" (ede-proj-makefile-sourcevar (car tg)) ") ")
661 (setq tg (cdr tg)))
662 (insert "\n")
663 (if targets
664 (insert "\tetags $^\n"))
665 ;; Now recurse into all subprojects
666 (setq tg (oref this subproj))
667 (while tg
668 (insert "\t$(MAKE) -C " (ede-subproject-relative-path (car tg)) " $(MFLAGS) $@\n")
669 (setq tg (cdr tg)))
670 (insert "\n")))
671
672
673 (provide 'ede/pmake)
674
675 ;; arch-tag: 7ad8e19f-cdee-484c-8caf-f15cb0fc4df2
676 ;;; ede/pmake.el ends here