1 ;;; ede/proj-obj.el --- EDE Generic Project Object code generation support
3 ;;; Copyright (C) 1998-2000, 2005, 2008-2012 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; Keywords: project, make
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; Handles a superclass of target types which create object code in
26 ;; and EDE Project file.
28 (eval-when-compile (require 'cl
))
30 (declare-function ede-pmake-varname
"ede/pmake")
32 (defvar ede-proj-objectcode-dodependencies nil
33 "Flag specifies to do automatic dependencies.")
36 (defclass ede-proj-target-makefile-objectcode
(ede-proj-target-makefile)
37 (;; Give this a new default
38 (configuration-variables :initform
("debug" .
(("CFLAGS" .
"-g")
40 ;; @TODO - add an include path.
41 (availablecompilers :initform
'(ede-gcc-compiler
44 ede-gfortran-module-compiler
47 ;; More C and C++ compilers, plus
48 ;; fortran or pascal can be added here
50 (availablelinkers :initform
'(ede-g++-linker
54 ;; Add more linker thingies here.
56 (sourcetype :initform
'(ede-source-c
63 ;; This object should take everything that
64 ;; gets compiled into objects like fortran
68 "Abstract class for Makefile based object code generating targets.
69 Belonging to this group assumes you could make a .o from an element source
72 (defclass ede-object-compiler
(ede-compiler)
73 ((uselinker :initform t
)
74 (dependencyvar :initarg
:dependencyvar
76 :custom
(cons (string :tag
"Variable")
77 (string :tag
"Value"))
79 "A variable dedicated to dependency generation."))
80 "Ede compiler class for source which must compiler, and link.")
82 ;;; C/C++ Compilers and Linkers
85 (ede-sourcecode "ede-source-c"
87 :sourcepattern
"\\.c$"
88 :auxsourcepattern
"\\.h$"
89 :garbagepattern
'("*.o" "*.obj" ".deps/*.P" ".lo"))
90 "C source code definition.")
92 (defvar ede-gcc-compiler
96 :dependencyvar
'("C_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
97 :variables
'(("CC" .
"gcc")
99 "$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)"))
100 :rules
(list (ede-makefile-rule
104 :rules
'("@echo '$(C_COMPILE) -c $<'; \\"
105 "$(C_COMPILE) $(C_DEPENDENCIES) -o $@ -c $<"
108 :autoconf
'("AC_PROG_CC" "AC_PROG_GCC_TRADITIONAL")
109 :sourcetype
'(ede-source-c)
110 :objectextention
".o"
113 "Compiler for C sourcecode.")
115 (defvar ede-cc-linker
119 :sourcetype
'(ede-source-c)
120 :variables
'(("C_LINK" .
"$(CC) $(CFLAGS) $(LDFLAGS) -L."))
121 :commands
'("$(C_LINK) -o $@ $^ $(LDDEPS)")
123 "Linker for C sourcecode.")
125 (defvar ede-source-c
++
126 (ede-sourcecode "ede-source-c++"
128 :sourcepattern
"\\.\\(c\\(pp?\\|c\\|xx\\|++\\)\\|C\\\(PP\\)?\\)$"
129 :auxsourcepattern
"\\.\\(hpp?\\|hh?\\|hxx\\|H\\)$"
130 :garbagepattern
'("*.o" "*.obj" ".deps/*.P" ".lo"))
131 "C++ source code definition.")
133 (defvar ede-g
++-compiler
137 :dependencyvar
'("CXX_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
138 :variables
'(("CXX" "g++")
140 "$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)")
142 :rules
(list (ede-makefile-rule
145 :dependencies
"%.cpp"
146 :rules
'("@echo '$(CXX_COMPILE) -c $<'; \\"
147 "$(CXX_COMPILE) $(CXX_DEPENDENCIES) -o $@ -c $<"
150 :autoconf
'("AC_PROG_CXX")
151 :sourcetype
'(ede-source-c++)
152 :objectextention
".o"
155 "Compiler for C sourcecode.")
157 (defvar ede-g
++-linker
161 ;; Only use this linker when c++ exists.
162 :sourcetype
'(ede-source-c++)
163 :variables
'(("CXX_LINK" .
"$(CXX) $(CFLAGS) $(LDFLAGS) -L."))
164 :commands
'("$(CXX_LINK) -o $@ $^ $(LDDEPS)")
165 :autoconf
'("AC_PROG_CXX")
167 "Linker needed for c++ programs.")
170 (defvar ede-source-lex
171 (ede-sourcecode "ede-source-lex"
173 :sourcepattern
"\\.l\\(l\\|pp\\|++\\)")
174 "Lex source code definition.
175 No garbage pattern since it creates C or C++ code.")
177 (defvar ede-lex-compiler
180 ;; Can we support regular makefiles too??
181 :autoconf
'("AC_PROG_LEX")
182 :sourcetype
'(ede-source-lex))
183 "Compiler used for Lexical source.")
186 (defvar ede-source-yacc
187 (ede-sourcecode "ede-source-yacc"
189 :sourcepattern
"\\.y\\(y\\|pp\\|++\\)")
190 "Yacc source code definition.
191 No garbage pattern since it creates C or C++ code.")
193 (defvar ede-yacc-compiler
196 ;; Can we support regular makefiles too??
197 :autoconf
'("AC_PROG_YACC")
198 :sourcetype
'(ede-source-yacc))
199 "Compiler used for yacc/bison grammar files source.")
201 ;;; Fortran Compiler/Linker
203 ;; Contributed by David Engster
204 (defvar ede-source-f90
205 (ede-sourcecode "ede-source-f90"
206 :name
"Fortran 90/95"
207 :sourcepattern
"\\.[fF]9[05]$"
208 :auxsourcepattern
"\\.incf$"
209 :garbagepattern
'("*.o" "*.mod" ".deps/*.P"))
210 "Fortran 90/95 source code definition.")
212 (defvar ede-source-f77
213 (ede-sourcecode "ede-source-f77"
215 :sourcepattern
"\\.\\([fF]\\|for\\)$"
216 :auxsourcepattern
"\\.incf$"
217 :garbagepattern
'("*.o" ".deps/*.P"))
218 "Fortran 77 source code definition.")
220 (defvar ede-gfortran-compiler
222 "ede-f90-compiler-gfortran"
224 :dependencyvar
'("F90_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
225 :variables
'(("F90" .
"gfortran")
227 "$(F90) $(DEFS) $(INCLUDES) $(F90FLAGS)"))
228 :rules
(list (ede-makefile-rule
231 :dependencies
"%.f90"
232 :rules
'("@echo '$(F90_COMPILE) -c $<'; \\"
233 "$(F90_COMPILE) $(F90_DEPENDENCIES) -o $@ -c $<"
236 :sourcetype
'(ede-source-f90 ede-source-f77
)
237 :objectextention
".o"
240 "Compiler for Fortran sourcecode.")
242 (defvar ede-gfortran-module-compiler
243 (clone ede-gfortran-compiler
244 "ede-f90-module-compiler-gfortran"
246 :sourcetype
'(ede-source-f90)
247 :commands
'("$(F90_COMPILE) -c $^")
248 :objectextention
".mod"
250 "Compiler for Fortran 90/95 modules.")
253 (defvar ede-gfortran-linker
255 "ede-gfortran-linker"
257 :sourcetype
'(ede-source-f90 ede-source-f77
)
258 :variables
'(("F90_LINK" .
"$(F90) $(CFLAGS) $(LDFLAGS) -L."))
259 :commands
'("$(F90_LINK) -o $@ $^")
261 "Linker needed for Fortran programs.")
265 (defvar ede-ld-linker
269 :variables
'(("LD" .
"ld")
270 ("LD_LINK" .
"$(LD) $(LDFLAGS) -L."))
271 :commands
'("$(LD_LINK) -o $@ $^ $(LDDEPS)")
273 "Linker needed for c++ programs.")
275 ;;; The EDE object compiler
277 (defmethod ede-proj-makefile-insert-variables ((this ede-object-compiler
))
278 "Insert variables needed by the compiler THIS."
280 (if (eieio-instance-inheritor-slot-boundp this
'dependencyvar
)
281 (with-slots (dependencyvar) this
282 (insert (car dependencyvar
) "=")
283 (let ((cd (cdr dependencyvar
)))
285 (mapc (lambda (c) (insert " " c
)) cd
)
289 ;;; EDE Object target type methods
291 (defmethod ede-proj-makefile-sourcevar
292 ((this ede-proj-target-makefile-objectcode
))
293 "Return the variable name for THIS's sources."
295 (concat (ede-pmake-varname this
) "_SOURCES"))
297 (defmethod ede-proj-makefile-dependency-files
298 ((this ede-proj-target-makefile-objectcode
))
299 "Return a list of source files to convert to dependencies.
300 Argument THIS is the target to get sources from."
301 (append (oref this source
) (oref this auxsource
)))
303 (defmethod ede-proj-makefile-insert-variables ((this ede-proj-target-makefile-objectcode
)
304 &optional moresource
)
305 "Insert variables needed by target THIS.
306 Optional argument MORESOURCE is not used."
307 (let ((ede-proj-objectcode-dodependencies
308 (oref (ede-target-parent this
) automatic-dependencies
)))
311 (defmethod ede-buffer-header-file((this ede-proj-target-makefile-objectcode
)
313 "There are no default header files."
314 (or (call-next-method)
315 ;; Ok, nothing obvious. Try looking in ourselves.
316 (let ((h (oref this auxsource
)))
317 ;; Add more logic here when the problem is better understood.
320 (provide 'ede
/proj-obj
)
322 ;;; ede/proj-obj.el ends here