diff mbox

[PR,libgcj/44341] introduce --with-target-{gmp,mpfr,...}

Message ID ormxmve089.fsf@livre.localdomain
State New
Headers show

Commit Message

Alexandre Oliva Jan. 20, 2011, 9:25 p.m. UTC
On Jan 20, 2011, Ralf Wildenhues <Ralf.Wildenhues@gmx.de> wrote:

> I didn't intend to claim that anything else was missing.

Oh.  It looked like you were saying some handling of flags for the
target was missing from the patch.  If that wasn't so, well, sorry, I
still can't quite understand what it was that you were saying, but if
you don't have objections (please confirm), I'll go ahead with the patch
below.

> I claimed that the fact that there was nothing else missing would make
> my much-shorter and more general patch quite almost eligible.
> What am I missing?

Consider --target=sh-linux-gnu --with-sysroot --with-gmp=/opt/host/gmp

With gmp for the host in /opt/host/gmp, and gmp for the target in the
sysroot (so no flags needed).

With your proposed approach, --with-gmp=/opt/host/gmp would still be
passed to libgcj, and it would attempt to use gmp for the host.

With the patch I posted, --with-gmp would not be passed to libgcj,
because we're building a cross compiler, and the compiler would find gmp
for the target in the sysroot.

Comments

Ralf Wildenhues Jan. 21, 2011, 6:16 a.m. UTC | #1
* Alexandre Oliva wrote on Thu, Jan 20, 2011 at 10:25:42PM CET:
> On Jan 20, 2011, Ralf Wildenhues wrote:
> 
> > I claimed that the fact that there was nothing else missing would make
> > my much-shorter and more general patch quite almost eligible.
> > What am I missing?
> 
> Consider --target=sh-linux-gnu --with-sysroot --with-gmp=/opt/host/gmp
> 
> With gmp for the host in /opt/host/gmp, and gmp for the target in the
> sysroot (so no flags needed).
> 
> With your proposed approach, --with-gmp=/opt/host/gmp would still be
> passed to libgcj, and it would attempt to use gmp for the host.

IOW, the user would have to use
  --target=sh-linux-gnu --with-sysroot --with-gmp=/opt/host/gmp \
  target_configargs=--with-gmp=

But that could be fixed as well in my approach to not be necessary,
in the same manner as is done in your patch IIUC.

I won't complain further, but I think that the proliferation of
top-level configure options is not a good thing.  I still consider
factorizing them somehow (and that {build,host,target}_configargs
can be a way to do that) an improvement over the current approach.

Since I don't really have the time to propose a well-tested alternative
solution at this point, and I understand this is meant for 4.6 please
go ahead (not sure if you need RM approval still).

Thanks,
Ralf

> for  ChangeLog
> from  Alexandre Oliva  <aoliva@redhat.com>
> 
> 	PR libgcj/44341
> 	* configure.ac: Remap --with-target-* to --with-* for target
> 	libraries.  Fix alignment of help messages.
> 	* config/cloog.m4: Likewise.
> 	* configure: Rebuilt.
> 
> for  gcc/ChangeLog
> from  Alexandre Oliva  <aoliva@redhat.com>
> 
> 	PR libgcj/44341
> 	* doc/install.texi: Document --with-target* options.
Mike Stump Jan. 21, 2011, 7:53 a.m. UTC | #2
On Jan 20, 2011, at 10:16 PM, Ralf Wildenhues wrote:
> I won't complain further, but I think that the proliferation of
> top-level configure options is not a good thing.  I still consider
> factorizing them somehow (and that {build,host,target}_configargs
> can be a way to do that) an improvement over the current approach.

Would be nice to create a tool to solve the configure/cmake/auto.*/make problem, though, solving that problem is probably as tractable as solving the spam problem, or the package management problem.  :-)  I can envision nice solutions, if you have the copious free time.

In short, I think we'll be forever stuck with something we can all agree to hate.
Alexandre Oliva Jan. 21, 2011, 3:16 p.m. UTC | #3
On Jan 21, 2011, Ralf Wildenhues <Ralf.Wildenhues@gmx.de> wrote:

>   --target=sh-linux-gnu --with-sysroot --with-gmp=/opt/host/gmp \
>   target_configargs=--with-gmp=

