;;; ede/proj-comp.el --- EDE Generic Project compiler/rule driver
-;; Copyright (C) 1999, 2000, 2001, 2004, 2005, 2007, 2009
+;; Copyright (C) 1999-2001, 2004-2005, 2007, 2009-2011
;; Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; To write a method that inserts a variable or rule for a compiler
;; based object, wrap the body of your call in `ede-compiler-only-once'
+(eval-when-compile (require 'cl))
(require 'ede) ;source object
(require 'ede/autoconf-edit)
"Flush the configure file (current buffer) to accomodate THIS."
nil)
+(defmacro proj-comp-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 'proj-comp-insert-variable-once 'lisp-indent-function 1)
+
(defmethod ede-proj-makefile-insert-variables ((this ede-compilation-program))
"Insert variables needed by the compiler THIS."
(if (eieio-instance-inheritor-slot-boundp this 'variables)
(with-slots (variables) this
(mapcar
(lambda (var)
- (insert (car var) "=")
- (let ((cd (cdr var)))
- (if (listp cd)
- (mapc (lambda (c) (insert " " c)) cd)
- (insert cd)))
- (insert "\n"))
+ (proj-comp-insert-variable-once (car var)
+ (let ((cd (cdr var)))
+ (if (listp cd)
+ (mapc (lambda (c) (insert " " c)) cd)
+ (insert cd)))))
variables))))
(defmethod ede-compiler-intermediate-objects-p ((this ede-compiler))