coin-or-tools / BuildTools

Macros and patches for GNU autotools
https://coin-or-tools.github.io/BuildTools/
Other
3 stars 7 forks source link

improve capability to use precompiled MUMPS library #64

Closed svigerske closed 5 years ago

svigerske commented 5 years ago

Issue created by migration from Trac.

Original creator: @svigerske

Original creation time: 2008-03-29 16:28:19

Assignee: @andrea5w

Version: 0.5

Hi,

the current way to provide a user-compiled MUMPS library is to specify a directory via --with-mumps-dir. Then the build system assumes to find the MUMPS header files there and the libraries $mumps_dir/lib/libdmumps.$libe, $mumps_dir/lib/libpord.$libe, $mumps_dir/libseq/libmpiseq.$libe. This probably works fine if MUMPS had been compiled with the MUMPS Makefiles.

However, in case that one has a mumps library (maybe as one instead of three files as produced by ThirdParty/Mumps) and header files in other locations, it seem to be extremly difficult to make Ipopt use this library. For other 3rd party codes, one can specify the link line and include flags via --with-PROJ-lib and --with-PROJ-incdir. This seem to offer more flexibility. Further, a --with-mumps-lib would allow to specify mumps-library-specific linking flags, e.g., in case that fortran runtime libraries from a different compiler are needed.

Finally, having also a --enable-mumps-libcheck option would be great, since it allows to build an Ipopt library that includes a Mumps interface without having the MUMPS library actually present or linking.

Thank you, Stefan

svigerske commented 5 years ago

Comment by @andrea5w created at 2008-03-30 04:18:11

Hi Stefan,

I will be happy to add a patch to coin.m4 if you could write the modification necessary to accommodate what you would like to have added.

Thanks

Andreas

svigerske commented 5 years ago

Comment by @andrea5w created at 2008-03-30 04:18:11

Changing status from new to assigned.

svigerske commented 5 years ago

Comment by @svigerske created at 2008-04-29 15:37:37

OK,

here is a modified AC_COIN_HAS_MUMPS function. It should define the same symbols,variables,conditionals,... as before, so there is no change in a configure.ac required.

For the user, the difference is that instead of --mumps-dir, he now has to specify the exact linking flags. Further, only one include dir is allowed, so the user will need to copy the mpi and mumps/pord header files in the same directory. The gain is a higher flexibility on the linking flags, e.g., I was now able to build Ipopt with gcc on machine without Fortran90 compiler using a MUMPS library that was build with an Intel compiler on a different machine.

AC_DEFUN([AC_COIN_HAS_MUMPS],
[
if test "$PACKAGE_NAME" = ThirdPartyMumps; then
  coin_mumpsobjdir=../Mumps
else
  coin_mumpsobjdir=../ThirdParty/Mumps
fi
coin_mumpssrcdir=$abs_source_dir/$coin_mumpsobjdir/MUMPS

MAKEOKFILE=.MakeOk

#check if user provides a MUMPS library (that works)
AC_LANG_PUSH(C)
AC_COIN_HAS_USER_LIBRARY(mumps, MUMPS, dmumps_c.h, dmumps_c)
AC_LANG_POP(C)

if test "$coin_has_mumps" = "true"; then  # user provided mumps library
  use_mumps=yes
  coin_has_mumps=yes

  MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $MUMPSINCDIR\`"
  ADDLIBS="$MUMPSLIB $ADDLIBS"

else # no user provided library, so we try to build our own
  use_mumps=BUILD

  # Check if the MUMPS' ThirdParty project has been configured
  if test "$PACKAGE_NAME" != ThirdPartyMumps; then
    if test -r $coin_mumpsobjdir/.MakeOk; then
      use_mumps=BUILD
      # Mumps needs pthreads
      AC_LANG_PUSH(C)
      save_LIBS="$LIBS"
      LIBS="$LIBS $FLIBS"
      AC_CHECK_LIB([pthread],[pthread_create],[LIBS="-lpthread $save_LIBS"; ADDLIBS="-lpthread $ADDLIBS"],[LIBS="save_LIBS"])
      AC_LANG_POP(C)

      MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $coin_mumpssrcdir/libseq\` -I\`\$(CYGPATH_W) $coin_mumpssrcdir/include\`"
    else
      use_mumps=
    fi
  fi

  # if a user provided library is used, then COIN_HAS_USER_LIBRARY takes care of the COIN_HAS_MUMPS conditional and preprocessor symbol
  AM_CONDITIONAL([COIN_HAS_MUMPS],[test x"$use_mumps" != x])
  if test x"$use_mumps" != x; then
    AC_DEFINE([COIN_HAS_MUMPS],[1],[If defined, the MUMPS Library is available.])
    coin_has_mumps=yes
  else
    coin_has_mumps=no
  fi
  AC_MSG_CHECKING([whether MUMPS is available])
  AC_MSG_RESULT([$coin_has_mumps])
fi

if test x"$use_mumps" != x; then
  # we need the Fortran runtime libraries if we want to link with C/C++
  coin_need_flibs=yes

  AC_SUBST(MUMPS_INCFLAGS)
fi

AM_CONDITIONAL([COIN_BUILD_MUMPS],[test "$use_mumps" = BUILD])

]) # AC_COIN_HAS_MUMPS

Best, Stefan

svigerske commented 5 years ago

Comment by @andrea5w created at 2009-02-23 03:05:46

Resolution: fixed