> But that could be fixed as well in my approach to not be necessary,
> in the same manner as is done in your patch IIUC.

I kind of like that option, but I foresee some complications.

Say, how do we detect the presence of overriders for say the gmp flags
in target_configargs, so as to discard all the host options, even when
not cross compiling.  Consider:

  --with-gmp=/opt/host/gmp-for-compiler \
  target_configargs=--with-gmp-include=/opt/host/gmp-for-libs/include\ \
\ \ \ \ \ \ \ \ \ \ --with-gmp-lib=/opt/host/gmp-for-libs/lib

Per current logic in the use of the gmp flags, --with-gmp would take
precedence over the other --with-gmp-* flags, even if they appear
afterwards.  And, if we were to invert that logic,
--with-gmp-(include|lib) for the host would then override --with-gmp for
the target, so we'd really need some means to realize that the user
meant to override the gmp settings for the target, and *not* pass the
flags that are only to be used for the host.

> I think that the proliferation of top-level configure options is not a
> good thing

I share that feeling, but hiding options for the target in a user
variable might bite us in the future.  Say, if we wanted to do make
toplevel decisions based on options to be passed to the target, like we
do when deciding whether or not to enable gmp for an in-tree build, we'd
have to go out of our way.  And it's not unrealistic to want to do just
that, so as to build gmp for the target as part of the target libs build
as well, so as to satisfy libgcj's requirements without requiring an
additional build step.


I'd rather standardize --(with|enable)-(build|host|target)-* or
--(with|enable)-*-for-(build|host|target) as applicable only to the
named platform, so that these wouldn't feel like new options, but rather
as standard variants of options.  But I'm not sufficiently convinced
this even makes sense in general to undertake the full effort ;-)
So I kind of started with --with-target-<lib> to see how that went.

How do you feel about this plan?
Ralf Wildenhues Jan. 21, 2011, 6:08 p.m. UTC | #4
* Alexandre Oliva wrote on Fri, Jan 21, 2011 at 04:16:16PM CET:
> On Jan 21, 2011, Ralf Wildenhues <Ralf.Wildenhues@gmx.de> wrote:
> 
> >   --target=sh-linux-gnu --with-sysroot --with-gmp=/opt/host/gmp \
> >   target_configargs=--with-gmp=
> 
> > But that could be fixed as well in my approach to not be necessary,
> > in the same manner as is done in your patch IIUC.
> 
> I kind of like that option, but I foresee some complications.
[...]

Yeah, I guess.  Thanks for persisting.

> > I think that the proliferation of top-level configure options is not a
> > good thing
> 
> I share that feeling, but hiding options for the target in a user
> variable might bite us in the future.  Say, if we wanted to do make
> toplevel decisions based on options to be passed to the target, like we
> do when deciding whether or not to enable gmp for an in-tree build, we'd
> have to go out of our way.  And it's not unrealistic to want to do just
> that, so as to build gmp for the target as part of the target libs build
> as well, so as to satisfy libgcj's requirements without requiring an
> additional build step.

OK fine then.

> I'd rather standardize --(with|enable)-(build|host|target)-* or
> --(with|enable)-*-for-(build|host|target) as applicable only to the
> named platform, so that these wouldn't feel like new options, but rather
> as standard variants of options.  But I'm not sufficiently convinced
> this even makes sense in general to undertake the full effort ;-)
> So I kind of started with --with-target-<lib> to see how that went.
> 
> How do you feel about this plan?

I'm OK with it.  But even if you don't pursue this now, I'd *really*
like post-4.6 trunk to see some abstractions like this (untested!):

# GCC_ARGWITH_SYSTEM(PACKAGE)
# --with-{build,host,target} flag for PACKAGE.
AC_DEFUN([GCC_ARG_WITH_SYSTEM],
[m4_foreach([system], [build, host, target],
   [m4_pushdef([nothostm], [m4_if(system, [host], [], [system-])])dnl
    AC_ARG_WITH(nothostm[$1],
       [AS_HELP_STRING([--with-]nosthostm,
          [specify directory for installed ]system[ $1 package])])
    m4_popdef([empty_for_host])dnl
   ])
])

apart from abstractions for --with-FOO{,-lib,-include} (which, by the
way, already exist in either gnulib or the Autoconf Macro Archive).

