Author: Andreas Tille <tille@debian.org>
Author: Sébastien Villemot <sebastien@debian.org>
Last-Update: 2017-09-10
Description: Use Debian package for BLAS/LAPACK (instead of obsolete clapack)
 - Use -lblas instead of -lblaswr
 - Use -ltmglib instead of -ltmg
 - Do not use f2c, not needed
 - Introduce prototypes for LAPACK functions used in the package
   (those are documented in the manpages from the liblapack-doc package)
--- a/src/lib/Makefile
+++ b/src/lib/Makefile
@@ -12,29 +12,9 @@ endif
 
 ifdef CLAPACKPATH		# only do below if using CLAPACK
 
-all: liblinks phastlib
-
-sharedlib: liblinks sharedphastlib
-
-# by default, CLAPACK uses non-standard library names, which confuses
-# the compiler.  We'll just create symbolic links in ${PHAST}/lib that
-# have proper names
-liblinks: ${PHAST}/lib/liblapack.a ${PHAST}/lib/libtmg.a \
-	${PHAST}/lib/libblaswr.a 
-
-${PHAST}/lib/liblapack.a: ${CLAPACKPATH}/lapack${PLAT}.a
-	mkdir -p ${PHAST}/lib
-	${LN} -s $< $@
-
-${PHAST}/lib/libtmg.a: ${CLAPACKPATH}/tmglib${PLAT}.a
-	mkdir -p ${PHAST}/lib
-	${LN} -s $< $@
-
-${PHAST}/lib/libblaswr.a: ${CLAPACKPATH}/blas${PLAT}.a
-	mkdir -p ${PHAST}/lib
-	${LN} -s $< $@
+all: phastlib
 
-else				# no CLAPACK: links not necessary
+sharedlib: sharedphastlib
 
 all: phastlib
 
--- a/src/make-include.mk
+++ b/src/make-include.mk
@@ -120,8 +120,6 @@ ifneq ($(TARGETOS), Windows)
     # PLAT is empty for windows builds
     PLAT =
   endif
-  # F2C libraries used by CLAPACK; most users won't need to edit
-  F2CPATH = ${CLAPACKPATH}/F2CLIBS
 endif
 
 # if neither VECLIB nor CLAPACKPATH is defined, then LAPACK will be
@@ -139,8 +137,7 @@ LIBS = -lphast -framework vecLib -lc -lm
 else
 ifdef CLAPACKPATH
 ifneq ($(TARGETOS), Windows)
-  CFLAGS += -I${CLAPACKPATH}/INCLUDE -I${F2CPATH}
-  LIBS = -lphast -llapack -ltmg -lblaswr -lc -lf2c -lm
+  LIBS = -lphast -llapack -ltmglib -lblas -lc -lm
 else
   CFLAGS += -I${CLAPACKPATH}/INCLUDE -I${F2CPATH} -DPCRE_STATIC
   LIBS = -lphast -lm  ${CLAPACKPATH}/liblapack.a ${CLAPACKPATH}/libf2c.a ${CLAPACKPATH}/libblas.a
@@ -149,7 +146,6 @@ endif
 # older than 3.1.1
 #CFLAGS += -I${CLAPACKPATH} -I${F2CPATH}
 #LIBS = -lphast -llapack -ltmg -lblaswr -lc -lF77 -lI77 -lm
-LIBPATH += -L${F2CPATH} 
 
 # bypass
 else
--- a/include/external_libs.h
+++ b/include/external_libs.h
@@ -39,10 +39,27 @@
 #else
 
 #ifndef SKIP_LAPACK 
-#include <f2c.h>  
-#include <clapack.h> 
-#define LAPACK_INT integer
-#define LAPACK_DOUBLE doublereal
+
+int dgeev_(char *jobvl, char *jobvr, int *n, double *a, int *lda, double *wr,
+           double *wi, double *vl, int *ldvl, double *vr, int *ldvr,
+           double *work, int *lwork, int *info);
+
+int dgebal_(char *job, int *n, double *a, int *lda, int *ilo, int *ihi,
+            double *scale, int *info);
+
+int dgesv_(int *n, int *nrhs, double *a, int *lda, int *ipiv, double *b,
+           int *ldb, int *info);
+
+int dgebak_(char *job, char *side, int *n, int *ilo, int *ihi, double *scale,
+            int *m, double *v, int *ldv, int *info);
+
+int dgetrf_(int *m, int *n, double *a, int *lda, int *ipiv, int *info);
+
+int dgetri_(int *n, double *a, int *lda, int *ipiv, double *work, int *lwork,
+            int *info);
+
+#define LAPACK_INT int
+#define LAPACK_DOUBLE double
 #endif  /*ifndef SKIP_LAPACK */
 
 #endif  /*ifdef VECLIB */
