Commit | Line | Data |
---|---|---|
acc33231 CY |
1 | ;;; ede-proj-shared.el --- EDE Generic Project shared library support |
2 | ||
73b0cd50 | 3 | ;;; Copyright (C) 1998-2000, 2009-2011 Free Software Foundation, Inc. |
acc33231 CY |
4 | |
5 | ;; Author: Eric M. Ludlam <zappo@gnu.org> | |
6 | ;; Keywords: project, make | |
7 | ||
8 | ;; This file is part of GNU Emacs. | |
9 | ||
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. | |
14 | ||
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. | |
19 | ||
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/>. | |
22 | ||
23 | ;;; Commentary: | |
24 | ;; | |
25 | ;; Handle shared object libraries in and EDE Project file. | |
26 | ;; Tries to deal with libtool and non-libtool situations. | |
27 | ||
28 | (require 'ede/pmake) | |
67d3ffe4 | 29 | (require 'ede/proj-obj) |
acc33231 CY |
30 | (require 'ede/proj-prog) |
31 | ||
32 | ;;; THIS NEEDS WORK. SEE ede-proj-obj. | |
33 | ||
34 | ;;; Code: | |
35 | (defclass ede-proj-target-makefile-shared-object | |
36 | (ede-proj-target-makefile-program) | |
cb85c0d8 EL |
37 | ((availablecompilers :initform '(ede-gcc-libtool-shared-compiler |
38 | ;;ede-gcc-shared-compiler | |
39 | ede-g++-libtool-shared-compiler | |
40 | ;;ede-g++-shared-compiler | |
41 | )) | |
42 | (availablelinkers :initform '(ede-cc-linker-libtool | |
43 | ede-g++-linker-libtool | |
44 | ;; Add more linker thingies here. | |
45 | )) | |
acc33231 CY |
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.") | |
50 | ) | |
51 | "This target generates a shared library.") | |
52 | ||
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 - addative modification of autoconf. | |
65 | :autoconf '("AC_PROG_LIBTOOL") | |
66 | ) | |
67 | "Compiler for C sourcecode.") | |
68 | ||
69 | (defvar ede-gcc-libtool-shared-compiler | |
70 | (clone ede-gcc-shared-compiler | |
71 | "ede-c-shared-compiler-libtool" | |
72 | :name "libtool" | |
67d3ffe4 | 73 | :variables '(("LIBTOOL" . "libtool") |
acc33231 CY |
74 | ("LTCOMPILE" . "$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)") |
75 | ("LTLINK" . "$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -L. -o $@") | |
76 | ) | |
67d3ffe4 CY |
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 $@ $<" | |
83 | ) | |
84 | )) | |
acc33231 CY |
85 | :autoconf '("AC_PROG_LIBTOOL") |
86 | ) | |
87 | "Compiler for C sourcecode.") | |
88 | ||
67d3ffe4 CY |
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 $@") | |
98 | ) | |
99 | :commands '("$(LTLINK) -o $@ $^") | |
100 | :autoconf '("AC_PROG_LIBTOOL") | |
101 | :objectextention ".la") | |
102 | "Linker needed for c++ programs.") | |
103 | ||
acc33231 CY |
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 - addative modification of autoconf. | |
112 | :autoconf '("AC_PROG_LIBTOOL") | |
113 | ) | |
114 | "Compiler for C sourcecode.") | |
115 | ||
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++") | |
67d3ffe4 CY |
121 | ("LIBTOOL" . "libtool") |
122 | ("LTCOMPILE" . "$(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)") | |
acc33231 | 123 | ) |
67d3ffe4 CY |
124 | :rules (list (ede-makefile-rule |
125 | "c++-inference-rule-libtool" | |
126 | :target "%.o" | |
cb85c0d8 | 127 | :dependencies "%.cpp" |
67d3ffe4 CY |
128 | :rules '("@echo '$(LTCOMPILE) -o $@ $<'; \\" |
129 | "$(LTCOMPILE) -o $@ $<" | |
130 | ) | |
131 | )) | |
acc33231 CY |
132 | :autoconf '("AC_PROG_LIBTOOL") |
133 | ) | |
134 | "Compiler for C sourcecode.") | |
135 | ||
67d3ffe4 CY |
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 $@") | |
145 | ) | |
146 | :commands '("$(LTLINK) -o $@ $^") | |
147 | :autoconf '("AC_PROG_LIBTOOL") | |
148 | :objectextention ".la") | |
149 | "Linker needed for c++ programs.") | |
150 | ||
acc33231 CY |
151 | ;;; @TODO - C++ versions of the above. |
152 | ||
153 | (when nil | |
154 | ||
155 | ||
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" | |
162 | "") | |
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")) | |
172 | ) | |
173 | ||
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")))) | |
180 | ||
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 acutally 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")))) | |
188 | ||
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) | |
194 | ||
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. | |
67d3ffe4 | 199 | (concat "lib" (ede-name this) ".la")) |
acc33231 CY |
200 | |
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))) | |
206 | ||
207 | ||
208 | (provide 'ede/proj-shared) | |
209 | ||
210 | ;;; ede/proj-shared.el ends here |