Commit | Line | Data |
---|---|---|
acc33231 CY |
1 | ;;; ede-proj-prog.el --- EDE Generic Project program support |
2 | ||
5df4f04c | 3 | ;; Copyright (C) 1998, 1999, 2000, 2001, 2005, 2008, 2009, 2010, 2011 |
cb758101 | 4 | ;; Free Software Foundation, Inc. |
acc33231 CY |
5 | |
6 | ;; Author: Eric M. Ludlam <zappo@gnu.org> | |
7 | ;; Keywords: project, make | |
8 | ||
9 | ;; This file is part of GNU Emacs. | |
10 | ||
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. | |
15 | ||
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. | |
20 | ||
21 | ;; You should have received a copy of the GNU General Public License | |
22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. | |
23 | ||
24 | ;;; Commentary: | |
25 | ;; | |
26 | ;; Handle building programs from object files in and EDE Project file. | |
27 | ||
67d3ffe4 | 28 | (eval-when-compile (require 'cl)) |
acc33231 CY |
29 | (require 'ede/pmake) |
30 | (require 'ede/proj-obj) | |
31 | ||
67d3ffe4 CY |
32 | (declare-function ede-shell-run-something "ede/shell") |
33 | ||
acc33231 CY |
34 | ;;; Code: |
35 | (defclass ede-proj-target-makefile-program | |
36 | (ede-proj-target-makefile-objectcode) | |
cb85c0d8 EL |
37 | ((ldlibs-local :initarg :ldlibs-local |
38 | :initform nil | |
39 | :type list | |
40 | :custom (repeat (string :tag "Local Library")) | |
41 | :documentation | |
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 | |
acc33231 CY |
45 | |
46 | Note: Currently only used for Automake projects." | |
47 | ) | |
48 | (ldflags :initarg :ldflags | |
49 | :initform nil | |
50 | :type list | |
51 | :custom (repeat (string :tag "Link Flag")) | |
52 | :documentation | |
53 | "Additional flags to add when linking this target. | |
cb85c0d8 EL |
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 | |
58 | :initform nil | |
59 | :type list | |
60 | :custom (repeat (string :tag "Library")) | |
61 | :documentation | |
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. | |
acc33231 | 66 | |
cb85c0d8 EL |
67 | Note: Currently only used for Automake projects." |
68 | ) | |
acc33231 CY |
69 | ) |
70 | "This target is an executable program.") | |
71 | ||
72 | (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 | (call-next-method)) | |
78 | ||
79 | (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") | |
cb85c0d8 EL |
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))) | |
88 | ) | |
acc33231 CY |
89 | (call-next-method)) |
90 | ||
cb85c0d8 EL |
91 | (defmethod ede-proj-makefile-insert-variables ((this ede-proj-target-makefile-program)) |
92 | "Insert variables needed by the compiler THIS." | |
93 | (call-next-method) | |
94 | (let ((lf (mapconcat 'identity (oref this ldflags) " "))) | |
acc33231 CY |
95 | (with-slots (ldlibs) this |
96 | (if ldlibs | |
cb85c0d8 EL |
97 | (setq lf |
98 | (concat lf " -l" (mapconcat 'identity ldlibs " -l"))))) | |
99 | ;; LDFLAGS as needed. | |
100 | (when (and lf (not (string= "" lf))) | |
101 | (ede-pmake-insert-variable-once "LDDEPS" (insert lf))))) | |
acc33231 CY |
102 | |
103 | (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) "")) | |
107 | (oref obj path) | |
108 | default-directory)) | |
109 | (cmd nil)) | |
110 | (unwind-protect | |
111 | (progn | |
112 | (set-buffer tb) | |
113 | (setq default-directory dd) | |
114 | (setq cmd (read-from-minibuffer | |
115 | "Run (like this): " | |
116 | (concat (symbol-name ede-debug-program-function) | |
117 | " " (ede-target-name obj)))) | |
118 | (funcall ede-debug-program-function cmd)) | |
119 | (kill-buffer tb)))) | |
120 | ||
67d3ffe4 CY |
121 | (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." | |
124 | (require 'ede/shell) | |
125 | (let ((tb (get-buffer-create " *padt*")) | |
126 | (dd (if (not (string= (oref obj path) "")) | |
127 | (oref obj path) | |
128 | default-directory)) | |
129 | (cmd nil)) | |
130 | (unwind-protect | |
131 | (progn | |
132 | (set-buffer tb) | |
133 | (setq default-directory dd) | |
134 | (setq cmd (or command | |
135 | (read-from-minibuffer | |
136 | "Run (like this): " | |
137 | (concat "./" (ede-target-name obj))))) | |
138 | (ede-shell-run-something obj cmd) | |
139 | ) | |
140 | (kill-buffer tb)))) | |
acc33231 CY |
141 | |
142 | (provide 'ede/proj-prog) | |
143 | ||
3999968a | 144 | ;; arch-tag: 0bfa9364-f385-4745-a846-462146a79a25 |
acc33231 | 145 | ;;; ede/proj-prog.el ends here |