Commit | Line | Data |
---|---|---|
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: | |
33 | progs="autoconf automake" | |
34 | ||
35 | ## Minimum versions we need: | |
36 | autoconf_min=`sed -n 's/^ *AC_PREREQ(\([0-9\.]*\)).*/\1/p' configure.in` | |
37 | ||
38 | ## FIXME how to determine this from the sources? | |
39 | automake_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. | |
47 | get_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". | |
54 | major_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". | |
61 | minor_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). | |
72 | check_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 | ||
96 | cat <<EOF | |
97 | Checking whether you have the necessary tools... | |
98 | (Read INSTALL.BZR for more details on building Emacs) | |
99 | ||
100 | EOF | |
101 | ||
102 | missing= | |
103 | ||
104 | for 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 | ||
128 | done | |
129 | ||
130 | ||
131 | if [ x"$missing" != x ]; then | |
132 | ||
133 | cat <<EOF | |
134 | ||
135 | Building Emacs from Bzr requires the following specialized programs: | |
136 | EOF | |
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 | ||
147 | Your system seems to be missing the following tool(s): | |
148 | EOF | |
149 | ||
150 | for prog in $missing; do | |
151 | eval why=\$${prog}_why | |
152 | ||
153 | echo "$prog ($why)" | |
154 | done | |
155 | ||
156 | cat <<EOF | |
157 | ||
158 | If you think you have the required tools, please add them to your PATH | |
159 | and re-run this script. | |
160 | ||
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. | |
165 | ||
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: | |
169 | ||
170 | ftp://ftp.gnu.org/gnu/PACKAGE/ | |
171 | ||
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. | |
176 | ||
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 | |
179 | ||
f6ca84c0 | 180 | autoreconf -i -I m4 |
66b87493 GM |
181 | |
182 | instead of this script. | |
183 | ||
184 | If all else fails, you can try using the pre-built versions of the | |
185 | generated files by doing: | |
186 | ||
34cb1cc6 | 187 | ./autogen/copy_autogen |
66b87493 GM |
188 | |
189 | This is not recommended - see the comments in \`copy_autogen'. | |
190 | ||
191 | Please report any problems with this script to bug-gnu-emacs@gnu.org . | |
192 | EOF | |
193 | ||
194 | exit 1 | |
195 | fi | |
196 | ||
197 | echo "Your system has the required tools, running autoreconf..." | |
198 | ||
199 | ||
200 | ## Let autoreconf figure out what, if anything, needs doing. | |
f6ca84c0 | 201 | autoreconf -i -I m4 || exit $? |
66b87493 GM |
202 | |
203 | echo "You can now run \`./configure'." | |
204 | ||
205 | exit 0 | |
206 | ||
207 | ### autogen.sh ends here |