blob: d0d8ee3db1f2f922c766efa19d8cb0e298e47e75 [file] [log] [blame]
# Copyright (C) 2008 Google Inc.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
AC_INIT(android-tools,1.0)
AC_PREREQ(2.59)
AC_CONFIG_FILES([Makefile])
AC_CANONICAL_SYSTEM
# We only allow the following 3 targets:
# 1. arm-android-eabi (primary target)
# 2. arm-eabi (to be phased out.)
# 3. arm-newlib-eabi (for gcc testing)
# 4.i[3456]86-*-linux-gnu, x86-*-linux-gnu (for x86 targets)
GDB_TARGET=$target
case $target in
arm-android-eabi | arm-unknown-eabi)
BUILD_ANDROID_GCC=yes
GDB_TARGET=arm-elf-linux
;;
arm-newlib-elf)
BUILD_ANDROID_GCC=no
;;
i[[3456]]86-*-linux-gnu | x86_64-*-linux-gnu)
BUILD_ANDROID_GCC=yes
;;
*)
AC_MSG_ERROR(Unsupported target $target.);
esac
AC_SUBST(BUILD_ANDROID_GCC)
AC_SUBST(GDB_TARGET)
AC_ARG_PROGRAM
# TOPLEVEL_CONFIGURE_ARGUMENTS lifted from top-level configure.ac in gcc.
# Export original configure arguments for use by sub-configures.
# Quote arguments with shell meta charatcers.
TOPLEVEL_CONFIGURE_ARGUMENTS=
set -- "$progname" "$@"
for ac_arg
do
case "$ac_arg" in
*" "*|*" "*|*[[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\']]*)
ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
# if the argument is of the form -foo=baz, quote the baz part only
ac_arg=`echo "'$ac_arg'" | sed "s/^'\([[-a-zA-Z0-9]]*=\)/\\1'/"` ;;
*) ;;
esac
# Add the quoted argument to the list.
TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS $ac_arg"
done
if test "$silent" = yes; then
TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS --silent"
fi
# Remove the initial space we just introduced and, as these will be
# expanded by make, quote '$'.
TOPLEVEL_CONFIGURE_ARGUMENTS=`echo "x$TOPLEVEL_CONFIGURE_ARGUMENTS" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
AC_SUBST(TOPLEVEL_CONFIGURE_ARGUMENTS)
# Base args. Strip norecursion, cache-file, srcdir, host, build,
# target, nonopt, and variable assignments. These are the ones we
# might not want to pass down to subconfigures. Also strip
# program-prefix, program-suffix, and program-transform-name, so that
# we can pass down a consistent program-transform-name.
baseargs=
keep_next=no
skip_next=no
eval "set -- $ac_configure_args"
for ac_arg
do
if test X"$skip_next" = X"yes"; then
skip_next=no
continue
fi
if test X"$keep_next" = X"yes"; then
case $ac_arg in
*\'*)
ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
baseargs="$baseargs '$ac_arg'"
keep_next=no
continue
fi
# Handle separated arguments. Based on the logic generated by
# autoconf 2.59.
case $ac_arg in
*=* | --config-cache | -C | -disable-* | --disable-* \
| -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
| -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
| -with-* | --with-* | -without-* | --without-* | --x)
separate_arg=no
;;
-*)
separate_arg=yes
;;
*)
separate_arg=no
;;
esac
case "$ac_arg" in
--no*)
continue
;;
--c* | \
--sr* | \
--ho* | \
--bu* | \
--t* | \
--program-* | \
-cache_file* | \
-srcdir* | \
-host* | \
-build* | \
-target* | \
-program-prefix* | \
-program-suffix* | \
-program-transform-name* )
skip_next=$separate_arg
continue
;;
-*)
# An option. Add it.
case $ac_arg in
*\'*)
ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
esac
baseargs="$baseargs '$ac_arg'"
keep_next=$separate_arg
;;
*)
# Either a variable assignment, or a nonopt (triplet). Don't
# pass it down; let the Makefile handle this.
continue
;;
esac
done
# Remove the initial space we just introduced and, as these will be
# expanded by make, quote '$'.
baseargs=`echo "x$baseargs" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
# Add in --program-transform-name, after --program-prefix and
# --program-suffix have been applied to it. Autoconf has already
# doubled dollar signs and backslashes in program_transform_name; we want
# the backslashes un-doubled, and then the entire thing wrapped in single
# quotes, because this will be expanded first by make and then by the shell.
# Also, because we want to override the logic in subdir configure scripts to
# choose program_transform_name, replace any s,x,x, with s,y,y,.
sed -e "s,\\\\\\\\,\\\\,g; s,','\\\\'',g; s/s,x,x,/s,y,y,/" <<EOF_SED > conftestsed.out
${program_transform_name}
EOF_SED
gcc_transform_name=`cat conftestsed.out`
rm -f conftestsed.out
baseargs="$baseargs --program-transform-name='${gcc_transform_name}'"
if test "$silent" = yes; then
baseargs="$baseargs --silent"
fi
AC_SUBST(baseargs)
#
# Check for Canadian cross, which is not supported.
#
AC_MSG_CHECKING([for Canadian cross])
if test $build != $host ; then
AC_MSG_ERROR(Canadian cross build not supported.)
fi
AC_MSG_RESULT(no)
# package to source path
case $srcdir in
/* | [A-Za-z]:*) package_to_srcdir=$srcdir ;;
*) package_to_srcdir=../$srcdir ;;
esac
AC_SUBST(package_to_srcdir)
#
# Specify tool component versions
#
# macro to check that we have a package. A package x exists if any one
# of the following exists (x is in the format of "tool-version"):
# 1. tool/x
# 2. tool/x.tar.gz
# 3. tool/x.tgz
# 4. tool/x.tar.bz2
m4_pattern_allow([^AC_MSG_ERROR$])
AC_DEFUN([ANDROID_CHECK_PACKAGE],
[x=$1; tool=${x%-*}; \
if test ! -d $srcdir/../$tool/$1 ; then
if test -f $srcdir/../$tool/$1.tar ; then
mkdir -p temp-src && tar -C temp-src -xf $srcdir/../$tool/$1.tar
elif test -f $srcdir/../$tool/$1.tar.gz ; then
mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/$1.tar.gz
elif test -f $srcdir/../$tool/$1.tgz ; then
mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/$1.tgz
elif test -f $srcdir/../$tool/$1.tar.bz2 ; then
mkdir -p temp-src && tar -C temp-src -xjf $srcdir/../$tool/$1.tar.bz2
else
AC_MSG_ERROR('package $1 does not exist.')
fi
fi ])
# binutils version (default is 2.17)
AC_MSG_CHECKING([target binutils version to build])
AC_ARG_WITH([binutils-version],
[ --with-binutils-version=VERSION
use binutils-VERSION (default is 2.17)],
[if test x"$withval" != x ; then
BINUTILS_VERSION="$withval"
fi],
[BINUTILS_VERSION="2.17"])
AC_MSG_RESULT($BINUTILS_VERSION)
AC_SUBST(BINUTILS_VERSION)
ANDROID_CHECK_PACKAGE(binutils-${BINUTILS_VERSION})
# gcc version (default is 4.2.1)
AC_MSG_CHECKING([target gcc version to build])
AC_ARG_WITH([gcc-version],
[ --with-gcc-version=VERSION
use gcc-VERSION (default is 4.2.1)],
[if test x"$withval" != x ; then
GCC_VERSION="$withval"
fi],
[GCC_VERSION="4.2.1"])
AC_MSG_RESULT($GCC_VERSION)
AC_SUBST(GCC_VERSION)
ANDROID_CHECK_PACKAGE(gcc-${GCC_VERSION})
# figure out if we need to build gmp and mpfr for gcc 4.3.0+
gcc_version_file="${srcdir}/gcc-${GCC_VERSION}/gcc/BASE-VER"
if test -f "${gcc_version_file}"; then
GCC_MAJOR=`head -n 1 $gcc_version_file | sed -e "s/[[^0-9]].*//"`
GCC_MINOR=`head -n 1 $gcc_version_file | \
sed -e "s/^[[0-9]]*\.//" -e "s/[[^0-9]].*//"`
if test "$GCC_MAJOR" -gt 4 -o \
\( "$GCC_MAJOR" -eq 4 -a "$GCC_MINOR" -ge 3 \) ; then
GCC_MIN_VERSION_4_3_0="yes"
else
GCC_MIN_VERSION_4_3_0="no"
fi
else
# No version file, assume it is trunk
GCC_MIN_VERSION_4_3_0="yes"
fi
AC_SUBST(GCC_MIN_VERSION_4_3_0)
# newlib version (default is 1.16.0)
# newlib is only used for arm-newlib-eabi for testing
if test x$target == xarm-newlib-elf ; then
AC_MSG_CHECKING([target newlib version to build])
AC_ARG_WITH([newlib-version],
[ --with-newlib-version=VERSION
use newlib-VERSION (default is 1.16.0)],
[if test x"$withval" != x ; then
NEWLIB_VERSION="$withval"
fi],
[NEWLIB_VERSION="1.16.0"])
AC_MSG_RESULT($NEWLIB_VERSION)
AC_SUBST(NEWLIB_VERSION)
ANDROID_CHECK_PACKAGE(newlib-${NEWLIB_VERSION})
fi
if test "$GCC_MIN_VERSION_4_3_0" == "yes"; then
# gmp version (default is 4.2.2)
# gmp is only used for gcc version higher than 4.3.0
AC_MSG_CHECKING([gmp version])
AC_ARG_WITH([gmp-version],
[ --with-gmp-version=VERSION
use gmp-VERSION (default is 4.2.2)],
[if test x"$withval" != x ; then
GMP_VERSION="$withval"
fi],
[GMP_VERSION="4.2.2"])
AC_MSG_RESULT($GMP_VERSION)
ANDROID_CHECK_PACKAGE(gmp-${GMP_VERSION})
# mpfr version (default is 2.3.0)
# mpfr is only used for gcc version higher than 4.3.0
AC_MSG_CHECKING([mpfr version])
AC_ARG_WITH([mpfr-version],
[ --with-mpfr-version=VERSION
use mpfr-VERSION (default is 2.3.0)],
[if test x"$withval" != x ; then
MPFR_VERSION="$withval"
fi],
[MPFR_VERSION="2.3.0"])
AC_MSG_RESULT($MPFR_VERSION)
ANDROID_CHECK_PACKAGE(mpfr-${MPFR_VERSION})
fi
AC_SUBST(GMP_VERSION)
AC_SUBST(MPFR_VERSION)
# gdb version (default is 6.6)
AC_MSG_CHECKING([target gdb version to build])
AC_ARG_WITH([gdb-version],
[ --with-gdb-version=VERSION
use gdb-VERSION (default is 6.6)],
[if test x"$withval" != x ; then
GDB_VERSION="$withval"
fi],
[GDB_VERSION="6.6"])
AC_MSG_RESULT($GDB_VERSION)
AC_SUBST(GDB_VERSION)
ANDROID_CHECK_PACKAGE(gdb-${GDB_VERSION})
AC_OUTPUT