Cheers,
Ralf
Paolo Bonzini Jan. 27, 2011, 8:08 a.m. UTC | #5
On 01/21/2011 07:08 PM, Ralf Wildenhues wrote:
> I'm OK with it.  But even if you don't pursue this now, I'd*really*
> like post-4.6 trunk to see some abstractions like this (untested!):

Agreed, something like this is needed to solve the confusion with 
libtool's sysrooting too.

Paolo
diff mbox

Patch

for  ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR libgcj/44341
	* configure.ac: Remap --with-target-* to --with-* for target
	libraries.  Fix alignment of help messages.
	* config/cloog.m4: Likewise.
	* configure: Rebuilt.

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR libgcj/44341
	* doc/install.texi: Document --with-target* options.

Index: configure.ac
===================================================================
--- configure.ac.orig	2011-01-19 19:58:20.685898557 -0200
+++ configure.ac	2011-01-20 15:18:30.131006796 -0200
@@ -385,7 +385,7 @@  case "${ENABLE_GOLD}" in
 esac
 
 AC_ARG_ENABLE(ld,
-[[  --enable-ld[=ARG]     build ld [ARG={default,yes,no}]]],
+[[  --enable-ld[=ARG]       build ld [ARG={default,yes,no}]]],
 ENABLE_LD=$enableval,
 ENABLE_LD=yes)
 
@@ -1334,12 +1334,14 @@  have_gmp=no
 
 # Specify a location for mpc
 # check for this first so it ends up on the link line before mpfr.
