summaryrefslogtreecommitdiff
path: root/math/scalapack
diff options
context:
space:
mode:
Diffstat (limited to 'math/scalapack')
-rw-r--r--math/scalapack/DESCR7
-rw-r--r--math/scalapack/Makefile30
-rw-r--r--math/scalapack/PLIST7
-rw-r--r--math/scalapack/buildlink3.mk17
-rw-r--r--math/scalapack/distinfo10
-rw-r--r--math/scalapack/patches/patch-PR67-MPI-linking418
-rw-r--r--math/scalapack/patches/patch-SRC_pdtrord.f19
-rw-r--r--math/scalapack/patches/patch-SRC_pstrord.f19
-rw-r--r--math/scalapack/patches/patch-SRC_pstrsen.f22
-rw-r--r--math/scalapack/patches/patch-scalapack.pc.in15
10 files changed, 564 insertions, 0 deletions
diff --git a/math/scalapack/DESCR b/math/scalapack/DESCR
new file mode 100644
index 00000000000..61edf427634
--- /dev/null
+++ b/math/scalapack/DESCR
@@ -0,0 +1,7 @@
+ScaLAPACK, or Scalable LAPACK, is a library of high performance linear
+algebra routines for distributed memory computers supporting MPI.
+
+The complete ScaLAPACK package is freely available on netlib and
+can be obtained via the World Wide Web or anonymous ftp.
+
+ http://www.netlib.org/scalapack/
diff --git a/math/scalapack/Makefile b/math/scalapack/Makefile
new file mode 100644
index 00000000000..430a0cdcaaa
--- /dev/null
+++ b/math/scalapack/Makefile
@@ -0,0 +1,30 @@
+# $NetBSD: Makefile,v 1.1 2022/08/25 22:58:00 thor Exp $
+
+DISTNAME= scalapack-2.2.0
+CATEGORIES= math
+MASTER_SITES= http://www.netlib.org/scalapack/
+EXTRACT_SUFX= .tgz
+
+MAINTAINER= thor@NetBSD.org
+HOMEPAGE= http://www.netlib.org/scalapack/
+COMMENT= Scalable Linear Algebra PACKage
+LICENSE= modified-bsd
+
+USE_CMAKE= yes
+USE_TOOLS+= pkg-config
+USE_LANGUAGES= c fortran
+
+CMAKE_ARGS= -DBLA_PREFER_PKGCONFIG=on \
+ -DBLA_PKGCONFIG_LAPACK=${LAPACK_PC:Q} \
+ -DBLA_PKGCONFIG_BLAS=${BLAS_PC:Q} \
+ -DBUILD_SHARED_LIBS=ON
+
+TEST_TARGET= test
+TEST_ENV+= LD_LIBRARY_PATH=${WRKSRC}/lib
+
+PKGCONFIG_OVERRIDE+= scalapack.pc.in
+
+.include "../../mk/blas.buildlink3.mk"
+.include "../../mk/mpi.buildlink3.mk"
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/math/scalapack/PLIST b/math/scalapack/PLIST
new file mode 100644
index 00000000000..10903618096
--- /dev/null
+++ b/math/scalapack/PLIST
@@ -0,0 +1,7 @@
+@comment $NetBSD: PLIST,v 1.1 2022/08/25 22:58:00 thor Exp $
+lib/cmake/${PKGNAME}/scalapack-config-version.cmake
+lib/cmake/${PKGNAME}/scalapack-config.cmake
+lib/cmake/${PKGNAME}/scalapack-targets-noconfig.cmake
+lib/cmake/${PKGNAME}/scalapack-targets.cmake
+lib/libscalapack.so
+lib/pkgconfig/scalapack.pc
diff --git a/math/scalapack/buildlink3.mk b/math/scalapack/buildlink3.mk
new file mode 100644
index 00000000000..b312bb6f571
--- /dev/null
+++ b/math/scalapack/buildlink3.mk
@@ -0,0 +1,17 @@
+# $NetBSD: buildlink3.mk,v 1.1 2022/08/25 22:58:00 thor Exp $
+
+BUILDLINK_TREE+= scalapack
+
+.if !defined(SCALAPACK_BUILDLINK3_MK)
+SCALAPACK_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.scalapack+= scalapack>=2.2.0
+BUILDLINK_ABI_DEPENDS.scalapack+= scalapack>=2.2.0
+BUILDLINK_PKGSRCDIR.scalapack?= ../../math/scalapack
+
+.include "../../mk/blas.buildlink3.mk"
+.include "../../mk/mpi.buildlink3.mk"
+
+.endif # SCALAPACK_BUILDLINK3_MK
+
+BUILDLINK_TREE+= -scalapack
diff --git a/math/scalapack/distinfo b/math/scalapack/distinfo
new file mode 100644
index 00000000000..c2a8ea224ef
--- /dev/null
+++ b/math/scalapack/distinfo
@@ -0,0 +1,10 @@
+$NetBSD: distinfo,v 1.1 2022/08/25 22:58:00 thor Exp $
+
+BLAKE2s (scalapack-2.2.0.tgz) = deff6c2cbd5993fa07333191f223995bfcdf55d65d30089970b976a97b2d9ccf
+SHA512 (scalapack-2.2.0.tgz) = 1e6c69a4faab8165c273479ff8b63e98df6a7253cffc524b5700d0344c3f89c52c5bccc5d3a9a9bded4d9da50080123abd8340b75e1f92317e471c4375704999
+Size (scalapack-2.2.0.tgz) = 4769286 bytes
+SHA1 (patch-PR67-MPI-linking) = 704d77790bcf5d73203a8d7a86161230d650e23c
+SHA1 (patch-SRC_pdtrord.f) = 7c51c59c4f570020595904e964901e27ec45e2c4
+SHA1 (patch-SRC_pstrord.f) = 1ca9fd5d3520b5ecb030f3e07fc0f13f1bbc8a2d
+SHA1 (patch-SRC_pstrsen.f) = 5956f03bae7ad44861a9b7776a1cb7a8438483fb
+SHA1 (patch-scalapack.pc.in) = c6a2b9068b89ecdf2b26263117b37761fdf14808
diff --git a/math/scalapack/patches/patch-PR67-MPI-linking b/math/scalapack/patches/patch-PR67-MPI-linking
new file mode 100644
index 00000000000..297c54bc900
--- /dev/null
+++ b/math/scalapack/patches/patch-PR67-MPI-linking
@@ -0,0 +1,418 @@
+$NetBSD: patch-PR67-MPI-linking,v 1.1 2022/08/25 22:58:01 thor Exp $
+
+This includes upstream PR67 and the version fix, to be removed
+on update to next upstream release after 2.2.0. It modifies several
+files, as it would not make sense to have lots of separate patches
+for this one thing.
+
+diff -ru ../scalapack-2.2.0/BLACS/CMakeLists.txt ./BLACS/CMakeLists.txt
+--- ../scalapack-2.2.0/BLACS/CMakeLists.txt 2021-10-12 21:09:12.000000000 +0200
++++ ./BLACS/CMakeLists.txt 2022-07-19 10:33:55.051376486 +0200
+@@ -1,4 +1,4 @@
+ add_subdirectory(SRC)
+-if(${SCALAPACK_BUILD_TESTING})
++if(${SCALAPACK_BUILD_TESTS})
+ add_subdirectory(TESTING)
+ endif()
+diff -ru ../scalapack-2.2.0/BLACS/TESTING/CMakeLists.txt ./BLACS/TESTING/CMakeLists.txt
+--- ../scalapack-2.2.0/BLACS/TESTING/CMakeLists.txt 2021-10-12 21:09:12.000000000 +0200
++++ ./BLACS/TESTING/CMakeLists.txt 2022-07-19 16:20:28.028299214 +0200
+@@ -6,7 +6,7 @@
+ endif()
+
+ add_executable(xFbtest ${FTestObj})
+-target_link_libraries(xFbtest scalapack)
++target_link_libraries(xFbtest scalapack MPI::MPI_Fortran)
+
+ set(CTestObj
+ Cbt.c)
+@@ -17,7 +17,7 @@
+ )
+
+ add_executable(xCbtest ${CTestObj} ${FTestObj})
+-target_link_libraries(xCbtest scalapack)
++target_link_libraries(xCbtest scalapack MPI::MPI_Fortran)
+
+ file(COPY bsbr.dat DESTINATION ${SCALAPACK_BINARY_DIR}/BLACS/TESTING)
+ file(COPY bt.dat DESTINATION ${SCALAPACK_BINARY_DIR}/BLACS/TESTING)
+Only in ./BLACS/TESTING: CMakeLists.txt.orig
+diff -ru ../scalapack-2.2.0/CMakeLists.txt ./CMakeLists.txt
+--- ../scalapack-2.2.0/CMakeLists.txt 2021-10-12 21:09:12.000000000 +0200
++++ ./CMakeLists.txt 2022-07-20 16:30:35.443344793 +0200
+@@ -1,4 +1,4 @@
+-cmake_minimum_required(VERSION 3.2)
++cmake_minimum_required(VERSION 3.9)
+ project(SCALAPACK C Fortran)
+ # Configure the warning and code coverage suppression file
+ configure_file(
+@@ -27,8 +27,7 @@
+ find_package(MPI)
+ if (MPI_FOUND)
+ message(STATUS "Found MPI_LIBRARY : ${MPI_FOUND} ")
+- INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
+-
++
+ find_program(MPI_C_COMPILER
+ NAMES mpicc
+ HINTS "${MPI_BASE_DIR}"
+@@ -232,14 +231,14 @@
+
+ if (UNIX)
+ add_library(scalapack ${blacs} ${tools} ${tools-C} ${extra_lapack} ${pblas} ${pblas-F} ${ptzblas} ${ptools} ${pbblas} ${redist} ${src} ${src-C})
+- target_link_libraries( scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++ target_link_libraries( scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_C)
+ scalapack_install_library(scalapack)
+ else (UNIX) # Need to separate Fortran and C Code
+ OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON )
+ add_library(scalapack ${blacs} ${tools-C} ${pblas} ${ptools} ${redist} ${src-C})
+- target_link_libraries( scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++ target_link_libraries( scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_C)
+ add_library(scalapack-F ${pblas-F} ${pbblas} ${ptzblas} ${tools} ${src} ${extra_lapack} )
+- target_link_libraries( scalapack-F ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++ target_link_libraries( scalapack-F ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
+ scalapack_install_library(scalapack)
+ scalapack_install_library(scalapack-F)
+ endif (UNIX)
+@@ -255,9 +254,9 @@
+ SET(CPACK_PACKAGE_NAME "ScaLAPACK")
+ SET(CPACK_PACKAGE_VENDOR "University of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd")
+ SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "ScaLAPACK- Linear Algebra Package")
+-set(SCALAPACK_VERSION 2.1.0)
++set(SCALAPACK_VERSION 2.2.0)
+ set(CPACK_PACKAGE_VERSION_MAJOR 2)
+-set(CPACK_PACKAGE_VERSION_MINOR 1)
++set(CPACK_PACKAGE_VERSION_MINOR 2)
+ set(CPACK_PACKAGE_VERSION_PATCH 0)
+ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
+ SET(CPACK_PACKAGE_INSTALL_DIRECTORY "SCALAPACK")
+Only in .: CMakeLists.txt.orig
+diff -ru ../scalapack-2.2.0/PBLAS/CMakeLists.txt ./PBLAS/CMakeLists.txt
+--- ../scalapack-2.2.0/PBLAS/CMakeLists.txt 2021-10-12 21:09:12.000000000 +0200
++++ ./PBLAS/CMakeLists.txt 2022-07-19 10:33:55.052376486 +0200
+@@ -1,5 +1,5 @@
+ add_subdirectory(SRC)
+-if(${SCALAPACK_BUILD_TESTING})
++if(${SCALAPACK_BUILD_TESTS})
+ add_subdirectory(TESTING)
+ add_subdirectory(TIMING)
+ endif()
+diff -ru ../scalapack-2.2.0/PBLAS/TESTING/CMakeLists.txt ./PBLAS/TESTING/CMakeLists.txt
+--- ../scalapack-2.2.0/PBLAS/TESTING/CMakeLists.txt 2021-10-12 21:09:12.000000000 +0200
++++ ./PBLAS/TESTING/CMakeLists.txt 2022-07-19 16:21:42.412306092 +0200
+@@ -44,20 +44,20 @@
+ add_executable(cpb3tst pcblas3tst.f ${cpbtcom})
+ add_executable(zpb3tst pzblas3tst.f ${zpbtcom})
+
+-target_link_libraries(spb1tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(dpb1tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(cpb1tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(zpb1tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++target_link_libraries(spb1tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(dpb1tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(cpb1tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(zpb1tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
+
+-target_link_libraries(spb2tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(dpb2tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(cpb2tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(zpb2tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++target_link_libraries(spb2tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(dpb2tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(cpb2tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(zpb2tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
+
+-target_link_libraries(spb3tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(dpb3tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(cpb3tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(zpb3tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++target_link_libraries(spb3tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(dpb3tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(cpb3tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(zpb3tst scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
+
+ add_test(spb1tst ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ./spb1tst)
+ add_test(dpb1tst ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ./dpb1tst)
+Only in ./PBLAS/TESTING: CMakeLists.txt.orig
+diff -ru ../scalapack-2.2.0/PBLAS/TIMING/CMakeLists.txt ./PBLAS/TIMING/CMakeLists.txt
+--- ../scalapack-2.2.0/PBLAS/TIMING/CMakeLists.txt 2021-10-12 21:09:12.000000000 +0200
++++ ./PBLAS/TIMING/CMakeLists.txt 2022-07-19 16:22:31.291310612 +0200
+@@ -44,20 +44,20 @@
+ add_executable(cpb3tim pcblas3tim.f ${cpbtcom})
+ add_executable(zpb3tim pzblas3tim.f ${zpbtcom})
+
+-target_link_libraries(spb1tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(dpb1tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(cpb1tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(zpb1tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++target_link_libraries(spb1tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(dpb1tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(cpb1tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(zpb1tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
+
+-target_link_libraries(spb2tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(dpb2tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(cpb2tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(zpb2tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++target_link_libraries(spb2tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(dpb2tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(cpb2tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(zpb2tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
+
+-target_link_libraries(spb3tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(dpb3tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(cpb3tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(zpb3tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++target_link_libraries(spb3tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(dpb3tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(cpb3tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(zpb3tim scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
+
+ add_test(spb1tim ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ./spb1tim)
+ add_test(dpb1tim ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ./dpb1tim)
+Only in ./PBLAS/TIMING: CMakeLists.txt.orig
+diff -ru ../scalapack-2.2.0/REDIST/CMakeLists.txt ./REDIST/CMakeLists.txt
+--- ../scalapack-2.2.0/REDIST/CMakeLists.txt 2021-10-12 21:09:12.000000000 +0200
++++ ./REDIST/CMakeLists.txt 2022-07-19 10:33:55.052376486 +0200
+@@ -1,4 +1,4 @@
+ add_subdirectory(SRC)
+-if(${SCALAPACK_BUILD_TESTING})
++if(${SCALAPACK_BUILD_TESTS})
+ add_subdirectory(TESTING)
+ endif()
+diff -ru ../scalapack-2.2.0/REDIST/TESTING/CMakeLists.txt ./REDIST/TESTING/CMakeLists.txt
+--- ../scalapack-2.2.0/REDIST/TESTING/CMakeLists.txt 2021-10-12 21:09:12.000000000 +0200
++++ ./REDIST/TESTING/CMakeLists.txt 2022-07-19 16:14:17.879264986 +0200
+@@ -15,17 +15,17 @@
+ add_executable(xctrmr pctrmrdrv.c)
+ add_executable(xztrmr pztrmrdrv.c)
+
+-target_link_libraries(xigemr scalapack )
+-target_link_libraries(xsgemr scalapack )
+-target_link_libraries(xdgemr scalapack )
+-target_link_libraries(xcgemr scalapack )
+-target_link_libraries(xzgemr scalapack )
++target_link_libraries(xigemr scalapack MPI::MPI_Fortran )
++target_link_libraries(xsgemr scalapack MPI::MPI_Fortran )
++target_link_libraries(xdgemr scalapack MPI::MPI_Fortran )
++target_link_libraries(xcgemr scalapack MPI::MPI_Fortran )
++target_link_libraries(xzgemr scalapack MPI::MPI_Fortran )
+
+-target_link_libraries(xitrmr scalapack )
+-target_link_libraries(xstrmr scalapack )
+-target_link_libraries(xdtrmr scalapack )
+-target_link_libraries(xctrmr scalapack )
+-target_link_libraries(xztrmr scalapack )
++target_link_libraries(xitrmr scalapack MPI::MPI_Fortran )
++target_link_libraries(xstrmr scalapack MPI::MPI_Fortran )
++target_link_libraries(xdtrmr scalapack MPI::MPI_Fortran )
++target_link_libraries(xctrmr scalapack MPI::MPI_Fortran )
++target_link_libraries(xztrmr scalapack MPI::MPI_Fortran )
+
+ #add_test(xigemr ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ./xigemr)
+ #add_test(xsgemr ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ./xsgemr)
+Only in ./REDIST/TESTING: CMakeLists.txt.orig
+diff -ru ../scalapack-2.2.0/TESTING/EIG/CMakeLists.txt ./TESTING/EIG/CMakeLists.txt
+--- ../scalapack-2.2.0/TESTING/EIG/CMakeLists.txt 2021-10-12 21:09:12.000000000 +0200
++++ ./TESTING/EIG/CMakeLists.txt 2022-07-19 16:19:40.461294815 +0200
+@@ -53,49 +53,49 @@
+ add_executable(xshseqr pshseqrdriver.f psmatgen2.f ${cmatgen})
+ add_executable(xdhseqr pdhseqrdriver.f pdmatgen2.f ${cmatgen})
+
+-target_link_libraries(xsbrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdbrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcbrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzbrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xshrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdhrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xchrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzhrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xstrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdtrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xctrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xztrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xssvd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdsvd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xssep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xsgsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdgsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcgsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzgsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xsnep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdnep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcnep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xznep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xcevc scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzevc scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xssyevr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdsyevr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcheevr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzheevr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++target_link_libraries(xsbrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdbrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcbrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzbrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xshrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdhrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xchrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzhrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xstrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdtrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xctrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xztrd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xssvd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdsvd scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xssep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xsgsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdgsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcgsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzgsep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xsnep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdnep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcnep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xznep scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xcevc scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzevc scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xssyevr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdsyevr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcheevr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzheevr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
+
+-target_link_libraries(xshseqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdhseqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++target_link_libraries(xshseqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdhseqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
+
+ if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
+ set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -std=legacy" ) # local to this directory
+Only in ./TESTING/EIG: CMakeLists.txt.orig
+diff -ru ../scalapack-2.2.0/TESTING/LIN/CMakeLists.txt ./TESTING/LIN/CMakeLists.txt
+--- ../scalapack-2.2.0/TESTING/LIN/CMakeLists.txt 2021-10-12 21:09:12.000000000 +0200
++++ ./TESTING/LIN/CMakeLists.txt 2022-07-19 16:16:53.702279395 +0200
+@@ -61,55 +61,55 @@
+ add_executable(xzls pzlsdriver.f pzlsinfo.f pzqrt13.f pzqrt14.f pzqrt16.f pzqrt17.f ${zmatgen})
+
+
+-target_link_libraries(xslu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xclu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xsdblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xddblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcdblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzdblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xsdtlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xddtlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcdtlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzdtlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xsgblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdgblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcgblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzgblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xsllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xspbllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdpbllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcpbllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzpbllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xsptllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdptllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcptllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzptllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xsinv scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdinv scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcinv scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzinv scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xsqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-
+-target_link_libraries(xsls scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xdls scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xcls scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
+-target_link_libraries(xzls scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++target_link_libraries(xslu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xclu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xsdblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xddblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcdblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzdblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xsdtlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xddtlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcdtlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzdtlu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xsgblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdgblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcgblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzgblu scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xsllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xspbllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdpbllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcpbllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzpbllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xsptllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdptllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcptllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzptllt scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xsinv scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdinv scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcinv scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzinv scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xsqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzqr scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++
++target_link_libraries(xsls scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xdls scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xcls scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
++target_link_libraries(xzls scalapack ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} MPI::MPI_Fortran)
+
+ if ("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
+ set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -std=legacy" ) # local to this directory
+Only in ./TESTING/LIN: CMakeLists.txt.orig
diff --git a/math/scalapack/patches/patch-SRC_pdtrord.f b/math/scalapack/patches/patch-SRC_pdtrord.f
new file mode 100644
index 00000000000..7779a526988
--- /dev/null
+++ b/math/scalapack/patches/patch-SRC_pdtrord.f
@@ -0,0 +1,19 @@
+$NetBSD: patch-SRC_pdtrord.f,v 1.1 2022/08/25 22:58:01 thor Exp $
+
+upstream gcc10 build fix, commit a0f76fc0c1c16646875b454b7d6f8d9d17726b5a
+
+--- SRC/pdtrord.f.orig 2021-10-12 19:09:12.000000000 +0000
++++ SRC/pdtrord.f
+@@ -487,10 +487,10 @@
+ MMAX( 1 ) = M
+ MMIN( 1 ) = M
+ IF( NPROCS.GT.1 )
+- $ CALL IGAMX2D( ICTXT, 'All', TOP, 1, 1, MMAX, 1, -1,
++ $ CALL IGAMX2D( ICTXT, 'All', TOP, 1, 1, MMAX( 1 ), 1, -1,
+ $ -1, -1, -1, -1 )
+ IF( NPROCS.GT.1 )
+- $ CALL IGAMN2D( ICTXT, 'All', TOP, 1, 1, MMIN, 1, -1,
++ $ CALL IGAMN2D( ICTXT, 'All', TOP, 1, 1, MMIN( 1 ), 1, -1,
+ $ -1, -1, -1, -1 )
+ IF( MMAX( 1 ).GT.MMIN( 1 ) ) THEN
+ M = MMAX( 1 )
diff --git a/math/scalapack/patches/patch-SRC_pstrord.f b/math/scalapack/patches/patch-SRC_pstrord.f
new file mode 100644
index 00000000000..d914985221d
--- /dev/null
+++ b/math/scalapack/patches/patch-SRC_pstrord.f
@@ -0,0 +1,19 @@
+$NetBSD: patch-SRC_pstrord.f,v 1.1 2022/08/25 22:58:01 thor Exp $
+
+upstream gcc10 build fix, commit a0f76fc0c1c16646875b454b7d6f8d9d17726b5a
+
+--- SRC/pstrord.f.orig 2021-10-12 19:09:12.000000000 +0000
++++ SRC/pstrord.f
+@@ -487,10 +487,10 @@
+ MMAX( 1 ) = M
+ MMIN( 1 ) = M
+ IF( NPROCS.GT.1 )
+- $ CALL IGAMX2D( ICTXT, 'All', TOP, 1, 1, MMAX, 1, -1,
++ $ CALL IGAMX2D( ICTXT, 'All', TOP, 1, 1, MMAX( 1 ), 1, -1,
+ $ -1, -1, -1, -1 )
+ IF( NPROCS.GT.1 )
+- $ CALL IGAMN2D( ICTXT, 'All', TOP, 1, 1, MMIN, 1, -1,
++ $ CALL IGAMN2D( ICTXT, 'All', TOP, 1, 1, MMIN( 1 ), 1, -1,
+ $ -1, -1, -1, -1 )
+ IF( MMAX( 1 ).GT.MMIN( 1 ) ) THEN
+ M = MMAX( 1 )
diff --git a/math/scalapack/patches/patch-SRC_pstrsen.f b/math/scalapack/patches/patch-SRC_pstrsen.f
new file mode 100644
index 00000000000..37ad7d6786b
--- /dev/null
+++ b/math/scalapack/patches/patch-SRC_pstrsen.f
@@ -0,0 +1,22 @@
+$NetBSD: patch-SRC_pstrsen.f,v 1.1 2022/08/25 22:58:01 thor Exp $
+
+upstream gcc10 build fix, commit a0f76fc0c1c16646875b454b7d6f8d9d17726b5a
+
+--- SRC/pstrsen.f.orig 2021-10-12 19:09:12.000000000 +0000
++++ SRC/pstrsen.f
+@@ -526,11 +526,11 @@
+ MMAX( 1 ) = M
+ MMIN( 1 ) = M
+ IF( NPROCS.GT.1 )
+- $ CALL IGAMX2D( ICTXT, 'All', TOP, 1, 1, MMAX, 1, -1,
+- $ -1, -1, -1, -1 )
++ $ CALL IGAMX2D( ICTXT, 'All', TOP, 1, 1, MMAX( 1 ), 1, -1,
++ $ -1, -1, -1, -1 )
+ IF( NPROCS.GT.1 )
+- $ CALL IGAMN2D( ICTXT, 'All', TOP, 1, 1, MMIN, 1, -1,
+- $ -1, -1, -1, -1 )
++ $ CALL IGAMN2D( ICTXT, 'All', TOP, 1, 1, MMIN( 1 ), 1, -1,
++ $ -1, -1, -1, -1 )
+ IF( MMAX( 1 ).GT.MMIN( 1 ) ) THEN
+ M = MMAX( 1 )
+ IF( NPROCS.GT.1 )
diff --git a/math/scalapack/patches/patch-scalapack.pc.in b/math/scalapack/patches/patch-scalapack.pc.in
new file mode 100644
index 00000000000..d0d00a08773
--- /dev/null
+++ b/math/scalapack/patches/patch-scalapack.pc.in
@@ -0,0 +1,15 @@
+$NetBSD: patch-scalapack.pc.in,v 1.1 2022/08/25 22:58:01 thor Exp $
+
+Do not assume fixed names for MPI and BLAS dependency pkg-config
+packages. They can vary.
+
+--- scalapack.pc.in.orig 2021-10-12 19:09:12.000000000 +0000
++++ scalapack.pc.in
+@@ -5,5 +5,5 @@ Name: scalapack
+ Description: SCALAPACK reference implementation
+ Version: @SCALAPACK_VERSION@
+ URL: http://www.netlib.org/scalapack/
+ Libs: -L${libdir} -lscalapack
+-Requires: mpi lapack blas
++Requires: @BLA_PKGCONFIG_LAPACK@ @BLA_PKGCONFIG_BLAS@
++Libs.private: @MPI_LIBRARIES@