]> nv-tegra.nvidia Code Review - android/toolchain/build.git/blob - configure.ac
Add --with-mpc-version to the build script.
[android/toolchain/build.git] / configure.ac
1 #   Copyright (C) 2008 Google Inc.
2 #
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.
7 #
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.
12 #
13
14 AC_INIT(android-tools,1.0)
15 AC_PREREQ(2.59)
16
17 AC_CONFIG_FILES([Makefile])
18
19 AC_CANONICAL_SYSTEM
20
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)
26
27 GDB_TARGET=$target
28 case $target in
29   arm-android-eabi | arm-unknown-eabi)
30     BUILD_ANDROID_GCC=yes
31     GDB_TARGET=arm-elf-linux
32     ;;
33   arm-newlib-elf)
34     BUILD_ANDROID_GCC=no
35     ;;
36   i[[3456]]86-*-linux-gnu | x86_64-*-linux-gnu)
37     BUILD_ANDROID_GCC=yes
38     ;;
39   *)
40     AC_MSG_ERROR(Unsupported target $target.);
41 esac
42 AC_SUBST(BUILD_ANDROID_GCC)
43 AC_SUBST(GDB_TARGET)
44 AC_ARG_PROGRAM
45
46 # TOPLEVEL_CONFIGURE_ARGUMENTS lifted from top-level configure.ac in gcc.
47
48 # Export original configure arguments for use by sub-configures.
49 # Quote arguments with shell meta charatcers.
50 TOPLEVEL_CONFIGURE_ARGUMENTS=
51 set -- "$progname" "$@"
52 for ac_arg
53 do
54   case "$ac_arg" in
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'/"` ;;
59   *) ;;
60   esac
61   # Add the quoted argument to the list.
62   TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS $ac_arg"
63 done
64 if test "$silent" = yes; then
65   TOPLEVEL_CONFIGURE_ARGUMENTS="$TOPLEVEL_CONFIGURE_ARGUMENTS --silent"
66 fi
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)
71
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.
77 baseargs=
78 keep_next=no
79 skip_next=no
80 eval "set -- $ac_configure_args"
81 for ac_arg
82 do
83   if test X"$skip_next" = X"yes"; then
84     skip_next=no
85     continue
86   fi
87   if test X"$keep_next" = X"yes"; then
88     case $ac_arg in
89       *\'*)
90         ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
91     esac
92     baseargs="$baseargs '$ac_arg'"
93     keep_next=no
94     continue
95   fi
96
97   # Handle separated arguments.  Based on the logic generated by
98   # autoconf 2.59.
99   case $ac_arg in
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)
104       separate_arg=no
105       ;;
106     -*)
107       separate_arg=yes
108       ;;
109     *)
110       separate_arg=no
111       ;;
112   esac
113
114   case "$ac_arg" in
115     --no*)
116       continue
117       ;;
118     --c* | \
119     --sr* | \
120     --ho* | \
121     --bu* | \
122     --t* | \
123     --program-* | \
124     -cache_file* | \
125     -srcdir* | \
126     -host* | \
127     -build* | \
128     -target* | \
129     -program-prefix* | \
130     -program-suffix* | \
131     -program-transform-name* )
132       skip_next=$separate_arg
133       continue
134       ;;
135     -*)
136       # An option.  Add it.
137       case $ac_arg in
138         *\'*)
139           ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
140       esac
141       baseargs="$baseargs '$ac_arg'"
142       keep_next=$separate_arg
143       ;;
144     *)
145       # Either a variable assignment, or a nonopt (triplet).  Don't
146       # pass it down; let the Makefile handle this.
147       continue
148       ;;
149   esac
150 done
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'`
154
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}
164 EOF_SED
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"
170 fi
171
172 AC_SUBST(baseargs)
173
174 #
175 # Check for Canadian cross, which is not supported.
176 #
177 AC_MSG_CHECKING([for Canadian cross])
178 if test $build != $host ; then
179   AC_MSG_ERROR(Canadian cross build not supported.)
180 fi
181 AC_MSG_RESULT(no)
182
183 # package to source path
184 case $srcdir in
185  /* | [A-Za-z]:*) package_to_srcdir=$srcdir ;;
186  *) package_to_srcdir=../$srcdir ;;
187 esac
188 AC_SUBST(package_to_srcdir)
189 #
190 # Specify tool component versions
191 #
192
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"):
195 # 1. tool/x
196 # 2. tool/x.tar.gz
197 # 3. tool/x.tgz
198 # 4. tool/x.tar.bz2
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
211   else
212     AC_MSG_ERROR('package $1 does not exist.')
213   fi
214 fi ])
215
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"
223    fi],
224 [BINUTILS_VERSION="2.17"])
225 AC_MSG_RESULT($BINUTILS_VERSION)
226 AC_SUBST(BINUTILS_VERSION)
227 ANDROID_CHECK_PACKAGE(binutils-${BINUTILS_VERSION})
228
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"
236    fi],
237 [GCC_VERSION="4.2.1"])
238 AC_MSG_RESULT($GCC_VERSION)
239 AC_SUBST(GCC_VERSION)
240 ANDROID_CHECK_PACKAGE(gcc-${GCC_VERSION})
241
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"
251   else
252     GCC_MIN_VERSION_4_3_0="no"
253   fi
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"
257   else
258     GCC_MIN_VERSION_4_5_0="no"
259   fi
260 else
261   # No version file, assume it is trunk
262   GCC_MIN_VERSION_4_3_0="yes"
263   GCC_MIN_VERSION_4_5_0="yes"
264 fi
265 AC_SUBST(GCC_MIN_VERSION_4_3_0)
266 AC_SUBST(GCC_MIN_VERSION_4_5_0)
267
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"
277    fi],
278 [NEWLIB_VERSION="1.16.0"])
279 AC_MSG_RESULT($NEWLIB_VERSION)
280 AC_SUBST(NEWLIB_VERSION)
281 ANDROID_CHECK_PACKAGE(newlib-${NEWLIB_VERSION})
282 fi
283
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"
293    fi],
294 [GMP_VERSION="4.2.2"])
295 AC_MSG_RESULT($GMP_VERSION)
296 ANDROID_CHECK_PACKAGE(gmp-${GMP_VERSION})
297
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"
306    fi],
307 [MPFR_VERSION="2.3.0"])
308 AC_MSG_RESULT($MPFR_VERSION)
309 ANDROID_CHECK_PACKAGE(mpfr-${MPFR_VERSION})
310
311 fi
312 AC_SUBST(GMP_VERSION)
313 AC_SUBST(MPFR_VERSION)
314
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"
324    fi],
325 [MPC_VERSION="0.8.1"])
326 AC_MSG_RESULT($MPC_VERSION)
327 ANDROID_CHECK_PACKAGE(mpc-${MPC_VERSION})
328 fi
329 AC_SUBST(MPC_VERSION)
330
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"
338    fi],
339 [GDB_VERSION="6.6"])
340 AC_MSG_RESULT($GDB_VERSION)
341 AC_SUBST(GDB_VERSION)
342 ANDROID_CHECK_PACKAGE(gdb-${GDB_VERSION})
343
344 AC_OUTPUT