-AC_ARG_WITH(mpc, [  --with-mpc=PATH        specify prefix directory for installed MPC package.
+AC_ARG_WITH(mpc, [  --with-mpc=PATH         specify prefix directory for installed MPC package.
                           Equivalent to --with-mpc-include=PATH/include
                           plus --with-mpc-lib=PATH/lib])
 AC_ARG_WITH(mpc-include, [  --with-mpc-include=PATH
                           specify directory for installed MPC include files])
-AC_ARG_WITH(mpc-lib, [  --with-mpc-lib=PATH    specify directory for the installed MPC library])
+AC_ARG_WITH(mpc-lib, [  --with-mpc-lib=PATH     specify directory for the installed MPC library])
+AC_ARG_WITH(target-mpc,
+		     [  --with-target-mpc*      same as above, but for target rather than host])
 
 if test "x$with_mpc" != x; then
   gmplibs="-L$with_mpc/lib $gmplibs"
@@ -1373,6 +1375,8 @@  AC_ARG_WITH(mpfr, [  --with-mpfr=PATH   
 AC_ARG_WITH(mpfr-include, [  --with-mpfr-include=PATH
                           specify directory for installed MPFR include files])
 AC_ARG_WITH(mpfr-lib, [  --with-mpfr-lib=PATH    specify directory for the installed MPFR library])
+AC_ARG_WITH(target-mpfr,
+		     [  --with-target-mpfr*     same as above, but for target rather than host])
 
 if test "x$with_mpfr" != x; then
   gmplibs="-L$with_mpfr/lib $gmplibs"
@@ -1405,6 +1409,8 @@  AC_ARG_WITH(gmp, [  --with-gmp=PATH     
                           plus --with-gmp-lib=PATH/lib])
 AC_ARG_WITH(gmp-include, [  --with-gmp-include=PATH specify directory for installed GMP include files])
 AC_ARG_WITH(gmp-lib, [  --with-gmp-lib=PATH     specify directory for the installed GMP library])
+AC_ARG_WITH(target-gmp,
+		     [  --with-target-gmp*      same as above, but for target rather than host])
 
 
 if test "x$with_gmp" != x; then
@@ -1558,7 +1564,7 @@  AC_SUBST(stage1_ldflags)
 
 # Libraries to use for stage1 or when not bootstrapping.
 AC_ARG_WITH(stage1-libs,
-[  -with-stage1-libs=LIBS      Libraries for stage1],
+[  --with-stage1-libs=LIBS  Libraries for stage1],
 [if test "$withval" = "no" -o "$withval" = "yes"; then
    stage1_libs=
  else
@@ -1570,7 +1576,7 @@  AC_SUBST(stage1_libs)
 # Libraries to use for stage2 and later builds.  This defaults to the
 # argument passed to --with-host-libstdcxx.
 AC_ARG_WITH(boot-libs,
-[  --with-boot-libs=LIBS     Libraries for stage2 and later],
+[  --with-boot-libs=LIBS   Libraries for stage2 and later],
 [if test "$withval" = "no" -o "$withval" = "yes"; then
    poststage1_libs=
  else
@@ -1605,6 +1611,8 @@  AC_ARG_WITH(ppl, [  --with-ppl=PATH     
                           plus --with-ppl-lib=PATH/lib])
 AC_ARG_WITH(ppl-include, [  --with-ppl-include=PATH Specify directory for installed PPL include files])
 AC_ARG_WITH(ppl-lib, [  --with-ppl-lib=PATH     Specify the directory for the installed PPL library])
+AC_ARG_WITH(target-ppl,
+		     [  --with-target-ppl*      same as above, but for target rather than host])
 
 case $with_ppl in 
   no)
@@ -2674,7 +2682,7 @@  esac
 AC_MSG_CHECKING(for default BUILD_CONFIG)
 
 AC_ARG_WITH([build-config],
-  [--with-build-config='NAME NAME2...'
+  [  --with-build-config='NAME NAME2...'
                           Use config/NAME.mk build configuration],
   [case $with_build_config in
    yes) with_build_config= ;;
@@ -2815,6 +2823,7 @@  AC_SUBST_FILE(serialization_dependencies
 # Also strip program-prefix, program-suffix, and program-transform-name,
 # so that we can pass down a consistent program-transform-name.
 baseargs=
+tbaseargs=
 keep_next=no
 skip_next=no
 eval "set -- $ac_configure_args"
@@ -2830,6 +2839,7 @@  do
 	ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
     baseargs="$baseargs '$ac_arg'"
+    tbaseargs="$tbaseargs '$ac_arg'"
     keep_next=no
     continue
   fi
@@ -2851,11 +2861,51 @@  do
       ;;
   esac
 
+  skip_targ=no
+  case $ac_arg in
+  --with-target-* | --without-target-*)
+    ;;
+
+changequote(,)
+  --with-* | --without-*)
+    libopt=`echo "$ac_arg" | sed -e 's,^--[^-_]*[-_],,' -e 's,=.*$,,'`
+
+    case $libopt in
+    *[-_]include)
+      lib=`echo "$libopt" | sed 's,[-_]include$,,'`
+      ;;
+    *[-_]lib)
+      lib=`echo "$libopt" | sed 's,[-_]lib$,,'`
+      ;;
+    *)
+      lib=$libopt
+      ;;
+    esac
+changequote([,])
+
+    case $lib in
+    mpc | mpfr | gmp | ppl | cloog)
+      # If we're processing --with-$lib, --with-$lib-include or
+      # --with-$lib-lib, for one of the libs above, and target is
+      # different from host, or options such as --with-target-$lib,
+      # --with-target-$lib-include or --with-target-$lib-lib were
+      # passed to configure, don't pass the current argument to any
+      # target library's configure.
+      if test x$is_cross_compiler = xyes ||
+	 eval test "X\${with_target_${lib}+set}\${with_target_${lib}_include+set}\${with_target_${lib}_lib+set}" != X; then
+        skip_targ=yes
+      fi
+      ;;
+    esac
+    ;;
+  esac
+
   case "$ac_arg" in
     --cache-file=/dev/null | \
     -cache-file=/dev/null )
       # Handled here to avoid the test to skip args below.
       baseargs="$baseargs '$ac_arg'"
+      tbaseargs="$tbaseargs '$ac_arg'"
       # Assert: $separate_arg should always be no.
       keep_next=$separate_arg
       ;;
@@ -2879,6 +2929,21 @@  do
       skip_next=$separate_arg
       continue
       ;;
+    --enable-target-* | \
+    --disable-target-* | \
+    --with-target-* | \
+    --without-target-*)
+      # A target option.  Add it, but edit out "-target" from the
+      # argument passed to configure the target library.
+      case $ac_arg in
+	*\'*)
+	  ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+      esac
+      baseargs="$baseargs '$ac_arg'"
+      ac_targ=`echo "$ac_arg" | sed 's,-target,,'`
+      tbaseargs="$tbaseargs '$ac_targ'"
+      keep_next=$separate_arg
+      ;;
     -*)
       # An option.  Add it.
       case $ac_arg in
@@ -2886,6 +2951,9 @@  do
 	  ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
       esac
       baseargs="$baseargs '$ac_arg'"
+      if test X"$skip_targ" = Xno; then
+        tbaseargs="$tbaseargs '$ac_arg'"
+      fi
       keep_next=$separate_arg
       ;;
     *)
