xref: /OK3568_Linux_fs/buildroot/package/openblas/openblas.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# openblas
4#
5################################################################################
6
7OPENBLAS_VERSION = 0.3.9
8OPENBLAS_SITE = $(call github,xianyi,OpenBLAS,v$(OPENBLAS_VERSION))
9OPENBLAS_LICENSE = BSD-3-Clause
10OPENBLAS_LICENSE_FILES = LICENSE
11OPENBLAS_INSTALL_STAGING = YES
12
13# Initialise OpenBLAS make options to $(TARGET_CONFIGURE_OPTS)
14OPENBLAS_MAKE_OPTS = $(TARGET_CONFIGURE_OPTS)
15
16# Enable cross-compiling
17OPENBLAS_MAKE_OPTS += CROSS=1
18
19# Set OpenBLAS target
20OPENBLAS_MAKE_OPTS += TARGET=$(BR2_PACKAGE_OPENBLAS_TARGET)
21
22# When Fortran is not available, only build the C version of BLAS
23ifeq ($(BR2_TOOLCHAIN_HAS_FORTRAN),)
24OPENBLAS_MAKE_OPTS += ONLY_CBLAS=1
25endif
26
27# Enable/Disable multi-threading (not for static-only since it uses dlfcn.h)
28ifeq ($(BR2_PACKAGE_OPENBLAS_USE_THREAD),y)
29OPENBLAS_MAKE_OPTS += USE_THREAD=1
30else
31OPENBLAS_MAKE_OPTS += USE_THREAD=0
32endif
33
34ifeq ($(BR2_PACKAGE_OPENBLAS_USE_LOCKING),y)
35OPENBLAS_MAKE_OPTS += USE_LOCKING=1
36else
37# not passing USE_LOCKING=0 as this could be confusing: its effect is implicit
38# in case of USE_THREAD=1.
39endif
40
41# We don't know if OpenMP is available or not, so disable
42OPENBLAS_MAKE_OPTS += USE_OPENMP=0
43
44# Static-only/Shared-only toggle
45# Note: static library is always generated so that applications can link
46# statically for size reduction, even if BR2_STATIC_LIBS is not set.
47ifeq ($(BR2_STATIC_LIBS),y)
48OPENBLAS_MAKE_OPTS += NO_SHARED=1
49endif
50
51# binutils version <= 2.23.2 has a bug
52# (https://sourceware.org/bugzilla/show_bug.cgi?id=14887) where
53# whitespaces in ARM register specifications such as [ r1, #12 ] or [
54# r2 ] cause the assembler to reject the code. Since there are
55# numerous instances of such cases in the code, we use sed rather than
56# a patch. We simply replace [ foobar ] by [foobar] to work around the
57# problem.
58define OPENBLAS_FIXUP_ARM_ASSEMBLY
59	$(SED) 's%\[\s*%\[%;s%\s*\]%\]%' $(@D)/kernel/arm/*.S
60endef
61
62OPENBLAS_POST_PATCH_HOOKS += OPENBLAS_FIXUP_ARM_ASSEMBLY
63
64define OPENBLAS_BUILD_CMDS
65	$(TARGET_MAKE_ENV) $(MAKE) $(OPENBLAS_MAKE_OPTS) \
66		-C $(@D)
67endef
68
69define OPENBLAS_INSTALL_STAGING_CMDS
70	$(TARGET_MAKE_ENV) $(MAKE) $(OPENBLAS_MAKE_OPTS) \
71		-C $(@D) install PREFIX=$(STAGING_DIR)/usr
72endef
73
74define OPENBLAS_INSTALL_TARGET_CMDS
75	$(TARGET_MAKE_ENV) $(MAKE) $(OPENBLAS_MAKE_OPTS) \
76		-C $(@D) install PREFIX=$(TARGET_DIR)/usr
77endef
78
79$(eval $(generic-package))
80