Remove some files that autoreconf can supply.
[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
66b87493 4## Copyright (C) 2011 Free Software Foundation, Inc.
067d23c9 5
66b87493
GM
6## Author: Glenn Morris <rgm@gnu.org>
7
8## This file is part of GNU Emacs.
9
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.
14
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.
19
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/>.
22
23### Commentary:
24
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.
29
30### Code:
31
32## Tools we need:
33progs="autoconf automake"
34
35## Minimum versions we need:
36autoconf_min=`sed -n 's/^ *AC_PREREQ(\([0-9\.]*\)).*/\1/p' configure.in`
37
38## FIXME how to determine this from the sources?
39automake_min=1.11
40
41
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.
47get_version ()
48{
49 $1 --version 2>&1 | sed -n '1 s/.* \([1-9][0-9\.]*\).*/\1/p'
50}
51
52## $1 = version string, eg "2.59"
53## Echo the major version, eg "2".
54major_version ()
55{
56 echo $1 | sed -e 's/\([0-9][0-9]*\)\..*/\1/'
57}
58
59## $1 = version string, eg "2.59"
60## Echo the minor version, eg "59".
61minor_version ()
62{
63 echo $1 | sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/'
64}
65
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).
72check_version ()
73{
74 have_version=`get_version $1`
75
76 [ x"$have_version" = x ] && return 1
77
78 have_maj=`major_version $have_version`
79 need_maj=`major_version $2`
80
81 [ x"$have_maj" != x ] && [ x"$need_maj" != x ] || return 3
82
83 [ $have_maj -gt $need_maj ] && return 0
84 [ $have_maj -lt $need_maj ] && return 2
85
86 have_min=`minor_version $have_version`
87 need_min=`minor_version $2`
88
89 [ x"$have_min" != x ] && [ x"$need_min" != x ] || return 3
90
91 [ $have_min -ge $need_min ] && return 0
92 return 2
93}
94
95
96cat <<EOF
97Checking whether you have the necessary tools...
98(Read INSTALL.BZR for more details on building Emacs)
99
100EOF
101
102missing=
103
104for prog in $progs; do
105
106 eval min=\$${prog}_min
107
108 echo "Checking for $prog (need at least version $min)..."
109
110 check_version $prog $min
111
112 retval=$?
113
114 case $retval in
115 0) stat="ok" ;;
116 1) stat="missing" ;;
117 2) stat="too old" ;;
118 *) stat="unable to check" ;;
119 esac
120
121 echo $stat
122
123 if [ $retval -ne 0 ]; then
124 missing="$missing $prog"
125 eval ${prog}_why=\""$stat"\"
126 fi
127
128done
129
130
131if [ x"$missing" != x ]; then
132
133 cat <<EOF
134
135Building Emacs from Bzr requires the following specialized programs:
136EOF
137
138 for prog in $progs; do
139 eval min=\$${prog}_min
140
141 echo "$prog (minimum version $min)"
142 done
143
144
145 cat <<EOF
146
147Your system seems to be missing the following tool(s):
148EOF
149
150 for prog in $missing; do
151 eval why=\$${prog}_why
152
153 echo "$prog ($why)"
154 done
155
156 cat <<EOF
157
158If you think you have the required tools, please add them to your PATH
159and re-run this script.
160
161Otherwise, please try installing them.
162On systems using rpm and yum, try: "yum install PACKAGE"
163On systems using dpkg and apt, try: "apt-get install PACKAGE"
164Then re-run this script.
165
166If you do not have permission to do this, or if the version provided
167by your system is too old, it is normally straightforward to build
168these packages from source. You can find the sources at:
169
170ftp://ftp.gnu.org/gnu/PACKAGE/
171
172Download the package (make sure you get at least the minimum version
173listed above), extract it using tar, then run configure, make,
174make install. Add the installation directory to your PATH and re-run
175this script.
176
177If you know that the required versions are in your PATH, but this
178script has made an error, then you can simply run
179
f6ca84c0 180autoreconf -i -I m4
66b87493
GM
181
182instead of this script.
183
184If all else fails, you can try using the pre-built versions of the
185generated files by doing:
186
34cb1cc6 187./autogen/copy_autogen
66b87493
GM
188
189This is not recommended - see the comments in \`copy_autogen'.
190
191Please report any problems with this script to bug-gnu-emacs@gnu.org .
192EOF
193
194 exit 1
195fi
196
197echo "Your system has the required tools, running autoreconf..."
198
199
200## Let autoreconf figure out what, if anything, needs doing.
f6ca84c0 201autoreconf -i -I m4 || exit $?
66b87493
GM
202
203echo "You can now run \`./configure'."
204
205exit 0
206
207### autogen.sh ends here