2 ### autogen.sh - tool to help build Emacs from a bzr checkout
4 ## Copyright (C) 2011-2014 Free Software Foundation, Inc.
6 ## Author: Glenn Morris <rgm@gnu.org>
7 ## Maintainer: emacs-devel@gnu.org
9 ## This file is part of GNU Emacs.
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.
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.
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/>.
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.
29 ## For more details, see the file INSTALL.REPO.
34 ## Note that we respect the values of AUTOCONF etc, like autoreconf does.
35 progs
="autoconf automake pkg-config"
37 ## Minimum versions we need:
38 autoconf_min
=`sed -n 's/^ *AC_PREREQ(\([0-9\.]*\)).*/\1/p' configure.ac`
40 ## This will need improving if more options are ever added to the
41 ## AM_INIT_AUTOMAKE call.
42 automake_min
=`sed -n 's/^ *AM_INIT_AUTOMAKE(\([0-9\.]*\)).*/\1/p' configure.ac`
44 pkg_config_min
=`sed -n 's/^ *PKG_PROG_PKG_CONFIG(\([0-9\.]*\)).*/\1/p' configure.ac`
45 # Building from the repository needs pkg-config 0.26 or later; see Bug#17438.
46 case $pkg_config_min in
47 0.
[0-9] |
0.
[0-9].
* |
0.1[0-9] |
0.1[0-9].
* |
0.2[0-5] |
0.2[0-5].
* )
51 ## $1 = program, eg "autoconf".
52 ## Echo the version string, eg "2.59".
53 ## FIXME does not handle things like "1.4a", but AFAIK those are
54 ## all old versions, so it is OK to fail there.
55 ## Also note that we do not handle micro versions.
58 ## Remove eg "./autogen.sh: line 50: autoconf: command not found".
59 $1 --version 2>&1 |
sed -e '/not found/d' -e 's/.* //' -n -e '1 s/\([0-9][0-9\.]*\).*/\1/p'
62 ## $1 = version string, eg "2.59"
63 ## Echo the major version, eg "2".
66 echo $1 |
sed -e 's/\([0-9][0-9]*\)\..*/\1/'
69 ## $1 = version string, eg "2.59"
70 ## Echo the minor version, eg "59".
73 echo $1 |
sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/'
77 ## $2 = minimum version.
78 ## Return 0 if program is present with version >= minimum version.
79 ## Return 1 if program is missing.
80 ## Return 2 if program is present but too old.
81 ## Return 3 for unexpected error (eg failed to parse version).
84 ## Respect eg $AUTOMAKE if it is set, like autoreconf does.
85 uprog
=`echo $1 | sed -e 's/-/_/g' -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
89 [ x
"$uprog" = x
] && uprog
=$1
91 have_version
=`get_version $uprog`
93 [ x
"$have_version" = x
] && return 1
95 have_maj
=`major_version $have_version`
96 need_maj
=`major_version $2`
98 [ x
"$have_maj" != x
] && [ x
"$need_maj" != x
] ||
return 3
100 [ $have_maj -gt $need_maj ] && return 0
101 [ $have_maj -lt $need_maj ] && return 2
103 have_min
=`minor_version $have_version`
104 need_min
=`minor_version $2`
106 [ x
"$have_min" != x
] && [ x
"$need_min" != x
] ||
return 3
108 [ $have_min -ge $need_min ] && return 0
114 Checking whether you have the necessary tools...
115 (Read INSTALL.REPO for more details on building Emacs)
121 for prog
in $progs; do
123 sprog
=`echo "$prog" | sed 's/-/_/g'`
125 eval min
=\$
${sprog}_min
127 echo "Checking for $prog (need at least version $min)..."
129 check_version
$prog $min
137 *) stat
="unable to check" ;;
142 if [ $retval -ne 0 ]; then
143 missing
="$missing $prog"
144 eval ${sprog}_why
=\""$stat"\"
150 if [ x
"$missing" != x
]; then
154 Building Emacs from Bzr requires the following specialized programs:
157 for prog
in $progs; do
158 sprog
=`echo "$prog" | sed 's/-/_/g'`
160 eval min
=\$
${sprog}_min
162 echo "$prog (minimum version $min)"
168 Your system seems to be missing the following tool(s):
171 for prog
in $missing; do
172 sprog
=`echo "$prog" | sed 's/-/_/g'`
174 eval why
=\$
${sprog}_why
181 If you think you have the required tools, please add them to your PATH
182 and re-run this script.
184 Otherwise, please try installing them.
185 On systems using rpm and yum, try: "yum install PACKAGE"
186 On systems using dpkg and apt, try: "apt-get install PACKAGE"
187 Then re-run this script.
189 If you do not have permission to do this, or if the version provided
190 by your system is too old, it is normally straightforward to build
191 these packages from source. You can find the sources at:
193 ftp://ftp.gnu.org/gnu/PACKAGE/
195 Download the package (make sure you get at least the minimum version
196 listed above), extract it using tar, then run configure, make,
197 make install. Add the installation directory to your PATH and re-run
200 If you know that the required versions are in your PATH, but this
201 script has made an error, then you can simply run
205 instead of this script.
207 Please report any problems with this script to bug-gnu-emacs@gnu.org .
213 # If automake is installed in a nonstandard location, find the standard
214 # location if possible and append it to ACLOCAL_PATH. That way, it will
215 # find the pkg.m4 that is installed in the standard location.
216 echo "Checking for pkg.m4..."
219 ac_dir
=`aclocal --print-ac-dir` ||
{
221 There was a problem running 'aclocal --print-ac-dir'.
222 The aclocal program is part of automake.
223 Please check your automake installation.
229 test -n "$ac_dir" && test -r "$ac_dir/pkg.m4" ||
{
231 # Maybe ACLOCAL_PATH is already set-up.
232 if test -n "$ACLOCAL_PATH"; then
235 for dir
in $ACLOCAL_PATH; do
236 if test -r "$dir/pkg.m4"; then
237 AUTORECONF_ENV
="ACLOCAL_PATH='$ACLOCAL_PATH'"
245 if test -z "$AUTORECONF_ENV"; then
248 before_first_aclocal
=true
250 if test -x "$dir/aclocal"; then
251 if $before_first_aclocal; then
252 before_first_aclocal
=false
253 elif ac_dir
=`"$dir/aclocal" --print-ac-dir` && test -r "$ac_dir/pkg.m4"
255 case $ACLOCAL_PATH in
256 '') ACLOCAL_PATH
=$ac_dir;;
257 ?
*) ACLOCAL_PATH
=$ACLOCAL_PATH:$ac_dir;;
260 AUTORECONF_ENV
="ACLOCAL_PATH='$ACLOCAL_PATH'"
269 ## OK, maybe pkg-config is in a weird place (eg on hydra).
270 if test -z "$AUTORECONF_ENV"; then
274 if test -x "$dir/pkg-config"; then
275 ac_dir
=`echo "$dir" | sed 's|bin$|share/aclocal|'`
276 if test -r "$ac_dir/pkg.m4"; then
277 case $ACLOCAL_PATH in
278 '') ACLOCAL_PATH
=$ac_dir;;
279 ?
*) ACLOCAL_PATH
=$ACLOCAL_PATH:$ac_dir;;
282 AUTORECONF_ENV
="ACLOCAL_PATH='$ACLOCAL_PATH'"
291 if test -z "$AUTORECONF_ENV"; then
293 The version of aclocal that you are using cannot find the pkg.m4 file that
294 pkg-config provides. If it is installed in some unusual directory /FOO/BAR,
295 set ACLOCAL_PATH='/FOO/BAR' in the environment and run this script again.
302 echo 'Your system has the required tools.'
303 echo "Running \"$AUTORECONF_ENV${env_space}autoreconf -fi -I m4\" ..."
306 ## Let autoreconf figure out what, if anything, needs doing.
307 ## Use autoreconf's -f option in case autoreconf itself has changed.
308 autoreconf
-fi -I m4 ||
exit $?
310 ## Create a timestamp, so that './autogen.sh; make' doesn't
311 ## cause 'make' to needlessly run 'autoheader'.
312 echo timestamp
> src
/stamp-h.
in ||
exit
314 echo "You can now run \"./configure$env_space$AUTORECONF_ENV\"."
318 ### autogen.sh ends here