1 # Copyright (C) 2008, 2010 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,2.0)
17 AC_CONFIG_FILES([Makefile])
21 # We only allow the following 3 targets:
22 # 1. arm-linux-androideabi (primary target)
23 # 2. arm-eabi (for Android kernel)
24 # 3. arm-newlib-eabi (for gcc testing)
25 # 4.i[3456]86-*-linux-gnu, x86-*-linux-gnu (for x86 targets)
29 arm-unknown-linux-androideabi | 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 TOPLEVEL_NO_GOLD_CONFIGURE_ARGUMENTS=
53 set -- "$progname" "$@"
57 *" "*|*" "*|*[[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\']]*)
58 ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"`
59 # if the argument is of the form -foo=baz, quote the baz part only
60 ac_arg=`echo "'$ac_arg'" | sed "s/^'\([[-a-zA-Z0-9]]*=\)/\\1'/"` ;;
63 # Add the quoted argument to the list.
64 TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS $ac_arg"
66 if test "$silent" = yes; then
67 TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS --silent"
69 # Remove the initial space we just introduced and, as these will be
70 # expanded by make, quote '$'.
71 TOPLEVEL_CONFIGURE_ARGUMENTS=`echo "x$TOPLEVEL_CONFIGURE_ARGUMENTS" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
72 AC_SUBST(TOPLEVEL_CONFIGURE_ARGUMENTS)
74 # Base args. Strip norecursion, cache-file, srcdir, host, build,
75 # target, nonopt, and variable assignments. These are the ones we
76 # might not want to pass down to subconfigures. Also strip
77 # program-prefix, program-suffix, and program-transform-name, so that
78 # we can pass down a consistent program-transform-name.
82 eval "set -- $ac_configure_args"
85 if test X"$skip_next" = X"yes"; then
89 if test X"$keep_next" = X"yes"; then
92 ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
94 baseargs="$baseargs '$ac_arg'"
99 # Handle separated arguments. Based on the logic generated by
102 *=* | --config-cache | -C | -disable-* | --disable-* \
103 | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
104 | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
105 | -with-* | --with-* | -without-* | --without-* | --x)
133 -program-transform-name* )
134 skip_next=$separate_arg
141 ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
143 baseargs="$baseargs '$ac_arg'"
144 keep_next=$separate_arg
147 # Either a variable assignment, or a nonopt (triplet). Don't
148 # pass it down; let the Makefile handle this.
153 # Remove the initial space we just introduced and, as these will be
154 # expanded by make, quote '$'.
155 baseargs=`echo "x$baseargs" | sed -e 's/^x *//' -e 's,\\$,$$,g'`
157 # Add in --program-transform-name, after --program-prefix and
158 # --program-suffix have been applied to it. Autoconf has already
159 # doubled dollar signs and backslashes in program_transform_name; we want
160 # the backslashes un-doubled, and then the entire thing wrapped in single
161 # quotes, because this will be expanded first by make and then by the shell.
162 # Also, because we want to override the logic in subdir configure scripts to
163 # choose program_transform_name, replace any s,x,x, with s,y,y,.
164 sed -e "s,\\\\\\\\,\\\\,g; s,','\\\\'',g; s/s,x,x,/s,y,y,/" <<EOF_SED > conftestsed.out
165 ${program_transform_name}
167 gcc_transform_name=`cat conftestsed.out`
168 rm -f conftestsed.out
169 baseargs="$baseargs --program-transform-name='${gcc_transform_name}'"
170 if test "$silent" = yes; then
171 baseargs="$baseargs --silent"
176 # Strip --{enable|disable}-{gold|ld}* from baseargs. These are used for the
177 # gold binutils. Note that baseargs are quoted.
179 for ac_arg in $baseargs
182 \'--enable-gold\' | \'--enable-gold=*\' | \'--disable-gold\' | \
183 \'--enable-ld\' | \'--enable-ld=*\' | \'--disable-ld\' )
186 gold_baseargs="$gold_baseargs $ac_arg"
191 AC_SUBST(gold_baseargs)
193 # package to source path
195 /* | [A-Za-z]:*) package_to_srcdir=$srcdir ;;
196 *) package_to_srcdir=../$srcdir ;;
198 AC_SUBST(package_to_srcdir)
200 # Specify tool component versions
203 # macro to check that we have a package. A package x exists if any one
204 # of the following exists (x is in the format of "tool-version"):
209 m4_pattern_allow([^AC_MSG_ERROR$])
210 AC_DEFUN([ANDROID_CHECK_PACKAGE],
211 [x=$1; tool=$(echo "$x" | sed -e 's/-.*//'); \
212 if test ! -d $srcdir/../$tool/$1 ; then
213 if test -f $srcdir/../$tool/$1.tar ; then
214 mkdir -p temp-src && tar -C temp-src -xf $srcdir/../$tool/$1.tar
215 elif test -f $srcdir/../$tool/$1.tar.gz ; then
216 mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/$1.tar.gz
217 elif test -f $srcdir/../$tool/$1.tgz ; then
218 mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../$tool/$1.tgz
219 elif test -f $srcdir/../$tool/$1.tar.bz2 ; then
220 mkdir -p temp-src && tar -C temp-src -xjf $srcdir/../$tool/$1.tar.bz2
221 elif test -f $srcdir/../tarballs/$1.tar ; then
222 mkdir -p temp-src && tar -C temp-src -xf $srcdir/../tarballs/$1.tar
223 elif test -f $srcdir/../tarballs/$1.tar.gz ; then
224 mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../tarballs/$1.tar.gz
225 elif test -f $srcdir/../tarballs/$1.tgz ; then
226 mkdir -p temp-src && tar -C temp-src -xzf $srcdir/../tarballs/$1.tgz
227 elif test -f $srcdir/../tarballs/$1.tar.bz2 ; then
228 mkdir -p temp-src && tar -C temp-src -xjf $srcdir/../tarballs/$1.tar.bz2
230 AC_MSG_ERROR('package $1 does not exist.')
234 # binutils version (default is 2.17)
235 AC_MSG_CHECKING([target binutils version to build])
236 AC_ARG_WITH([binutils-version],
237 [ --with-binutils-version=VERSION
238 use binutils-VERSION (default is 2.17)],
239 [if test x"$withval" != x ; then
240 BINUTILS_VERSION="$withval"
242 [BINUTILS_VERSION="2.17"])
243 AC_MSG_RESULT($BINUTILS_VERSION)
244 AC_SUBST(BINUTILS_VERSION)
245 ANDROID_CHECK_PACKAGE(binutils-${BINUTILS_VERSION})
247 # gold binutils version (default is the same version as the main
249 GOLD_VERSION="$BINUTILS_VERSION"
250 AC_MSG_CHECKING([target gold binutils version to build])
251 AC_ARG_WITH([gold-version],
252 [ --with-gold-version=VERSION
253 use binutils-VERSION for gold (default is the main binutils version)],
254 [if test x"$withval" != x ; then
255 GOLD_VERSION="$withval"
257 AC_MSG_RESULT($GOLD_VERSION)
258 AC_SUBST(GOLD_VERSION)
260 # Skip check if we are using the main binutils for gold.
261 if test x"$GOLD_VERSION" != x"$BINUTILS_VERSION" ; then
262 ANDROID_CHECK_PACKAGE(binutils-${GOLD_VERSION})
265 # gcc version (default is 4.2.1)
266 AC_MSG_CHECKING([target gcc version to build])
267 AC_ARG_WITH([gcc-version],
268 [ --with-gcc-version=VERSION
269 use gcc-VERSION (default is 4.2.1)],
270 [if test x"$withval" != x ; then
271 GCC_VERSION="$withval"
273 [GCC_VERSION="4.2.1"])
274 AC_MSG_RESULT($GCC_VERSION)
275 AC_SUBST(GCC_VERSION)
276 ANDROID_CHECK_PACKAGE(gcc-${GCC_VERSION})
278 # figure out if we need to build gmp and mpfr for gcc 4.3.0+
279 gcc_version_file="${srcdir}/../gcc/gcc-${GCC_VERSION}/gcc/BASE-VER"
280 if test -f "${gcc_version_file}"; then
281 GCC_MAJOR=`head -n 1 $gcc_version_file | sed -e "s/[[^0-9]].*//"`
282 GCC_MINOR=`head -n 1 $gcc_version_file | \
283 sed -e "s/^[[0-9]]*\.//" -e "s/[[^0-9]].*//"`
284 if test "$GCC_MAJOR" -gt 4 -o \
285 \( "$GCC_MAJOR" -eq 4 -a "$GCC_MINOR" -ge 3 \) ; then
286 GCC_MIN_VERSION_4_3_0="yes"
288 GCC_MIN_VERSION_4_3_0="no"
290 if test "$GCC_MAJOR" -gt 4 -o \
291 \( "$GCC_MAJOR" -eq 4 -a "$GCC_MINOR" -ge 5 \) ; then
292 GCC_MIN_VERSION_4_5_0="yes"
294 GCC_MIN_VERSION_4_5_0="no"
297 # No version file, assume it is trunk
298 GCC_MIN_VERSION_4_3_0="yes"
299 GCC_MIN_VERSION_4_5_0="yes"
301 AC_SUBST(GCC_MIN_VERSION_4_3_0)
302 AC_SUBST(GCC_MIN_VERSION_4_5_0)
304 # newlib version (default is 1.16.0)
305 # newlib is only used for arm-newlib-eabi for testing
306 if test x$target == xarm-newlib-elf ; then
307 AC_MSG_CHECKING([target newlib version to build])
308 AC_ARG_WITH([newlib-version],
309 [ --with-newlib-version=VERSION
310 use newlib-VERSION (default is 1.16.0)],
311 [if test x"$withval" != x ; then
312 NEWLIB_VERSION="$withval"
314 [NEWLIB_VERSION="1.16.0"])
315 AC_MSG_RESULT($NEWLIB_VERSION)
316 AC_SUBST(NEWLIB_VERSION)
317 ANDROID_CHECK_PACKAGE(newlib-${NEWLIB_VERSION})
320 if test "$GCC_MIN_VERSION_4_3_0" == "yes"; then
321 # gmp version (default is 4.2.2)
322 # gmp is only used for gcc version higher than 4.3.0
323 AC_MSG_CHECKING([gmp version])
324 AC_ARG_WITH([gmp-version],
325 [ --with-gmp-version=VERSION
326 use gmp-VERSION (default is 4.2.2)],
327 [if test x"$withval" != x ; then
328 GMP_VERSION="$withval"
330 [GMP_VERSION="4.2.2"])
331 AC_MSG_RESULT($GMP_VERSION)
332 ANDROID_CHECK_PACKAGE(gmp-${GMP_VERSION})
334 # mpfr version (default is 2.3.0)
335 # mpfr is only used for gcc version higher than 4.3.0
336 AC_MSG_CHECKING([mpfr version])
337 AC_ARG_WITH([mpfr-version],
338 [ --with-mpfr-version=VERSION
339 use mpfr-VERSION (default is 2.3.0)],
340 [if test x"$withval" != x ; then
341 MPFR_VERSION="$withval"
343 [MPFR_VERSION="2.3.0"])
344 AC_MSG_RESULT($MPFR_VERSION)
345 ANDROID_CHECK_PACKAGE(mpfr-${MPFR_VERSION})
348 AC_SUBST(GMP_VERSION)
349 AC_SUBST(MPFR_VERSION)
351 if test "$GCC_MIN_VERSION_4_5_0" == "yes"; then
352 # mpc version (default is 0.8.1)
353 # mpc is only used for gcc version higher than 4.5.0
354 AC_MSG_CHECKING([mpc version])
355 AC_ARG_WITH([mpc-version],
356 [ --with-mpc-version=VERSION
357 use mpc-VERSION (default is 0.8.1)],
358 [if test x"$withval" != x; then
359 MPC_VERSION="$withval"
361 [MPC_VERSION="0.8.1"])
362 AC_MSG_RESULT($MPC_VERSION)
363 ANDROID_CHECK_PACKAGE(mpc-${MPC_VERSION})
365 AC_SUBST(MPC_VERSION)
367 # gdb version (default is 6.6)
368 AC_MSG_CHECKING([target gdb version to build])
369 AC_ARG_WITH([gdb-version],
370 [ --with-gdb-version=VERSION
371 use gdb-VERSION (default is 6.6)],
372 [if test x"$withval" != x ; then
373 GDB_VERSION="$withval"
376 AC_MSG_RESULT($GDB_VERSION)
377 AC_SUBST(GDB_VERSION)
378 ANDROID_CHECK_PACKAGE(gdb-${GDB_VERSION})
381 AC_ARG_WITH([sysroot],
383 use target sysroot in DIR],
384 [if test x"$withval" != x ; then
385 if test $build != $host ; then
387 "$prefix"|"${prefix%/}/"*)
390 AC_MSG_ERROR('Target sysroot must be a subdirectory of <prefix> for canadian cross build $prefix ; $withval')
397 [if test $build != $host ; then
398 AC_MSG_ERROR('Target sysroot is not set for canadian cross build')
402 # Specify a location for mpc
403 AC_ARG_WITH(mpc, [ --with-mpc=PATH
404 specify prefix directory for installed MPC package.],
405 [if test -d "$withval" ; then
409 elif test x"$withval" != x"no"; then
410 AC_MSG_ERROR(invalid value for --with-mpc)
417 # Specify a location for mpfr
418 AC_ARG_WITH(mpfr, [ --with-mpfr=PATH
419 specify prefix directory for installed MPFR package.],
420 [if test -d "$withval" ; then
423 elif test x"$withval" != x"no"; then
424 AC_MSG_ERROR(invalid value for --with-mpfr)
431 # Specify a location for gmp
432 AC_ARG_WITH(gmp, [ --with-gmp=PATH
433 specify prefix directory for the installed GMP package.],
434 [if test -d "$withval" ; then
436 elif test x"$withval" != x"no"; then
437 AC_MSG_ERROR(invalid value for --with-gmp)