1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
|
diff --git a/configure b/configure
index 833f483..bcfa62d 100755
--- a/configure
+++ b/configure
@@ -3226,574 +3226,14 @@ else
echo
echo "Warning: this option has not been extensively tested!"
echo "Please report problems to ccp4@ccp4.ac.uk"
- # Search for vendor LAPACK/BLAS first
- if test ! "$with_netlib_lapack" ; then
- # Initialise variables to blank
- lapackdir=
- XLAPACK_LIB=
- # Possible directories to check for vendor or pre-existing LAPACK or
- # BLAS - add to these if you want to test others
- trydirs="`echo $LD_LIBRARY_PATH |sed -e s/:/\ /g` /lib /usr/lib /usr/local/lib"
- # Possible library names
- # These are the names like xxxx where the library will be libxxxx.a
- # or libxxxx.so
- echo
- echo "Guessing names for native/vendor LAPACK and/or BLAS libraries"
- echo "on this system"
- case $system in
- linux | linux64 | linux32 )
- # linux users will usually have them in /usr/lib but don't call it
- trylapack="lapack"
- tryblas="blas"
- # if code is non_shared then this can lead to problems. both blas and lapack
- # need to be resolved even if they are not called!
- if test "$non_shared" = yes; then
- echo "You are compiling linux non_shared. This sometimes causes problems "
- echo " so checking for requirements."
- echo "Checking: try to link library against test program"
- if test -f testlink.f || test -f testlink ; then
- rm -f testlink*
- fi
- cat > testlink.f <<EOF
- PROGRAM TESTLINK
-C A bit of scala code to test the linking
- real bf(3), bnorm
-c
- integer maxbmt
- parameter (maxbmt = 2)
- double precision B(maxbmt,maxbmt), eigval(maxbmt),
- $ eigvec(maxbmt,maxbmt), w(5*maxbmt)
- integer m, ia, ix, istat
-c
- B(1,1) = 1.00
- B(1,2) = 1.00
- B(2,1) = 1.00
- B(2,2) = 1.00
-c
- m = maxbmt
- ia = maxbmt
- ix = maxbmt
- call dsyev('N', 'L', m, B, ia, eigval, w, 5*maxbmt, istat)
- end
-EOF
- #firstly test without -lblas
- test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -llapack"
- echo $test_compile
- if { (eval $test_compile >& /dev/null ) 2>&1; } && test -s testlink ; then
- # Compilation was okay
- echo "... only -llapack needed"
- XLAPACK_LIB="-llapack"
- # Set the next two variables so that configure
- # doesn't try to build netlib libraries
- LAPACKLIB="lapack"
- noblas=yes
- trylapack=
- tryblas=
- else
- echo "more than just -llapack needed...."
- test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -llapack -lblas"
- echo $test_compile
- if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
- # Compilation was okay
- echo "...-llapack and -lblas were needed"
- XLAPACK_LIB="-llapack -lblas"
- # Set the next two variables so that configure
- # doesn't try to build netlib libraries
- LAPACKLIB="lapack blas"
- noblas=no
- trylapack=
- tryblas=
- else
- echo "....could not find either lapack or blas."
- fi
- fi
- fi
- # add 64 bit libs
- case $system in
- linux64 ) trydirs="/usr/lib64 ${trydirs}" ;;
- esac
-
- ;;
- osf1)
- # OSF1 has dxml (old version) and cxml
- # which should have both lapack and blas
- trylapack="dxml cxml"
- tryblas=
- trydirs="${trydirs} /usr/shlib"
- ;;
- irix)
- # Additional search paths for IRIX
- trydirs="${trydirs} /usr/lib32"
- # SCSL should have both LAPACK and BLAS
- trylapack="scs"
- tryblas="blas"
- ;;
- irix64)
- # Additional search paths for IRIX64
- trydirs="${trydirs} /usr/lib64"
- # SCSL should have both LAPACK and BLAS
- trylapack="scs"
- tryblas="blas"
- # Extra compiler flags?
- #XLAPACKFLAGS="-OPT:IEEE_NaN_inf=ON"
- ;;
- aix)
- # Additional search paths for AIX
- trydirs="${trydirs}"
- # AIX might have ESSL library - blas only I think
- trylapack=
- tryblas="essl"
- ;;
- hpux)
- # Additional search paths for HPUX
- trydirs="${trydirs} /opt/fortran/lib /opt/fortran/lib/pa2.0 /opt/mlib/lib/pa2.0"
- # HPUX should have both LAPACK (part of mlib) and BLAS
- trylapack="lapack"
- tryblas="blas"
- # Extra compiler flags?
- # +U77 required for ETIME function - this is already in XFFLAGS
- #XLAPACKFLAGS="+U77"
- ;;
-
- sunos | sunos64)
- # Sun has libraries with BLAS and LAPACK invoked using
- # -xlic_lib=sunperf
- trylapack=
- tryblas=
- echo "SunOs can use the Sun Performance Library (if installed)"
- echo "which has both BLAS and LAPACK 3.0"
- echo
- echo "Looking for a valid library to use..."
- echo
- # Loop over the possible library names
- try_libs="sunperf"
- for testlib in $try_libs
- do
- if test ! "$XLAPACK_LIB" ; then
- # Try running a test compile to see if this a valid library
- if test -f testlink.f || test -f testlink ; then
- rm -f testlink*
- fi
- cat > testlink.f <<EOF
-c Test fortran program to link against library
- PROGRAM TESTLINK
- IMPLICIT NONE
- INTEGER A
- A = 1
- STOP
- END
-EOF
- test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -dalign -xlic_lib=$testlib"
- echo $test_compile
- if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
- # Compilation was okay
- echo "... -xlic_lib=$testlib is okay"
- XLAPACK_LIB="-dalign -xlic_lib=$testlib"
- # Set the next two variables so that configure
- # doesn't try to build netlib libraries
- LAPACKLIB="$testlib"
- noblas=yes
- else
- # Compilation failed
- echo "... cannot use -xlic_lib=$testlib"
- fi
- # End of test for testlib
- fi
- # End of loop over possible lib names
- done
- # Report if no suitable library was found
- if test ! "$XLAPACK_LIB" ; then
- echo
- echo "No suitable LAPACK library was found."
- echo "This may be because the Sun Performance Library is not"
- echo "installed on your system"
- echo "Contact your system administrator or Sun vendor"
- fi
- ;;
- Darwin | Darwin32 | Darwin64 )
- # Darwin has libraries with BLAS and LAPACK invoked using
- # -framework vecLib
- echo "Darwin can use the vecLib Library (if installed)"
- echo "which has both BLAS and LAPACK 3.0"
- echo
- # This is a special case so try running a test compile
- echo "Checking: try to link library against test program"
- if test -f testlink.f || test -f testlink ; then
- rm -f testlink*
- fi
- cat > testlink.f <<EOF
-c Test fortran program to link against library
- PROGRAM TESTLINK
- IMPLICIT NONE
- INTEGER A
- A = 1
- STOP
- END
-EOF
- test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -framework vecLib"
- echo $test_compile
- if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
- # Compilation was okay
- echo "... -framework vecLib is okay"
- XLAPACK_LIB="-framework vecLib"
- # Set the next two variables so that configure
- # doesn't try to build netlib libraries
- LAPACKLIB="vecLib"
- noblas=yes
- else
-#alternative linking for vecLib libraries
- case `uname -sr` in
- *Darwin\ 7.* ) test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -lcc_dynamic -Wl,-framework -Wl,vecLib" ;;
- * ) test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -Wl,-framework -Wl,vecLib" ;;
- esac
-
- echo $test_compile
- if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
- # Compilation was okay
- echo "... -framework vecLib is okay"
- XLAPACK_LIB="-Wl,-framework -Wl,vecLib"
- # Set the next two variables so that configure
- # doesn't try to build netlib libraries
- LAPACKLIB="-Wl,-framework -Wl,vecLib"
- noblas=yes
- else
- # Compilation failed
- echo "... cannot use -framework vecLib"
- echo
- fi
- fi
- trylapack=
- tryblas=
-# try the fink installation
- trydirs="${trydirs} /sw"
- ;;
- Darwin_ibm_compilers )
- # Darwin has libraries with BLAS and LAPACK invoked using
- # -framework vecLib
- echo "Darwin can use the vecLib Library (if installed)"
- echo "which has both BLAS and LAPACK 3.0"
- echo
- # This is a special case so try running a test compile
- echo "Checking: try to link library against test program"
- if test -f testlink.f || test -f testlink ; then
- rm -f testlink*
- fi
- cat > testlink.f <<EOF
-c Test fortran program to link against library
- PROGRAM TESTLINK
- IMPLICIT NONE
- INTEGER A
- A = 1
- STOP
- END
-EOF
- case `uname -sr` in
- Darwin\ 8* )
- XLAPACK_LIB="-L/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A -lLAPACK -lBLAS"
- test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f $XLAPACK_LIB"
- ;;
- Darwin\ 7* )
- XLAPACK_LIB="-L/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A -lLAPACK -lBLAS"
- test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -lcc_dynamic $XLAPACK_LIB"
- ;;
- *)
- XLAPACK_LIB="/System/Library/Frameworks/vecLib.Framework/Versions/Current/VecLib"
- test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f $XLAPACK_LIB"
- esac
- echo $test_compile
- if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
- # Compilation was okay
- echo "... -framework vecLib is okay"
- # Set the next two variables so that configure
- # doesn't try to build netlib libraries
- LAPACKLIB="vecLib"
- noblas=yes
- else
- # Compilation failed
- XLAPACK_LIB=""
- echo "... cannot use -framework vecLib"
- echo
- fi
- trylapack=
- tryblas=
-# try the fink installation
- trydirs="${trydirs} /sw"
- ;;
-
- Darwin_intel_compilers)
- # Darwin has libraries with BLAS and LAPACK invoked using
- # -F vecLib
- echo "Darwin can use the vecLib Library (if installed)"
- echo "which has both BLAS and LAPACK 3.0"
- echo
- # This is a special case so try running a test compile
- echo "Checking: try to link library against test program"
- if test -f testlink.f || test -f testlink ; then
- rm -f testlink*
- fi
- cat > testlink.f <<EOF
-c Test fortran program to link against library
- PROGRAM TESTLINK
- IMPLICIT NONE
- INTEGER A
- A = 1
- STOP
- END
-EOF
- test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -Wl,-framework -Wl,vecLib"
- echo $test_compile
- if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
- # Compilation was okay
- # doesn't try to build netlib libraries
- XLAPACK_LIB="-F /System/Library/Frameworks -Qoption,ld,-framework -Qoption,ld,vecLib"
- LAPACKLIB="vecLib"
- noblas=yes
- else
- # Compilation failed
- echo "... cannot use -framework vecLib"
- echo
- fi
- trylapack=
- tryblas=
-# try the fink installation
- trydirs="${trydirs} /sw"
- ;;
-
-# linux_ia64_sgi_altix)
-# SGI Japan
- ia64_linux_intel)
- # Additional search paths for Linux/IA64
- trydirs="${trydirs} /opt/scsl/lib /usr/lib /usr/local/lib"
- # SCSL and MKL should have both LAPACK and BLAS
- trylapack="mkl_lapack scs lapack"
- tryblas="mkl scs blas"
- ;;
- linux_ibm_compilers )
- trylapack="lapack"
- tryblas="blas"
- ;;
- linux64_ibm_compilers )
- trydirs="/usr/lib64 ${trydirs}"
- trylapack="lapack"
- tryblas="blas"
- ;;
- linux_intel_compilers )
- trydirs="/usr/lib64 ${trydirs}"
- trylapack="mkl_lapack lapack"
- tryblas="mkl blas"
- ;;
- *)
- echo "The guesses for this system may not be correct - please"
- echo "e-mail ccp4@ccp4.ac.uk if you have any extra information"
- echo
- # Default guess is just libblas
- trylapack="lapack"
- tryblas="blas"
- ;;
- esac
- #
- # Search for LAPACK libraries
- #
- # Write out what the guesses are
- if test "$trylapack" ; then
- echo "Possible LAPACK library names for this system:"
- for libname in $trylapack
- do
- echo " lib$libname"
- done
- # Possible library name extensions
- tryexts="a so dylib"
- # Now loop over all the possibilities and see if anything
- # turns up
- echo
- echo "Searching for libraries with LAPACK and BLAS:"
- for testdir in $trydirs
- do
- for testlib in $trylapack
- do
- for ext in $tryexts
- do
- if test ! "$LAPACKLIB"; then
- if test -s "$testdir/lib$testlib.$ext" ; then
- echo "...found LAPACK library: $testdir/lib$testlib.$ext"
- # Now try and link to a test program
- # This is really for IRIX where libraries can be
- # o32 or n32
- echo " Testing: try to link library against test program"
- if test -f testlink.f || test -f testlink ; then
- rm -f testlink*
- fi
- cat > testlink.f <<EOF
-c Test fortran program to link against library
- PROGRAM TESTLINK
- IMPLICIT NONE
- INTEGER A
- A = 1
- STOP
- END
-EOF
- test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -L$testdir -l$testlib"
- test_ccompile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -L$testdir -l$testlib $XLDFLAGS"
- echo $test_compile
- if { (eval $test_compile ) 2>&1; } && test -s testlink ; then
- have_lapack=yes
- else
-# cover clapack option
- echo $test_ccompile
- if { (eval $test_ccompile ) 2>&1; } && test -s testlink ; then
- have_lapack=yes
- fi
- fi
- if test x$have_lapack = xyes ; then
- # This one is okay
- LAPACKLIB="$testlib"
- LAPACKDIR="$testdir"
- echo "Link ok - using lib$LAPACKLIB from $LAPACKDIR"
- #
- XLAPACK_LIB="-L$LAPACKDIR -l$LAPACKLIB"
- #
- # Test to see if we need BLAS too
- # Do this by trying to compile a test program
- # Use the LSAME test for now
- echo
- echo " * Checking whether we need a separate BLAS library *"
- echo " Testing: try linking library against test program"
- cd lib/lapack/test
- if test -f testlsame ; then
- rm -f testsame testlsame.o
- fi
- test_compile="$FC $FOPTIM $XFFLAGS -o testlsame lsametst.f -L$LAPACKDIR -l$LAPACKLIB"
- test_ccompile="$FC $FOPTIM $XFFLAGS -o testlsame lsametst.f -L$LAPACKDIR -l$LAPACKLIB $XLDFLAGS"
- echo $test_compile
- if { ( eval $test_compile) 2>&1;} && test -s testlsame ; then
- have_blas=yes
- else
-#cblas route
- echo $test_ccompile
- if { ( eval $test_ccompile) 2>&1;} && test -s testlsame ; then
- have_blas=yes
- fi
- fi
- if test x$have_blas = xyes ; then
- echo "Test program okay - additional separate BLAS not required"
- noblas=yes
- else
- echo "Test program failed - need a separate BLAS library"
- fi
- cd ../../..
- else
- # Keep looking
- echo " link failed - cannot use lib$testlib"
- fi
- fi
- fi
- done
- done
- if test ! "$LAPACKLIB"; then
- echo "...nothing in $testdir"
- fi
- done
- fi
-
- # If LAPACKLIB hasn't been set at this point then no LAPACK library
- # was found
- if test ! "$LAPACKLIB" ; then
- echo
- echo "No pre-existing LAPACK library found - NetLib LAPACK will be built instead"
- make_lapack=lapacklib
- fi
- # Look for possible BLAS
- if test ! "$noblas" ; then
- if test "$tryblas" ; then
- echo
- echo "Possible BLAS library names for this system:"
- for libname in $tryblas
- do
- echo " lib$libname"
- done
- # Possible library name extensions
- tryexts="a so"
- # Now loop over all the possibilities and see if anything
- # turns up
- echo
- echo "Searching for libraries with BLAS:"
- for testdir in $trydirs
- do
- for testlib in $tryblas
- do
- for ext in $tryexts
- do
- if test ! "$BLASLIB"; then
- if test -s "$testdir/lib$testlib.$ext" ; then
- echo "...found BLAS library: $testdir/lib$testlib.$ext"
- # Now try and link to a test program
- # This is really for IRIX where libraries can be
- # o32 or n32
- echo " Testing: try to link library against test program"
- if test -f testlink.f || test -f testlink ; then
- rm -f testlink*
- fi
- cat > testlink.f <<EOF
-c Test fortran program to link against library
- PROGRAM TESTLINK
- IMPLICIT NONE
- INTEGER A
- A = 1
- STOP
- END
-EOF
- test_compile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -L$testdir -l$testlib"
- test_ccompile="$FC $FOPTIM $XFFLAGS -o testlink testlink.f -L$testdir -l$testlib $XLDFLAGS"
- echo $test_compile
- if { ( eval $test_compile) 2>&1;} && test -s testlink ; then
- have_blas=yes
- else
- echo $test_ccompile
- if { ( eval $test_compile) 2>&1;} && test -s testlink ; then
- have_blas=yes
- fi
- fi
- if test x$have_blas = xyes ; then
- # This one is okay
- BLASLIB="$testlib"
- BLASDIR="$testdir"
- BLASEXT="$ext"
- echo "Link ok - using lib$BLASLIB from $BLASDIR"
- XLAPACK_LIB="$XLAPACK_LIB -L$BLASDIR -l$BLASLIB"
- else
- # Keep looking
- echo " link failed - cannot use lib$testlib"
- fi
- fi
- fi
- done
- done
- if test ! "$BLASLIB"; then
- echo "...nothing in $testdir"
- fi
- done
- fi
- # Do we need to build BLAS too?
- if test ! "$BLASLIB" ; then
- echo
- echo "No pre-existing BLAS library was found - NetLib BLAS will be built instead"
- echo "This may result in poorer performance of the LAPACK routines"
- make_blas=blaslib
- BLASLIB=blas
- BLASDIR="$srcdir/lib/lapack"
- BLASEXT="a"
- fi
- fi
+ # gentoo is clever
+ make_blas=
+ make_lapack=
+ BLASLIB=$(pkg-config --libs blas)
+ LAPACKLIB=$(pkg-config --libs lapack)
+ XLAPACK_LIB="${BLASLIB} ${LAPACKLIB}"
+ XFFLAGS_LAPACK="$(pkg-config --cflags lapack blas)"
# Otherwise force building of NetLib BLAS and LAPACK libs
- else
- echo
- echo "! Force building of NetLib BLAS and LAPACK..."
- make_blas=blaslib
- make_lapack=lapacklib
- BLASLIB=blas
- BLASDIR="$srcdir/lib/lapack"
- BLASEXT="a"
- fi
# need to know if we the lapack library was linked using the C or
# fortran linker
if test -f testlink.f || test -f testlink || test -f testlink.c ; then
@@ -3916,8 +3356,8 @@ RANLIB = ${RANLIB}
INSTALL_DATA = ${INSTALL_DATA}
libdir = $libdir
#
-BLASLIB = lib${BLASLIB}.${BLASEXT}
-LAPACKLIB = liblapack.a
+BLASLIB = ${BLASLIB}
+LAPACKLIB = ${LAPACKLIB}
#
# These variables define targets in the main Makefile
blaslib = ${make_blas}
|