1 ;;; ede-proj-prog.el --- EDE Generic Project program support
3 ;; Copyright (C) 1998-2001, 2005, 2008-2017 Free Software Foundation,
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
7 ;; Keywords: project, make
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
26 ;; Handle building programs from object files in and EDE Project file.
28 (eval-when-compile (require 'cl
))
30 (require 'ede
/proj-obj
)
32 (declare-function ede-shell-run-something
"ede/shell")
35 (defclass ede-proj-target-makefile-program
36 (ede-proj-target-makefile-objectcode)
37 ((ldlibs-local :initarg
:ldlibs-local
40 :custom
(repeat (string :tag
"Local Library"))
42 "Libraries that are part of this project.
43 The full path to these libraries should be specified, such as:
44 ../lib/libMylib.la or ../ar/myArchive.a
46 Note: Currently only used for Automake projects."
48 (ldflags :initarg
:ldflags
51 :custom
(repeat (string :tag
"Link Flag"))
53 "Additional flags to add when linking this target.
54 Use this to specify specific options to the linker.
55 A Common use may be to add -L to specify in-project locations of libraries
56 specified with ldlibs.")
57 (ldlibs :initarg
:ldlibs
60 :custom
(repeat (string :tag
"Library"))
62 "Libraries, such as \"m\" or \"Xt\" which this program depends on.
63 The linker flag \"-l\" is automatically prepended. Do not include a \"lib\"
64 prefix, or a \".so\" suffix.
65 Use the `ldflags' slot to specify where in-project libraries might be.
67 Note: Currently only used for Automake projects."
70 "This target is an executable program.")
72 (cl-defmethod ede-proj-makefile-insert-automake-pre-variables
73 ((this ede-proj-target-makefile-program
))
74 "Insert bin_PROGRAMS variables needed by target THIS."
75 (ede-pmake-insert-variable-shared "bin_PROGRAMS"
76 (insert (ede-name this
)))
77 (cl-call-next-method))
79 (cl-defmethod ede-proj-makefile-insert-automake-post-variables
80 ((this ede-proj-target-makefile-program
))
81 "Insert bin_PROGRAMS variables needed by target THIS."
82 (ede-pmake-insert-variable-shared
83 (concat (ede-name this
) "_LDADD")
84 (mapc (lambda (l) (insert " " l
)) (oref this ldlibs-local
))
85 (mapc (lambda (c) (insert " " c
)) (oref this ldflags
))
86 (when (oref this ldlibs
)
87 (mapc (lambda (d) (insert " -l" d
)) (oref this ldlibs
)))
89 (cl-call-next-method))
91 (cl-defmethod ede-proj-makefile-insert-variables ((this ede-proj-target-makefile-program
))
92 "Insert variables needed by the compiler THIS."
94 (let ((lf (mapconcat 'identity
(oref this ldflags
) " ")))
95 (with-slots (ldlibs) this
98 (concat lf
" -l" (mapconcat 'identity ldlibs
" -l")))))
100 (when (and lf
(not (string= "" lf
)))
101 (ede-pmake-insert-variable-once "LDDEPS" (insert lf
)))))
103 (cl-defmethod project-debug-target ((obj ede-proj-target-makefile-program
))
104 "Debug a program target OBJ."
105 (let ((tb (get-buffer-create " *padt*"))
106 (dd (if (not (string= (oref obj path
) ""))
113 (setq default-directory dd
)
114 (setq cmd
(read-from-minibuffer
116 (concat (symbol-name ede-debug-program-function
)
117 " " (ede-target-name obj
))))
118 (funcall ede-debug-program-function cmd
))
121 (cl-defmethod project-run-target ((obj ede-proj-target-makefile-program
) &optional command
)
122 "Run a program target OBJ.
123 Optional COMMAND is the command to run in place of asking the user."
125 (let ((tb (get-buffer-create " *padt*"))
126 (dd (if (not (string= (oref obj path
) ""))
133 (setq default-directory dd
)
134 (setq cmd
(or command
135 (read-from-minibuffer
137 (concat "./" (ede-target-name obj
)))))
138 (ede-shell-run-something obj cmd
)
142 (provide 'ede
/proj-prog
)
144 ;;; ede/proj-prog.el ends here