Update copyright year to 2015
[emacs.git] / lisp / cedet / ede / proj-shared.el
blob37999a3759318c339495b5ad2c7bb9a7afa5a49c
1 ;;; ede-proj-shared.el --- EDE Generic Project shared library support
3 ;;; Copyright (C) 1998-2000, 2009-2015 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/>.
23 ;;; Commentary:
25 ;; Handle shared object libraries in and EDE Project file.
26 ;; Tries to deal with libtool and non-libtool situations.
28 (require 'ede/pmake)
29 (require 'ede/proj-obj)
30 (require 'ede/proj-prog)
32 ;;; THIS NEEDS WORK. SEE ede-proj-obj.
34 ;;; Code:
35 (defclass ede-proj-target-makefile-shared-object
36 (ede-proj-target-makefile-program)
37 ((availablecompilers :initform '(ede-gcc-libtool-shared-compiler
38 ;;ede-gcc-shared-compiler
39 ede-g++-libtool-shared-compiler
40 ;;ede-g++-shared-compiler
42 (availablelinkers :initform '(ede-cc-linker-libtool
43 ede-g++-linker-libtool
44 ;; Add more linker thingies here.
46 (ldflags :custom (repeat (string :tag "Libtool flag"))
47 :documentation
48 "Additional flags to add when linking this shared library.
49 Use ldlibs to add addition libraries.")
51 "This target generates a shared library.")
53 (defvar ede-gcc-shared-compiler
54 (clone ede-gcc-compiler
55 "ede-c-shared-compiler"
56 :name "gcc -shared"
57 :variables '(("CC_SHARED" . "gcc")
58 ("C_SHARED_COMPILE" .
59 "$(CC_SHARED) -shared $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)"))
60 ; :linkvariables '(("C_SHARED_LINK" .
61 ; "$(CC_SHARED) -shared $(CFLAGS) $(LDFLAGS) -L. -o $@ $^")
62 ; )
63 ; :commands '("$(C_SHARED_LINK) %s")
64 ;; @TODO - additive modification of autoconf.
65 :autoconf '("AC_PROG_LIBTOOL")
67 "Compiler for C sourcecode.")
69 (defvar ede-gcc-libtool-shared-compiler
70 (clone ede-gcc-shared-compiler
71 "ede-c-shared-compiler-libtool"
72 :name "libtool"
73 :variables '(("LIBTOOL" . "libtool")
74 ("LTCOMPILE" . "$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)")
75 ("LTLINK" . "$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -L. -o $@")
77 :rules (list (ede-makefile-rule
78 "cc-inference-rule-libtool"
79 :target "%.o"
80 :dependencies "%.c"
81 :rules '("@echo '$(LTCOMPILE) -o $@ $<'; \\"
82 "$(LTCOMPILE) -o $@ $<"
85 :autoconf '("AC_PROG_LIBTOOL")
87 "Compiler for C sourcecode.")
89 (defvar ede-cc-linker-libtool
90 (clone ede-cc-linker
91 "ede-cc-linker-libtool"
92 :name "cc shared"
93 ;; Only use this linker when c++ exists.
94 :sourcetype '(ede-source-c++)
95 :variables '(
96 ("LIBTOOL" . "libtool")
97 ("LTLINK" . "$(LIBTOOL) --tag=CPP --mode=link $(CPP) $(CFLAGS) $(LDFLAGS) -L. -o $@")
99 :commands '("$(LTLINK) -o $@ $^")
100 :autoconf '("AC_PROG_LIBTOOL")
101 :objectextention ".la")
102 "Linker needed for c++ programs.")
104 (defvar ede-g++-shared-compiler
105 (clone ede-g++-compiler
106 "ede-c++-shared-compiler"
107 :name "gcc -shared"
108 :variables '(("CXX_SHARED" . "g++")
109 ("CXX_SHARED_COMPILE" .
110 "$(CXX_SHARED) -shared $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)"))
111 ;; @TODO - additive modification of autoconf.
112 :autoconf '("AC_PROG_LIBTOOL")
114 "Compiler for C sourcecode.")
116 (defvar ede-g++-libtool-shared-compiler
117 (clone ede-g++-shared-compiler
118 "ede-c++-shared-compiler-libtool"
119 :name "libtool"
120 :variables '(("CXX" "g++")
121 ("LIBTOOL" . "libtool")
122 ("LTCOMPILE" . "$(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)")
124 :rules (list (ede-makefile-rule
125 "c++-inference-rule-libtool"
126 :target "%.o"
127 :dependencies "%.cpp"
128 :rules '("@echo '$(LTCOMPILE) -o $@ $<'; \\"
129 "$(LTCOMPILE) -o $@ $<"
132 :autoconf '("AC_PROG_LIBTOOL")
134 "Compiler for C sourcecode.")
136 (defvar ede-g++-linker-libtool
137 (clone ede-g++-linker
138 "ede-g++-linker-libtool"
139 :name "g++"
140 ;; Only use this linker when c++ exists.
141 :sourcetype '(ede-source-c++)
142 :variables '(
143 ("LIBTOOL" . "libtool")
144 ("LTLINK" . "$(LIBTOOL) --tag=CXX --mode=link $(CXX) $(CFLAGS) $(LDFLAGS) -L. -o $@")
146 :commands '("$(LTLINK) -o $@ $^")
147 :autoconf '("AC_PROG_LIBTOOL")
148 :objectextention ".la")
149 "Linker needed for c++ programs.")
151 ;;; @TODO - C++ versions of the above.
153 (when nil
156 (insert;; These C to O rules create dependencies
157 "%.o: %.c\n"
158 "\t@echo '$(COMPILE) -c $<'; \\\n"
159 "\t$(COMPILE)"
160 (if (oref this automatic-dependencies)
161 " -Wp,-MD,.deps/$(*F).P"
163 " -c $<\n\n")
164 (if have-libtool
165 (insert;; These C to shared o rules create pic code.
166 "%.lo: %.c\n"
167 "\t@echo '$(LTCOMPILE) -c $<'; \\\n"
168 "\t$(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $<\n"
169 "\t@-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \\\n"
170 "\t < .deps/$(*F).p > .deps/$(*F).P\n"
171 "\t@-rm -f .deps/$(*F).p\n\n"))
174 (defmethod ede-proj-configure-add-missing
175 ((this ede-proj-target-makefile-shared-object))
176 "Query if any files needed by THIS provided by automake are missing.
177 Results in --add-missing being passed to automake."
178 (not (and (ede-expand-filename (ede-toplevel) "ltconfig")
179 (ede-expand-filename (ede-toplevel) "ltmain.sh"))))
181 (defmethod ede-proj-makefile-insert-automake-pre-variables
182 ((this ede-proj-target-makefile-shared-object))
183 "Insert bin_PROGRAMS variables needed by target THIS.
184 We aren't actually inserting SOURCE details, but this is used by the
185 Makefile.am generator, so use it to add this important bin program."
186 (ede-pmake-insert-variable-shared "lib_LTLIBRARIES"
187 (insert (concat "lib" (ede-name this) ".la"))))
189 (defmethod ede-proj-makefile-insert-automake-post-variables
190 ((this ede-proj-target-makefile-shared-object))
191 "Insert bin_PROGRAMS variables needed by target THIS.
192 We need to override -program which has an LDADD element."
193 nil)
195 (defmethod ede-proj-makefile-target-name ((this ede-proj-target-makefile-shared-object))
196 "Return the name of the main target for THIS target."
197 ;; We need some platform gunk to make the .so change to .sl, or .a,
198 ;; depending on the platform we are going to compile against.
199 (concat "lib" (ede-name this) ".la"))
201 (defmethod ede-proj-makefile-sourcevar ((this ede-proj-target-makefile-shared-object))
202 "Return the variable name for THIS's sources."
203 (if (eq (oref (ede-target-parent this) makefile-type) 'Makefile.am)
204 (concat "lib" (oref this name) "_la_SOURCES")
205 (call-next-method)))
208 (provide 'ede/proj-shared)
210 ;;; ede/proj-shared.el ends here