comparison m4/octave_blas_f77_func.m4 @ 31122:1077a1c277fb

build: Use caching for Fortran values in configure. * configure.ac: Rename ax_blas_integer_size to ax_cv_blas_integer_size. * octave_blas_f77_func.m4: Use AC_CACHE_CHECK macro for Fortran values. Rename values from "ax_blas_..." to "ax_cv_blas_..." to comply with requirement for "_cv_" in configure cache naming.
author Rik <rik@octave.org>
date Wed, 06 Jul 2022 22:03:13 -0700
parents f19e621d7f2d
children
comparison
equal deleted inserted replaced
31121:bb63f6bf9b51 31122:1077a1c277fb
72 elif test x"$ax_blas_ok" = xyes; then 72 elif test x"$ax_blas_ok" = xyes; then
73 save_ax_blas_f77_func_LIBS="$LIBS" 73 save_ax_blas_f77_func_LIBS="$LIBS"
74 LIBS="$BLAS_LIBS $LIBS" 74 LIBS="$BLAS_LIBS $LIBS"
75 AC_LANG_PUSH(Fortran 77) 75 AC_LANG_PUSH(Fortran 77)
76 # LSAME check (LOGICAL return values) 76 # LSAME check (LOGICAL return values)
77 AC_MSG_CHECKING([whether LSAME is called correctly from Fortran]) 77 AC_CACHE_CHECK([whether LSAME is called correctly from Fortran],
78 AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ 78 [ax_cv_blas_lsame_fcall_ok],
79 [AC_RUN_IFELSE([AC_LANG_PROGRAM(,[[
79 logical lsame,w 80 logical lsame,w
80 external lsame 81 external lsame
81 character c1,c2 82 character c1,c2
82 c1 = 'A' 83 c1 = 'A'
83 c2 = 'B' 84 c2 = 'B'
84 w = lsame(c1,c2) 85 w = lsame(c1,c2)
85 if (w) stop 1 86 if (w) stop 1
86 w = lsame(c1,c1) 87 w = lsame(c1,c1)
87 if (.not. w) stop 1 88 if (.not. w) stop 1
88 ]]),[ax_blas_lsame_fcall_ok=yes], 89 ]])],
89 [ax_blas_lsame_fcall_ok=no]) 90 ax_cv_blas_lsame_fcall_ok=yes,
90 AC_MSG_RESULT([$ax_blas_lsame_fcall_ok]) 91 ax_cv_blas_lsame_fcall_ok=no)
92 ])
91 # ISAMAX check (INTEGER return values) 93 # ISAMAX check (INTEGER return values)
92 AC_MSG_CHECKING([whether ISAMAX is called correctly from Fortran]) 94 # FIXME: This value is never used, so why do we calculate it?
93 AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ 95 AC_CACHE_CHECK([whether ISAMAX is called correctly from Fortran],
96 [ax_cv_blas_isamax_fcall_ok],
97 [AC_RUN_IFELSE([AC_LANG_PROGRAM(,[[
94 integer isamax,i 98 integer isamax,i
95 external isamax 99 external isamax
96 real a(2) 100 real a(2)
97 a(1) = 1e0 101 a(1) = 1e0
98 a(2) = -2e0 102 a(2) = -2e0
99 i = isamax(2,a,1) 103 i = isamax(2,a,1)
100 if (i.ne.2) stop 1 104 if (i.ne.2) stop 1
101 ]]),[ax_blas_isamax_fcall_ok=yes], 105 ]])],
102 [ax_blas_isamax_fcall_ok=no]) 106 ax_cv_blas_isamax_fcall_ok=yes,
103 AC_MSG_RESULT([$ax_blas_isamax_fcall_ok]) 107 ax_cv_blas_isamax_fcall_ok=no)
108 ])
104 # SDOT check (REAL return values) 109 # SDOT check (REAL return values)
105 AC_MSG_CHECKING([whether SDOT is called correctly from Fortran]) 110 AC_CACHE_CHECK([whether SDOT is called correctly from Fortran],
106 AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ 111 [ax_cv_blas_sdot_fcall_ok],
112 [AC_RUN_IFELSE([AC_LANG_PROGRAM(,[[
107 real sdot,a(1),b(1),w 113 real sdot,a(1),b(1),w
108 external sdot 114 external sdot
109 a(1) = 1e0 115 a(1) = 1e0
110 b(1) = 2e0 116 b(1) = 2e0
111 w = sdot(1,a,1,b,1) 117 w = sdot(1,a,1,b,1)
112 if (w .ne. a(1)*b(1)) stop 1 118 if (w .ne. a(1)*b(1)) stop 1
113 ]]),[ax_blas_sdot_fcall_ok=yes], 119 ]])],
114 [ax_blas_sdot_fcall_ok=no]) 120 ax_cv_blas_sdot_fcall_ok=yes,
115 AC_MSG_RESULT([$ax_blas_sdot_fcall_ok]) 121 ax_cv_blas_sdot_fcall_ok=no)
122 ])
116 # DDOT check (DOUBLE return values) 123 # DDOT check (DOUBLE return values)
117 AC_MSG_CHECKING([whether DDOT is called correctly from Fortran]) 124 AC_CACHE_CHECK([whether DDOT is called correctly from Fortran],
118 AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ 125 [ax_cv_blas_ddot_fcall_ok],
126 [AC_RUN_IFELSE([AC_LANG_PROGRAM(,[[
119 double precision ddot,a(1),b(1),w 127 double precision ddot,a(1),b(1),w
120 external ddot 128 external ddot
121 a(1) = 1d0 129 a(1) = 1d0
122 b(1) = 2d0 130 b(1) = 2d0
123 w = ddot(1,a,1,b,1) 131 w = ddot(1,a,1,b,1)
124 if (w .ne. a(1)*b(1)) stop 1 132 if (w .ne. a(1)*b(1)) stop 1
125 ]]),[ax_blas_ddot_fcall_ok=yes], 133 ]])],
126 [ax_blas_ddot_fcall_ok=no]) 134 ax_cv_blas_ddot_fcall_ok=yes,
127 AC_MSG_RESULT([$ax_blas_ddot_fcall_ok]) 135 ax_cv_blas_ddot_fcall_ok=no)
136 ])
128 # CDOTU check (COMPLEX return values) 137 # CDOTU check (COMPLEX return values)
129 AC_MSG_CHECKING([whether CDOTU is called correctly from Fortran]) 138 AC_CACHE_CHECK([whether CDOTU is called correctly from Fortran],
130 AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ 139 [ax_cv_blas_cdotu_fcall_ok],
140 [AC_RUN_IFELSE([AC_LANG_PROGRAM(,[[
131 complex cdotu,a(1),b(1),w 141 complex cdotu,a(1),b(1),w
132 external cdotu 142 external cdotu
133 a(1) = cmplx(1e0,1e0) 143 a(1) = cmplx(1e0,1e0)
134 b(1) = cmplx(1e0,2e0) 144 b(1) = cmplx(1e0,2e0)
135 w = cdotu(1,a,1,b,1) 145 w = cdotu(1,a,1,b,1)
136 if (w .ne. a(1)*b(1)) stop 1 146 if (w .ne. a(1)*b(1)) stop 1
137 ]]),[ax_blas_cdotu_fcall_ok=yes], 147 ]])],
138 [ax_blas_cdotu_fcall_ok=no]) 148 ax_cv_blas_cdotu_fcall_ok=yes,
139 AC_MSG_RESULT([$ax_blas_cdotu_fcall_ok]) 149 ax_cv_blas_cdotu_fcall_ok=no)
150 ])
140 # ZDOTU check (DOUBLE COMPLEX return values) 151 # ZDOTU check (DOUBLE COMPLEX return values)
141 AC_MSG_CHECKING([whether ZDOTU is called correctly from Fortran]) 152 AC_CACHE_CHECK([whether ZDOTU is called correctly from Fortran],
142 AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ 153 [ax_cv_blas_zdotu_fcall_ok],
154 [AC_RUN_IFELSE([AC_LANG_PROGRAM(,[[
143 double complex zdotu,a(1),b(1),w 155 double complex zdotu,a(1),b(1),w
144 external zdotu 156 external zdotu
145 a(1) = dcmplx(1d0,1d0) 157 a(1) = dcmplx(1d0,1d0)
146 b(1) = dcmplx(1d0,2d0) 158 b(1) = dcmplx(1d0,2d0)
147 w = zdotu(1,a,1,b,1) 159 w = zdotu(1,a,1,b,1)
148 if (w .ne. a(1)*b(1)) stop 1 160 if (w .ne. a(1)*b(1)) stop 1
149 ]]),[ax_blas_zdotu_fcall_ok=yes], 161 ]])],
150 [ax_blas_zdotu_fcall_ok=no]) 162 ax_cv_blas_zdotu_fcall_ok=yes,
151 AC_MSG_RESULT([$ax_blas_zdotu_fcall_ok]) 163 ax_cv_blas_zdotu_fcall_ok=no)
164 ])
152 # Check BLAS library integer size. If it does not appear to be 165 # Check BLAS library integer size. If it does not appear to be
153 # 8 bytes, we assume it is 4 bytes. 166 # 8 bytes, we assume it is 4 bytes.
154 # FIXME: this may fail with things like -ftrapping-math. 167 # FIXME: this may fail with things like -ftrapping-math.
155 AC_MSG_CHECKING([BLAS library integer size]) 168 AC_CACHE_CHECK([BLAS library integer size],
156 AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ 169 [ax_cv_blas_integer_size],
170 [AC_RUN_IFELSE([AC_LANG_PROGRAM(,[[
157 integer*8 two, n 171 integer*8 two, n
158 integer*4 n2(2) 172 integer*4 n2(2)
159 double precision d, a(1), b(1), ddot 173 double precision d, a(1), b(1), ddot
160 equivalence (n, n2) 174 equivalence (n, n2)
161 175
198 212
199 if (d .eq. 1.0) then 213 if (d .eq. 1.0) then
200 stop 1 214 stop 1
201 endif 215 endif
202 216
203 ]]),[ax_blas_integer_size=8], 217 ]])],
204 [ax_blas_integer_size=4]) 218 ax_cv_blas_integer_size=8,
205 AC_MSG_RESULT([$ax_blas_integer_size]) 219 ax_cv_blas_integer_size=4)
220 ])
206 221
207 AC_LANG_POP(Fortran 77) 222 AC_LANG_POP(Fortran 77)
208 223
209 # if any of the tests failed, reject the BLAS library 224 # if any of the tests failed, reject the BLAS library
210 if test $ax_blas_lsame_fcall_ok = yes \ 225 if test $ax_cv_blas_lsame_fcall_ok = yes \
211 -a $ax_blas_sdot_fcall_ok = yes \ 226 -a $ax_cv_blas_sdot_fcall_ok = yes \
212 -a $ax_blas_ddot_fcall_ok = yes \ 227 -a $ax_cv_blas_ddot_fcall_ok = yes \
213 -a $ax_blas_cdotu_fcall_ok = yes \ 228 -a $ax_cv_blas_cdotu_fcall_ok = yes \
214 -a $ax_blas_zdotu_fcall_ok = yes ; then 229 -a $ax_cv_blas_zdotu_fcall_ok = yes ; then
215 ax_blas_f77_func_ok=yes; 230 ax_blas_f77_func_ok=yes;
216 $1 231 $1
217 else 232 else
218 ax_blas_f77_func_ok=no; 233 ax_blas_f77_func_ok=no;
219 $2 234 $2