Nuke arch-tags.
[bpt/emacs.git] / lisp / cedet / ede / make.el
CommitLineData
acc33231
CY
1;;; ede/make.el --- General information about "make"
2
5df4f04c 3;;; Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
acc33231
CY
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.
61The makefile generated by EDE for C files uses syntax that depends on GNU Make,
62so 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.
69The check passes if the MAKE version is no high enough, or if it
70is not GNU make.
71If NOERROR is non-nil, return t for success, nil for failure.
72If 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 )
de3a1fe9 79 (with-current-buffer b
acc33231 80 ;; Setup, and execute make.
acc33231
CY
81 (setq default-directory cd)
82 (erase-buffer)
83 (call-process ede-make-command nil b nil
84 "--version")
85 ;; Check the buffer for the string
86 (goto-char (point-min))
87 (when (looking-at "GNU Make\\(?: version\\)? \\([0-9][^,]+\\),")
88 (setq rev (match-string 1))
89 (require 'inversion)
90 (setq ans (not (inversion-check-version rev nil ede-make-min-version))))
91
92 ;; Answer reporting.
2054a44c 93 (when (and (called-interactively-p 'interactive) ans)
acc33231
CY
94 (message "GNU Make version %s. Good enough for CEDET." rev))
95
96 (when (and (not noerror) (not ans))
97 (error "EDE requires GNU Make version %s or later. Configure `ede-make-command' to fix"
98 ede-make-min-version))
99 ans)))
100
101(provide 'ede/make)
102
103;; Local variables:
104;; generated-autoload-file: "loaddefs.el"
acc33231
CY
105;; generated-autoload-load-name: "ede/make"
106;; End:
107
108;;; ede/make.el ends here