summaryrefslogtreecommitdiff
path: root/math/lapack
diff options
context:
space:
mode:
authorbacon <bacon@pkgsrc.org>2020-10-12 21:51:57 +0000
committerbacon <bacon@pkgsrc.org>2020-10-12 21:51:57 +0000
commitafefcaa6e54efd2e5b8f95abf655d5d040ae36be (patch)
tree301b42c86078439d0507aa5e1cb691c3fb6da5d2 /math/lapack
parent064b357d6f40e50256ec30d40eeb2381a21baa63 (diff)
downloadpkgsrc-afefcaa6e54efd2e5b8f95abf655d5d040ae36be.tar.gz
math/blas, math/lapack: Install interchangeable BLAS system
Install the new interchangeable BLAS system created by Thomas Orgis, currently supporting Netlib BLAS/LAPACK, OpenBLAS, cblas, lapacke, and Apple's Accelerate.framework. This system allows the user to select any BLAS implementation without modifying packages or using package options, by setting PKGSRC_BLAS_TYPES in mk.conf. See mk/blas.buildlink3.mk for details. This commit should not alter behavior of existing packages as the system defaults to Netlib BLAS/LAPACK, which until now has been the only supported implementation. Details: Add new mk/blas.buildlink3.mk for inclusion in dependent packages Install compatible Netlib math/blas and math/lapack packages Update math/blas and math/lapack MAINTAINER approved by adam@ OpenBLAS, cblas, and lapacke will follow in separate commits Update direct dependents to use mk/blas.buildlink3.mk Perform recursive revbump
Diffstat (limited to 'math/lapack')
-rw-r--r--math/lapack/DESCR12
-rw-r--r--math/lapack/Makefile22
-rw-r--r--math/lapack/Makefile.common57
-rw-r--r--math/lapack/PLIST8
-rw-r--r--math/lapack/buildlink3.mk9
-rw-r--r--math/lapack/distinfo20
-rw-r--r--math/lapack/patches/patch-BLAS_SRC_CMakeLists.txt18
-rw-r--r--math/lapack/patches/patch-CBLAS_cblas.pc.in13
-rw-r--r--math/lapack/patches/patch-CBLAS_src_CMakeLists.txt25
-rw-r--r--math/lapack/patches/patch-CMakeLists.txt153
-rw-r--r--math/lapack/patches/patch-LAPACKE_CMakeLists.txt46
-rw-r--r--math/lapack/patches/patch-LAPACKE_lapacke.pc.in13
-rw-r--r--math/lapack/patches/patch-SRC_CMakeLists.txt30
-rw-r--r--math/lapack/patches/patch-TESTING_MATGEN_CMakeLists.txt21
-rw-r--r--math/lapack/patches/patch-TESTING_dbal.in14
-rw-r--r--math/lapack/version.mk3
16 files changed, 394 insertions, 70 deletions
diff --git a/math/lapack/DESCR b/math/lapack/DESCR
index 72e7874eff6..0ae22553729 100644
--- a/math/lapack/DESCR
+++ b/math/lapack/DESCR
@@ -1,3 +1,11 @@
+The BLAS (Basic Linear Algebra Subprograms) are high quality "building
+block" routines for performing basic vector and matrix
+operations. Level 1 BLAS do vector-vector operations, Level 2 BLAS do
+matrix-vector operations, and Level 3 BLAS do matrix-matrix
+operations. Because the BLAS are efficient, portable, and widely
+available, they're commonly used in the development of high quality
+linear algebra software, LINPACK and LAPACK for example.
+
LAPACK is a highly portable Fortran 77 library which provides routines
for solving systems of simultaneous linear equations, least-squares
solutions of linear systems of equations, eigenvalue problems, and
@@ -8,3 +16,7 @@ and estimating condition numbers. Dense and banded matrices are
handled, but not general sparse matrices. In all areas, similar
functionality is provided for real and complex matrices, in both
single and double precision.
+
+This package contains the Fortran 77 reference implementation of BLAS
+and LAPACK from Netlib. The C wrappers CBLAS and LAPACKE are provided
+in separate packages.
diff --git a/math/lapack/Makefile b/math/lapack/Makefile
index 4af306f3fe8..75866356e9d 100644
--- a/math/lapack/Makefile
+++ b/math/lapack/Makefile
@@ -1,13 +1,19 @@
-# $NetBSD: Makefile,v 1.40 2020/02/28 21:48:53 plunky Exp $
+# $NetBSD: Makefile,v 1.41 2020/10/12 21:51:57 bacon Exp $
-.include "Makefile.common"
+MAINTAINER= thomas.orgis@uni-hamburg.de
+COMMENT= Linear Algebra PACKage (Netlib reference implementation)
+PKGREVISION= 1
-COMMENT= Linear Algebra PACKage
-
-# use external blas
-CMAKE_ARGS+= -DBLAS_LIBRARIES:STRING=${BLAS_LIBS}
-
-BUILD_TARGET= lapack
+LAPACK_COMPONENT= lapack
+LAPACK_COMPONENT_CMAKE_ARGS= \
+ -DUSE_OPTIMIZED_BLAS=ON \
+ -DBLAS_LIBRARIES=${BLAS_LIBS:Q} \
+ -DUSE_OPTIMIZED_LAPACK=OFF \
+ -DCBLAS=OFF -DLAPACKE=OFF -DLAPACK=ON
+# This always uses Netlib BLAS. Other optimized BLAS packages bring
+# their own LAPACK, hence cblas and lapacke packages use
+# mk/blas.buildlink3.mk instead.
.include "../../math/blas/buildlink3.mk"
+.include "../../math/lapack/Makefile.common"
.include "../../mk/bsd.pkg.mk"
diff --git a/math/lapack/Makefile.common b/math/lapack/Makefile.common
index d601b489f76..cfe81228474 100644
--- a/math/lapack/Makefile.common
+++ b/math/lapack/Makefile.common
@@ -1,46 +1,43 @@
-# $NetBSD: Makefile.common,v 1.11 2020/02/28 21:48:53 plunky Exp $
+# $NetBSD: Makefile.common,v 1.12 2020/10/12 21:51:57 bacon Exp $
# used by math/blas/Makefile
+# used by math/cblas/Makefile
+# used by math/lapacke/Makefile
# used by math/lapack/Makefile
-DISTNAME= lapack-3.9.0
+# Common Makefile for packages derived from the Netlib BLAS/LAPACK sources.
+# Package Makefile sets LAPACK_COMPONENT and LAPACK_COMPONENT_CMAKE_ARGS to
+# choose the library to install.
+# LAPACK_COMPONENT can be "lapack", "lapacke", or "cblas"
+
+DISTNAME= lapack-${NETLIB_BLAS_VERSION}
+PKGNAME= ${LAPACK_COMPONENT}-${NETLIB_BLAS_VERSION}
CATEGORIES= math
-MASTER_SITES= ${MASTER_SITE_NETLIB:=lapack/}
-EXTRACT_SUFX= .tgz
+MASTER_SITES= ${MASTER_SITE_GITHUB:=Reference-LAPACK/}
+GITHUB_PROJECT= lapack
+GITHUB_TAG= v${NETLIB_BLAS_VERSION}
-MAINTAINER= adam@NetBSD.org
HOMEPAGE= https://www.netlib.org/lapack/
LICENSE= modified-bsd
-DISTINFO_FILE= ${.CURDIR}/../../math/lapack/distinfo
+# All parts are in the same section
PATCHDIR= ${.CURDIR}/../../math/lapack/patches
+DISTINFO_FILE= ${.CURDIR}/../../math/lapack/distinfo
USE_LANGUAGES= c fortran
USE_CMAKE= yes
-OBJDIR= obj
-
-CONFIGURE_DIRS= ${OBJDIR}
-CMAKE_ARG_PATH= ..
-CMAKE_ARGS+= -DBUILD_SHARED_LIBS:BOOL=ON
-CMAKE_ARGS+= -DBUILD_DEPRECATED:BOOL=ON
-CMAKE_ARGS+= -DBUILD_TESTING:BOOL=ON
-
-TEST_TARGET= all test
-TEST_ENV= LD_LIBRARY_PATH=${WRKSRC}/${OBJDIR}/lib
-
-pre-configure:
- cd ${WRKSRC} && ${MKDIR} ${OBJDIR}
-
-do-install:
- cd ${WRKSRC}/${OBJDIR} && \
- ${PKGSRC_SETENV} ${INSTALL_ENV} ${MAKE_ENV} \
- ${CMAKE} -DCMAKE_INSTALL_COMPONENT=RuntimeLibraries \
- -P cmake_install.cmake
+WRKSRC= ${WRKDIR}/${DISTNAME}
+CONFIGURE_DIRS= build
+CMAKE_ARG_PATH= ${WRKSRC}
-INSTALLATION_DIRS= lib
+# Note: We patch the build to install both static and
+# shared libraries.
+CMAKE_ARGS= -DBUILD_DEPRECATED=ON \
+ -DBUILD_SHARED_LIBS=ON \
+ -DBUILD_STATIC_LIBS=ON \
+ ${LAPACK_COMPONENT_CMAKE_ARGS}
-# blas fails using the gold linker with:
-# fatal error: --sysroot=: must take a non-empty argument
-# Work around it on DragonFly by specifying the classic gnu linker
+.include "../../math/lapack/version.mk"
-MAKE_ENV.DragonFly+= LDVER=ld.bfd
+post-extract:
+ ${RUN} ${MKDIR} ${WRKSRC}/build
diff --git a/math/lapack/PLIST b/math/lapack/PLIST
index 1e08f1ec9c7..9b1dfa08dcc 100644
--- a/math/lapack/PLIST
+++ b/math/lapack/PLIST
@@ -1,4 +1,10 @@
-@comment $NetBSD: PLIST,v 1.4 2020/02/28 21:48:53 plunky Exp $
+@comment $NetBSD: PLIST,v 1.5 2020/10/12 21:51:57 bacon Exp $
+lib/cmake/lapack-${PKGVERSION}/lapack-config-version.cmake
+lib/cmake/lapack-${PKGVERSION}/lapack-config.cmake
+lib/cmake/lapack-${PKGVERSION}/lapack-targets-release.cmake
+lib/cmake/lapack-${PKGVERSION}/lapack-targets.cmake
+lib/liblapack.a
lib/liblapack.so
lib/liblapack.so.3
lib/liblapack.so.${PKGVERSION}
+lib/pkgconfig/lapack.pc
diff --git a/math/lapack/buildlink3.mk b/math/lapack/buildlink3.mk
index 1eb9492d3d5..c463c2a06cb 100644
--- a/math/lapack/buildlink3.mk
+++ b/math/lapack/buildlink3.mk
@@ -1,13 +1,16 @@
-# $NetBSD: buildlink3.mk,v 1.9 2009/03/20 19:24:57 joerg Exp $
+# $NetBSD: buildlink3.mk,v 1.10 2020/10/12 21:51:57 bacon Exp $
BUILDLINK_TREE+= lapack
.if !defined(LAPACK_BUILDLINK3_MK)
LAPACK_BUILDLINK3_MK:=
-BUILDLINK_API_DEPENDS.lapack+= lapack>=3.1.1
-BUILDLINK_ABI_DEPENDS.lapack+= lapack>=3.1.1
+BUILDLINK_API_DEPENDS.lapack+= lapack>=3.9.0
+BUILDLINK_ABI_DEPENDS.lapack+= lapack>=3.9.0nb1
BUILDLINK_PKGSRCDIR.lapack?= ../../math/lapack
+
+.include "../../math/blas/buildlink3.mk"
+
.endif # LAPACK_BUILDLINK3_MK
BUILDLINK_TREE+= -lapack
diff --git a/math/lapack/distinfo b/math/lapack/distinfo
index 6f1d7660b54..63328f7d698 100644
--- a/math/lapack/distinfo
+++ b/math/lapack/distinfo
@@ -1,8 +1,14 @@
-$NetBSD: distinfo,v 1.22 2020/02/28 21:48:53 plunky Exp $
+$NetBSD: distinfo,v 1.23 2020/10/12 21:51:57 bacon Exp $
-SHA1 (lapack-3.9.0.tgz) = 9da5f17521260e9f0cfefd9dfc5616d9ef10efb0
-RMD160 (lapack-3.9.0.tgz) = 136c181f31fd056956a96cec723ceb5a4fdf3feb
-SHA512 (lapack-3.9.0.tgz) = 90c2c8372c2567b15c25653ed64e7c86a2cb0f1dda116f33716c6877490415210217af5badb67cb50e9d428f56ff83d33a3dad60b6ed7d31919164f6e7e98e0f
-Size (lapack-3.9.0.tgz) = 9347104 bytes
-SHA1 (patch-TESTING_MATGEN_CMakeLists.txt) = 695655299ccc48eec4c38c75d50144b3a13ee8db
-SHA1 (patch-TESTING_dbal.in) = 3a6a726b6504a07fb1c0908a3893ea46aca670ea
+SHA1 (lapack-3.9.0.tar.gz) = 0451d180eed2b12b94aaae77e772d7573e87bec4
+RMD160 (lapack-3.9.0.tar.gz) = 333bf17b3e2503c26cdd2139566fdc788be1d0c3
+SHA512 (lapack-3.9.0.tar.gz) = 424956ad941a60a4b71e0d451ad48db12a692f8a71a90f3ca7f71d6ecc1922f392746ea84df1c47a46577ed2db32e9e47ec44ad248207c5ac7da179becb712ef
+Size (lapack-3.9.0.tar.gz) = 7534567 bytes
+SHA1 (patch-BLAS_SRC_CMakeLists.txt) = c8c69e6e0c67337af999863c4f5c64618d1374d7
+SHA1 (patch-CBLAS_cblas.pc.in) = 3befb18c1b7f2f82c6da83ea10f913c817acf09f
+SHA1 (patch-CBLAS_src_CMakeLists.txt) = faa1ad6c322830cb62e0f5bdab33732c0372cce3
+SHA1 (patch-CMakeLists.txt) = ea2bec54dd2c283a96862ef760826bf6e633613e
+SHA1 (patch-LAPACKE_CMakeLists.txt) = b5d4fb36550e1ae47e7e68ffec0e10afa3ac8864
+SHA1 (patch-LAPACKE_lapacke.pc.in) = 7f0d91aaceac7f9980650ec90dbda95cf09b768f
+SHA1 (patch-SRC_CMakeLists.txt) = 2908cdeb0d94f51ec16b02b8a6426dd6cde7e10f
+SHA1 (patch-TESTING_MATGEN_CMakeLists.txt) = 84d4cde8fef49c6efc9f50a3219b0299375934d5
diff --git a/math/lapack/patches/patch-BLAS_SRC_CMakeLists.txt b/math/lapack/patches/patch-BLAS_SRC_CMakeLists.txt
new file mode 100644
index 00000000000..206893b7887
--- /dev/null
+++ b/math/lapack/patches/patch-BLAS_SRC_CMakeLists.txt
@@ -0,0 +1,18 @@
+$NetBSD: patch-BLAS_SRC_CMakeLists.txt,v 1.1 2020/10/12 21:51:57 bacon Exp $
+
+Support combined build of shared and static libraries.
+
+--- BLAS/SRC/CMakeLists.txt.orig 2017-11-13 04:15:54.000000000 +0000
++++ BLAS/SRC/CMakeLists.txt
+@@ -104,3 +104,11 @@ set_target_properties(
+ SOVERSION ${LAPACK_MAJOR_VERSION}
+ )
+ lapack_install_library(blas)
++if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
++ add_library(blas_static STATIC ${SOURCES})
++ set_target_properties(
++ blas_static PROPERTIES
++ OUTPUT_NAME blas
++ )
++ lapack_install_library(blas_static)
++endif()
diff --git a/math/lapack/patches/patch-CBLAS_cblas.pc.in b/math/lapack/patches/patch-CBLAS_cblas.pc.in
new file mode 100644
index 00000000000..3f2d601778f
--- /dev/null
+++ b/math/lapack/patches/patch-CBLAS_cblas.pc.in
@@ -0,0 +1,13 @@
+$NetBSD: patch-CBLAS_cblas.pc.in,v 1.1 2020/10/12 21:51:57 bacon Exp $
+
+Install BLAS libs here rather than from a separate package
+
+--- CBLAS/cblas.pc.in.orig 2019-03-27 14:34:40.823289167 +0000
++++ CBLAS/cblas.pc.in
+@@ -6,5 +6,5 @@ Description: C Standard Interface to BLA
+ Version: @LAPACK_VERSION@
+ URL: http://www.netlib.org/blas/#_cblas
+ Libs: -L${libdir} -lcblas
++Libs.private: @BLAS_LIBRARIES@
+ Cflags: -I${includedir}
+-Requires.private: blas
diff --git a/math/lapack/patches/patch-CBLAS_src_CMakeLists.txt b/math/lapack/patches/patch-CBLAS_src_CMakeLists.txt
new file mode 100644
index 00000000000..53675d55718
--- /dev/null
+++ b/math/lapack/patches/patch-CBLAS_src_CMakeLists.txt
@@ -0,0 +1,25 @@
+$NetBSD: patch-CBLAS_src_CMakeLists.txt,v 1.1 2020/10/12 21:51:57 bacon Exp $
+
+Support combined build of shared and static libraries.
+
+--- CBLAS/src/CMakeLists.txt.orig 2017-11-13 04:15:54.000000000 +0000
++++ CBLAS/src/CMakeLists.txt
+@@ -126,3 +126,18 @@ target_include_directories(cblas PUBLIC
+ )
+ target_link_libraries(cblas PRIVATE ${BLAS_LIBRARIES})
+ lapack_install_library(cblas)
++
++if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
++ add_library(cblas_static STATIC ${SOURCES})
++ set_target_properties(
++ cblas_static PROPERTIES
++ LINKER_LANGUAGE C
++ OUTPUT_NAME cblas
++ )
++ target_include_directories(cblas_static PUBLIC
++ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
++ $<INSTALL_INTERFACE:include>
++ )
++ target_link_libraries(cblas_static PRIVATE ${BLAS_LIBRARIES})
++ lapack_install_library(cblas_static)
++endif()
diff --git a/math/lapack/patches/patch-CMakeLists.txt b/math/lapack/patches/patch-CMakeLists.txt
new file mode 100644
index 00000000000..6fa11d49f9c
--- /dev/null
+++ b/math/lapack/patches/patch-CMakeLists.txt
@@ -0,0 +1,153 @@
+$NetBSD: patch-CMakeLists.txt,v 1.1 2020/10/12 21:51:57 bacon Exp $
+
+Avoid installation of LAPACK CMake and pkg-config files when not installing
+LAPACK, also allowing explicitly to switch off LAPACK build for BLAS-only
+packaging.
+
+--- CMakeLists.txt.orig 2020-03-03 15:36:43.155560348 +0100
++++ CMakeLists.txt 2020-03-03 15:36:34.827560837 +0100
+@@ -112,8 +112,10 @@
+
+
+ # --------------------------------------------------
+-set(LAPACK_INSTALL_EXPORT_NAME lapack-targets)
+
++if(LAPACK)
++
++set(LAPACK_INSTALL_EXPORT_NAME lapack-targets)
+ macro(lapack_install_library lib)
+ install(TARGETS ${lib}
+ EXPORT ${LAPACK_INSTALL_EXPORT_NAME}
+@@ -123,6 +125,18 @@
+ )
+ endmacro()
+
++else()
++
++macro(lapack_install_library lib)
++ install(TARGETS ${lib}
++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development
++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries
++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT RuntimeLibraries
++ )
++endmacro()
++
++endif()
++
+ set(PKG_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+
+ # --------------------------------------------------
+@@ -252,6 +266,10 @@
+
+ option(USE_OPTIMIZED_LAPACK "Whether or not to use an optimized LAPACK library instead of included netlib LAPACK" OFF)
+
++option(LAPACK "Whether to build or use LAPACK (to enable a BLAS-only build)")
++
++if(LAPACK)
++
+ # --------------------------------------------------
+ # LAPACK
+ # User did not provide a LAPACK Library but specified to search for one
+@@ -293,6 +311,8 @@
+ CACHE STRING "Linker flags for shared libs" FORCE)
+ endif()
+
++endif()
++
+ if(BUILD_TESTING)
+ add_subdirectory(TESTING)
+ endif()
+@@ -374,14 +394,18 @@
+ set(ALL_TARGETS ${ALL_TARGETS} blas)
+ endif()
+
++if(LAPACK)
+ if(NOT LATESTLAPACK_FOUND)
+ set(ALL_TARGETS ${ALL_TARGETS} lapack)
++ set(BUILD_LAPACK ON)
++endif()
+ endif()
+
+ if(BUILD_TESTING OR LAPACKE_WITH_TMG)
+ set(ALL_TARGETS ${ALL_TARGETS} tmglib)
+ endif()
+
++if(LAPACK)
+ # Export lapack targets, not including lapacke, from the
+ # install tree, if any.
+ set(_lapack_config_install_guard_target "")
+@@ -395,6 +419,7 @@
+ # lapack-config.cmake to load targets from the install tree.
+ list(GET ALL_TARGETS 0 _lapack_config_install_guard_target)
+ endif()
++endif()
+
+ # Include cblas in targets exported from the build tree.
+ if(CBLAS)
+@@ -406,6 +431,7 @@
+ set(ALL_TARGETS ${ALL_TARGETS} lapacke)
+ endif()
+
++if(LAPACK)
+ # Export lapack and lapacke targets from the build tree, if any.
+ set(_lapack_config_build_guard_target "")
+ if(ALL_TARGETS)
+@@ -415,32 +441,34 @@
+ # for lapack-config.cmake to load targets from the build tree.
+ list(GET ALL_TARGETS 0 _lapack_config_build_guard_target)
+ endif()
++endif()
+
+-configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-build.cmake.in
+- ${LAPACK_BINARY_DIR}/lapack-config.cmake @ONLY)
+-
++if(BUILD_LAPACK)
++ configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-build.cmake.in
++ ${LAPACK_BINARY_DIR}/lapack-config.cmake @ONLY)
+
+-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lapack.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc @ONLY)
++ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lapack.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc @ONLY)
+ install(FILES
+- ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc
+- DESTINATION ${PKG_CONFIG_DIR}
+- COMPONENT Development
+- )
++ ${CMAKE_CURRENT_BINARY_DIR}/lapack.pc
++ DESTINATION ${PKG_CONFIG_DIR}
++ COMPONENT Development
++ )
+
+-configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-install.cmake.in
+- ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)
++ configure_file(${LAPACK_SOURCE_DIR}/CMAKE/lapack-config-install.cmake.in
++ ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake @ONLY)
+
+-include(CMakePackageConfigHelpers)
+-write_basic_package_version_file(
+- ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
+- VERSION ${LAPACK_VERSION}
+- COMPATIBILITY SameMajorVersion
+- )
++ include(CMakePackageConfigHelpers)
++ write_basic_package_version_file(
++ ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
++ VERSION ${LAPACK_VERSION}
++ COMPATIBILITY SameMajorVersion
++ )
+
+-install(FILES
+- ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake
+- ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
+- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lapack-${LAPACK_VERSION}
+- COMPONENT Development
+- )
+-
+\ Kein Zeilenumbruch am Dateiende.
++ install(FILES
++ ${LAPACK_BINARY_DIR}/CMakeFiles/lapack-config.cmake
++ ${LAPACK_BINARY_DIR}/lapack-config-version.cmake
++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lapack-${LAPACK_VERSION}
++ COMPONENT Development
++ )
++endif()
++
diff --git a/math/lapack/patches/patch-LAPACKE_CMakeLists.txt b/math/lapack/patches/patch-LAPACKE_CMakeLists.txt
new file mode 100644
index 00000000000..a198f12bef7
--- /dev/null
+++ b/math/lapack/patches/patch-LAPACKE_CMakeLists.txt
@@ -0,0 +1,46 @@
+$NetBSD: patch-LAPACKE_CMakeLists.txt,v 1.1 2020/10/12 21:51:57 bacon Exp $
+
+Support combined build of shared and static libraries.
+
+--- LAPACKE/CMakeLists.txt.orig 2020-01-03 19:33:52.766364829 +0100
++++ LAPACKE/CMakeLists.txt 2020-01-03 19:49:05.115280246 +0100
+@@ -94,6 +94,26 @@
+ target_link_libraries(lapacke PRIVATE ${LAPACK_LIBRARIES})
+
+ lapack_install_library(lapacke)
++
++if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
++ add_library(lapacke_static STATIC ${SOURCES})
++ set_target_properties(
++ lapacke_static PROPERTIES
++ OUTPUT_NAME lapacke
++ )
++ target_include_directories(lapacke_static PUBLIC
++ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
++ $<INSTALL_INTERFACE:include>
++ )
++
++ if(LAPACKE_WITH_TMG)
++ target_link_libraries(lapacke_static PRIVATE tmglib)
++ endif()
++ target_link_libraries(lapacke_static PRIVATE ${LAPACK_LIBRARIES})
++
++ lapack_install_library(lapacke_static)
++endif()
++
+ install(
+ FILES ${LAPACKE_INCLUDE} ${LAPACK_BINARY_DIR}/include/lapacke_mangling.h
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+@@ -126,7 +146,8 @@
+ COMPONENT Development
+ )
+
+-install(EXPORT lapacke-targets
+- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lapacke-${LAPACK_VERSION}
+- COMPONENT Development
+- )
++#install(EXPORT lapacke-targets
++# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lapacke-${LAPACK_VERSION}
++# COMPONENT Development
++# )
++
diff --git a/math/lapack/patches/patch-LAPACKE_lapacke.pc.in b/math/lapack/patches/patch-LAPACKE_lapacke.pc.in
new file mode 100644
index 00000000000..956abb7300d
--- /dev/null
+++ b/math/lapack/patches/patch-LAPACKE_lapacke.pc.in
@@ -0,0 +1,13 @@
+$NetBSD: patch-LAPACKE_lapacke.pc.in,v 1.1 2020/10/12 21:51:57 bacon Exp $
+
+Install libs here rather than from a separate package
+
+--- LAPACKE/lapacke.pc.in.orig 2019-03-27 14:35:14.016006535 +0000
++++ LAPACKE/lapacke.pc.in
+@@ -6,5 +6,5 @@ Description: C Standard Interface to LAP
+ Version: @LAPACK_VERSION@
+ URL: http://www.netlib.org/lapack/#_standard_c_language_apis_for_lapack
+ Libs: -L${libdir} -llapacke
++Libs.private: @LAPACK_LIBRARIES@ @BLAS_LIBRARIES@
+ Cflags: -I${includedir}
+-Requires.private: lapack
diff --git a/math/lapack/patches/patch-SRC_CMakeLists.txt b/math/lapack/patches/patch-SRC_CMakeLists.txt
new file mode 100644
index 00000000000..7b0501f8293
--- /dev/null
+++ b/math/lapack/patches/patch-SRC_CMakeLists.txt
@@ -0,0 +1,30 @@
+$NetBSD: patch-SRC_CMakeLists.txt,v 1.1 2020/10/12 21:51:57 bacon Exp $
+
+Support combined build of shared and static libraries.
+
+--- SRC/CMakeLists.txt.orig 2019-11-21 08:57:43.000000000 +0100
++++ SRC/CMakeLists.txt 2020-01-03 19:53:12.452257316 +0100
+@@ -518,3 +518,23 @@
+ endif()
+
+ lapack_install_library(lapack)
++
++if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
++ add_library(lapack_static STATIC ${SOURCES})
++ set_target_properties(
++ lapack_static PROPERTIES
++ OUTPUT_NAME lapack
++ )
++
++ if(USE_XBLAS)
++ target_link_libraries(lapack_static PRIVATE ${XBLAS_LIBRARY})
++ endif()
++ target_link_libraries(lapack_static PRIVATE ${BLAS_LIBRARIES})
++
++ if (_is_coverage_build)
++ target_link_libraries(lapack_static PRIVATE gcov)
++ add_coverage(lapack_static)
++ endif()
++
++ lapack_install_library(lapack_static)
++endif()
diff --git a/math/lapack/patches/patch-TESTING_MATGEN_CMakeLists.txt b/math/lapack/patches/patch-TESTING_MATGEN_CMakeLists.txt
index d8c08da0d8b..59032354410 100644
--- a/math/lapack/patches/patch-TESTING_MATGEN_CMakeLists.txt
+++ b/math/lapack/patches/patch-TESTING_MATGEN_CMakeLists.txt
@@ -1,12 +1,19 @@
-$NetBSD: patch-TESTING_MATGEN_CMakeLists.txt,v 1.1 2020/02/28 21:48:54 plunky Exp $
+$NetBSD: patch-TESTING_MATGEN_CMakeLists.txt,v 1.2 2020/10/12 21:51:57 bacon Exp $
-we don't actually want to install the testing matrix generator lib
+Support combined build of shared and static libraries.
---- TESTING/MATGEN/CMakeLists.txt.orig 2020-02-20 13:46:28.024672825 +0000
+--- TESTING/MATGEN/CMakeLists.txt.orig 2017-11-13 04:15:54.000000000 +0000
+++ TESTING/MATGEN/CMakeLists.txt
-@@ -49,4 +49,4 @@ list(REMOVE_DUPLICATES SOURCES)
-
+@@ -50,3 +50,12 @@ list(REMOVE_DUPLICATES SOURCES)
add_library(tmglib ${SOURCES})
target_link_libraries(tmglib ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
--lapack_install_library(tmglib)
-+#lapack_install_library(tmglib)
+ lapack_install_library(tmglib)
++if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
++ add_library(tmglib_static STATIC ${SOURCES})
++ set_target_properties(
++ tmglib_static PROPERTIES
++ OUTPUT_NAME tmglib
++ )
++ target_link_libraries(tmglib_static ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
++ lapack_install_library(tmglib_static)
++endif()
diff --git a/math/lapack/patches/patch-TESTING_dbal.in b/math/lapack/patches/patch-TESTING_dbal.in
deleted file mode 100644
index 93b20e15018..00000000000
--- a/math/lapack/patches/patch-TESTING_dbal.in
+++ /dev/null
@@ -1,14 +0,0 @@
-$NetBSD: patch-TESTING_dbal.in,v 1.1 2020/02/28 21:48:54 plunky Exp $
-
-remove extraneous semicolon from testing data (causes test to fail)
-
---- TESTING/dbal.in.orig 2020-02-20 21:55:51.547637125 +0000
-+++ TESTING/dbal.in
-@@ -209,6 +209,6 @@ DBL: Tests DGEBAL
- 0.00000000000000000000D+00 0.00000000000000000000D+00 0.00000000000000000000D+00 0.63043209914231165391D-03 0.10000000000000000000D+01 0.79310682416114036641D+03
- 0.00000000000000000000D+00 0.00000000000000000000D+00 0.00000000000000000000D+00 0.00000000000000000000D+00 0.12608641982846233078D-02 0.10000000000000000000D+01
-
-- 2.494800386918399765D+291 1.582914569427869018D+175 1.004336277661868922D+59 3.186183822264904554D-58 5.053968264940243633D-175 0.40083367200179455560D-291;
-+ 2.494800386918399765D+291 1.582914569427869018D+175 1.004336277661868922D+59 3.186183822264904554D-58 5.053968264940243633D-175 0.40083367200179455560D-291
-
- 0
diff --git a/math/lapack/version.mk b/math/lapack/version.mk
new file mode 100644
index 00000000000..5bc9ebdc678
--- /dev/null
+++ b/math/lapack/version.mk
@@ -0,0 +1,3 @@
+# $NetBSD: version.mk,v 1.1 2020/10/12 21:51:57 bacon Exp $
+
+NETLIB_BLAS_VERSION= 3.9.0