So I've finally gotten MDAnalysis (a python module which relies on LAPACK) to work with custom LAPACK shared library. It makes me wonder what other functions are missing from the lapack libs that numpy/scipy compile against by default. But I think numpy/scipy compile lapack functions statically; so they should be optimized if you compile them from source.
In any case, I worked on
LAPACK version 3.3.0 and had to modify the following make related files:
(1) {root}/make.inc
(2) {root}/SRC/Makefile
(3) {root}/BLAS/SRC/Makefile
(4) {root}/Makefile
Where {root} is your extraction path.
(1) For {root}/make.inc:
At minimum, add
"-fPIC" to the configuration variables listed below.
FORTRAN
OPTS
LOADER
I also appended
"-02 -pipe" for optimization and speedier compilation on to FORTRAN and LOADER
For ease of installation, I added a new varaible, PREFIX, which designates the installation path:
#INSTALLATION PATH
PREFIX=/home/group/shared_libraries/centos64/pkgs/lapack/3.3.0/
(2) For {root}/SRC/Makefile:
Update the main target:
all: ../$(LAPACKLIB) liblapack.so
Add the following build target and rule
liblapack.so: $(ALLOBJ)
gfortran -shared -Wl,-soname,$@ -o $@ $(ALLOBJ)
And you'll need to remove some redundancy from the object files list:
#DSLASRC = spotrs.o sgetrs.o spotrf.o sgetrf.o
DSLASRC = spotrs.o sgetrs.o sgetrf.o
#ZCLASRC = cpotrs.o cgetrs.o cpotrf.o cgetrf.o
ZCLASRC =(3) For {root}/BLAS/SRC/Makefile:
Update the main target to read as follows
all: $(BLASLIB) libblas.so
Of course, you can create an alias in the {root}/make.inc for BLASLIBSO = libblas.so
Now add the new target:
libblas.so: $(ALLOBJ)
gfortran -shared -Wl,-soname,$@ -o $@ $(ALLOBJ)
(4) For {root}/Makefile
Added an install rule which depends on the PREFIX setting from make.inc:
install: all
cp BLAS/SRC/libblas.so $(PREFIX)/lib
cp SRC/liblapack.so $(PREFIX)/lib
cp *.a $(PREFIX)/lib
That's it!