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