1 ;;; ede/proj-obj.el --- EDE Generic Project Object code generation support
3 ;;; Copyright (C) 1998, 1999, 2000, 2005, 2008, 2009, 2010
4 ;;; Free Software Foundation, Inc.
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
7 ;; Keywords: project, make
9 ;; This file is part of GNU Emacs.
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.
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.
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/>.
26 ;; Handles a superclass of target types which create object code in
27 ;; and EDE Project file.
29 (eval-when-compile (require 'cl
))
31 (declare-function ede-pmake-varname
"ede/pmake")
33 (defvar ede-proj-objectcode-dodependencies nil
34 "Flag specifies to do automatic dependencies.")
37 (defclass ede-proj-target-makefile-objectcode
(ede-proj-target-makefile)
38 (;; Give this a new default
39 (configuration-variables :initform
("debug" .
(("CFLAGS" .
"-g")
41 ;; @TODO - add an include path.
42 (availablecompilers :initform
(ede-gcc-compiler
45 ede-gfortran-module-compiler
46 ;; More C and C++ compilers, plus
47 ;; fortran or pascal can be added here
49 (availablelinkers :initform
(ede-g++-linker
53 ;; Add more linker thingies here.
55 (sourcetype :initform
(ede-source-c
60 ;; This object should take everything that
61 ;; gets compiled into objects like fortran
65 "Abstract class for Makefile based object code generating targets.
66 Belonging to this group assumes you could make a .o from an element source
69 (defclass ede-object-compiler
(ede-compiler)
70 ((uselinker :initform t
)
71 (dependencyvar :initarg
:dependencyvar
73 :custom
(cons (string :tag
"Variable")
74 (string :tag
"Value"))
76 "A variable dedicated to dependency generation."))
77 "Ede compiler class for source which must compiler, and link.")
79 ;;; C/C++ Compilers and Linkers
82 (ede-sourcecode "ede-source-c"
84 :sourcepattern
"\\.c$"
85 :auxsourcepattern
"\\.h$"
86 :garbagepattern
'("*.o" "*.obj" ".deps/*.P" ".lo"))
87 "C source code definition.")
89 (defvar ede-gcc-compiler
93 :dependencyvar
'("C_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
94 :variables
'(("CC" .
"gcc")
96 "$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)"))
97 :rules
(list (ede-makefile-rule
101 :rules
'("@echo '$(C_COMPILE) -c $<'; \\"
102 "$(C_COMPILE) $(C_DEPENDENCIES) -o $@ -c $<"
105 :autoconf
'("AC_PROG_CC" "AC_PROG_GCC_TRADITIONAL")
106 :sourcetype
'(ede-source-c)
107 :objectextention
".o"
110 "Compiler for C sourcecode.")
112 (defvar ede-cc-linker
116 :sourcetype
'(ede-source-c)
117 :variables
'(("C_LINK" .
"$(CC) $(CFLAGS) $(LDFLAGS) -L."))
118 :commands
'("$(C_LINK) -o $@ $^")
120 "Linker for C sourcecode.")
122 (defvar ede-source-c
++
123 (ede-sourcecode "ede-source-c++"
125 :sourcepattern
"\\.\\(cpp\\|cc\\|cxx\\)$"
126 :auxsourcepattern
"\\.\\(hpp\\|hh?\\|hxx\\)$"
127 :garbagepattern
'("*.o" "*.obj" ".deps/*.P" ".lo"))
128 "C++ source code definition.")
130 (defvar ede-g
++-compiler
134 :dependencyvar
'("CXX_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
135 :variables
'(("CXX" "g++")
137 "$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)")
139 :rules
(list (ede-makefile-rule
142 :dependencies
"%.cpp"
143 :rules
'("@echo '$(CXX_COMPILE) -c $<'; \\"
144 "$(CXX_COMPILE) $(CXX_DEPENDENCIES) -o $@ -c $<"
147 :autoconf
'("AC_PROG_CXX")
148 :sourcetype
'(ede-source-c++)
149 :objectextention
".o"
152 "Compiler for C sourcecode.")
154 (defvar ede-g
++-linker
158 ;; Only use this linker when c++ exists.
159 :sourcetype
'(ede-source-c++)
160 :variables
'(("CXX_LINK" .
"$(CXX) $(CFLAGS) $(LDFLAGS) -L."))
161 :commands
'("$(CXX_LINK) -o $@ $^")
162 :autoconf
'("AC_PROG_CXX")
164 "Linker needed for c++ programs.")
166 ;;; Fortran Compiler/Linker
168 ;; Contributed by David Engster
169 (defvar ede-source-f90
170 (ede-sourcecode "ede-source-f90"
171 :name
"Fortran 90/95"
172 :sourcepattern
"\\.[fF]9[05]$"
173 :auxsourcepattern
"\\.incf$"
174 :garbagepattern
'("*.o" "*.mod" ".deps/*.P"))
175 "Fortran 90/95 source code definition.")
177 (defvar ede-source-f77
178 (ede-sourcecode "ede-source-f77"
180 :sourcepattern
"\\.\\([fF]\\|for\\)$"
181 :auxsourcepattern
"\\.incf$"
182 :garbagepattern
'("*.o" ".deps/*.P"))
183 "Fortran 77 source code definition.")
185 (defvar ede-gfortran-compiler
187 "ede-f90-compiler-gfortran"
189 :dependencyvar
'("F90_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
190 :variables
'(("F90" .
"gfortran")
192 "$(F90) $(DEFS) $(INCLUDES) $(F90FLAGS)"))
193 :rules
(list (ede-makefile-rule
196 :dependencies
"%.f90"
197 :rules
'("@echo '$(F90_COMPILE) -c $<'; \\"
198 "$(F90_COMPILE) $(F90_DEPENDENCIES) -o $@ -c $<"
201 :sourcetype
'(ede-source-f90 ede-source-f77
)
202 :objectextention
".o"
205 "Compiler for Fortran sourcecode.")
207 (defvar ede-gfortran-module-compiler
208 (clone ede-gfortran-compiler
209 "ede-f90-module-compiler-gfortran"
211 :sourcetype
'(ede-source-f90)
212 :commands
'("$(F90_COMPILE) -c $^")
213 :objectextention
".mod"
215 "Compiler for Fortran 90/95 modules.")
218 (defvar ede-gfortran-linker
220 "ede-gfortran-linker"
222 :sourcetype
'(ede-source-f90 ede-source-f77
)
223 :variables
'(("F90_LINK" .
"$(F90) $(CFLAGS) $(LDFLAGS) -L."))
224 :commands
'("$(F90_LINK) -o $@ $^")
226 "Linker needed for Fortran programs.")
230 (defvar ede-ld-linker
234 :variables
'(("LD" .
"ld")
235 ("LD_LINK" .
"$(LD) $(LDFLAGS) -L."))
236 :commands
'("$(LD_LINK) -o $@ $^")
238 "Linker needed for c++ programs.")
240 ;;; The EDE object compiler
242 (defmethod ede-proj-makefile-insert-variables ((this ede-object-compiler
))
243 "Insert variables needed by the compiler THIS."
245 (if (eieio-instance-inheritor-slot-boundp this
'dependencyvar
)
246 (with-slots (dependencyvar) this
247 (insert (car dependencyvar
) "=")
248 (let ((cd (cdr dependencyvar
)))
250 (mapc (lambda (c) (insert " " c
)) cd
)
254 ;;; EDE Object target type methods
256 (defmethod ede-proj-makefile-sourcevar
257 ((this ede-proj-target-makefile-objectcode
))
258 "Return the variable name for THIS's sources."
260 (concat (ede-pmake-varname this
) "_SOURCES"))
262 (defmethod ede-proj-makefile-dependency-files
263 ((this ede-proj-target-makefile-objectcode
))
264 "Return a list of source files to convert to dependencies.
265 Argument THIS is the target to get sources from."
266 (append (oref this source
) (oref this auxsource
)))
268 (defmethod ede-proj-makefile-insert-variables ((this ede-proj-target-makefile-objectcode
)
269 &optional moresource
)
270 "Insert variables needed by target THIS.
271 Optional argument MORESOURCE is not used."
272 (let ((ede-proj-objectcode-dodependencies
273 (oref (ede-target-parent this
) automatic-dependencies
)))
276 (defmethod ede-buffer-header-file((this ede-proj-target-makefile-objectcode
)
278 "There are no default header files."
279 (or (call-next-method)
280 ;; Ok, nothing obvious. Try looking in ourselves.
281 (let ((h (oref this auxsource
)))
282 ;; Add more logic here when the problem is better understood.
285 (provide 'ede
/proj-obj
)
287 ;; arch-tag: f521b89f-1a3f-4910-ba81-65de3f421698
288 ;;; ede/proj-obj.el ends here