]> code.delx.au - gnu-emacs/blob - lisp/cedet/ede/proj-shared.el
* cedet/ede/pmake.el (ede-pmake-insert-variable-once): Delete.
[gnu-emacs] / lisp / cedet / ede / proj-shared.el
1 ;;; ede-proj-shared.el --- EDE Generic Project shared library support
2
3 ;;; Copyright (C) 1998, 1999, 2000, 2009 Free Software Foundation, Inc.
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)
29 (require 'ede/proj-prog)
30
31 ;;; THIS NEEDS WORK. SEE ede-proj-obj.
32
33 ;;; Code:
34 (defclass ede-proj-target-makefile-shared-object
35 (ede-proj-target-makefile-program)
36 ((availablecompilers :initform (ede-gcc-shared-compiler
37 ede-gcc-libtool-shared-compiler
38 ede-g++-shared-compiler
39 ede-g++-libtool-shared-compiler
40 ))
41 (ldflags :custom (repeat (string :tag "Libtool flag"))
42 :documentation
43 "Additional flags to add when linking this shared library.
44 Use ldlibs to add addition libraries.")
45 )
46 "This target generates a shared library.")
47
48 (defvar ede-gcc-shared-compiler
49 (clone ede-gcc-compiler
50 "ede-c-shared-compiler"
51 :name "gcc -shared"
52 :variables '(("CC_SHARED" . "gcc")
53 ("C_SHARED_COMPILE" .
54 "$(CC_SHARED) -shared $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)"))
55 ; :linkvariables '(("C_SHARED_LINK" .
56 ; "$(CC_SHARED) -shared $(CFLAGS) $(LDFLAGS) -L. -o $@ $^")
57 ; )
58 ; :commands '("$(C_SHARED_LINK) %s")
59 ;; @TODO - addative modification of autoconf.
60 :autoconf '("AC_PROG_LIBTOOL")
61 )
62 "Compiler for C sourcecode.")
63
64 (defvar ede-gcc-libtool-shared-compiler
65 (clone ede-gcc-shared-compiler
66 "ede-c-shared-compiler-libtool"
67 :name "libtool"
68 :variables '(("LIBTOOL" . "$(SHELL) libtool")
69 ("LTCOMPILE" . "$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)")
70 ("LTLINK" . "$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -L. -o $@")
71 )
72 :commands '("$(LTLINK) $^"
73 )
74 :autoconf '("AC_PROG_LIBTOOL")
75 )
76 "Compiler for C sourcecode.")
77
78 (defvar ede-g++-shared-compiler
79 (clone ede-g++-compiler
80 "ede-c++-shared-compiler"
81 :name "gcc -shared"
82 :variables '(("CXX_SHARED" . "g++")
83 ("CXX_SHARED_COMPILE" .
84 "$(CXX_SHARED) -shared $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)"))
85 ;; @TODO - addative modification of autoconf.
86 :autoconf '("AC_PROG_LIBTOOL")
87 )
88 "Compiler for C sourcecode.")
89
90 (defvar ede-g++-libtool-shared-compiler
91 (clone ede-g++-shared-compiler
92 "ede-c++-shared-compiler-libtool"
93 :name "libtool"
94 :variables '(("CXX" "g++")
95 ("LIBTOOL" . "$(SHELL) libtool")
96 ("LTCOMPILE" . "$(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)")
97 ("LTLINK" . "$(LIBTOOL) --mode=link $(CXX) $(CFLAGS) $(LDFLAGS) -L. -o $@")
98 )
99 :commands '("$(LTLINK) $^"
100 )
101 :autoconf '("AC_PROG_LIBTOOL")
102 )
103 "Compiler for C sourcecode.")
104
105 ;;; @TODO - C++ versions of the above.
106
107 (when nil
108
109
110 (insert;; These C to O rules create dependencies
111 "%.o: %.c\n"
112 "\t@echo '$(COMPILE) -c $<'; \\\n"
113 "\t$(COMPILE)"
114 (if (oref this automatic-dependencies)
115 " -Wp,-MD,.deps/$(*F).P"
116 "")
117 " -c $<\n\n")
118 (if have-libtool
119 (insert;; These C to shared o rules create pic code.
120 "%.lo: %.c\n"
121 "\t@echo '$(LTCOMPILE) -c $<'; \\\n"
122 "\t$(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $<\n"
123 "\t@-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \\\n"
124 "\t < .deps/$(*F).p > .deps/$(*F).P\n"
125 "\t@-rm -f .deps/$(*F).p\n\n"))
126 )
127
128 (defmethod ede-proj-configure-add-missing
129 ((this ede-proj-target-makefile-shared-object))
130 "Query if any files needed by THIS provided by automake are missing.
131 Results in --add-missing being passed to automake."
132 (not (and (ede-expand-filename (ede-toplevel) "ltconfig")
133 (ede-expand-filename (ede-toplevel) "ltmain.sh"))))
134
135 (defmethod ede-proj-makefile-insert-automake-pre-variables
136 ((this ede-proj-target-makefile-shared-object))
137 "Insert bin_PROGRAMS variables needed by target THIS.
138 We aren't acutally inserting SOURCE details, but this is used by the
139 Makefile.am generator, so use it to add this important bin program."
140 (ede-pmake-insert-variable-shared "lib_LTLIBRARIES"
141 (insert (concat "lib" (ede-name this) ".la"))))
142
143 (defmethod ede-proj-makefile-insert-automake-post-variables
144 ((this ede-proj-target-makefile-shared-object))
145 "Insert bin_PROGRAMS variables needed by target THIS.
146 We need to override -program which has an LDADD element."
147 nil)
148
149 (defmethod ede-proj-makefile-target-name ((this ede-proj-target-makefile-shared-object))
150 "Return the name of the main target for THIS target."
151 ;; We need some platform gunk to make the .so change to .sl, or .a,
152 ;; depending on the platform we are going to compile against.
153 (concat "lib" (ede-name this) ".so"))
154
155 (defmethod ede-proj-makefile-sourcevar ((this ede-proj-target-makefile-shared-object))
156 "Return the variable name for THIS's sources."
157 (if (eq (oref (ede-target-parent this) makefile-type) 'Makefile.am)
158 (concat "lib" (oref this name) "_la_SOURCES")
159 (call-next-method)))
160
161
162 (provide 'ede/proj-shared)
163
164 ;; arch-tag: 05f22c3e-b269-4411-9425-65e8fe4ab74a
165 ;;; ede/proj-shared.el ends here