* cedet/ede/proj-shared.el (ede-proj-makefile-target-name): Use .la
[emacs.git] / lisp / cedet / ede / proj-shared.el
blob37aeb7230422c32f96a91a99e67814c377f7c64d
1 ;;; ede-proj-shared.el --- EDE Generic Project shared library support
3 ;;; Copyright (C) 1998, 1999, 2000, 2009 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-prog)
31 ;;; THIS NEEDS WORK. SEE ede-proj-obj.
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
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.")
46 "This target generates a shared library.")
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")
62 "Compiler for C sourcecode.")
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 $@")
72 :commands '("$(LTLINK) $^"
74 :autoconf '("AC_PROG_LIBTOOL")
76 "Compiler for C sourcecode.")
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")
88 "Compiler for C sourcecode.")
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 $@")
99 :commands '("$(LTLINK) $^"
101 :autoconf '("AC_PROG_LIBTOOL")
103 "Compiler for C sourcecode.")
105 ;;; @TODO - C++ versions of the above.
107 (when nil
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"
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"))
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"))))
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"))))
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)
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)
154 (if (eq (oref (ede-target-parent this) makefile-type)
155 'Makefile.am)
156 ".la"
157 ".so")))
159 (defmethod ede-proj-makefile-sourcevar ((this ede-proj-target-makefile-shared-object))
160 "Return the variable name for THIS's sources."
161 (if (eq (oref (ede-target-parent this) makefile-type) 'Makefile.am)
162 (concat "lib" (oref this name) "_la_SOURCES")
163 (call-next-method)))
166 (provide 'ede/proj-shared)
168 ;; arch-tag: 05f22c3e-b269-4411-9425-65e8fe4ab74a
169 ;;; ede/proj-shared.el ends here