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.

205 lines
7.0KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_blas_f77_func.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_BLAS_F77_FUNC([ACTION-IF-PASS[, ACTION-IF-FAIL[, ACTION-IF-CROSS-COMPILING]])
  8. # AX_BLAS_WITH_F77_FUNC([ACTION-IF-FOUND-AND-PASS[, ACTION-IF-NOT-FOUND-OR-FAIL]])
  9. #
  10. # DESCRIPTION
  11. #
  12. # These macros are intended as a supplement to the AX_BLAS macro, to
  13. # verify that BLAS functions are properly callable from Fortran. This is
  14. # necessary, for example, if you want to build the LAPACK library on top
  15. # of the BLAS.
  16. #
  17. # AX_BLAS_F77_FUNC uses the defined BLAS_LIBS and Fortran environment to
  18. # check for compatibility, and takes a specific action in case of success,
  19. # resp. failure, resp. cross-compilation.
  20. #
  21. # AX_BLAS_WITH_F77_FUNC is a drop-in replacement wrapper for AX_BLAS that
  22. # calls AX_BLAS_F77_FUNC after detecting a BLAS library and rejects it on
  23. # failure (i.e. pretends that no library was found).
  24. #
  25. # LICENSE
  26. #
  27. # Copyright (c) 2008 Jaroslav Hajek <highegg@gmail.com>
  28. #
  29. # This program is free software: you can redistribute it and/or modify it
  30. # under the terms of the GNU General Public License as published by the
  31. # Free Software Foundation, either version 3 of the License, or (at your
  32. # option) any later version.
  33. #
  34. # This program is distributed in the hope that it will be useful, but
  35. # WITHOUT ANY WARRANTY; without even the implied warranty of
  36. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  37. # Public License for more details.
  38. #
  39. # You should have received a copy of the GNU General Public License along
  40. # with this program. If not, see <https://www.gnu.org/licenses/>.
  41. #
  42. # As a special exception, the respective Autoconf Macro's copyright owner
  43. # gives unlimited permission to copy, distribute and modify the configure
  44. # scripts that are the output of Autoconf when processing the Macro. You
  45. # need not follow the terms of the GNU General Public License when using
  46. # or distributing such scripts, even though portions of the text of the
  47. # Macro appear in them. The GNU General Public License (GPL) does govern
  48. # all other use of the material that constitutes the Autoconf Macro.
  49. #
  50. # This special exception to the GPL applies to versions of the Autoconf
  51. # Macro released by the Autoconf Archive. When you make and distribute a
  52. # modified version of the Autoconf Macro, you may extend this special
  53. # exception to the GPL to apply to your modified version as well.
  54. #serial 9
  55. AU_ALIAS([ACX_BLAS_F77_FUNC], [AX_BLAS_F77_FUNC])
  56. AC_DEFUN([AX_BLAS_F77_FUNC], [
  57. AC_PREREQ(2.50)
  58. AC_REQUIRE([AX_BLAS])
  59. # F77 call-compatibility checks
  60. if test "$cross_compiling" = yes ; then
  61. ifelse($3, ,$1,$3)
  62. elif test x"$ax_blas_ok" = xyes; then
  63. save_ax_blas_f77_func_LIBS="$LIBS"
  64. LIBS="$BLAS_LIBS $LIBS"
  65. AC_LANG_PUSH(Fortran 77)
  66. # LSAME check (LOGICAL return values)
  67. AC_MSG_CHECKING([whether LSAME is called correctly from Fortran])
  68. AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
  69. logical lsame,w
  70. external lsame
  71. character c1,c2
  72. c1 = 'A'
  73. c2 = 'B'
  74. w = lsame(c1,c2)
  75. if (w) stop 1
  76. w = lsame(c1,c1)
  77. if (.not. w) stop 1
  78. ]]),[ax_blas_lsame_fcall_ok=yes],
  79. [ax_blas_lsame_fcall_ok=no])
  80. AC_MSG_RESULT([$ax_blas_lsame_fcall_ok])
  81. # ISAMAX check (INTEGER return values)
  82. AC_MSG_CHECKING([whether ISAMAX is called correctly from Fortran])
  83. AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
  84. integer isamax,i
  85. external isamax
  86. real a(2)
  87. a(1) = 1e0
  88. a(2) = -2e0
  89. i = isamax(2,a,1)
  90. if (i.ne.2) stop 1
  91. ]]),[ax_blas_isamax_fcall_ok=yes],
  92. [ax_blas_isamax_fcall_ok=no])
  93. AC_MSG_RESULT([$ax_blas_isamax_fcall_ok])
  94. # SDOT check (REAL return values)
  95. AC_MSG_CHECKING([whether SDOT is called correctly from Fortran])
  96. AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
  97. real sdot,a(1),b(1),w
  98. external sdot
  99. a(1) = 1e0
  100. b(1) = 2e0
  101. w = sdot(1,a,1,b,1)
  102. if (w .ne. a(1)*b(1)) stop 1
  103. ]]),[ax_blas_sdot_fcall_ok=yes],
  104. [ax_blas_sdot_fcall_ok=no])
  105. AC_MSG_RESULT([$ax_blas_sdot_fcall_ok])
  106. # DDOT check (DOUBLE return values)
  107. AC_MSG_CHECKING([whether DDOT is called correctly from Fortran])
  108. AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
  109. double precision ddot,a(1),b(1),w
  110. external ddot
  111. a(1) = 1d0
  112. b(1) = 2d0
  113. w = ddot(1,a,1,b,1)
  114. if (w .ne. a(1)*b(1)) stop 1
  115. ]]),[ax_blas_ddot_fcall_ok=yes],
  116. [ax_blas_ddot_fcall_ok=no])
  117. AC_MSG_RESULT([$ax_blas_ddot_fcall_ok])
  118. # CDOTU check (COMPLEX return values)
  119. AC_MSG_CHECKING([whether CDOTU is called correctly from Fortran])
  120. AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
  121. complex cdotu,a(1),b(1),w
  122. external cdotu
  123. a(1) = cmplx(1e0,1e0)
  124. b(1) = cmplx(1e0,2e0)
  125. w = cdotu(1,a,1,b,1)
  126. if (w .ne. a(1)*b(1)) stop 1
  127. ]]),[ax_blas_cdotu_fcall_ok=yes],
  128. [ax_blas_cdotu_fcall_ok=no])
  129. AC_MSG_RESULT([$ax_blas_cdotu_fcall_ok])
  130. # ZDOTU check (DOUBLE COMPLEX return values)
  131. AC_MSG_CHECKING([whether ZDOTU is called correctly from Fortran])
  132. AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
  133. double complex zdotu,a(1),b(1),w
  134. external zdotu
  135. a(1) = dcmplx(1d0,1d0)
  136. b(1) = dcmplx(1d0,2d0)
  137. w = zdotu(1,a,1,b,1)
  138. if (w .ne. a(1)*b(1)) stop 1
  139. ]]),[ax_blas_zdotu_fcall_ok=yes],
  140. [ax_blas_zdotu_fcall_ok=no])
  141. AC_MSG_RESULT([$ax_blas_zdotu_fcall_ok])
  142. # Check for correct integer size
  143. # FIXME: this may fail with things like -ftrapping-math.
  144. AC_MSG_CHECKING([whether the integer size is correct])
  145. AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
  146. integer n,nn(3)
  147. real s,a(1),b(1),sdot
  148. a(1) = 1.0
  149. b(1) = 1.0
  150. c Generate -2**33 + 1, if possible
  151. n = 2
  152. n = -4 * (n ** 30)
  153. n = n + 1
  154. if (n >= 0) goto 1
  155. c This means we're on 64-bit integers. Check whether the BLAS is, too.
  156. s = sdot(n,a,1,b,1)
  157. if (s .ne. 0.0) stop 1
  158. 1 continue
  159. c We may be on 32-bit integers, and the BLAS on 64 bits. This is almost bound
  160. c to have already failed, but just in case, we'll check.
  161. nn(1) = -1
  162. nn(2) = 1
  163. nn(3) = -1
  164. s = sdot(nn(2),a,1,b,1)
  165. if (s .ne. 1.0) stop 1
  166. ]]),[ax_blas_integer_size_ok=yes],
  167. [ax_blas_integer_size_ok=no])
  168. AC_MSG_RESULT([$ax_blas_integer_size_ok])
  169. AC_LANG_POP(Fortran 77)
  170. # if any of the tests failed, reject the BLAS library
  171. if test $ax_blas_lsame_fcall_ok = yes \
  172. -a $ax_blas_sdot_fcall_ok = yes \
  173. -a $ax_blas_ddot_fcall_ok = yes \
  174. -a $ax_blas_cdotu_fcall_ok = yes \
  175. -a $ax_blas_zdotu_fcall_ok = yes \
  176. -a $ax_blas_integer_size_ok = yes; then
  177. ax_blas_f77_func_ok=yes;
  178. $1
  179. else
  180. ax_blas_f77_func_ok=no;
  181. $2
  182. fi
  183. LIBS="$save_ax_blas_f77_func_LIBS"
  184. fi
  185. ])dnl AX_BLAS_F77_FUNC
  186. AC_DEFUN([AX_BLAS_WITH_F77_FUNC], [
  187. AC_PREREQ(2.50)
  188. AX_BLAS([# disable special action], [])
  189. if test x$ax_blas_ok = xyes ; then
  190. AX_BLAS_F77_FUNC(
  191. [ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1])],
  192. [ax_blas_ok=no; BLAS_LIBS=])
  193. fi
  194. if test x$ax_blas_ok = xno ; then
  195. $2
  196. fi
  197. ])dnl AX_BLAS_WITH_F77_FUNC