Remove redundant (require 'timer) in midnight.el
[emacs.git] / autogen.sh
blobce742a9c18aca04a0c0834db49cc693e0c5a2b1e
1 #!/bin/sh
2 ### autogen.sh - tool to help build Emacs from a bzr checkout
4 ## Copyright (C) 2011 Free Software Foundation, Inc.
6 ## Author: Glenn Morris <rgm@gnu.org>
8 ## This file is part of GNU Emacs.
10 ## GNU Emacs is free software: you can redistribute it and/or modify
11 ## it under the terms of the GNU General Public License as published by
12 ## the Free Software Foundation, either version 3 of the License, or
13 ## (at your option) any later version.
15 ## GNU Emacs is distributed in the hope that it will be useful,
16 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ## GNU General Public License for more details.
20 ## You should have received a copy of the GNU General Public License
21 ## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ### Commentary:
25 ## The Emacs bzr repository does not include the configure script
26 ## (and associated helpers). The first time you fetch Emacs from bzr,
27 ## run this script to generate the necessary files.
28 ## For more details, see the file INSTALL.BZR.
30 ### Code:
32 ## Tools we need:
33 progs="autoconf automake"
35 ## Minimum versions we need:
36 autoconf_min=`sed -n 's/^ *AC_PREREQ(\([0-9\.]*\)).*/\1/p' configure.in`
38 ## FIXME how to determine this from the sources?
39 automake_min=1.11
42 ## $1 = program, eg "autoconf".
43 ## Echo the version string, eg "2.59".
44 ## FIXME does not handle things like "1.4a", but AFAIK those are
45 ## all old versions, so it is OK to fail there.
46 ## Also note that we do not handle micro versions.
47 get_version ()
49 $1 --version 2>&1 | sed -n '1 s/.* \([1-9][0-9\.]*\).*/\1/p'
52 ## $1 = version string, eg "2.59"
53 ## Echo the major version, eg "2".
54 major_version ()
56 echo $1 | sed -e 's/\([0-9][0-9]*\)\..*/\1/'
59 ## $1 = version string, eg "2.59"
60 ## Echo the minor version, eg "59".
61 minor_version ()
63 echo $1 | sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/'
66 ## $1 = program
67 ## $2 = minimum version.
68 ## Return 0 if program is present with version >= minumum version.
69 ## Return 1 if program is missing.
70 ## Return 2 if program is present but too old.
71 ## Return 3 for unexpected error (eg failed to parse version).
72 check_version ()
74 have_version=`get_version $1`
76 [ x"$have_version" = x ] && return 1
78 have_maj=`major_version $have_version`
79 need_maj=`major_version $2`
81 [ x"$have_maj" != x ] && [ x"$need_maj" != x ] || return 3
83 [ $have_maj -gt $need_maj ] && return 0
84 [ $have_maj -lt $need_maj ] && return 2
86 have_min=`minor_version $have_version`
87 need_min=`minor_version $2`
89 [ x"$have_min" != x ] && [ x"$need_min" != x ] || return 3
91 [ $have_min -ge $need_min ] && return 0
92 return 2
96 cat <<EOF
97 Checking whether you have the necessary tools...
98 (Read INSTALL.BZR for more details on building Emacs)
102 missing=
104 for prog in $progs; do
106 eval min=\$${prog}_min
108 echo "Checking for $prog (need at least version $min)..."
110 check_version $prog $min
112 retval=$?
114 case $retval in
115 0) stat="ok" ;;
116 1) stat="missing" ;;
117 2) stat="too old" ;;
118 *) stat="unable to check" ;;
119 esac
121 echo $stat
123 if [ $retval -ne 0 ]; then
124 missing="$missing $prog"
125 eval ${prog}_why=\""$stat"\"
128 done
131 if [ x"$missing" != x ]; then
133 cat <<EOF
135 Building Emacs from Bzr requires the following specialized programs:
138 for prog in $progs; do
139 eval min=\$${prog}_min
141 echo "$prog (minimum version $min)"
142 done
145 cat <<EOF
147 Your system seems to be missing the following tool(s):
150 for prog in $missing; do
151 eval why=\$${prog}_why
153 echo "$prog ($why)"
154 done
156 cat <<EOF
158 If you think you have the required tools, please add them to your PATH
159 and re-run this script.
161 Otherwise, please try installing them.
162 On systems using rpm and yum, try: "yum install PACKAGE"
163 On systems using dpkg and apt, try: "apt-get install PACKAGE"
164 Then re-run this script.
166 If you do not have permission to do this, or if the version provided
167 by your system is too old, it is normally straightforward to build
168 these packages from source. You can find the sources at:
170 ftp://ftp.gnu.org/gnu/PACKAGE/
172 Download the package (make sure you get at least the minimum version
173 listed above), extract it using tar, then run configure, make,
174 make install. Add the installation directory to your PATH and re-run
175 this script.
177 If you know that the required versions are in your PATH, but this
178 script has made an error, then you can simply run
180 autoreconf -i -I m4
182 instead of this script.
184 If all else fails, you can try using the pre-built versions of the
185 generated files by doing:
187 ./autogen/copy_autogen
189 This is not recommended - see the comments in \`copy_autogen'.
191 Please report any problems with this script to bug-gnu-emacs@gnu.org .
194 exit 1
197 echo "Your system has the required tools, running autoreconf..."
200 ## Let autoreconf figure out what, if anything, needs doing.
201 autoreconf -i -I m4 || exit $?
203 echo "You can now run \`./configure'."
205 exit 0
207 ### autogen.sh ends here