@@ -2912,10 +2980,13 @@  EOF_SED
 gcc_transform_name=`cat conftestsed.out`
 rm -f conftestsed.out
 baseargs="$baseargs --program-transform-name='${gcc_transform_name}'"
+tbaseargs="$tbaseargs --program-transform-name='${gcc_transform_name}'"
 if test "$silent" = yes; then
   baseargs="$baseargs --silent"
+  tbaseargs="$tbaseargs --silent"
 fi
 baseargs="$baseargs --disable-option-checking"
+tbaseargs="$tbaseargs --disable-option-checking"
 
 # Record and document user additions to sub configure arguments.
 AC_ARG_VAR([build_configargs],
@@ -2944,7 +3015,7 @@  esac
 # This seems to be due to autoconf 2.5x stupidity.
 host_configargs="$host_configargs --cache-file=./config.cache ${extra_host_args} ${baseargs}"
 
-target_configargs="$target_configargs ${baseargs}"
+target_configargs="$target_configargs ${tbaseargs}"
 
 # Passing a --with-cross-host argument lets the target libraries know
 # whether they are being built with a cross-compiler or being built
@@ -3315,7 +3386,7 @@  AC_SUBST(COMPILER_NM_FOR_TARGET)
 
 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
 AC_ARG_ENABLE(maintainer-mode,
-[  --enable-maintainer-mode enable make rules and dependencies not useful
+[  --enable-maintainer-mode   enable make rules and dependencies not useful
                           (and sometimes confusing) to the casual installer],
       USE_MAINTAINER_MODE=$enableval,
       USE_MAINTAINER_MODE=no)
Index: configure
===================================================================
--- configure.orig	2011-01-20 15:17:27.527990763 -0200
+++ configure	2011-01-20 15:18:30.298004171 -0200
@@ -750,14 +750,17 @@  enable_build_with_cxx
 with_mpc
 with_mpc_include
 with_mpc_lib
+with_target_mpc
 with_mpfr_dir
 with_mpfr
 with_mpfr_include
 with_mpfr_lib
+with_target_mpfr
 with_gmp_dir
 with_gmp
 with_gmp_include
 with_gmp_lib
+with_target_gmp
 with_host_libstdcxx
 with_stage1_ldflags
 with_stage1_libs
@@ -766,10 +769,12 @@  with_boot_ldflags
 with_ppl
 with_ppl_include
 with_ppl_lib
+with_target_ppl
 enable_ppl_version_check
 with_cloog
 with_cloog_include
 with_cloog_lib
+with_target_cloog
 enable_cloog_backend
 enable_cloog_version_check
 enable_lto
@@ -1454,7 +1459,7 @@  Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --enable-gold[=ARG]     build gold [ARG={default,yes,no}]
-  --enable-ld[=ARG]     build ld [ARG={default,yes,no}]
+  --enable-ld[=ARG]       build ld [ARG={default,yes,no}]
   --disable-libquadmath   do not build libquadmath directory
   --disable-libquadmath-support
                           disable libquadmath support for Fortran
@@ -1477,7 +1482,7 @@  Optional Features:
                           force sequential configuration of
                           sub-packages for the host, target or build
                           machine, or all sub-packages
-  --enable-maintainer-mode enable make rules and dependencies not useful
+  --enable-maintainer-mode   enable make rules and dependencies not useful
                           (and sometimes confusing) to the casual installer
   --enable-stage1-checking[=all]   choose additional checking for stage1
                           of the compiler
@@ -1487,12 +1492,13 @@  Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-build-libsubdir=DIR  Directory where to find libraries for build system
-  --with-mpc=PATH        specify prefix directory for installed MPC package.
+  --with-mpc=PATH         specify prefix directory for installed MPC package.
                           Equivalent to --with-mpc-include=PATH/include
                           plus --with-mpc-lib=PATH/lib
   --with-mpc-include=PATH
                           specify directory for installed MPC include files
-  --with-mpc-lib=PATH    specify directory for the installed MPC library
+  --with-mpc-lib=PATH     specify directory for the installed MPC library
+  --with-target-mpc*      same as above, but for target rather than host
   --with-mpfr-dir=PATH    this option has been REMOVED
   --with-mpfr=PATH        specify prefix directory for installed MPFR package.
                           Equivalent to --with-mpfr-include=PATH/include
@@ -1500,23 +1506,26 @@  Optional Packages:
   --with-mpfr-include=PATH
                           specify directory for installed MPFR include files
   --with-mpfr-lib=PATH    specify directory for the installed MPFR library
+  --with-target-mpfr*     same as above, but for target rather than host
   --with-gmp-dir=PATH     this option has been REMOVED
   --with-gmp=PATH         specify prefix directory for the installed GMP package.
                           Equivalent to --with-gmp-include=PATH/include
                           plus --with-gmp-lib=PATH/lib
   --with-gmp-include=PATH specify directory for installed GMP include files
   --with-gmp-lib=PATH     specify directory for the installed GMP library
+  --with-target-gmp*      same as above, but for target rather than host
   --with-host-libstdcxx=L Use linker arguments L to link with libstdc++
                           when linking with PPL
   --with-stage1-ldflags=FLAGS Linker flags for stage1
-  -with-stage1-libs=LIBS      Libraries for stage1
-  --with-boot-libs=LIBS     Libraries for stage2 and later
+  --with-stage1-libs=LIBS  Libraries for stage1
+  --with-boot-libs=LIBS   Libraries for stage2 and later
   --with-boot-ldflags=FLAGS Linker flags for stage2 and later
   --with-ppl=PATH         Specify prefix directory for the installed PPL package
                           Equivalent to --with-ppl-include=PATH/include
                           plus --with-ppl-lib=PATH/lib
   --with-ppl-include=PATH Specify directory for installed PPL include files
   --with-ppl-lib=PATH     Specify the directory for the installed PPL library
+  --with-target-ppl*      same as above, but for target rather than host
   --with-cloog=PATH       Specify prefix directory for the installed CLooG-PPL
                           package. Equivalent to
                           --with-cloog-include=PATH/include plus
@@ -1525,11 +1534,12 @@  Optional Packages:
                           Specify directory for installed CLooG include files
   --with-cloog-lib=PATH   Specify the directory for the installed CLooG
                           library
+  --with-target-cloog*    same as above, but for target rather than host
   --with-build-sysroot=SYSROOT
                           use sysroot as the system root during the build
   --with-debug-prefix-map='A=B C=D ...'
                              map A to B, C to D ... in debug information
---with-build-config='NAME NAME2...'
+  --with-build-config='NAME NAME2...'
                           Use config/NAME.mk build configuration
   --with-build-time-tools=PATH
                           use given path to find target tools during the build
@@ -5218,6 +5228,12 @@  if test "${with_mpc_lib+set}" = set; the
 fi
 
 
+# Check whether --with-target-mpc was given.
+if test "${with_target_mpc+set}" = set; then :
+  withval=$with_target_mpc;
+fi
+
+
 if test "x$with_mpc" != x; then
   gmplibs="-L$with_mpc/lib $gmplibs"
   gmpinc="-I$with_mpc/include $gmpinc"
@@ -5267,6 +5283,12 @@  if test "${with_mpfr_lib+set}" = set; th
 fi
 
 
+# Check whether --with-target-mpfr was given.
+if test "${with_target_mpfr+set}" = set; then :
+  withval=$with_target_mpfr;
+fi
+
+
 if test "x$with_mpfr" != x; then
   gmplibs="-L$with_mpfr/lib $gmplibs"
   gmpinc="-I$with_mpfr/include $gmpinc"
@@ -5316,6 +5338,12 @@  if test "${with_gmp_lib+set}" = set; the
 fi
 
 
+# Check whether --with-target-gmp was given.
+if test "${with_target_gmp+set}" = set; then :
+  withval=$with_target_gmp;
+fi
+
+
 
 if test "x$with_gmp" != x; then
   gmplibs="-L$with_gmp/lib $gmplibs"
@@ -5675,6 +5703,12 @@  if test "${with_ppl_lib+set}" = set; the
 fi
 
 
+# Check whether --with-target-ppl was given.
+if test "${with_target_ppl+set}" = set; then :
+  withval=$with_target_ppl;
+fi
+
+
 case $with_ppl in
   no)
     ppllibs=
@@ -5764,6 +5798,12 @@  if test "${with_cloog_lib+set}" = set; t
 fi
 
 
+# Check whether --with-target-cloog was given.
+if test "${with_target_cloog+set}" = set; then :
+  withval=$with_target_cloog;
+fi
+
+
   # Check whether --enable-cloog-backend was given.
 if test "${enable_cloog_backend+set}" = set; then :
   enableval=$enable_cloog_backend;  if   test "x${enableval}" = "xisl"; then
@@ -7304,6 +7344,7 @@  serialization_dependencies=serdep.tmp
 # Also strip program-prefix, program-suffix, and program-transform-name,
 # so that we can pass down a consistent program-transform-name.
 baseargs=
+tbaseargs=
 keep_next=no
 skip_next=no
 eval "set -- $ac_configure_args"
@@ -7319,6 +7360,7 @@  do
 	ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
     baseargs="$baseargs '$ac_arg'"
+    tbaseargs="$tbaseargs '$ac_arg'"
     keep_next=no
     continue
   fi
@@ -7340,11 +7382,51 @@  do
       ;;
   esac
 
+  skip_targ=no
+  case $ac_arg in
+  --with-target-* | --without-target-*)
+    ;;
+
+
+  --with-* | --without-*)
+    libopt=`echo "$ac_arg" | sed -e 's,^--[^-_]*[-_],,' -e 's,=.*$,,'`
+
+    case $libopt in
+    *[-_]include)
+      lib=`echo "$libopt" | sed 's,[-_]include$,,'`
+      ;;
+    *[-_]lib)
+      lib=`echo "$libopt" | sed 's,[-_]lib$,,'`
+      ;;
+    *)
+      lib=$libopt
+      ;;
+    esac
+
+
+    case $lib in
+    mpc | mpfr | gmp | ppl | cloog)
+      # If we're processing --with-$lib, --with-$lib-include or
+      # --with-$lib-lib, for one of the libs above, and target is
+      # different from host, or options such as --with-target-$lib,
+      # --with-target-$lib-include or --with-target-$lib-lib were
+      # passed to configure, don't pass the current argument to any
+      # target library's configure.
+      if test x$is_cross_compiler = xyes ||
+	 eval test "X\${with_target_${lib}+set}\${with_target_${lib}_include+set}\${with_target_${lib}_lib+set}" != X; then
+        skip_targ=yes
+      fi
+      ;;
+    esac
+    ;;
+  esac
+
   case "$ac_arg" in
     --cache-file=/dev/null | \
     -cache-file=/dev/null )
       # Handled here to avoid the test to skip args below.
       baseargs="$baseargs '$ac_arg'"
