Skip to content

HTTPS clone URL

Subversion checkout URL

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