summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 60093e6bee05aa35a5e6bd7bd6a23093fdce55a7 (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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Maintainer: Chocobo1 <chocobo1 AT archlinux DOT net>
# Previous maintainer: Jean-Francis Roy <jeanfrancisroy _AT_ gmail _DOT_ com>
# Contributor: Giuseppe Borzi <gborzi _AT_ ieee _DOT_ org>

pkgbase=openblas-git
pkgname=('openblas-git' 'openblas64-git' 'blas-openblas-git' 'blas64-openblas-git')
pkgver=0.3.31.r60.g1ef631999
pkgrel=1
pkgdesc="An optimized BLAS library based on GotoBLAS2 1.13 BSD"
arch=('i686' 'x86_64')
url="https://www.openmathlib.org/OpenBLAS/"
license=('BSD-3-Clause')
depends=('glibc' 'libgcc')
makedepends=('git' 'cmake' 'gcc-fortran' 'perl')
provides=("openblas=$pkgver")
conflicts=('openblas')
source=("git+https://github.com/OpenMathLib/OpenBLAS.git")
sha256sums=('SKIP')


pkgver() {
  cd "OpenBLAS"

  _tag=$(git tag -l --sort -v:refname | grep -E '^v?[0-9\.]+$' | head -n1)
  _rev=$(git rev-list --count "$_tag"..HEAD)
  _hash=$(git rev-parse --short HEAD)
  printf "%s.r%s.g%s" "$_tag" "$_rev" "$_hash" | sed 's/^v//'
}

build() {
  cd "OpenBLAS"

  # Setting FC manually to avoid picking up f95 and breaking the cmake build
  # https://github.com/xianyi/OpenBLAS/issues/4072#issuecomment-1576388332

  # Setting ASM flags for CET support.  Setting FFLAGS for CET support.
  # Remove ` -Wformat -Werror=format-security` not supported by gcc-fortran.

  ASMFLAGS="$CFLAGS" \
  FFLAGS="${CFLAGS/ -Wformat -Werror=format-security/}" \
  FC="gfortran" \
  cmake -B "_build" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="/usr" \
    -DCMAKE_INSTALL_LIBDIR="lib" \
    -DBUILD_SHARED_LIBS=ON \
    -DBUILD_TESTING=OFF \
    -DDYNAMIC_ARCH=ON \
    -DNUM_THREADS=64 \
    -DTARGET=CORE2 \
    -DUSE_OPENMP=1
  cmake --build "_build"

  ASMFLAGS="$CFLAGS" \
  FFLAGS="${CFLAGS/ -Wformat -Werror=format-security/}" \
  FC="gfortran" \
  cmake -B "_build64" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="/usr" \
    -DCMAKE_INSTALL_LIBDIR="lib" \
    -DBUILD_SHARED_LIBS=ON \
    -DBUILD_TESTING=OFF \
    -DDYNAMIC_ARCH=ON \
    -DINTERFACE64=1 \
    -DNUM_THREADS=64 \
    -DTARGET=CORE2 \
    -DUSE_OPENMP=1
  cmake --build "_build64"
}

check() {
  cd "OpenBLAS"

  #cmake --build "_build" --target test
  #cmake --build "_build64" --target test
}

package_openblas-git() {
  cd "OpenBLAS"

  DESTDIR="$pkgdir" cmake --install "_build"
  install -Dm644 "LICENSE" -t "$pkgdir/usr/share/licenses/openblas"
}

package_openblas64-git() {
  pkgdesc+=" (64-bit integers)"

  cd "OpenBLAS"

  DESTDIR="$pkgdir" cmake --install "_build64"
  install -Dm644 "LICENSE" -t "$pkgdir/usr/share/licenses/openblas64"

  cd "$pkgdir/usr/lib"
  ln -s "libopenblas_64.so" "libopenblas64_.so"  # Needed by julia
}

package_blas-openblas-git() {
  pkgdesc+=" (Provides BLAS/CBLAS/LAPACK/LAPACKE system-wide)"
  depends=('openblas-git')
  provides=('blas' 'cblas' 'lapack' 'lapacke' "openblas-lapack=$pkgver")
  conflicts=('blas' 'cblas' 'lapack' 'lapacke' 'openblas-lapack')
  replaces=('openblas-lapack')

  mkdir -p "$pkgdir/usr/lib/pkgconfig"
  cd "$pkgdir/usr/lib"
  for _lib in blas cblas lapack lapacke; do
    ln -s "libopenblas.so" "lib${_lib}.so"
    ln -s "libopenblas.so" "lib${_lib}.so.3"
    ln -s "openblas.pc" "$pkgdir/usr/lib/pkgconfig/${_lib}.pc"
  done
}

package_blas64-openblas-git() {
  pkgdesc+=" (64-bit integers, provides BLAS/CBLAS/LAPACK/LAPACKE system-wide)"
  depends=('openblas64-git')
  provides=('blas64' 'cblas64' 'lapack64' 'lapacke64')
  conflicts=('blas64' 'cblas64' 'lapack64' 'lapacke64')

  mkdir -p "$pkgdir/usr/lib/pkgconfig"
  cd "$pkgdir/usr/lib"
  for _lib in blas64 cblas64 lapack64 lapacke64; do
    ln -s "libopenblas_64.so" "lib${_lib}.so"
    ln -s "libopenblas_64.so" "lib${_lib}.so.3"
    ln -s "openblas64.pc" "$pkgdir/usr/lib/pkgconfig/${_lib}.pc"
  done
}