This patch makes --with-gmp and --with-mpfr similar to --with-as and
others, where you don't need to have the as program in your PATH if
explicitly specified.
I now understood what you are looking for.
A good solution would be to use the macros AC_LIB_LINKFLAGS and friends,
which were first written for the AM_GETTEXT macro. These provide a good
way to find gmp and friends, and to optionally add -R or -Wl,-rpath
options to the command line (this is controlled by configure switches
--enable-rpath and --disable-rpath).
The macro is used like
AC_LIB_LINKFLAGS(gmp)
AC_LIB_LINKFLAGS(mpfr)
and it will set LIBGMP, LTLIBGMP, INCGMP, and similar variables for
mpfr. The disadvantage is that the variable names have to be changed
throughout, and that --with-* option is --with-libgmp and --with-libmpfr.
If you really need to support --with-gmp-dir and --with-mpfr-dir, you
can set the cache variables
ac_cv_libgmp_libs
ac_cv_libgmp_ltlibs (will be equal to the above)
ac_cv_libgmp_cppflags
the same way you set gmpinc and gmplibs in this snippet:
gmpinc="$gmpinc -I$with_gmp_dir"
if test -f "$with_gmp_dir/.libs/libgmp.a"; then
gmplibs="$gmplibs $with_gmp_dir/.libs/libgmp.a"
elif test -f "$with_gmp_dir/_libs/libgmp.a"; then
gmplibs="$gmplibs $with_gmp_dir/_libs/libgmp.a"
fi
Sorry for wasting your time for months and not proposing this solution.
OTOH I think that stage 1 is a good time to do this.
Paolo