* test/automated/calc-tests.el: New file and add tests for math-bignum.
[bpt/emacs.git] / autogen.sh
CommitLineData
067d23c9 1#!/bin/sh
66b87493 2### autogen.sh - tool to help build Emacs from a bzr checkout
067d23c9 3
ba318903 4## Copyright (C) 2011-2014 Free Software Foundation, Inc.
067d23c9 5
66b87493 6## Author: Glenn Morris <rgm@gnu.org>
34dc21db 7## Maintainer: emacs-devel@gnu.org
66b87493
GM
8
9## This file is part of GNU Emacs.
10
11## GNU Emacs is free software: you can redistribute it and/or modify
12## it under the terms of the GNU General Public License as published by
13## the Free Software Foundation, either version 3 of the License, or
14## (at your option) any later version.
15
16## GNU Emacs is distributed in the hope that it will be useful,
17## but WITHOUT ANY WARRANTY; without even the implied warranty of
18## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19## GNU General Public License for more details.
20
21## You should have received a copy of the GNU General Public License
22## along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24### Commentary:
25
26## The Emacs bzr repository does not include the configure script
27## (and associated helpers). The first time you fetch Emacs from bzr,
28## run this script to generate the necessary files.
ac4c50ad 29## For more details, see the file INSTALL.REPO.
66b87493
GM
30
31### Code:
32
33## Tools we need:
42e85a8f 34## Note that we respect the values of AUTOCONF etc, like autoreconf does.
66b87493
GM
35progs="autoconf automake"
36
37## Minimum versions we need:
c4444d16 38autoconf_min=`sed -n 's/^ *AC_PREREQ(\([0-9\.]*\)).*/\1/p' configure.ac`
66b87493 39
7d732d1a
GM
40## This will need improving if more options are ever added to the
41## AM_INIT_AUTOMAKE call.
42automake_min=`sed -n 's/^ *AM_INIT_AUTOMAKE(\([0-9\.]*\)).*/\1/p' configure.ac`
66b87493
GM
43
44
45## $1 = program, eg "autoconf".
46## Echo the version string, eg "2.59".
47## FIXME does not handle things like "1.4a", but AFAIK those are
48## all old versions, so it is OK to fail there.
49## Also note that we do not handle micro versions.
50get_version ()
51{
42e85a8f
GM
52 ## Remove eg "./autogen.sh: line 50: autoconf: command not found".
53 $1 --version 2>&1 | sed -e '/not found/d' -n -e '1 s/.* \([1-9][0-9\.]*\).*/\1/p'
66b87493
GM
54}
55
56## $1 = version string, eg "2.59"
57## Echo the major version, eg "2".
58major_version ()
59{
60 echo $1 | sed -e 's/\([0-9][0-9]*\)\..*/\1/'
61}
62
63## $1 = version string, eg "2.59"
64## Echo the minor version, eg "59".
65minor_version ()
66{
67 echo $1 | sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/'
68}
69
70## $1 = program
71## $2 = minimum version.
c80e3b4a 72## Return 0 if program is present with version >= minimum version.
66b87493
GM
73## Return 1 if program is missing.
74## Return 2 if program is present but too old.
75## Return 3 for unexpected error (eg failed to parse version).
76check_version ()
77{
42e85a8f
GM
78 ## Respect eg $AUTOMAKE if it is set, like autoreconf does.
79 uprog=`echo $1 | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
80
81 eval uprog=\$${uprog}
82
83 [ x"$uprog" = x ] && uprog=$1
84
85 have_version=`get_version $uprog`
66b87493
GM
86
87 [ x"$have_version" = x ] && return 1
88
89 have_maj=`major_version $have_version`
90 need_maj=`major_version $2`
91
92 [ x"$have_maj" != x ] && [ x"$need_maj" != x ] || return 3
93
94 [ $have_maj -gt $need_maj ] && return 0
95 [ $have_maj -lt $need_maj ] && return 2
96
97 have_min=`minor_version $have_version`
98 need_min=`minor_version $2`
99
100 [ x"$have_min" != x ] && [ x"$need_min" != x ] || return 3
101
102 [ $have_min -ge $need_min ] && return 0
103 return 2
104}
105
106
107cat <<EOF
108Checking whether you have the necessary tools...
ac4c50ad 109(Read INSTALL.REPO for more details on building Emacs)
66b87493
GM
110
111EOF
112
113missing=
114
115for prog in $progs; do
116
117 eval min=\$${prog}_min
118
119 echo "Checking for $prog (need at least version $min)..."
120
121 check_version $prog $min
122
123 retval=$?
124
125 case $retval in
126 0) stat="ok" ;;
127 1) stat="missing" ;;
128 2) stat="too old" ;;
129 *) stat="unable to check" ;;
130 esac
131
132 echo $stat
133
134 if [ $retval -ne 0 ]; then
135 missing="$missing $prog"
136 eval ${prog}_why=\""$stat"\"
137 fi
138
139done
140
141
142if [ x"$missing" != x ]; then
143
144 cat <<EOF
145
146Building Emacs from Bzr requires the following specialized programs:
147EOF
148
149 for prog in $progs; do
150 eval min=\$${prog}_min
151
152 echo "$prog (minimum version $min)"
153 done
154
155
156 cat <<EOF
157
158Your system seems to be missing the following tool(s):
159EOF
160
161 for prog in $missing; do
162 eval why=\$${prog}_why
163
164 echo "$prog ($why)"
165 done
166
167 cat <<EOF
168
169If you think you have the required tools, please add them to your PATH
170and re-run this script.
171
172Otherwise, please try installing them.
173On systems using rpm and yum, try: "yum install PACKAGE"
174On systems using dpkg and apt, try: "apt-get install PACKAGE"
175Then re-run this script.
176
177If you do not have permission to do this, or if the version provided
178by your system is too old, it is normally straightforward to build
179these packages from source. You can find the sources at:
180
181ftp://ftp.gnu.org/gnu/PACKAGE/
182
183Download the package (make sure you get at least the minimum version
184listed above), extract it using tar, then run configure, make,
185make install. Add the installation directory to your PATH and re-run
186this script.
187
188If you know that the required versions are in your PATH, but this
189script has made an error, then you can simply run
190
f6ca84c0 191autoreconf -i -I m4
66b87493
GM
192
193instead of this script.
194
66b87493
GM
195Please report any problems with this script to bug-gnu-emacs@gnu.org .
196EOF
197
dee26dfa 198 exit 1
66b87493
GM
199fi
200
201echo "Your system has the required tools, running autoreconf..."
202
203
204## Let autoreconf figure out what, if anything, needs doing.
f6ca84c0 205autoreconf -i -I m4 || exit $?
66b87493 206
3f750e43
PE
207## Create a timestamp, so that './autogen.sh; make' doesn't
208## cause 'make' to needlessly run 'autoheader'.
209echo timestamp > src/stamp-h.in || exit
210
66b87493
GM
211echo "You can now run \`./configure'."
212
213exit 0
214
215### autogen.sh ends here