X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/3999968a738479642f0b508da1cf1920e254c079..678fb7066698ebfe3aecba722294025ed26da01b:/lisp/cedet/ede/proj-comp.el diff --git a/lisp/cedet/ede/proj-comp.el b/lisp/cedet/ede/proj-comp.el index 2bda2dd106..8277f58a5e 100644 --- a/lisp/cedet/ede/proj-comp.el +++ b/lisp/cedet/ede/proj-comp.el @@ -1,6 +1,6 @@ ;;; 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-2012 ;; Free Software Foundation, Inc. ;; Author: Eric M. Ludlam @@ -44,6 +44,7 @@ ;; 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) @@ -82,7 +83,7 @@ For example, yacc/lex files need additional chain rules, or inferences.") :documentation "The commands used to execute this compiler. The object which uses this compiler will place these commands after -it's rule definition.") +its rule definition.") (autoconf :initarg :autoconf :initform nil :type list @@ -96,8 +97,8 @@ use the same autoconf form.") (objectextention :initarg :objectextention :type string :documentation - "A string which is the extention used for object files. -For example, C code uses .o on unix, and Emacs Lisp uses .elc.") + "A string which is the extension used for object files. +For example, C code uses .o on Unix, and Emacs Lisp uses .elc.") ) "A program used to compile or link a program via a Makefile. Contains everything needed to output code into a Makefile, or autoconf @@ -148,7 +149,7 @@ belonging to the target name.") :type list :custom (repeat string) :documentation "Scripts to execute. -These scripst will be executed in sh (Unless the SHELL variable is overriden). +These scripts will be executed in sh (Unless the SHELL variable is overridden). Do not prefix with TAB. Each individual element of this list can be either a string, or a lambda function. (The custom element does not yet express that.") @@ -235,7 +236,7 @@ This will prevent rules from creating duplicate variables or rules." ;;; Methods: (defmethod ede-proj-tweak-autoconf ((this ede-compilation-program)) - "Tweak the configure file (current buffer) to accomodate THIS." + "Tweak the configure file (current buffer) to accommodate THIS." (mapcar (lambda (obj) (cond ((stringp obj) @@ -247,21 +248,32 @@ This will prevent rules from creating duplicate variables or rules." (oref this autoconf))) (defmethod ede-proj-flush-autoconf ((this ede-compilation-program)) - "Flush the configure file (current buffer) to accomodate THIS." + "Flush the configure file (current buffer) to accommodate 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)) @@ -343,5 +355,4 @@ compiler it decides to use after inserting in the rule." (provide 'ede/proj-comp) -;; arch-tag: ade67766-1a5d-467a-826a-93e95594d717 ;;; ede/proj-comp.el ends here