* admin/notes/copyright: Remove comments about deleted files in src/{m,s}.
[emacs.git] / lisp / cedet / ede / proj-prog.el
blobf33f5327beb50f12bdd11ae3d5d09916a295992d
1 ;;; ede-proj-prog.el --- EDE Generic Project program support
3 ;; Copyright (C) 1998-2001, 2005, 2008-2011 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 building programs from object files in and EDE Project file.
27 (eval-when-compile (require 'cl))
28 (require 'ede/pmake)
29 (require 'ede/proj-obj)
31 (declare-function ede-shell-run-something "ede/shell")
33 ;;; Code:
34 (defclass ede-proj-target-makefile-program
35 (ede-proj-target-makefile-objectcode)
36 ((ldlibs-local :initarg :ldlibs-local
37 :initform nil
38 :type list
39 :custom (repeat (string :tag "Local Library"))
40 :documentation
41 "Libraries that are part of this project.
42 The full path to these libraries should be specified, such as:
43 ../lib/libMylib.la or ../ar/myArchive.a
45 Note: Currently only used for Automake projects."
47 (ldflags :initarg :ldflags
48 :initform nil
49 :type list
50 :custom (repeat (string :tag "Link Flag"))
51 :documentation
52 "Additional flags to add when linking this target.
53 Use this to specify specific options to the linker.
54 A Common use may be to add -L to specify in-project locations of libraries
55 specified with ldlibs.")
56 (ldlibs :initarg :ldlibs
57 :initform nil
58 :type list
59 :custom (repeat (string :tag "Library"))
60 :documentation
61 "Libraries, such as \"m\" or \"Xt\" which this program depends on.
62 The linker flag \"-l\" is automatically prepended. Do not include a \"lib\"
63 prefix, or a \".so\" suffix.
64 Use the 'ldflags' slot to specify where in-project libraries might be.
66 Note: Currently only used for Automake projects."
69 "This target is an executable program.")
71 (defmethod ede-proj-makefile-insert-automake-pre-variables
72 ((this ede-proj-target-makefile-program))
73 "Insert bin_PROGRAMS variables needed by target THIS."
74 (ede-pmake-insert-variable-shared "bin_PROGRAMS"
75 (insert (ede-name this)))
76 (call-next-method))
78 (defmethod ede-proj-makefile-insert-automake-post-variables
79 ((this ede-proj-target-makefile-program))
80 "Insert bin_PROGRAMS variables needed by target THIS."
81 (ede-pmake-insert-variable-shared
82 (concat (ede-name this) "_LDADD")
83 (mapc (lambda (l) (insert " " l)) (oref this ldlibs-local))
84 (mapc (lambda (c) (insert " " c)) (oref this ldflags))
85 (when (oref this ldlibs)
86 (mapc (lambda (d) (insert " -l" d)) (oref this ldlibs)))
88 (call-next-method))
90 (defmethod ede-proj-makefile-insert-variables ((this ede-proj-target-makefile-program))
91 "Insert variables needed by the compiler THIS."
92 (call-next-method)
93 (let ((lf (mapconcat 'identity (oref this ldflags) " ")))
94 (with-slots (ldlibs) this
95 (if ldlibs
96 (setq lf
97 (concat lf " -l" (mapconcat 'identity ldlibs " -l")))))
98 ;; LDFLAGS as needed.
99 (when (and lf (not (string= "" lf)))
100 (ede-pmake-insert-variable-once "LDDEPS" (insert lf)))))
102 (defmethod project-debug-target ((obj ede-proj-target-makefile-program))
103 "Debug a program target OBJ."
104 (let ((tb (get-buffer-create " *padt*"))
105 (dd (if (not (string= (oref obj path) ""))
106 (oref obj path)
107 default-directory))
108 (cmd nil))
109 (unwind-protect
110 (progn
111 (set-buffer tb)
112 (setq default-directory dd)
113 (setq cmd (read-from-minibuffer
114 "Run (like this): "
115 (concat (symbol-name ede-debug-program-function)
116 " " (ede-target-name obj))))
117 (funcall ede-debug-program-function cmd))
118 (kill-buffer tb))))
120 (defmethod project-run-target ((obj ede-proj-target-makefile-program) &optional command)
121 "Run a program target OBJ.
122 Optional COMMAND is the command to run in place of asking the user."
123 (require 'ede/shell)
124 (let ((tb (get-buffer-create " *padt*"))
125 (dd (if (not (string= (oref obj path) ""))
126 (oref obj path)
127 default-directory))
128 (cmd nil))
129 (unwind-protect
130 (progn
131 (set-buffer tb)
132 (setq default-directory dd)
133 (setq cmd (or command
134 (read-from-minibuffer
135 "Run (like this): "
136 (concat "./" (ede-target-name obj)))))
137 (ede-shell-run-something obj cmd)
139 (kill-buffer tb))))
141 (provide 'ede/proj-prog)
143 ;;; ede/proj-prog.el ends here