# Enable shared library build
# Copyright (C) 2009,2011 Georgi D. Sotirov <gdsotirov@dir.bg>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
# Visit SlackPack at http://sotirov-bg.net/slackpack/
#
# $Id: lapack-3.3.1.diff,v 1.1 2011/10/20 21:34:03 gsotirov Exp $
#

diff -urNad lapack-3.3.1-orig/SRC/Makefile lapack-3.3.1/SRC/Makefile
--- lapack-3.3.1-orig/SRC/Makefile	2011-03-07 17:11:26.000000000 +0200
+++ lapack-3.3.1/SRC/Makefile	2011-10-20 23:38:30.000000000 +0300
@@ -371,7 +371,7 @@
    zla_heamv.o zla_hercond_c.o zla_hercond_x.o zla_herpvgrw.o		\
    zla_lin_berr.o zlarscl2.o zlascl2.o zla_wwaddw.o
 
-all: ../$(LAPACKLIB)
+all: $(LAPACKLIB)
 
 ifdef USEXBLAS
 ALLXOBJ=$(SXLASRC) $(DXLASRC) $(CXLASRC) $(ZXLASRC) $(ALLXAUX)
@@ -380,9 +380,8 @@
 ALLOBJ=$(SLASRC) $(DLASRC) $(DSLASRC) $(CLASRC) $(ZLASRC) $(ZCLASRC) \
 	   $(SCLAUX) $(DZLAUX) $(ALLAUX)
 
-../$(LAPACKLIB): $(ALLOBJ) $(ALLXOBJ)
-	$(ARCH) $(ARCHFLAGS) $@ $(ALLOBJ) $(ALLXOBJ)
-	$(RANLIB) $@
+$(LAPACKLIB): $(ALLOBJ) $(ALLXOBJ)
+	$(FORTRAN) -shared -Wl,-soname=$@ -o $@ $(ALLOBJ) $(ALLXOBJ) $(BLASLIB)
 
 single: $(SLASRC) $(ALLAUX) $(SCLAUX) 
 	$(ARCH) $(ARCHFLAGS) ../$(LAPACKLIB) $(SLASRC) $(ALLAUX) \
@@ -423,7 +422,7 @@
 	@FRC=$(FRC)
 
 clean:
-	rm -f *.o
+	rm -f *.o *.so.*
 
 .f.o: 
 	$(FORTRAN) $(OPTS) -c $< -o $@
diff -urNad lapack-3.3.1-orig/make.inc.example lapack-3.3.1/make.inc.example
--- lapack-3.3.1-orig/make.inc.example	2011-04-18 23:00:50.000000000 +0300
+++ lapack-3.3.1/make.inc.example	2011-10-20 23:57:25.000000000 +0300
@@ -4,6 +4,11 @@
 #  LAPACK, Version 3.3.1                                           #
 #  April 2011                                                      #
 ####################################################################
+
+VER_MAJ = 3
+VER_MIN = 3
+VER_PATCH = 1
+
 #
 # See the INSTALL/ directory for more examples.
 #
@@ -19,11 +24,11 @@
 #  selected.  Define LOADER and LOADOPTS to refer to the loader
 #  and desired load options for your machine.
 #
-FORTRAN  = gfortran -fimplicit-none -g
-OPTS     =
+FORTRAN  = gfortran -fimplicit-none
+OPTS     = -O $(FFLAGS) -mieee-fp -fPIC
 DRVOPTS  = $(OPTS)
-NOOPT    = -g -O0
-LOADER   = gfortran -g
+NOOPT    = $(FFLAGS) -O0 -mieee-fp -ffloat-store -fPIC
+LOADER   = gfortran
 LOADOPTS =
 #
 # Timer for the SECOND and DSECND routines
@@ -33,10 +38,10 @@
 # For RS6K : SECOND and DSECND will use a call to the EXTERNAL FUNCTION ETIME_
 # TIMER    = EXT_ETIME_
 # For gfortran compiler: SECOND and DSECND will use a call to the INTERNAL FUNCTION ETIME
-# TIMER    = INT_ETIME
+TIMER    = INT_ETIME
 # If your Fortran compiler does not provide etime (like Nag Fortran Compiler, etc...)
 # SECOND and DSECND will use a call to the Fortran standard INTERNAL FUNCTION CPU_TIME 
-TIMER    = INT_CPU_TIME
+# TIMER    = INT_CPU_TIME
 # If neither of this works...you can use the NONE value... In that case, SECOND and DSECND will always return 0
 # TIMER     = NONE
 #
@@ -51,7 +56,7 @@
 #  The target's machine-specific, optimized BLAS library should be
 #  used whenever possible.
 #
-BLASLIB      = ../../blas$(PLAT).a
+BLASLIB      = -lblas
 #
 #  Location of the extended-precision BLAS (XBLAS) Fortran library
 #  used for building and testing extended-precision routines.  The
@@ -64,7 +69,7 @@
 #
 #  Names of generated libraries.
 #
-LAPACKLIB    = lapack$(PLAT).a
+LAPACKLIB    = liblapack.so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH)
 TMGLIB       = tmglib$(PLAT).a
 EIGSRCLIB    = eigsrc$(PLAT).a
 LINSRCLIB    = linsrc$(PLAT).a
