pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

mk/blas.bl3: rework to use PKGSRC_BLAS_PREFERRED as list



Module Name:	pkgsrc-wip
Committed By:	Dr. Thomas Orgis <thomas.orgis%uni-hamburg.de@localhost>
Pushed By:	thor
Date:		Wed Jul 17 18:50:48 2019 +0200
Changeset:	bf2238dcb86f51818e23e066d61d592fdae3c874

Modified Files:
	mk/blas.buildlink3.mk

Log Message:
mk/blas.bl3: rework to use PKGSRC_BLAS_PREFERRED as list

As a result of the discussion on tech-pkg, the BLAS choice is
an ordered list of preferred choices which is matched against
BLAS_ACCEPTED as set by the package Makefile. The user-settable
variable gets the PKGSRC_ prefix.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=bf2238dcb86f51818e23e066d61d592fdae3c874

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 mk/blas.buildlink3.mk | 63 ++++++++++++++++++++++++++++++++-------------------
 1 file changed, 40 insertions(+), 23 deletions(-)

diffs:
diff --git a/mk/blas.buildlink3.mk b/mk/blas.buildlink3.mk
index d334d1b276..fb2673968a 100644
--- a/mk/blas.buildlink3.mk
+++ b/mk/blas.buildlink3.mk
@@ -14,69 +14,86 @@
 #
 # === User-settable variables ===
 #
-# BLAS_TYPE
-#	This value represents the type of BLAS we wish to use on the system.
+# PKGSRC_BLAS_PREFERRED
+#  This value specifies an exhaustive list of BLAS implementations
+#  we wish to use on the system, in descending order of preference.
+#
+#  Possible: one or more of netlib, openblas, openblas_pthread,
+#    openblas_openmp, and accelerate.framework
+#    (to come: Intel MKL, other external optimized builds)
 #
-#	Possible: netlib, openblas, openblas_pthread, openblas_openmp
-#	Default: netlib
+#  Default: netlib
 #
 # === Per-package variables ===
 #
 # BLAS_ACCEPTED
 #       This is a list of blas packages that are compatible with the current
 #       package. If not set, any package is OK.
+#
+# === Variables for package Makefiles to use ===
+# 
+# BLAS_TYPE
+#   This is the finally selected type of BLAS from BLAS_PREFERRED or none.
+# BLAS_LIBS
+#   linker flags to use for linking to BLAS library
+# LAPACK_LIBS
+#   linker flags to use for linking to LAPACK library
+
+BUILD_DEFS+=	PKGSRC_BLAS_PREFERRED
+BUILD_DEFS_EFFECTS+=	BLAS_TYPE BLAS_LIBS LAPACK_LIBS
 
 .if !defined(BLAS_BUILDLINK3_MK)
-BLAS_BUILDLINK3_MK=	# define it
+BLAS_BUILDLINK3_MK=
 
 .include "../../mk/bsd.prefs.mk"
 
 # List of all possible BLAS choices.
 _BLAS_TYPES=	netlib openblas openblas_pthread openblas_openmp
-# Add Accelerate framework on Darwin (pulled from math/R).
 .if exists(/System/Library/Frameworks/Accelerate.framework)
 _BLAS_TYPES+=	accelerate.framework
 .endif
-# Currently chosen type.
-# Default is the standard, slow, easily available.
-BLAS_TYPE?=	netlib
-BLAS_LIBS=
-BLAS_ACCEPTED?= ${_BLAS_TYPES}
 
-.  if !empty(BLAS_ACCEPTED:M${BLAS_TYPE})
-_BLAS_TYPE=     ${BLAS_TYPE}
-.  else
-_BLAS_TYPE=     none
-.  endif
+BLAS_ACCEPTED?=	${_BLAS_TYPES}
+PKGSRC_BLAS_PREFERRED?= netlib openblas
+
+_BLAS_MATCH=
+.for b in ${PKGSRC_BLAS_PREFERRED}
+_BLAS_MATCH+=	${BLAS_ACCEPTED:M${b}}
+.endfor
+.if(!empty(_BLAS_MATCH))
+BLAS_TYPE=	${_BLAS_MATCH:[1]}
+.else
+BLAS_TYPE=	none
+.endif
 
-.if ${_BLAS_TYPE} == "netlib"
+.if ${BLAS_TYPE} == "netlib"
 _BLAS_PACKAGE=	wip/lapack
 BLAS_LIBS=	-lblas
 LAPACK_LIBS=	-llapack ${BLAS_LIBS}
-.elif ${_BLAS_TYPE} == "openblas"
+.elif ${BLAS_TYPE} == "openblas"
 _BLAS_PACKAGE=	wip/openblas
 BLAS_LIBS=	-lopenblas
 LAPACK_LIBS=	${BLAS_LIBS}
-.elif ${_BLAS_TYPE} == "openblas_pthread"
+.elif ${BLAS_TYPE} == "openblas_pthread"
 _BLAS_PACKAGE=	wip/openblas_pthread
 BLAS_LIBS=	-lopenblas_pthread
 LAPACK_LIBS=	${BLAS_LIBS}
-.elif ${_BLAS_TYPE} == "openblas_openmp"
+.elif ${BLAS_TYPE} == "openblas_openmp"
 _BLAS_PACKAGE=	wip/openblas_openmp
 BLAS_LIBS=	-lopenblas_openmp
 LAPACK_LIBS=	${BLAS_LIBS}
-.elif ${_BLAS_TYPE} == "accelerate.framework"
+.elif ${BLAS_TYPE} == "accelerate.framework"
 BLAS_LIBS=	-framework Accelerate
 LAPACK_LIBS=	${BLAS_LIBS}
 # TODO: atlas
 # TODO: external BLAS (other OpenBLAS/ATLAS, Intel MKL)
 .else # invalid or unimplemented type
 PKG_FAIL_REASON+=	\
-	"${BLAS_TYPE} is not an acceptable BLAS type for ${PKGNAME}."
+	"There is no acceptable BLAS for ${PKGNAME} in: ${PKGSRC_BLAS_PREFERRED}."
 .endif
 
 .if defined(_BLAS_PACKAGE)
 .include "../../${_BLAS_PACKAGE}/buildlink3.mk"
 .endif
 
-.endif	# BLAS_BUILDLINK3_MK
+.endif # BLAS_BUILDLINK3_MK


Home | Main Index | Thread Index | Old Index