Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
5.4KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_trilinos_base.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_TRILINOS_BASE([, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Test for the Trilinos (http://trilinos.sandia.gov/) libraries.
  12. #
  13. # Provides a --with-trilinos=DIR option. Searches --with-trilinos,
  14. # $TRILINOS_HOME, and the usual places for Trilinos installation headers.
  15. #
  16. # Requires that a development branch or released version greater than
  17. # MINIMUM-VERSION be found. If not specified, the default minimum version
  18. # is 8.0.0.
  19. #
  20. # Supports separately specifying --with-trilinos-include or
  21. # --with-trilinos-libdir to override default locations underneath either
  22. # --with-trilinos or $TRILINOS_HOME.
  23. #
  24. # On success, adds -Ipath to CPPFLAGS, -Lpath to LDFLAGS, sets the
  25. # variable TRILINOS_INCLUDE based on the discovered location of
  26. # Trilinos_version.h, and #defines HAVE_TRILINOS. When ACTION-IF-NOT-FOUND
  27. # is not specified, the default behavior is for configure to fail.
  28. #
  29. # LICENSE
  30. #
  31. # Copyright (c) 2009 Rhys Ulerich <rhys.ulerich@gmail.com>
  32. # Copyright (c) 2009 Thomas Porschberg <thomas@randspringer.de>
  33. # Copyright (c) 2009 Caolan McNamara <caolan@skynet.ie>
  34. # Copyright (c) 2009 Alexandre Duret-Lutz <adl@gnu.org>
  35. # Copyright (c) 2009 Matthew Mueller <donut@azstarnet.com>
  36. #
  37. # Copying and distribution of this file, with or without modification, are
  38. # permitted in any medium without royalty provided the copyright notice
  39. # and this notice are preserved. This file is offered as-is, without any
  40. # warranty.
  41. #serial 10
  42. AC_DEFUN([AX_TRILINOS_BASE],
  43. [
  44. AC_REQUIRE([AX_TRILINOS_ABSOLUTE_HEADER])
  45. AC_ARG_VAR(TRILINOS_HOME,[root directory of Trilinos installation])
  46. AC_ARG_WITH(trilinos, [AS_HELP_STRING([--with-trilinos[=DIR]],[root directory of Trilinos installation])],[
  47. with_trilinos=$withval
  48. if test "${with_trilinos}" != yes; then
  49. TRILINOS_HOME=$withval
  50. trilinos_include="$withval/include"
  51. trilinos_libdir="$withval/lib"
  52. fi
  53. ],[
  54. with_trilinos=$withval
  55. if test "x${TRILINOS_HOME}" != "x"; then
  56. trilinos_include="${TRILINOS_HOME}/include"
  57. trilinos_libdir="${TRILINOS_HOME}/lib"
  58. fi
  59. ])
  60. AC_ARG_WITH(trilinos-include,
  61. [AS_HELP_STRING([--with-trilinos-include=DIR],[specify exact directory for Trilinos headers])],[
  62. if test -d "$withval"; then
  63. trilinos_include="$withval"
  64. else
  65. AC_MSG_ERROR([--with-trilinos-include expected directory name])
  66. fi
  67. ])
  68. AC_ARG_WITH(trilinos-libdir, [AS_HELP_STRING([--with-trilinos-libdir=DIR],[specify exact directory for Trilinos libraries])],[
  69. if test -d "$withval"; then
  70. trilinos_libdir="$withval"
  71. else
  72. AC_MSG_ERROR([--with-trilinos-libdir expected directory name])
  73. fi
  74. ])
  75. if test "${with_trilinos}" != no ; then
  76. OLD_LIBS=$LIBS
  77. OLD_LDFLAGS=$LDFLAGS
  78. OLD_CPPFLAGS=$CPPFLAGS
  79. if test -d "${trilinos_libdir}" ; then
  80. LDFLAGS="-L${trilinos_libdir} $LDFLAGS"
  81. fi
  82. if test -d "${trilinos_include}" ; then
  83. CPPFLAGS="-I${trilinos_include} $CPPFLAGS"
  84. fi
  85. succeeded=no
  86. AC_CHECK_HEADER([Trilinos_version.h],[found_header=yes],[found_header=no])
  87. if test "$found_header" = yes; then
  88. dnl Patterned after AX_BOOST_BASE
  89. trilinos_lib_version_req=ifelse([$1],,8.0.0,$1)
  90. trilinos_lib_version_req_shorten=`expr $trilinos_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
  91. trilinos_lib_version_req_major=`expr $trilinos_lib_version_req : '\([[0-9]]*\)'`
  92. trilinos_lib_version_req_minor=`expr $trilinos_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
  93. trilinos_lib_version_req_sub_minor=`expr $trilinos_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
  94. if test "x$trilinos_lib_version_req_sub_minor" = "x" ; then
  95. trilinos_lib_version_req_sub_minor="0"
  96. fi
  97. WANT_TRILINOS_VERSION=`expr $trilinos_lib_version_req_major \* 10000 \+ $trilinos_lib_version_req_minor \* 100 \+ $trilinos_lib_version_req_sub_minor`
  98. AC_LANG_PUSH([C++])
  99. AC_MSG_CHECKING(for Trilinos release >= $trilinos_lib_version_req)
  100. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  101. @%:@include <Trilinos_version.h>
  102. ]], [[
  103. #if (TRILINOS_MAJOR_VERSION == 0)
  104. /* Development branch has zero major version. A-OK. */
  105. #elif (TRILINOS_MAJOR_MINOR_VERSION >= $WANT_TRILINOS_VERSION)
  106. /* Stable release of appropriate version. A-OK. */
  107. #else
  108. # error Trilinos version is too old
  109. #endif
  110. ]])],[
  111. AC_MSG_RESULT(yes)
  112. succeeded=yes
  113. ],[
  114. AC_MSG_RESULT(no)
  115. ])
  116. AC_LANG_POP([C++])
  117. fi
  118. if test "$succeeded" = no; then
  119. LIBS=$OLD_LIBS
  120. LDFLAGS=$OLD_LDFLAGS
  121. CPPFLAGS=$OLD_CPPFLAGS
  122. ifelse([$3],,AC_MSG_ERROR([Trilinos not found. Try either --with-trilinos or setting TRILINOS_HOME.]),
  123. [$3])
  124. else
  125. dnl Find the absolute path to Trilinos_version.h
  126. dnl We need it to back out the discovered TRILINOS_INCLUDE directory.
  127. AX_TRILINOS_ABSOLUTE_HEADER([Trilinos_version.h])
  128. TRILINOS_INCLUDE=`AS_DIRNAME([$ax_cv_absolute_Trilinos_version_h])`
  129. AC_DEFINE(HAVE_TRILINOS,1,[Define if Trilinos is available])
  130. AC_SUBST(TRILINOS_INCLUDE)
  131. ifelse([$2],,,[$2])
  132. fi
  133. fi
  134. ])