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/>.
25 ;; Handle building programs from object files in and EDE Project file.
27 (eval-when-compile (require 'cl
))
29 (require 'ede
/proj-obj
)
31 (declare-function ede-shell-run-something
"ede/shell")
34 (defclass ede-proj-target-makefile-program
35 (ede-proj-target-makefile-objectcode)
36 ((ldlibs-local :initarg
:ldlibs-local
39 :custom
(repeat (string :tag
"Local Library"))
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
50 :custom
(repeat (string :tag
"Link Flag"))
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
59 :custom
(repeat (string :tag
"Library"))
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
)))
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
)))
90 (defmethod ede-proj-makefile-insert-variables ((this ede-proj-target-makefile-program
))
91 "Insert variables needed by the compiler THIS."
93 (let ((lf (mapconcat 'identity
(oref this ldflags
) " ")))
94 (with-slots (ldlibs) this
97 (concat lf
" -l" (mapconcat 'identity ldlibs
" -l")))))
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
) ""))
112 (setq default-directory dd
)
113 (setq cmd
(read-from-minibuffer
115 (concat (symbol-name ede-debug-program-function
)
116 " " (ede-target-name obj
))))
117 (funcall ede-debug-program-function cmd
))
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."
124 (let ((tb (get-buffer-create " *padt*"))
125 (dd (if (not (string= (oref obj path
) ""))
132 (setq default-directory dd
)
133 (setq cmd
(or command
134 (read-from-minibuffer
136 (concat "./" (ede-target-name obj
)))))
137 (ede-shell-run-something obj cmd
)
141 (provide 'ede
/proj-prog
)
143 ;;; ede/proj-prog.el ends here