aboutsummaryrefslogtreecommitdiffstats
path: root/community/openblas/APKBUILD
blob: dc5f38a30890435a02f81e645ad3580a750c5459 (plain) (blame)
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
# Contributor: Isaac Dunham <ibid.ag@gmail.com>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Isaac Dunham <ibid.ag@gmail.com>
pkgname=openblas
_pkgname=OpenBLAS
pkgver=0.2.19
pkgrel=0
pkgdesc="A fast BSD-licensed BLAS based on gotoBLAS2, with LAPACK"
url="http://www.openblas.net"
arch="all"
license="BSD"
depends=""
depends_dev="gfortran"
makedepends="$depends_dev perl linux-headers"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::http://github.com/xianyi/$_pkgname/archive/v$pkgver.tar.gz
	"
builddir="$srcdir/$_pkgname-$pkgver"
_builddir64="$builddir-64"

# USE_OPENMP=0: see GCC bug 60035
# NO_AFFINITY: don't expect to work on musl, also breaks R and not
#              recommended for Julia
_flags="USE_OPENMP=0
	NO_LAPACK=0
	MAJOR_VERSION=3
	NO_AFFINITY=1
	"
case "$CARCH" in
x86_64 | aarch64)
	subpackages="$subpackages $pkgname-ilp64"
	_flags="$_flags NUM_THREADS=32"  # match kernel's CONFIG_NR_CPUS
	_ilp64=true
;;
*)
	_flags="$_flags NUM_THREADS=8"  # 32bit machines usually have less cores
	_ilp64=false
;;
esac

# DYNAMIC_ARCH is supported on x86* only, see https://github.com/xianyi/OpenBLAS/issues/709
case "$CARCH" in
x86*) _flags="$_flags TARGET=core2 DYNAMIC_ARCH=1";;
armhf) _flags="$_flags TARGET=ARMV7 DYNAMIC_ARCH=0";;
aarch64) _flags="$_flags TARGET=ARMV8 DYNAMIC_ARCH=0";;
*) _flags="$_flags DYNAMIC_ARCH=0";;
esac

# Flags for ILP64 variant.
_flags64="$_flags
	INTERFACE64=1
	SYMBOLSUFFIX=64_"

prepare() {
	default_prepare || return 1

	cp -ar "$builddir" "$_builddir64"
}

build() {
	CFLAGS= make -C "$builddir" \
		$_flags CFLAGS="$CFLAGS" PREFIX=/usr || return 1

	if $_ilp64; then
		msg "Building with ILP64..."
		CFLAGS= make -C "$_builddir64" \
			$_flags64 CFLAGS="$CFLAGS" PREFIX=/usr || return 1
	fi
}

package() {
	if $_ilp64; then
		make -C "$_builddir64" $_flags64 \
			PREFIX="$pkgdir/usr" install || return 1
	fi

	cd "$builddir"

	make $_flags PREFIX="$pkgdir/usr" install || return 1

	# Remove reference to $pkgdir.
	sed -i "s|$pkgdir||" "$pkgdir"/usr/lib/cmake/$pkgname/OpenBLASConfig.cmake

	mkdir -p "$pkgdir"/usr/share/doc/$pkgname
	install -m 0644 Changelog.txt TargetList.txt USAGE.md \
		"$pkgdir"/usr/share/doc/$pkgname/ || return 1

	install -Dm 0644 LICENSE \
		"$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

ilp64() {
	pkgdesc="$pkgdesc (ILP64)"
	arch="x86_64 aarch64"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libopenblas64_* "$subpkgdir"/usr/lib/
}

md5sums="28c998054fd377279741c6f0b9ea7941  openblas-0.2.19.tar.gz"
sha256sums="9c40b5e4970f27c5f6911cb0a28aa26b6c83f17418b69f8e5a116bb983ca8557  openblas-0.2.19.tar.gz"
sha512sums="7081a8540b8037c0d4d6db0ec4b51277856c0e0f4e2575671984e5deb3482102da8936c43691087c8475d67070f89ac6925e4867ead60802aa2a29e8517e7495  openblas-0.2.19.tar.gz"