+      tbaseargs="$tbaseargs '$ac_arg'"
       # Assert: $separate_arg should always be no.
       keep_next=$separate_arg
       ;;
@@ -7368,6 +7450,21 @@  do
       skip_next=$separate_arg
       continue
       ;;
+    --enable-target-* | \
+    --disable-target-* | \
+    --with-target-* | \
+    --without-target-*)
+      # A target option.  Add it, but edit out "-target" from the
+      # argument passed to configure the target library.
+      case $ac_arg in
+	*\'*)
+	  ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+      esac
+      baseargs="$baseargs '$ac_arg'"
+      ac_targ=`echo "$ac_arg" | sed 's,-target,,'`
+      tbaseargs="$tbaseargs '$ac_targ'"
+      keep_next=$separate_arg
+      ;;
     -*)
       # An option.  Add it.
       case $ac_arg in
@@ -7375,6 +7472,9 @@  do
 	  ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
       esac
       baseargs="$baseargs '$ac_arg'"
+      if test X"$skip_targ" = Xno; then
+        tbaseargs="$tbaseargs '$ac_arg'"
+      fi
       keep_next=$separate_arg
       ;;
     *)
@@ -7401,10 +7501,13 @@  EOF_SED
 gcc_transform_name=`cat conftestsed.out`
 rm -f conftestsed.out
 baseargs="$baseargs --program-transform-name='${gcc_transform_name}'"
