Mercurial > emacs
comparison lisp/cedet/ede/make.el @ 104496:8c4870c15962
* cedet/ede.el, cedet/ede/*.el: New files.
* cedet/cedet.el: Require ede.
* cedet/semantic/symref/filter.el (semantic-symref-hits-in-region):
Require semantic/idle.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 20 Sep 2009 15:06:05 +0000 |
parents | |
children | 7f4c7f5c0eba |
comparison
equal
deleted
inserted
replaced
104495:4659ddbe20bf | 104496:8c4870c15962 |
---|---|
1 ;;; ede/make.el --- General information about "make" | |
2 | |
3 ;;; Copyright (C) 2009 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com> | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs 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 3 of the License, or | |
12 ;; (at your option) any later version. | |
13 | |
14 ;; GNU Emacs 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. If not, see <http://www.gnu.org/licenses/>. | |
21 | |
22 ;;; Commentary: | |
23 ;; | |
24 ;; This file needs to choose the version of "make" it wants to use. | |
25 ;; Whenever an executable "gmake" is available, we prefer that since | |
26 ;; it usually means GNU Make. If it doesn't exist, use "make". | |
27 ;; | |
28 ;; Run tests on make --version to be sure it is GNU make so that | |
29 ;; logical error messages can be provided. | |
30 | |
31 ;;; Code: | |
32 | |
33 (declare-function inversion-check-version "inversion") | |
34 | |
35 (if (fboundp 'locate-file) | |
36 (defsubst ede--find-executable (exec) | |
37 "Return an expanded file name for a program EXEC on the exec path." | |
38 (locate-file exec exec-path)) | |
39 | |
40 ;; Else, older version of Emacs. | |
41 | |
42 (defsubst ede--find-executable (exec) | |
43 "Return an expanded file name for a program EXEC on the exec path." | |
44 (let ((p exec-path) | |
45 (found nil)) | |
46 (while (and p (not found)) | |
47 (let ((f (expand-file-name exec (car p)))) | |
48 (if (file-exists-p f) | |
49 (setq found f))) | |
50 (setq p (cdr p))) | |
51 found)) | |
52 ) | |
53 | |
54 (defvar ede-make-min-version "3.0" | |
55 "Minimum version of GNU make required.") | |
56 | |
57 (defcustom ede-make-command (cond ((ede--find-executable "gmake") | |
58 "gmake") | |
59 (t "make")) ;; What to do? | |
60 "The MAKE command to use for EDE when compiling. | |
61 The makefile generated by EDE for C files uses syntax that depends on GNU Make, | |
62 so this should be set to something that can execute GNU Make files." | |
63 :group 'ede | |
64 :type 'string) | |
65 | |
66 ;;;###autoload | |
67 (defun ede-make-check-version (&optional noerror) | |
68 "Check the version of GNU Make installed. | |
69 The check passes if the MAKE version is no high enough, or if it | |
70 is not GNU make. | |
71 If NOERROR is non-nil, return t for success, nil for failure. | |
72 If NOERROR is nil, then throw an error on failure. Return t otherwise." | |
73 (interactive) | |
74 (let ((b (get-buffer-create "*EDE Make Version*")) | |
75 (cd default-directory) | |
76 (rev nil) | |
77 (ans nil) | |
78 ) | |
79 (save-excursion | |
80 ;; Setup, and execute make. | |
81 (set-buffer b) | |
82 (setq default-directory cd) | |
83 (erase-buffer) | |
84 (call-process ede-make-command nil b nil | |
85 "--version") | |
86 ;; Check the buffer for the string | |
87 (goto-char (point-min)) | |
88 (when (looking-at "GNU Make\\(?: version\\)? \\([0-9][^,]+\\),") | |
89 (setq rev (match-string 1)) | |
90 (require 'inversion) | |
91 (setq ans (not (inversion-check-version rev nil ede-make-min-version)))) | |
92 | |
93 ;; Answer reporting. | |
94 (when (and (interactive-p) ans) | |
95 (message "GNU Make version %s. Good enough for CEDET." rev)) | |
96 | |
97 (when (and (not noerror) (not ans)) | |
98 (error "EDE requires GNU Make version %s or later. Configure `ede-make-command' to fix" | |
99 ede-make-min-version)) | |
100 ans))) | |
101 | |
102 (provide 'ede/make) | |
103 | |
104 ;; Local variables: | |
105 ;; generated-autoload-file: "loaddefs.el" | |
106 ;; generated-autoload-feature: ede/loaddefs | |
107 ;; generated-autoload-load-name: "ede/make" | |
108 ;; End: | |
109 | |
110 ;;; ede/make.el ends here |