Initial Commit
[temp.git] / site-lisp / cedet-1.0pre4 / ede / ede-proj-shared.el
blobc8362a92681920b46b6944352ec0588241a697cc
1 ;;; ede-proj-shared.el --- EDE Generic Project shared library support
3 ;;; Copyright (C) 1998, 1999, 2000 Eric M. Ludlam
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; Keywords: project, make
7 ;; RCS: $Id: ede-proj-shared.el,v 1.9 2005/09/30 20:17:12 zappo Exp $
9 ;; This software is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
14 ;; This software is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
24 ;;; Commentary:
26 ;; Handle shared object libraries in and EDE Project file.
27 ;; Tries to deal with libtool and non-libtool situations.
29 (require 'ede-pmake)
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-shared-compiler
38 ede-gcc-libtool-shared-compiler))
39 (ldflags :custom (repeat (string :tag "Libtool flag"))
40 :documentation
41 "Additional flags to add when linking this shared library.
42 Use ldlibs to add addition libraries.")
44 "This target generates a shared library.")
46 (defvar ede-gcc-shared-compiler
47 (clone ede-gcc-compiler
48 "ede-c-shared-compiler"
49 :name "gcc -shared"
50 :variables '(("CC_SHARED" . "gcc")
51 ("C_SHARED_COMPILE" .
52 "$(CC_SHARED) -shared $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)"))
53 ; :linkvariables '(("C_SHARED_LINK" .
54 ; "$(CC_SHARED) -shared $(CFLAGS) $(LDFLAGS) -L. -o $@ $^")
55 ; )
56 ; :commands '("$(C_SHARED_LINK) %s")
57 :autoconf '("AM_PROG_LIBTOOL")
59 "Compiler for C sourcecode.")
61 (defvar ede-gcc-libtool-shared-compiler
62 (clone ede-gcc-shared-compiler
63 "ede-c-shared-compiler-libtool"
64 :name "libtool"
65 :variables '(("LIBTOOL" . "$(SHELL) libtool")
66 ("LTCOMPILE" . "$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)")
67 ("LTLINK" . "$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -L. -o $@")
69 :commands '("$(LTLINK) $^"
71 :autoconf '("AM_PROG_LIBTOOL")
73 "Compiler for C sourcecode.")
75 (when nil
78 (insert;; These C to O rules create dependencies
79 "%.o: %.c\n"
80 "\t@echo '$(COMPILE) -c $<'; \\\n"
81 "\t$(COMPILE)"
82 (if (oref this automatic-dependencies)
83 " -Wp,-MD,.deps/$(*F).P"
84 "")
85 " -c $<\n\n")
86 (if have-libtool
87 (insert;; These C to shared o rules create pic code.
88 "%.lo: %.c\n"
89 "\t@echo '$(LTCOMPILE) -c $<'; \\\n"
90 "\t$(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $<\n"
91 "\t@-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \\\n"
92 "\t < .deps/$(*F).p > .deps/$(*F).P\n"
93 "\t@-rm -f .deps/$(*F).p\n\n"))
96 (defmethod ede-proj-configure-add-missing
97 ((this ede-proj-target-makefile-shared-object))
98 "Query if any files needed by THIS provided by automake are missing.
99 Results in --add-missing being passed to automake."
100 (not (and (ede-expand-filename (ede-toplevel) "ltconfig")
101 (ede-expand-filename (ede-toplevel) "ltmain.sh"))))
103 (defmethod ede-proj-makefile-insert-automake-pre-variables
104 ((this ede-proj-target-makefile-shared-object))
105 "Insert bin_PROGRAMS variables needed by target THIS.
106 We aren't acutally inserting SOURCE details, but this is used by the
107 Makefile.am generator, so use it to add this important bin program."
108 (ede-pmake-insert-variable-shared "lib_LTLIBRARIES"
109 (insert (concat "lib" (ede-name this) ".la"))))
111 (defmethod ede-proj-makefile-insert-automake-post-variables
112 ((this ede-proj-target-makefile-shared-object))
113 "Insert bin_PROGRAMS variables needed by target THIS.
114 We need to override -program which has an LDADD element."
115 nil)
117 (defmethod ede-proj-makefile-target-name ((this ede-proj-target-makefile-shared-object))
118 "Return the name of the main target for THIS target."
119 ;; We need some platform gunk to make the .so change to .sl, or .a,
120 ;; depending on the platform we are going to compile against.
121 (concat "lib" (ede-name this) ".so"))
123 (defmethod ede-proj-makefile-sourcevar ((this ede-proj-target-makefile-shared-object))
124 "Return the variable name for THIS's sources."
125 (if (eq (oref (ede-target-parent this) makefile-type) 'Makefile.am)
126 (concat "lib" (oref this name) "_la_SOURCES")
127 (call-next-method)))
130 (provide 'ede-proj-shared)
132 ;;; ede-proj-shared.el ends here