+tbaseargs="$tbaseargs --program-transform-name='${gcc_transform_name}'"
 if test "$silent" = yes; then
   baseargs="$baseargs --silent"
+  tbaseargs="$tbaseargs --silent"
 fi
 baseargs="$baseargs --disable-option-checking"
+tbaseargs="$tbaseargs --disable-option-checking"
 
 # Record and document user additions to sub configure arguments.
 
@@ -7430,7 +7533,7 @@  esac
 # This seems to be due to autoconf 2.5x stupidity.
 host_configargs="$host_configargs --cache-file=./config.cache ${extra_host_args} ${baseargs}"
 
-target_configargs="$target_configargs ${baseargs}"
+target_configargs="$target_configargs ${tbaseargs}"
 
 # Passing a --with-cross-host argument lets the target libraries know
 # whether they are being built with a cross-compiler or being built
Index: config/cloog.m4
===================================================================
--- config/cloog.m4.orig	2011-01-16 10:29:55.054969196 -0200
+++ config/cloog.m4	2011-01-20 15:18:30.327003715 -0200
@@ -36,6 +36,10 @@  AC_DEFUN([CLOOG_INIT_FLAGS],
     [AS_HELP_STRING(
       [--with-cloog-lib=PATH],
       [Specify the directory for the installed CLooG library])])
