Initial Commit
[packages] / xemacs-packages / ede / ede-proj-prog.el
1 ;;; ede-proj-prog.el --- EDE Generic Project program support
2
3 ;;;  Copyright (C) 1998, 1999, 2000, 2001, 2005  Eric M. Ludlam
4
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; Keywords: project, make
7 ;; RCS: $Id: ede-proj-prog.el,v 1.1 2007-11-26 15:22:09 michaels Exp $
8
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.
13
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.
18
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.
23
24 ;;; Commentary:
25 ;;
26 ;; Handle building programs from object files in and EDE Project file.
27
28 (require 'ede-pmake)
29 (require 'ede-proj-obj)
30
31 ;;; Code:
32 (defclass ede-proj-target-makefile-program
33   (ede-proj-target-makefile-objectcode)
34   ((ldlibs :initarg :ldlibs
35            :initform nil
36            :type list
37            :custom (repeat (string :tag "Library"))
38            :documentation
39            "Libraries, such as \"m\" or \"Xt\" which this program dependso on.
40 The linker flag \"-l\" is automatically prepended.  Do not include a \"lib\"
41 prefix, or a \".so\" suffix.
42
43 Note: Currently only used for Automake projects."
44            )
45    (ldflags :initarg :ldflags
46             :initform nil
47             :type list
48             :custom (repeat (string :tag "Link Flag"))
49             :documentation
50             "Additional flags to add when linking this target.
51 Use ldlibs to add addition libraries.  Use this to specify specific
52 options to the linker.
53
54 Note: Not currently used.  This bug needs to be fixed.")
55    )
56    "This target is an executable program.")
57
58 (defmethod ede-proj-makefile-insert-automake-pre-variables
59   ((this ede-proj-target-makefile-program))
60   "Insert bin_PROGRAMS variables needed by target THIS."
61   (ede-pmake-insert-variable-shared "bin_PROGRAMS"
62     (insert (ede-name this)))
63   (call-next-method))
64
65 (defmethod ede-proj-makefile-insert-automake-post-variables
66   ((this ede-proj-target-makefile-program))
67   "Insert bin_PROGRAMS variables needed by target THIS."
68   (ede-pmake-insert-variable-shared
69       (concat (ede-name this) "_LDADD")
70     (mapcar (lambda (c) (insert " -l" c)) (oref this ldlibs)))
71   ;; For other targets THIS depends on
72   ;;
73   ;; NOTE: FIX THIS
74   ;; 
75   ;;(ede-pmake-insert-variable-shared
76   ;;    (concat (ede-name this) "_DEPENDENCIES")
77   ;;  (mapcar (lambda (d) (insert d)) (oref this FOOOOOOOO)))
78   (call-next-method))
79
80 (defmethod ede-proj-makefile-insert-rules ((this ede-proj-target-makefile-program))
81   "Insert rules needed by THIS target."
82   (let ((ede-proj-compiler-object-linkflags
83          (mapconcat 'identity (oref this ldflags) " ")))
84     (with-slots (ldlibs) this
85       (if ldlibs
86           (setq ede-proj-compiler-object-linkflags
87                 (concat ede-proj-compiler-object-linkflags
88                         " -l"
89                         (mapconcat 'identity ldlibs " -l")))))
90     (call-next-method)))
91
92 (defmethod project-debug-target ((obj ede-proj-target-makefile-program))
93   "Debug a program target OBJ."
94   (let ((tb (get-buffer-create " *padt*"))
95         (dd (if (not (string= (oref obj path) ""))
96                 (oref obj path)
97               default-directory))
98         (cmd nil))
99     (unwind-protect
100         (progn
101           (set-buffer tb)
102           (setq default-directory dd)
103           (setq cmd (read-from-minibuffer
104                      "Run (like this): "
105                      (concat (symbol-name ede-debug-program-function)
106                              " " (ede-target-name obj))))
107           (funcall ede-debug-program-function cmd))
108       (kill-buffer tb))))
109
110
111 (provide 'ede-proj-prog)
112
113 ;;; ede-proj-prog.el ends here