Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / lisp / cedet / ede / make.el
blobd05e21b63e0e3ccc575839c1ef09d4a4f634c5fa
1 ;;; ede/make.el --- General information about "make"
3 ;;; Copyright (C) 2009-2014 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
7 ;; This file is part of GNU Emacs.
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.
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.
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/>.
22 ;;; Commentary:
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".
28 ;; Run tests on make --version to be sure it is GNU make so that
29 ;; logical error messages can be provided.
31 ;;; Code:
33 (declare-function inversion-check-version "inversion")
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))
40 ;; Else, older version of Emacs.
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))
54 (defvar ede-make-min-version "3.0"
55 "Minimum version of GNU make required.")
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)
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)
79 (with-current-buffer b
80 ;; Setup, and execute make.
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))))
92 ;; Answer reporting.
93 (when (and (called-interactively-p 'interactive) ans)
94 (message "GNU Make version %s. Good enough for CEDET." rev))
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)))
101 (provide 'ede/make)
103 ;; Local variables:
104 ;; generated-autoload-file: "loaddefs.el"
105 ;; generated-autoload-load-name: "ede/make"
106 ;; End:
108 ;;; ede/make.el ends here