+  AC_ARG_WITH([target-cloog],
+    [AS_HELP_STRING(
+      [--with-target-cloog*],
+      [same as above, but for target rather than host])])
 
   AC_ARG_ENABLE(cloog-backend,
     [AS_HELP_STRING(
Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi.orig	2011-01-20 15:19:04.995458821 -0200
+++ gcc/doc/install.texi	2011-01-20 15:39:37.021558680 -0200
@@ -312,6 +312,13 @@  and @option{--with-gmp-include}.  Altern
 distribution is found in a subdirectory of your GCC sources named
 @file{gmp}, it will be built together with GCC@.
 
+The Java run-time also requires GMP.  If you are building a cross
+compiler for Java, libgcj will require a build of GMP for the target.
+If it is not in the target compiler's search path, the
+@option{--with-target-gmp} configure option (or
+@option{--with-target-gmp-include} and @option{--with-target-gmp-lib})
+tell libgcj where to find it.
+
 @item MPFR Library version 2.4.2 (or later)
 
 Necessary to build GCC@.  It can be downloaded from
@@ -1597,6 +1604,33 @@  you can explicitly specify the directory
 shorthand assumptions are not correct, you can use the explicit
 include and lib options directly.
 
+@item --with-target-gmp=@var{pathname}
+@itemx --with-target-gmp-include=@var{pathname}
+@itemx --with-target-gmp-lib=@var{pathname}
+@itemx --with-target-mpfr=@var{pathname}
+@itemx --with-target-mpfr-include=@var{pathname}
+@itemx --with-target-mpfr-lib=@var{pathname}
+@itemx --with-target-mpc=@var{pathname}
+@itemx --with-target-mpc-include=@var{pathname}
+@itemx --with-target-mpc-lib=@var{pathname}
+@itemx --with-target-ppl=@var{pathname}
+@itemx --with-target-ppl-include=@var{pathname}
+@itemx --with-target-ppl-lib=@var{pathname}
+@itemx --with-target-cloog=@var{pathname}
+@itemx --with-target-cloog-include=@var{pathname}
+@itemx --with-target-cloog-lib=@var{pathname}
+The @option{--with-target-*} options are target variants of the
+corresponding @option{--with-*} host options.  They are transformed to
+@option{--with-*} when configuring target libraries, overriding the
+options for the host.  When building a native compiler, the host options
+are passed on to target libraries as well, unless overridden, but when
+building a cross compiler, the host options are excluded from the target
+library configuration.  For example, @samp{libjava} requires GMP: if you
+have it where the compiler wouldn't find by itself, a single
+@option{--with-gmp} flag will do for both host and target, but if you
+want to or have to use a different GMP with the target libraries (say,
+it's a cross compiler you're building), use @option{--with-target-gmp}.
+
 @item --with-host-libstdcxx=@var{linker-args}
 If you are linking with a static copy of PPL, you can use this option
 to specify how the linker should find the standard C++ library used