I've been working on PR libfortran/21547: f951 is linked with libgmp, but when this library is shared and located in a non-standard path, building with ./configure --with-gmp=/foo/bar fails because the correct $(RPATH_ENVVAR) is not set when building the libgfortran. The conclusions I draw after gazing helplessly at the toplevel Makefile.* for hours is:

- I should add a GMPLBISDIR variable in the configure.in to store the paths to the libraries as a colon-separated list of absolute paths
  - the GMPLIBSDIR should be added to the HOST_LIB_PATH
- then, i don't really know how this should come into HOST_LIB_PATH; perhaps by way of HOST_LIB_PATH_gcc

I have attached a patch that implements things that way. The questions I now have are:

  - is that the Right Scheme for doing this?
- with this patch, the libgfortran is built, but the gfortran testsuite doesn't run; why isn't $(RPATH_ENVVAR) including HOST_LIB_PATH for the testsuite?

Thanks,
FX
Index: Makefile.tpl
===================================================================
--- Makefile.tpl	(revision 106019)
+++ Makefile.tpl	(working copy)
@@ -216,6 +216,7 @@
 
 # Where to find GMP
 HOST_GMPLIBS = @gmplibs@
+HOST_GMPLIBSDIR = @gmplibsdir@
 HOST_GMPINC = @gmpinc@
 
 # ----------------------------------------------
@@ -615,7 +616,7 @@
 
 # Define HOST_LIB_PATH_gcc here, for the sake of TARGET_LIB_PATH, ouch
 @if gcc
-HOST_LIB_PATH_gcc = $$r/$(HOST_SUBDIR)/gcc:$$r/$(HOST_SUBDIR)/prev-gcc:
+HOST_LIB_PATH_gcc = $$r/$(HOST_SUBDIR)/gcc:$$r/$(HOST_SUBDIR)/prev-gcc:$(HOST_GMPLIBSDIR):
 @endif gcc
 
 [+ FOR host_modules +][+ IF lib_path +]
Index: configure.in
===================================================================
--- configure.in	(revision 106019)
+++ configure.in	(working copy)
@@ -1058,6 +1058,7 @@
 # Check for GMP and MPFR
 gmplibs=
 gmpinc=
+gmplibsdir=
 have_gmp=yes
 # Specify a location for mpfr
 # check for this first so it ends up on the link line before gmp.
@@ -1075,6 +1076,7 @@
 if test "x$with_mpfr" != x; then
   gmplibs="-L$with_mpfr/lib $gmplibs"
   gmpinc="-I$with_mpfr/include"
+  gmplibsdir="$with_mpfr/lib"
 fi
 
 # Specify a location for gmp
@@ -1097,6 +1099,11 @@
 if test "x$with_gmp" != x; then
   gmplibs="-L$with_gmp/lib $gmplibs"
   gmpinc="-I$with_gmp/include $gmpinc"
+  if test "x$gmplibsdir" != x; then
+    gmplibsdir="$gmplibsdir:$with_gmp/lib"
+  else
+    gmplibsdir="$with_gmp/lib"
+  fi
 fi
 
 saved_CFLAGS="$CFLAGS"
@@ -1125,6 +1132,7 @@
 # Flags needed for both GMP and/or MPFR
 AC_SUBST(gmplibs)
 AC_SUBST(gmpinc)
+AC_SUBST(gmplibsdir)
 
 # By default, C is the only stage 1 language.
 stage1_languages=c
Index: libgfortran/Makefile.in
===================================================================
--- libgfortran/Makefile.in	(revision 106403)
+++ libgfortran/Makefile.in	(working copy)
@@ -278,6 +278,7 @@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
 FPU_HOST_HEADER = @FPU_HOST_HEADER@
+GMPLIBSDIR = @GMPLIBSDIR@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
Index: libgfortran/configure.ac
===================================================================
--- libgfortran/configure.ac	(revision 106403)
+++ libgfortran/configure.ac	(working copy)
@@ -141,6 +141,8 @@
 AC_PROG_FC(gfortran)
 FCFLAGS="$FCFLAGS -Wall -fno-repack-arrays -fno-underscoring"
 
+AC_ARG_VAR(GMPLIBSDIR,[Directories containing the GMP and MPFR libraries])
+
 # extra LD Flags which are required for targets
 case "${host}" in
   *-darwin*)

Reply via email to