1 ;;; ede/proj-obj.el --- EDE Generic Project Object code generation support
3 ;;; Copyright (C) 1998, 1999, 2000, 2005, 2008, 2009
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.
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
45 ;; More C and C++ compilers, plus
46 ;; fortran or pascal can be added here
48 (availablelinkers :initform
(ede-g++-linker
49 ;; Add more linker thingies here.
53 (sourcetype :initform
(ede-source-c
58 ;; This object should take everything that
59 ;; gets compiled into objects like fortran
63 "Abstract class for Makefile based object code generating targets.
64 Belonging to this group assumes you could make a .o from an element source
67 (defclass ede-object-compiler
(ede-compiler)
68 ((uselinker :initform t
)
69 (dependencyvar :initarg
:dependencyvar
71 :custom
(cons (string :tag
"Variable")
72 (string :tag
"Value"))
74 "A variable dedicated to dependency generation."))
75 "Ede compiler class for source which must compiler, and link.")
77 ;;; C/C++ Compilers and Linkers
80 (ede-sourcecode "ede-source-c"
82 :sourcepattern
"\\.c$"
83 :auxsourcepattern
"\\.h$"
84 :garbagepattern
'("*.o" "*.obj" ".deps/*.P" ".lo"))
85 "C source code definition.")
87 (defvar ede-gcc-compiler
91 :dependencyvar
'("C_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
92 :variables
'(("CC" .
"gcc")
94 "$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)"))
95 :rules
(list (ede-makefile-rule
99 :rules
'("@echo '$(C_COMPILE) -c $<'; \\"
100 "$(C_COMPILE) $(C_DEPENDENCIES) -o $@ -c $<"
103 :autoconf
'("AC_PROG_CC" "AC_PROG_GCC_TRADITIONAL")
104 :sourcetype
'(ede-source-c)
105 :objectextention
".o"
108 "Compiler for C sourcecode.")
110 (defvar ede-source-c
++
111 (ede-sourcecode "ede-source-c++"
113 :sourcepattern
"\\.\\(cpp\\|cc\\|cxx\\)$"
114 :auxsourcepattern
"\\.\\(hpp\\|hh?\\|hxx\\)$"
115 :garbagepattern
'("*.o" "*.obj" ".deps/*.P" ".lo"))
116 "C++ source code definition.")
118 (defvar ede-g
++-compiler
122 :dependencyvar
'("CXX_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
123 :variables
'(("CXX" "g++")
125 "$(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)")
127 :rules
(list (ede-makefile-rule
130 :dependencies
"%.cpp"
131 :rules
'("@echo '$(CXX_COMPILE) -c $<'; \\"
132 "$(CXX_COMPILE) $(CXX_DEPENDENCIES) -o $@ -c $<"
135 :autoconf
'("AC_PROG_CXX")
136 :sourcetype
'(ede-source-c++)
137 :objectextention
".o"
140 "Compiler for C sourcecode.")
142 (defvar ede-g
++-linker
146 ;; Only use this linker when c++ exists.
147 :sourcetype
'(ede-source-c++)
148 :variables
'(("CXX_LINK" .
149 "$(CXX) $(CFLAGS) $(LDFLAGS) -L. -o $@")
151 :commands
'("$(CXX_LINK) $^")
152 :autoconf
'("AC_PROG_CXX")
154 "Linker needed for c++ programs.")
156 ;;; Fortran Compiler/Linker
158 ;; Contributed by David Engster
159 (defvar ede-source-f90
160 (ede-sourcecode "ede-source-f90"
161 :name
"Fortran 90/95"
162 :sourcepattern
"\\.[fF]9[05]$"
163 :auxsourcepattern
"\\.incf$"
164 :garbagepattern
'("*.o" "*.mod" ".deps/*.P"))
165 "Fortran 90/95 source code definition.")
167 (defvar ede-source-f77
168 (ede-sourcecode "ede-source-f77"
170 :sourcepattern
"\\.\\([fF]\\|for\\)$"
171 :auxsourcepattern
"\\.incf$"
172 :garbagepattern
'("*.o" ".deps/*.P"))
173 "Fortran 77 source code definition.")
175 (defvar ede-gfortran-compiler
177 "ede-f90-compiler-gfortran"
179 :dependencyvar
'("F90_DEPENDENCIES" .
"-Wp,-MD,.deps/$(*F).P")
180 :variables
'(("F90" .
"gfortran")
182 "$(F90) $(DEFS) $(INCLUDES) $(F90FLAGS)"))
183 :rules
(list (ede-makefile-rule
186 :dependencies
"%.f90"
187 :rules
'("@echo '$(F90_COMPILE) -c $<'; \\"
188 "$(F90_COMPILE) $(F90_DEPENDENCIES) -o $@ -c $<"
191 :sourcetype
'(ede-source-f90 ede-source-f77
)
192 :objectextention
".o"
195 "Compiler for Fortran sourcecode.")
197 (defvar ede-gfortran-module-compiler
198 (clone ede-gfortran-compiler
199 "ede-f90-module-compiler-gfortran"
201 :sourcetype
'(ede-source-f90)
202 :commands
'("$(F90_COMPILE) -c $^")
203 :objectextention
".mod"
205 "Compiler for Fortran 90/95 modules.")
208 (defvar ede-gfortran-linker
210 "ede-gfortran-linker"
212 :sourcetype
'(ede-source-f90 ede-source-f77
)
213 :variables
'(("F90_LINK" .
214 "$(F90) $(CFLAGS) $(LDFLAGS) -L. -o $@")
216 :commands
'("$(F90_LINK) $^")
218 "Linker needed for Fortran programs.")
222 (defvar ede-ld-linker
226 :variables
'(("LD" .
"ld")
228 "$(LD) $(LDFLAGS) -L. -o $@")
230 :commands
'("$(LD_LINK) $^")
232 "Linker needed for c++ programs.")
234 ;;; The EDE object compiler
236 (defmethod ede-proj-makefile-insert-variables ((this ede-object-compiler
))
237 "Insert variables needed by the compiler THIS."
239 (if (eieio-instance-inheritor-slot-boundp this
'dependencyvar
)
240 (with-slots (dependencyvar) this
241 (insert (car dependencyvar
) "=")
242 (let ((cd (cdr dependencyvar
)))
244 (mapc (lambda (c) (insert " " c
)) cd
)
248 ;;; EDE Object target type methods
250 (defmethod ede-proj-makefile-sourcevar
251 ((this ede-proj-target-makefile-objectcode
))
252 "Return the variable name for THIS's sources."
254 (concat (ede-pmake-varname this
) "_SOURCES"))
256 (defmethod ede-proj-makefile-dependency-files
257 ((this ede-proj-target-makefile-objectcode
))
258 "Return a list of source files to convert to dependencies.
259 Argument THIS is the target to get sources from."
260 (append (oref this source
) (oref this auxsource
)))
262 (defmethod ede-proj-makefile-insert-variables ((this ede-proj-target-makefile-objectcode
)
263 &optional moresource
)
264 "Insert variables needed by target THIS.
265 Optional argument MORESOURCE is not used."
266 (let ((ede-proj-objectcode-dodependencies
267 (oref (ede-target-parent this
) automatic-dependencies
)))
270 (defmethod ede-buffer-header-file((this ede-proj-target-makefile-objectcode
)
272 "There are no default header files."
273 (or (call-next-method)
274 ;; Ok, nothing obvious. Try looking in ourselves.
275 (let ((h (oref this auxsource
)))
276 ;; Add more logic here when the problem is better understood.
279 (provide 'ede
/proj-obj
)
281 ;; arch-tag: f521b89f-1a3f-4910-ba81-65de3f421698
282 ;;; ede/proj-obj.el ends here