summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e5b01e8d59f162d6f6804c478ac4a8333f26bcd3 (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Maintainer: robertfoster

pkgbase=whisper.cpp
pkgname=(
  "${pkgbase}"
  "${pkgbase}-cublas"
  "${pkgbase}-clblas"
  "${pkgbase}-openvino"
)
pkgver=1.5.4
pkgrel=3
pkgdesc="Port of OpenAI's Whisper model in C/C++"
arch=('armv7h' 'aarch64' 'x86_64')
url="https://github.com/ggerganov/whisper.cpp"
license=("MIT")
depends=('glibc' 'gcc-libs')
makedepends=(
  'clblast'
  'cmake'
  'cuda'
  'git'
  'blas-openblas'
  'openvino'
)
source=("${pkgbase}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz")

prepare() {
  if [ ! -d "${srcdir}/${pkgbase}-clblas" ]; then
    cp -r "${srcdir}/${pkgbase}-${pkgver}" \
      "${srcdir}/${pkgbase}-clblas"
    cp -r "${srcdir}/${pkgbase}-${pkgver}" \
      "${srcdir}/${pkgbase}-cublas"
    cp -r "${srcdir}/${pkgbase}-${pkgver}" \
      "${srcdir}/${pkgbase}-openblas"
    cp -r "${srcdir}/${pkgbase}-${pkgver}" \
      "${srcdir}/${pkgbase}-openvino"
  fi
}

_package() {
  for i in build/bin/*; do
    install -Dm755 "${i}" \
      "${pkgdir}/usr/bin/${pkgbase}-${i//build\/bin\//}"
  done
  mv "${pkgdir}/usr/bin/${pkgbase}-main" \
    "${pkgdir}/usr/bin/${pkgbase}"
  install -Dm644 LICENSE \
    -t "${pkgdir}/usr/share/licenses/${pkgbase}"
}

build() {
  local _cmake_args=(
    -B build
    -S .
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_BUILD_TYPE=Release
  )
  local _cmake_openblas_args=(
    "${_cmake_args[@]}"
    -DWHISPER_OPENBLAS=ON
  )

  local _cmake_clblas_args=(
    "${_cmake_args[@]}"
    -DWHISPER_CLBLAST=ON
  )

  local _cmake_cublas_args=(
    "${_cmake_args[@]}"
    -DWHISPER_CUBLAS=ON
  )

  local _cmake_openvino_args=(
    "${_cmake_args[@]}"
    -DWHISPER_OPENVINO=on
  )

  echo "Build ${pkgbase} with OPENBlas"
  cd "${srcdir}/${pkgbase}-openblas"
  cmake "${_cmake_openblas_args[@]}"
  cmake --build build

  echo "Build ${pkgbase} with OpenCL"
  cd "${srcdir}/${pkgbase}-clblas"
  cmake "${_cmake_clblas_args[@]}"
  cmake --build build

  echo "Build ${pkgbase} with CUBlas (NVIDIA CUDA)"
  cd "${srcdir}/${pkgbase}-cublas"
  export PATH+=":/opt/cuda/bin"
  cmake "${_cmake_cublas_args[@]}"
  cmake --build build

  echo "Build ${pkgbase} with OpenVINO run-time"
  cd "${srcdir}/${pkgbase}-openvino"
  source /opt/intel/openvino/setupvars.sh
  cmake "${_cmake_openvino_args[@]}"
  cmake --build build
}

package_whisper.cpp() {
  pkgdesc="$pkgdesc (with OPENBlas CPU optimizations)"
  depends+=('openblas-lapack')
  provides=("${pkgbase}=${pkgver}")

  cd "${pkgbase}-openblas"
  DESTDIR="${pkgdir}" cmake --install build
  _package
}

package_whisper.cpp-clblas() {
  pkgdesc="$pkgdesc (with OpenCL optimizations)"
  depends+=('clblast')
  provides=("${pkgbase}=${pkgver}")
  conflicts=("${pkgbase}")

  cd "${pkgbase}-clblas"
  DESTDIR="${pkgdir}" cmake --install build
  _package
}

package_whisper.cpp-cublas() {
  pkgdesc="$pkgdesc (with NVIDIA CUDA optimizations)"
  depends+=('cuda')
  provides=("${pkgbase}=${pkgver}")
  conflicts=("${pkgbase}")

  cd "${pkgbase}-cublas"
  DESTDIR="${pkgdir}" cmake --install build
  _package
}

package_whisper.cpp-openvino() {
  pkgdesc="$pkgdesc (with OpenVINO run-time)"
  depends+=('openvino' 'pugixml')
  provides=("${pkgbase}=${pkgver}")
  conflicts=("${pkgbase}")

  cd "${pkgbase}-openvino"
  DESTDIR="${pkgdir}" cmake --install build
  _package
}

sha256sums=('06eed84de310fdf5408527e41e863ac3b80b8603576ba0521177464b1b341a3a')