1 ;;; ede/proj-obj.el --- EDE Generic Project Object code generation support
3 ;;; Copyright (C) 1998, 1999, 2000, 2005, 2008, 2009, 2010, 2011, 2012
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
48 ;; More C and C++ compilers, plus
49 ;; fortran or pascal can be added here
51 (availablelinkers :initform
'(ede-g++-linker
55 ;; Add more linker thingies here.
57 (sourcetype :initform
'(ede-source-c
64 ;; This object should take everything that
65 ;; gets compiled into objects like fortran
69 "Abstract class for Makefile based object code generating targets.
70 Belonging to this group assumes you could make a .o from an element source
73 (defclass ede-object-compiler
(ede-compiler)
74 ((uselinker :initform t
)
75 (dependencyvar :initarg
:dependencyvar
77 :custom
(cons (string :tag
"Variable")
78 (string :tag
"Value"))
80 "A variable dedicated to dependency generation."))
81 "Ede compiler class for source which must compiler, and link.")
83 ;;; C/C++ Compilers and Linkers
86 (ede-sourcecode "ede-source-c"
88 :sourcepattern
"\\.c$"
89 :auxsourcepattern
"\\.h$"
90 :garbagepattern
'("*.o" "*.obj" ".deps/*.P" ".lo"))
91 "C source code definition.")
93 (defvar ede-gcc-compiler
97 :dependencyvar
'("C_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
98 :variables
'(("CC" .
"gcc")
100 "$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)"))
101 :rules
(list (ede-makefile-rule
105 :rules
'("@echo '$(C_COMPILE) -c $<'; \\"
106 "$(C_COMPILE) $(C_DEPENDENCIES) -o $@ -c $<"
109 :autoconf
'("AC_PROG_CC" "AC_PROG_GCC_TRADITIONAL")
110 :sourcetype
'(ede-source-c)
111 :objectextention
".o"
114 "Compiler for C sourcecode.")
116 (defvar ede-cc-linker
120 :sourcetype
'(ede-source-c)
121 :variables
'(("C_LINK" .
"$(CC) $(CFLAGS) $(LDFLAGS) -L."))
122 :commands
'("$(C_LINK) -o $@ $^ $(LDDEPS)")
124 "Linker for C sourcecode.")
126 (defvar ede-source-c
++
127 (ede-sourcecode "ede-source-c++"
129 :sourcepattern
"\\.\\(c\\(pp?\\|c\\|xx\\|++\\)\\|C\\\(PP\\)?\\)$"
130 :auxsourcepattern
"\\.\\(hpp?\\|hh?\\|hxx\\|H\\)$"
131 :garbagepattern
'("*.o" "*.obj" ".deps/*.P" ".lo"))
132 "C++ source code definition.")
134 (defvar ede-g
++-compiler
138 :dependencyvar
'("CXX_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
139 :variables
'(("CXX" "g++")
141 "$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)")
143 :rules
(list (ede-makefile-rule
146 :dependencies
"%.cpp"
147 :rules
'("@echo '$(CXX_COMPILE) -c $<'; \\"
148 "$(CXX_COMPILE) $(CXX_DEPENDENCIES) -o $@ -c $<"
151 :autoconf
'("AC_PROG_CXX")
152 :sourcetype
'(ede-source-c++)
153 :objectextention
".o"
156 "Compiler for C sourcecode.")
158 (defvar ede-g
++-linker
162 ;; Only use this linker when c++ exists.
163 :sourcetype
'(ede-source-c++)
164 :variables
'(("CXX_LINK" .
"$(CXX) $(CFLAGS) $(LDFLAGS) -L."))
165 :commands
'("$(CXX_LINK) -o $@ $^ $(LDDEPS)")
166 :autoconf
'("AC_PROG_CXX")
168 "Linker needed for c++ programs.")
171 (defvar ede-source-lex
172 (ede-sourcecode "ede-source-lex"
174 :sourcepattern
"\\.l\\(l\\|pp\\|++\\)")
175 "Lex source code definition.
176 No garbage pattern since it creates C or C++ code.")
178 (defvar ede-lex-compiler
181 ;; Can we support regular makefiles too??
182 :autoconf
'("AC_PROG_LEX")
183 :sourcetype
'(ede-source-lex))
184 "Compiler used for Lexical source.")
187 (defvar ede-source-yacc
188 (ede-sourcecode "ede-source-yacc"
190 :sourcepattern
"\\.y\\(y\\|pp\\|++\\)")
191 "Yacc source code definition.
192 No garbage pattern since it creates C or C++ code.")
194 (defvar ede-yacc-compiler
197 ;; Can we support regular makefiles too??
198 :autoconf
'("AC_PROG_YACC")
199 :sourcetype
'(ede-source-yacc))
200 "Compiler used for yacc/bison grammar files source.")
202 ;;; Fortran Compiler/Linker
204 ;; Contributed by David Engster
205 (defvar ede-source-f90
206 (ede-sourcecode "ede-source-f90"
207 :name
"Fortran 90/95"
208 :sourcepattern
"\\.[fF]9[05]$"
209 :auxsourcepattern
"\\.incf$"
210 :garbagepattern
'("*.o" "*.mod" ".deps/*.P"))
211 "Fortran 90/95 source code definition.")
213 (defvar ede-source-f77
214 (ede-sourcecode "ede-source-f77"
216 :sourcepattern
"\\.\\([fF]\\|for\\)$"
217 :auxsourcepattern
"\\.incf$"
218 :garbagepattern
'("*.o" ".deps/*.P"))
219 "Fortran 77 source code definition.")
221 (defvar ede-gfortran-compiler
223 "ede-f90-compiler-gfortran"
225 :dependencyvar
'("F90_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
226 :variables
'(("F90" .
"gfortran")
228 "$(F90) $(DEFS) $(INCLUDES) $(F90FLAGS)"))
229 :rules
(list (ede-makefile-rule
232 :dependencies
"%.f90"
233 :rules
'("@echo '$(F90_COMPILE) -c $<'; \\"
234 "$(F90_COMPILE) $(F90_DEPENDENCIES) -o $@ -c $<"
237 :sourcetype
'(ede-source-f90 ede-source-f77
)
238 :objectextention
".o"
241 "Compiler for Fortran sourcecode.")
243 (defvar ede-gfortran-module-compiler
244 (clone ede-gfortran-compiler
245 "ede-f90-module-compiler-gfortran"
247 :sourcetype
'(ede-source-f90)
248 :commands
'("$(F90_COMPILE) -c $^")
249 :objectextention
".mod"
251 "Compiler for Fortran 90/95 modules.")
254 (defvar ede-gfortran-linker
256 "ede-gfortran-linker"
258 :sourcetype
'(ede-source-f90 ede-source-f77
)
259 :variables
'(("F90_LINK" .
"$(F90) $(CFLAGS) $(LDFLAGS) -L."))
260 :commands
'("$(F90_LINK) -o $@ $^")
262 "Linker needed for Fortran programs.")
266 (defvar ede-ld-linker
270 :variables
'(("LD" .
"ld")
271 ("LD_LINK" .
"$(LD) $(LDFLAGS) -L."))
272 :commands
'("$(LD_LINK) -o $@ $^ $(LDDEPS)")
274 "Linker needed for c++ programs.")
276 ;;; The EDE object compiler
278 (defmethod ede-proj-makefile-insert-variables ((this ede-object-compiler
))
279 "Insert variables needed by the compiler THIS."
281 (if (eieio-instance-inheritor-slot-boundp this
'dependencyvar
)
282 (with-slots (dependencyvar) this
283 (insert (car dependencyvar
) "=")
284 (let ((cd (cdr dependencyvar
)))
286 (mapc (lambda (c) (insert " " c
)) cd
)
290 ;;; EDE Object target type methods
292 (defmethod ede-proj-makefile-sourcevar
293 ((this ede-proj-target-makefile-objectcode
))
294 "Return the variable name for THIS's sources."
296 (concat (ede-pmake-varname this
) "_SOURCES"))
298 (defmethod ede-proj-makefile-dependency-files
299 ((this ede-proj-target-makefile-objectcode
))
300 "Return a list of source files to convert to dependencies.
301 Argument THIS is the target to get sources from."
302 (append (oref this source
) (oref this auxsource
)))
304 (defmethod ede-proj-makefile-insert-variables ((this ede-proj-target-makefile-objectcode
)
305 &optional moresource
)
306 "Insert variables needed by target THIS.
307 Optional argument MORESOURCE is not used."
308 (let ((ede-proj-objectcode-dodependencies
309 (oref (ede-target-parent this
) automatic-dependencies
)))
312 (defmethod ede-buffer-header-file((this ede-proj-target-makefile-objectcode
)
314 "There are no default header files."
315 (or (call-next-method)
316 ;; Ok, nothing obvious. Try looking in ourselves.
317 (let ((h (oref this auxsource
)))
318 ;; Add more logic here when the problem is better understood.
321 (provide 'ede
/proj-obj
)
323 ;; arch-tag: f521b89f-1a3f-4910-ba81-65de3f421698
324 ;;; ede/proj-obj.el ends here