;;; ede-pmake.el --- EDE Generic Project Makefile code generator.
-;;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-;;; 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+;; 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; Keywords: project, make
;; 1) Insert distribution source variables for targets
;; 2) Insert user requested rules
+(eval-when-compile (require 'cl))
(require 'ede/proj)
(require 'ede/proj-obj)
(require 'ede/proj-comp)
+(declare-function ede-srecode-setup "ede/srecode")
+(declare-function ede-srecode-insert "ede/srecode")
+
;;; Code:
(defmethod ede-proj-makefile-create ((this ede-proj-project) mfilename)
"Create a Makefile for all Makefile targets in THIS.
MFILENAME is the makefile to generate."
+ (require 'ede/srecode)
(let ((mt nil)
(isdist (string= mfilename (ede-proj-dist-makefile this)))
(depth 0)
((eq (oref this makefile-type) 'Makefile.in)
(error "Makefile.in is not supported"))
((eq (oref this makefile-type) 'Makefile.am)
- (require 'ede-pconf)
+ (require 'ede/pconf)
+ ;; Basic vars needed:
+ (ede-proj-makefile-automake-insert-subdirs this)
+ (ede-proj-makefile-automake-insert-extradist this)
;; Distribution variables
(let ((targ (if isdist (oref this targets) mt)))
(ede-compiler-begin-unique
"Add VARNAME into the current Makefile.
Execute BODY in a location where a value can be placed."
`(let ((addcr t) (v ,varname))
- (if (re-search-backward (concat "^" v "\\s-*=") nil t)
- (progn
- (ede-pmake-end-of-variable)
- (if (< (current-column) 40)
- (if (and (/= (preceding-char) ?=)
- (/= (preceding-char) ? ))
- (insert " "))
- (insert "\\\n "))
- (setq addcr nil))
- (insert v "="))
+ (if (save-excursion
+ (goto-char (point-max))
+ (re-search-backward (concat "^" v "\\s-*=") nil t))
+ (progn
+ (goto-char (match-end 0))
+ (ede-pmake-end-of-variable)
+ (if (< (current-column) 40)
+ (if (and (/= (preceding-char) ?=)
+ (/= (preceding-char) ? ))
+ (insert " "))
+ (insert "\\\n "))
+ (setq addcr nil))
+ (insert v "="))
+ ,@body
+ (if addcr (insert "\n"))
+ (goto-char (point-max))))
+(put 'ede-pmake-insert-variable-shared 'lisp-indent-function 1)
+
+(defmacro ede-pmake-insert-variable-once (varname &rest body)
+ "Add VARNAME into the current Makefile if it doesn't exist.
+Execute BODY in a location where a value can be placed."
+ `(let ((addcr t) (v ,varname))
+ (unless (re-search-backward (concat "^" v "\\s-*=") nil t)
+ (insert v "=")
,@body
(if addcr (insert "\n"))
- (goto-char (point-max))))
-(put 'ede-pmake-insert-variable-shared 'lisp-indent-function 1)
+ (goto-char (point-max)))
+ ))
+(put 'ede-pmake-insert-variable-once 'lisp-indent-function 1)
;;; SOURCE VARIABLE NAME CONSTRUCTION
conf-table))
(let* ((top "")
(tmp this))
+ ;; Use relative paths for subdirs.
(while (ede-parent-project tmp)
(setq tmp (ede-parent-project tmp)
top (concat "../" top)))
- (insert "\ntop=" top))
+ ;; If this is the top, then use CURDIR.
+ (if (and (not (oref this metasubproject)) (string= top ""))
+ (insert "\ntop=\"$(CURDIR)\"/")
+ (insert "\ntop=" top)))
(insert "\nede_FILES=" (file-name-nondirectory (oref this file)) " "
(file-name-nondirectory (ede-proj-dist-makefile this)) "\n"))
(link (ede-proj-linkers this))
(name (ede-proj-makefile-target-name this))
(src (oref this source)))
- (while comp
- (ede-compiler-only-once (car comp)
- (ede-proj-makefile-insert-object-variables (car comp) name src)
- (ede-proj-makefile-insert-variables (car comp)))
- (setq comp (cdr comp)))
- (while link
- (ede-linker-only-once (car link)
- (ede-proj-makefile-insert-variables (car link)))
- (setq link (cdr link)))))
+ (ede-proj-makefile-insert-object-variables (car comp) name src)
+ (dolist (obj comp)
+ (ede-compiler-only-once obj
+ (ede-proj-makefile-insert-variables obj)))
+ (dolist (linker link)
+ (ede-linker-only-once linker
+ (ede-proj-makefile-insert-variables linker)))))
(defmethod ede-proj-makefile-insert-automake-pre-variables
((this ede-proj-target))
(ede-proj-makefile-insert-dist-dependencies this)
)
+(defmethod ede-proj-makefile-automake-insert-subdirs ((this ede-proj-project))
+ "Insert a SUBDIRS variable for Automake."
+ (proj-comp-insert-variable-once "SUBDIRS"
+ (ede-map-subprojects
+ this (lambda (sproj)
+ (insert " " (ede-subproject-relative-path sproj))
+ ))))
+
+(defmethod ede-proj-makefile-automake-insert-extradist ((this ede-proj-project))
+ "Insert the EXTRADIST variable entries needed for Automake and EDE."
+ (proj-comp-insert-variable-once "EXTRA_DIST" (insert "Project.ede")))
+
(defmethod ede-proj-makefile-insert-dist-rules ((this ede-proj-project))
"Insert distribution rules for THIS in a Makefile, such as CLEAN and DIST."
(let ((junk (ede-proj-makefile-garbage-patterns this))
(cond ((eq (cdr sv) 'share)
;; This variable may be shared between multiple targets.
(if (re-search-backward (concat "\\$(" (car sv) ")")
- (save-excursion
- (beginning-of-line)
- (point))
- t)
+ (point-at-bol) t)
;; If its already in the dist target, then skip it.
nil
(setq sv (car sv))))
have a list of intermediates (object files), and others don't care.
This allows customization of how these elements appear."
(let* ((c (ede-proj-compilers this))
- (io (ede-or (mapcar 'ede-compiler-intermediate-objects-p c)))
+ (io (eval (cons 'or (mapcar 'ede-compiler-intermediate-objects-p c))))
(out nil))
(if io
(progn