* automated/Makefile.in (setwins): Include the 'data' subdirectory.
[emacs.git] / autogen.sh
blobe7c28c16d94e15a3a811fdb1e3d49ceeef2c1bb5
1 #!/bin/sh
2 ### autogen.sh - tool to help build Emacs from a bzr checkout
4 ## Copyright (C) 2011-2013 Free Software Foundation, Inc.
6 ## Author: Glenn Morris <rgm@gnu.org>
8 ## This file is part of GNU Emacs.
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.
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.
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/>.
23 ### Commentary:
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.
30 ### Code:
32 ## Tools we need:
33 ## Note that we respect the values of AUTOCONF etc, like autoreconf does.
34 progs="autoconf automake"
36 ## Minimum versions we need:
37 autoconf_min=`sed -n 's/^ *AC_PREREQ(\([0-9\.]*\)).*/\1/p' configure.ac`
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`
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 ()
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'
55 ## $1 = version string, eg "2.59"
56 ## Echo the major version, eg "2".
57 major_version ()
59 echo $1 | sed -e 's/\([0-9][0-9]*\)\..*/\1/'
62 ## $1 = version string, eg "2.59"
63 ## Echo the minor version, eg "59".
64 minor_version ()
66 echo $1 | sed -e 's/[0-9][0-9]*\.\([0-9][0-9]*\).*/\1/'
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 ()
77 ## Respect eg $AUTOMAKE if it is set, like autoreconf does.
78 uprog=`echo $1 | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
80 eval uprog=\$${uprog}
82 [ x"$uprog" = x ] && uprog=$1
84 have_version=`get_version $uprog`
86 [ x"$have_version" = x ] && return 1
88 have_maj=`major_version $have_version`
89 need_maj=`major_version $2`
91 [ x"$have_maj" != x ] && [ x"$need_maj" != x ] || return 3
93 [ $have_maj -gt $need_maj ] && return 0
94 [ $have_maj -lt $need_maj ] && return 2
96 have_min=`minor_version $have_version`
97 need_min=`minor_version $2`
99 [ x"$have_min" != x ] && [ x"$need_min" != x ] || return 3
101 [ $have_min -ge $need_min ] && return 0
102 return 2
106 cat <<EOF
107 Checking whether you have the necessary tools...
108 (Read INSTALL.BZR for more details on building Emacs)
112 missing=
114 for prog in $progs; do
116 eval min=\$${prog}_min
118 echo "Checking for $prog (need at least version $min)..."
120 check_version $prog $min
122 retval=$?
124 case $retval in
125 0) stat="ok" ;;
126 1) stat="missing" ;;
127 2) stat="too old" ;;
128 *) stat="unable to check" ;;
129 esac
131 echo $stat
133 if [ $retval -ne 0 ]; then
134 missing="$missing $prog"
135 eval ${prog}_why=\""$stat"\"
138 done
141 if [ x"$missing" != x ]; then
143 cat <<EOF
145 Building Emacs from Bzr requires the following specialized programs:
148 for prog in $progs; do
149 eval min=\$${prog}_min
151 echo "$prog (minimum version $min)"
152 done
155 cat <<EOF
157 Your system seems to be missing the following tool(s):
160 for prog in $missing; do
161 eval why=\$${prog}_why
163 echo "$prog ($why)"
164 done
166 cat <<EOF
168 If you think you have the required tools, please add them to your PATH
169 and re-run this script.
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.
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:
180 ftp://ftp.gnu.org/gnu/PACKAGE/
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.
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
190 autoreconf -i -I m4
192 instead of this script.
194 If all else fails, you can try using the pre-built versions of the
195 generated files by doing:
197 ./autogen/copy_autogen
199 This is not recommended - see the comments in \`copy_autogen'.
201 Please report any problems with this script to bug-gnu-emacs@gnu.org .
204 exit 1
207 echo "Your system has the required tools, running autoreconf..."
210 ## Let autoreconf figure out what, if anything, needs doing.
211 autoreconf -i -I m4 || exit $?
213 ## Create a timestamp, so that './autogen.sh; make' doesn't
214 ## cause 'make' to needlessly run 'autoheader'.
215 echo timestamp > src/stamp-h.in || exit
217 echo "You can now run \`./configure'."
219 exit 0
221 ### autogen.sh ends here