aboutsummaryrefslogtreecommitdiff
path: root/libs/openblas/Makefile
blob: 9ad78b37f5def611317db5a8d19a1c03c17c5718 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#
# Copyright (C) 2021 Alexandru Ardelean <ardeleanalex@gmail.com>
#

include $(TOPDIR)/rules.mk

PKG_NAME:=OpenBLAS
PKG_VERSION:=0.3.18
PKG_RELEASE:=$(AUTORELEASE)

PKG_SOURCE:=OpenBLAS-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/xianyi/OpenBLAS/releases/download/v$(PKG_VERSION)/
PKG_HASH:=1632c1e8cca62d8bed064b37747e331a1796fc46f688626337362bf0d16aeadb
PKG_LICENSE:=BSD 3-Clause
PKG_MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>

PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk

define Package/openblas
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE:=An optimized library for BLAS (Basic Linear Algebra Subprograms)
  URL:=https://www.openblas.net/
  DEPENDS:= \
       @!arc \
       @!powerpc \
       +INSTALL_GFORTRAN:libgfortran
endef

define Package/openblas/description
  OpenBLAS is an optimized BLAS (Basic Linear Algebra Subprograms) library
  based on GotoBLAS2 1.13 BSD version.
endef

define Package/openblas/config
menu "Configuration"
depends on PACKAGE_openblas

config OPENBLAS_TARGET_OVERRIDE
	string
	prompt "Manual CPU target override (from the OpenBLAS TargetList.txt file)"

endmenu
endef

OPENBLAS_TARGET=$(call qstrip,$(CONFIG_OPENBLAS_TARGET_OVERRIDE))
CPU_TYPE=$(call qstrip,$(CONFIG_CPU_TYPE))

ifeq ($(OPENBLAS_TARGET),)
# initialize to GENERIC as default
OPENBLAS_TARGET:=GENERIC

ifeq ($(ARCH),aarch64)
  OPENBLAS_TARGET:=ARMV8
else ifeq ($(ARCH),arm)
  OPENBLAS_TARGET:=ARMV5
else ifeq ($(ARCH),mips)
  ifeq ($(CPU_TYPE),24kc)
    OPENBLAS_TARGET:=MIPS24K
  endif # CPU_TYPE == 24kc
else ifeq ($(ARCH),mipsel)
  ifeq ($(CPU_TYPE),24kc)
    OPENBLAS_TARGET:=MIPS24K
  endif # CPU_TYPE == 24kc
else ifeq ($(ARCH),powerpc)
  OPENBLAS_TARGET:=PPC440
endif
endif # ifeq ($(OPENBLAS_TARGET),)

ifeq ($(CONFIG_ARCH_64BIT),y)
OPENBLAS_BINARY:=64
else
OPENBLAS_BINARY:=32
endif

MAKE_FLAGS += \
	CROSS=1 \
	HOSTCC=$(HOSTCC_NOCACHE) \
	CROSS_SUFFIX=$(TARGET_CROSS) \
	BINARY=$(OPENBLAS_BINARY) \
	NUM_THREADS=2 \
	PREFIX=/usr \
	COMMON_OPT="" \
	TARGET=$(call qstrip,$(OPENBLAS_TARGET))

ifneq ($(CONFIG_INSTALL_GFORTRAN),y)
MAKE_FLAGS += NOFORTRAN=1
endif

define Build/InstallDev
	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
	$(INSTALL_DIR) $(1)/usr/include
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/* $(1)/usr/lib/pkgconfig/
endef

define Package/openblas/install
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libopenblas*.so* $(1)/usr/lib/
endef

$(eval $(call BuildPackage,openblas))