1 ;;; ede-proj-obj.el --- EDE Generic Project Object code generation support
3 ;;; Copyright (C) 1998, 1999, 2000, 2005 Eric M. Ludlam
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; Keywords: project, make
7 ;; RCS: $Id: ede-proj-obj.el,v 1.1 2007-11-26 15:22:09 michaels Exp $
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)
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.
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.
26 ;; Handles a supperclass of target types which create object code in
27 ;; and EDE Project file.
30 ;; (require 'ede-pmake)
31 ;; The above require is needed for ede-pmake-varname, but introduces
32 ;; a circular dependency. Leave it be.
34 (defvar ede-proj-objectcode-dodependencies nil
35 "Flag specifies to do automatic dependencies.")
38 (defclass ede-proj-target-makefile-objectcode (ede-proj-target-makefile)
39 (;; Give this a new default
40 (configuration-variables :initform ("debug" . (("CFLAGS" . "-g")
42 (availablecompilers :initform (ede-gcc-compiler
44 ;; More C and C++ compilers, plus
45 ;; fortran or pascal can be added here
47 (availablelinkers :initform (ede-g++-linker
48 ;; Add more linker thingies here.
51 (sourcetype :initform (ede-source-c
54 ;; This object should take everything that
55 ;; gets compiled into objects like fortran
59 "Abstract class for Makefile based object code generating targets.
60 Belonging to this group assumes you could make a .o from an element source
63 (defclass ede-object-compiler (ede-compiler)
64 ((uselinker :initform t)
65 (dependencyvar :initarg :dependencyvar
67 :custom (cons (string :tag "Variable")
68 (string :tag "Value"))
70 "A variable dedicated to dependency generation."))
71 "Ede compiler class for source which must compiler, and link.")
74 (ede-sourcecode "ede-source-c"
76 :sourcepattern "\\.c$"
77 :auxsourcepattern "\\.h$"
78 :garbagepattern '("*.o" "*.obj" ".deps/*.P" ".lo"))
79 "C source code definition.")
81 (defvar ede-gcc-compiler
85 :dependencyvar '("C_DEPENDENCIES" . "-Wp,-MD,.deps/$(*F).P")
86 :variables '(("CC" . "gcc")
88 "$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)"))
89 :rules (list (ede-makefile-rule
93 :rules '("@echo '$(C_COMPILE) -c $<'; \\"
94 "$(C_COMPILE) $(C_DEPENDENCIES) -o $@ -c $<"
97 :autoconf '("AC_PROG_CC" "AC_PROG_GCC_TRADITIONAL")
98 :sourcetype '(ede-source-c)
102 "Compiler for C sourcecode.")
104 (defvar ede-source-c++
105 (ede-sourcecode "ede-source-c++"
107 :sourcepattern "\\.cpp$"
108 :auxsourcepattern "\\.hpp$"
109 :garbagepattern '("*.o" "*.obj" ".deps/*.P" ".lo"))
110 "C++ source code definition.")
112 (defvar ede-g++-compiler
116 :dependencyvar '("CXX_DEPENDENCIES" . "-Wp,-MD,.deps/$(*F).P")
117 :variables '(("CXX" "g++")
119 "$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)")
121 :rules (list (ede-makefile-rule
124 :dependencies "%.cpp"
125 :rules '("@echo '$(CXX_COMPILE) -c $<'; \\"
126 "$(CXX_COMPILE) $(CXX_DEPENDENCIES) -o $@ -c $<"
129 :autoconf '("AC_PROG_CXX")
130 :sourcetype '(ede-source-c++)
131 :objectextention ".o"
134 "Compiler for C sourcecode.")
136 (defvar ede-g++-linker
140 ;; Only use this linker when c++ exists.
141 :sourcetype '(ede-source-c++)
142 :variables '(("CXX_LINK" .
143 "$(CXX) $(CFLAGS) $(LDFLAGS) -L. -o $@")
145 :commands '("$(CXX_LINK) $^")
146 :autoconf '("AC_PROG_CXX")
148 "Linker needed for c++ programs.")
150 (defvar ede-ld-linker
154 :variables '(("LD" . "ld")
156 "$(LD) $(LDFLAGS) -L. -o $@")
158 :commands '("$(LD_LINK) $^")
160 "Linker needed for c++ programs.")
162 ;;; The EDE object compiler
164 (defmethod ede-proj-makefile-insert-variables ((this ede-object-compiler))
165 "Insert variables needed by the compiler THIS."
167 (if (slot-boundp this 'dependencyvar)
168 (with-slots (dependencyvar) this
169 (insert (car dependencyvar) "=")
170 (let ((cd (cdr dependencyvar)))
172 (mapc (lambda (c) (insert " " c)) cd)
176 ;;; EDE Object target type methods
178 (defmethod ede-proj-makefile-sourcevar
179 ((this ede-proj-target-makefile-objectcode))
180 "Return the variable name for THIS's sources."
181 (concat (ede-pmake-varname this) "_SOURCES"))
183 (defmethod ede-proj-makefile-dependency-files
184 ((this ede-proj-target-makefile-objectcode))
185 "Return a list of source files to convert to dependencies.
186 Argument THIS is the target to get sources from."
187 (append (oref this source) (oref this auxsource)))
189 (defmethod ede-proj-makefile-insert-variables ((this ede-proj-target-makefile-objectcode)
190 &optional moresource)
191 "Insert variables needed by target THIS.
192 Optional argument MORESOURCE is not used."
193 (let ((ede-proj-objectcode-dodependencies
194 (oref (ede-target-parent this) automatic-dependencies)))
197 (defmethod ede-buffer-header-file((this ede-proj-target-makefile-objectcode)
199 "There are no default header files."
200 (or (call-next-method)
201 ;; Ok, nothing obvious. Try looking in ourselves.
202 (let ((h (oref this auxsource)))
203 ;; Add more logic here when the problem is better understood.
206 (provide 'ede-proj-obj)
208 ;;; ede-proj-obj.el ends here