1 # Copyright (C) 2008 Google Inc.
3 # This file is free software; you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
14 AC_INIT(android-tools,1.0)
17 AC_CONFIG_FILES([Makefile])
21 # We only allow the following 3 targets:
22 # 1. arm-android-eabi (primary target)
23 # 2. arm-eabi (to be phased out.)
24 # 3. arm-newlib-eabi (for gcc testing)
25 # 4.i[3456]86-*-linux-gnu, x86-*-linux-gnu (for x86 targets)
29 arm-android-eabi | arm-unknown-eabi)
31 GDB_TARGET=arm-elf-linux
36 i[[3456]]86-*-linux-gnu | x86_64-*-linux-gnu)
40 AC_MSG_ERROR(Unsupported target $target.);
42 AC_SUBST(BUILD_ANDROID_GCC)
46 # TOPLEVEL_CONFIGURE_ARGUMENTS lifted from top-level configure.ac in gcc.
48 # Export original configure arguments for use by sub-configures.
49 # Quote arguments with shell meta charatcers.
50 TOPLEVEL_CONFIGURE_ARGUMENTS=
51 set -- "$progname" "$@"
55 *" "*|*" "*|*[[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\']]*)
56 ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
57 # if the argument is of the form -foo=baz, quote the baz part only
58 ac_arg=`echo "'$ac_arg'" | sed "s/^'\([[-a-zA-Z0-9]]*=\)/\\1'/"` ;;
61 # Add the quoted argument to the list.
62 TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS $ac_arg"
64 if test "$silent" = yes; then
65 TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS --silent"
67 # Remove the initial space we just introduced and, as these will be
68 # expanded by make, quote '$'.
69 TOPLEVEL_CONFIGURE_ARGUMENTS=`echo "x$TOPLEVEL_CONFIGURE_ARGUMENTS" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
70 AC_SUBST(TOPLEVEL_CONFIGURE_ARGUMENTS)
72 # Base args. Strip norecursion, cache-file, srcdir, host, build,
73 # target, nonopt, and variable assignments. These are the ones we
74 # might not want to pass down to subconfigures. Also strip
75 # program-prefix, program-suffix, and program-transform-name, so that
76 # we can pass down a consistent program-transform-name.
80 eval "set -- $ac_configure_args"
83 if test X"$skip_next" = X"yes"; then
87 if test X"$keep_next" = X"yes"; then
90 ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
92 baseargs="$baseargs '$ac_arg'"
97 # Handle separated arguments. Based on the logic generated by
100 *=* | --config-cache | -C | -disable-* | --disable-* \
101 | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
102 | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
103 | -with-* | --with-* | -without-* | --without-* | --x)
131 -program-transform-name* )
132 skip_next=$separate_arg
139 ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
141 baseargs="$baseargs '$ac_arg'"
142 keep_next=$separate_arg
145 # Either a variable assignment, or a nonopt (triplet). Don't
146 # pass it down; let the Makefile handle this.
151 # Remove the initial space we just introduced and, as these will be
152 # expanded by make, quote '$'.
153 baseargs=`echo "x$baseargs" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
155 # Add in --program-transform-name, after --program-prefix and
156 # --program-suffix have been applied to it. Autoconf has already
157 # doubled dollar signs and backslashes in program_transform_name; we want
158 # the backslashes un-doubled, and then the entire thing wrapped in single
159 # quotes, because this will be expanded first by make and then by the shell.
160 # Also, because we want to override the logic in subdir configure scripts to
161 # choose program_transform_name, replace any s,x,x, with s,y,y,.
162 sed -e "s,\\\\\\\\,\\\\,g; s,','\\\\'',g; s/s,x,x,/s,y,y,/" <<EOF_SED > conftestsed.out
163 ${program_transform_name}
165 gcc_transform_name=`cat conftestsed.out`
166 rm -f conftestsed.out
167 baseargs="$baseargs --program-transform-name='${gcc_transform_name}'"
168 if test "$silent" = yes; then
169 baseargs="$baseargs --silent"
175 # Check for Canadian cross, which is not supported.
177 AC_MSG_CHECKING([for Canadian cross])
178 if test $build != $host ; then
179 AC_MSG_ERROR(Canadian cross build not supported.)
183 # package to source path
185 /* | [A-Za-z]:*) package_to_srcdir=$srcdir ;;
186 *) package_to_srcdir=../$srcdir ;;
188 AC_SUBST(package_to_srcdir)
190 # Specify tool component versions
193 # macro to check that we have a package. A package x exists if any one
194 # of the following exists (x is in the format of "tool-version"):
199 m4_pattern_allow([^AC_MSG_ERROR$])
200 AC_DEFUN([ANDROID_CHECK_PACKAGE],
201 [x=$1; tool=${x%-*}; \
202 if test ! -d $srcdir/../$tool/$1 ; then
203 if test -f $srcdir/../$tool/$1.tar ; then
204 mkdir -p temp-src && tar -C temp-src -xf $srcdir/../$tool/$1.tar
205 elif test -f $srcdir/../$tool/$1.tar.gz ; then
206 mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/$1.tar.gz
207 elif test -f $srcdir/../$tool/$1.tgz ; then
208 mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/$1.tgz
209 elif test -f $srcdir/../$tool/$1.tar.bz2 ; then
210 mkdir -p temp-src && tar -C temp-src -xjf $srcdir/../$tool/$1.tar.bz2
212 AC_MSG_ERROR('package $1 does not exist.')
216 # binutils version (default is 2.17)
217 AC_MSG_CHECKING([target binutils version to build])
218 AC_ARG_WITH([binutils-version],
219 [ --with-binutils-version=VERSION
220 use binutils-VERSION (default is 2.17)],
221 [if test x"$withval" != x ; then
222 BINUTILS_VERSION="$withval"
224 [BINUTILS_VERSION="2.17"])
225 AC_MSG_RESULT($BINUTILS_VERSION)
226 AC_SUBST(BINUTILS_VERSION)
227 ANDROID_CHECK_PACKAGE(binutils-${BINUTILS_VERSION})
229 # gcc version (default is 4.2.1)
230 AC_MSG_CHECKING([target gcc version to build])
231 AC_ARG_WITH([gcc-version],
232 [ --with-gcc-version=VERSION
233 use gcc-VERSION (default is 4.2.1)],
234 [if test x"$withval" != x ; then
235 GCC_VERSION="$withval"
237 [GCC_VERSION="4.2.1"])
238 AC_MSG_RESULT($GCC_VERSION)
239 AC_SUBST(GCC_VERSION)
240 ANDROID_CHECK_PACKAGE(gcc-${GCC_VERSION})
242 # figure out if we need to build gmp and mpfr for gcc 4.3.0+
243 gcc_version_file="${srcdir}/gcc-${GCC_VERSION}/gcc/BASE-VER"
244 if test -f "${gcc_version_file}"; then
245 GCC_MAJOR=`head -n 1 $gcc_version_file | sed -e "s/[[^0-9]].*//"`
246 GCC_MINOR=`head -n 1 $gcc_version_file | \
247 sed -e "s/^[[0-9]]*\.//" -e "s/[[^0-9]].*//"`
248 if test "$GCC_MAJOR" -gt 4 -o \
249 \( "$GCC_MAJOR" -eq 4 -a "$GCC_MINOR" -ge 3 \) ; then
250 GCC_MIN_VERSION_4_3_0="yes"
252 GCC_MIN_VERSION_4_3_0="no"
254 if test "$GCC_MAJOR" -gt 4 -o \
255 \( "$GCC_MAJOR" -eq 4 -a "$GCC_MINOR" -ge 5 \) ; then
256 GCC_MIN_VERSION_4_5_0="yes"
258 GCC_MIN_VERSION_4_5_0="no"
261 # No version file, assume it is trunk
262 GCC_MIN_VERSION_4_3_0="yes"
263 GCC_MIN_VERSION_4_5_0="yes"
265 AC_SUBST(GCC_MIN_VERSION_4_3_0)
266 AC_SUBST(GCC_MIN_VERSION_4_5_0)
268 # newlib version (default is 1.16.0)
269 # newlib is only used for arm-newlib-eabi for testing
270 if test x$target == xarm-newlib-elf ; then
271 AC_MSG_CHECKING([target newlib version to build])
272 AC_ARG_WITH([newlib-version],
273 [ --with-newlib-version=VERSION
274 use newlib-VERSION (default is 1.16.0)],
275 [if test x"$withval" != x ; then
276 NEWLIB_VERSION="$withval"
278 [NEWLIB_VERSION="1.16.0"])
279 AC_MSG_RESULT($NEWLIB_VERSION)
280 AC_SUBST(NEWLIB_VERSION)
281 ANDROID_CHECK_PACKAGE(newlib-${NEWLIB_VERSION})
284 if test "$GCC_MIN_VERSION_4_3_0" == "yes"; then
285 # gmp version (default is 4.2.2)
286 # gmp is only used for gcc version higher than 4.3.0
287 AC_MSG_CHECKING([gmp version])
288 AC_ARG_WITH([gmp-version],
289 [ --with-gmp-version=VERSION
290 use gmp-VERSION (default is 4.2.2)],
291 [if test x"$withval" != x ; then
292 GMP_VERSION="$withval"
294 [GMP_VERSION="4.2.2"])
295 AC_MSG_RESULT($GMP_VERSION)
296 ANDROID_CHECK_PACKAGE(gmp-${GMP_VERSION})
298 # mpfr version (default is 2.3.0)
299 # mpfr is only used for gcc version higher than 4.3.0
300 AC_MSG_CHECKING([mpfr version])
301 AC_ARG_WITH([mpfr-version],
302 [ --with-mpfr-version=VERSION
303 use mpfr-VERSION (default is 2.3.0)],
304 [if test x"$withval" != x ; then
305 MPFR_VERSION="$withval"
307 [MPFR_VERSION="2.3.0"])
308 AC_MSG_RESULT($MPFR_VERSION)
309 ANDROID_CHECK_PACKAGE(mpfr-${MPFR_VERSION})
312 AC_SUBST(GMP_VERSION)
313 AC_SUBST(MPFR_VERSION)
315 if test "$GCC_MIN_VERSION_4_5_0" == "yes"; then
316 # mpc version (default is 0.8.1)
317 # mpc is only used for gcc version higher than 4.5.0
318 AC_MSG_CHECKING([mpc version])
319 AC_ARG_WITH([mpc-version],
320 [ --with-mpc-version=VERSION
321 use mpc-VERSION (default is 0.8.1)],
322 [if test x"$withval" != x; then
323 MPC_VERSION="$withval"
325 [MPC_VERSION="0.8.1"])
326 AC_MSG_RESULT($MPC_VERSION)
327 ANDROID_CHECK_PACKAGE(mpc-${MPC_VERSION})
329 AC_SUBST(MPC_VERSION)
331 # gdb version (default is 6.6)
332 AC_MSG_CHECKING([target gdb version to build])
333 AC_ARG_WITH([gdb-version],
334 [ --with-gdb-version=VERSION
335 use gdb-VERSION (default is 6.6)],
336 [if test x"$withval" != x ; then
337 GDB_VERSION="$withval"
340 AC_MSG_RESULT($GDB_VERSION)
341 AC_SUBST(GDB_VERSION)
342 ANDROID_CHECK_PACKAGE(gdb-${GDB_VERSION})