package/armadillo: allow to select between lapack or openblas
authorGwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
Sun, 25 Jul 2021 11:12:31 +0000 (13:12 +0200)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Tue, 3 Aug 2021 20:49:16 +0000 (22:49 +0200)
armadillo can use lapack or openblas as BLAS provider. LAPACK support is
optional.

This patch
- adds an _ARCH_SUPPORTS variable to check if one is available
- adds an option to choose lapack or openblas as BLAS provider

The choice is required since applications may potentially need lapack.

Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/armadillo/Config.in
package/armadillo/armadillo.mk

index b2b61a3233de7fdbaaa052331f0ddf7fdeaf9fce..7aed4fd02fe9967d4dba1e9b879b610c7dd38f4b 100644 (file)
@@ -1,20 +1,38 @@
 comment "armadillo needs a toolchain w/ C++"
+       depends on BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS
        depends on !BR2_INSTALL_LIBSTDCPP
-       depends on !BR2_powerpc
-       depends on !BR2_m68k_cf
 
-comment "armadillo needs a glibc toolchain w/ C++"
-       depends on BR2_powerpc
-       depends on !BR2_INSTALL_LIBSTDCPP || BR2_TOOLCHAIN_USES_UCLIBC
+comment "armadillo needs a toolchain w/ fortran, C++"
+       depends on !BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS # otherwise, see comment above
+       depends on BR2_PACKAGE_LAPACK_ARCH_SUPPORTS
+       depends on !BR2_TOOLCHAIN_HAS_FORTRAN || !BR2_INSTALL_LIBSTDCPP
 
 config BR2_PACKAGE_ARMADILLO
        bool "armadillo"
+       depends on BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS || \
+               (BR2_PACKAGE_LAPACK_ARCH_SUPPORTS && BR2_TOOLCHAIN_HAS_FORTRAN)
        depends on BR2_INSTALL_LIBSTDCPP
-       depends on !BR2_powerpc || BR2_TOOLCHAIN_USES_GLIBC # clapack
-       depends on !BR2_m68k_cf # clapack
-       select BR2_PACKAGE_CLAPACK
        help
          Armadillo: An Open Source C++ Linear Algebra Library for
          Fast Prototyping and Computationally Intensive Experiments.
 
          http://arma.sourceforge.net/
+
+if BR2_PACKAGE_ARMADILLO
+
+choice
+       prompt "BLAS implementation"
+
+config BR2_PACKAGE_ARMADILLO_OPENBLAS
+       bool "openblas"
+       depends on BR2_PACKAGE_OPENBLAS_ARCH_SUPPORTS
+       select BR2_PACKAGE_OPENBLAS
+
+config BR2_PACKAGE_ARMADILLO_LAPACK
+       bool "lapack"
+       depends on BR2_PACKAGE_LAPACK_ARCH_SUPPORTS && BR2_TOOLCHAIN_HAS_FORTRAN
+       select BR2_PACKAGE_LAPACK
+
+endchoice
+
+endif
index 624b842ef6f34d51a21bf715faa2b4c0d68739b9..dcac2bf8cd2333f0abcbbb19e27bcf2670c6ddcc 100644 (file)
@@ -7,11 +7,27 @@
 ARMADILLO_VERSION = 9.900.2
 ARMADILLO_SOURCE = armadillo-$(ARMADILLO_VERSION).tar.xz
 ARMADILLO_SITE = https://downloads.sourceforge.net/project/arma
-ARMADILLO_DEPENDENCIES = clapack
 ARMADILLO_INSTALL_STAGING = YES
 ARMADILLO_LICENSE = Apache-2.0
 ARMADILLO_LICENSE_FILES = LICENSE.txt
 
 ARMADILLO_CONF_OPTS = -DDETECT_HDF5=false
 
+# blas support may be provided by lapack (libblas.a) or openblas (libopenblas.a)
+ARMADILLO_CONF_OPTS += -DBLAS_FOUND=ON
+ifeq ($(BR2_PACKAGE_ARMADILLO_OPENBLAS),y)
+ARMADILLO_CONF_OPTS += -DBLAS_LIBRARIES=-lopenblas
+ARMADILLO_DEPENDENCIES = openblas
+else
+# Since BR2_PACKAGE_LAPACK is selected in this case, the dependency on it is
+# added below.
+ARMADILLO_CONF_OPTS += -DBLAS_LIBRARIES=-lblas
+endif
+
+# lapack support is optional and can only be provided by lapack, not openblas
+ifeq ($(BR2_PACKAGE_LAPACK),y)
+ARMADILLO_CONF_OPTS += -DLAPACK_FOUND=ON
+ARMADILLO_DEPENDENCIES += lapack
+endif
+
 $(eval $(cmake-package))