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.

112 lines
3.8KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_f90_library.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_F90_LIBRARY(LIBRARY, LIB-REGEXP, FUNCTION-BODY [, SEARCH-PATH [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Set up the compiler flags to link a given fortran 90 library LIBRARY is
  12. # the name of the library. LIB-REGEXP is a regular expression (used by
  13. # find) matched by the filename of the library, this is useful either if
  14. # the library filename does not follow the traditional libxxx.a or
  15. # libxxx.so pattern, or if some specific information is embedded into the
  16. # name, like compiler used, debugging status ...). FUNCTION-BODY is the
  17. # body of a function (including the 'use' statements and the call to a
  18. # function defined by the library) SEARCH-PATH is a colon-separated list
  19. # of directories that will be used as the base directories for 'find' to
  20. # look for the library file. If empty, the search path will be composed of
  21. # $prefix/lib, $ac_default_prefix/lib, and $LD_LIBRARY_PATH. Two output
  22. # variables named F90_LDFLAGS_xxx and F90_LIBS_xxx will be set up with the
  23. # proper flag for substitution in Makefiles (xxx is built from the first
  24. # argument, with autoconf traditional escapes).
  25. #
  26. # LICENSE
  27. #
  28. # Copyright (c) 2009 Luc Maisonobe <luc@spaceroots.org>
  29. #
  30. # Copying and distribution of this file, with or without modification, are
  31. # permitted in any medium without royalty provided the copyright notice
  32. # and this notice are preserved. This file is offered as-is, without any
  33. # warranty.
  34. #serial 13
  35. AC_DEFUN([AX_F90_LIBRARY],[
  36. AS_VAR_PUSHDEF([ax_ldflags],[ax_cv_f90_ldflags_$1])
  37. AS_VAR_PUSHDEF([ax_libs],[ax_cv_f90_libs_$1])
  38. AC_MSG_CHECKING([$1 Fortran 90 library])
  39. AC_LANG_PUSH(Fortran)
  40. AS_VAR_SET([ax_ldflags],"")
  41. AS_VAR_SET([ax_libs],"not found")
  42. if test "x$4" = x ; then
  43. if test "x$prefix" != "xNONE" ; then
  44. ax_search="$prefix:$ac_default_prefix"
  45. else
  46. ax_search="$ac_default_prefix"
  47. fi
  48. for ax_base in "" `echo $LD_LIBRARY_PATH | tr ':' '\012'` ; do
  49. if test "x$ax_base" != x ; then
  50. changequote(,)dnl
  51. ax_base=`echo $ax_base | sed 's,/[^/]*$,,'`
  52. changequote([,])dnl
  53. ax_search="${ax_search}:${ax_base}"
  54. fi
  55. done
  56. else
  57. ax_search="$4"
  58. fi
  59. ax_save_LDFLAGS="$LDFLAGS"
  60. ax_save_LIBS="$LIBS"
  61. for ax_base in `echo $ax_search | tr ':' '\012'` ; do
  62. if test "AS_VAR_GET(ax_libs)" = "not found" ; then
  63. for ax_lib in "" `find $ax_base -follow -name '$2' -print` ; do
  64. if test "x$ax_lib" != x ; then
  65. changequote(,)dnl
  66. ax_dir=`echo $ax_lib | sed 's,/[^/]*$,,'`
  67. ax_lib=`echo $ax_lib | sed 's,.*/\([^/]*\)$,\1,'`
  68. changequote([,])dnl
  69. case "$ax_lib" in
  70. lib*)
  71. changequote(,)dnl
  72. ax_lib="`echo $ax_lib | sed 's,lib\(.*\)\.[^.]*$,\1,'`"
  73. changequote([,])dnl
  74. AS_VAR_SET([ax_ldflags],"-L$ax_dir")
  75. AS_VAR_SET([ax_libs],"-l$ax_lib")
  76. ;;
  77. *)
  78. AS_VAR_SET([ax_ldflags],"")
  79. AS_VAR_SET(ax_libs,"$ax_lib")
  80. ;;
  81. esac
  82. LDFLAGS="$ax_save_LDFLAGS AS_VAR_GET(ax_ldflags)"
  83. LIBS="AS_VAR_GET(ax_libs) $ax_save_LIBS"
  84. AC_LINK_IFELSE([program conftest_program
  85. $3
  86. end program conftest_program
  87. ],[],[AS_VAR_SET(ax_ldflags,"")
  88. AS_VAR_SET(ax_libs,"not found")
  89. ])
  90. fi
  91. done
  92. fi
  93. done
  94. AC_LANG_POP(Fortran)
  95. AC_MSG_RESULT([AS_VAR_GET(ax_ldflags) AS_VAR_GET(ax_libs)])
  96. if test "AS_VAR_GET(ax_libs)" = "not found"; then
  97. AS_TR_SH(F90_LDFLAGS_$1)=""
  98. AS_TR_SH(F90_LIBS_$1)=""
  99. $6
  100. else
  101. AS_TR_SH(F90_LDFLAGS_$1)=AS_VAR_GET(ax_ldflags)
  102. AS_TR_SH(F90_LIBS_$1)=AS_VAR_GET(ax_libs)
  103. $5
  104. fi
  105. AC_SUBST(AS_TR_SH(F90_LDFLAGS_$1))
  106. AC_SUBST(AS_TR_SH(F90_LIBS_$1))
  107. AS_VAR_POPDEF([ax_libs])
  108. AS_VAR_POPDEF([ax_ldflags])
  109. ])