summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d7c9c2c435a3769302a2e7a13935b63992dbcad3 (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
pkgname=darknet-hankai-git
pkgver=4.0
pkgrel=1
pkgdesc="Darknet: neural network framework for object detection"
arch=('x86_64' 'aarch64' 'i686')
url="https://github.com/hank-ai/darknet"
license=('Apache-2.0')
depends=('opencv')
makedepends=('cmake' 'git')
optdepends=(
  'cuda'
  'cudnn'
  'rocm-opencl-runtime'
  'rocm-hip-runtime'
  'rocm-hip-sdk'
)
source=("git+https://github.com/hank-ai/darknet.git")
sha256sums=('SKIP')

pkgver() {
  cd "$srcdir/darknet" || return 1
  git fetch --tags
  git describe --tags --abbrev=0 | sed 's/^v//'
}

prepare() {
  cd "$srcdir/darknet"
  mkdir -p build
}

build() {
  cd "$srcdir/darknet/build"
  
  if [[ "$(uname -m)" == "aarch64" ]]; then
    cmake -DCMAKE_BUILD_TYPE=Release \
          -DCMAKE_INSTALL_PREFIX=/usr \
          ..
  else
    if lspci | grep -i nvidia > /dev/null; then
      cmake -DCMAKE_BUILD_TYPE=Release \
            -DCMAKE_INSTALL_PREFIX=/usr \
            -DCUDA_TOOLKIT_ROOT_DIR=/opt/cuda \
            ..
    elif lspci | grep -i amd > /dev/null; then
      cmake -DCMAKE_BUILD_TYPE=Release \
            -DCMAKE_INSTALL_PREFIX=/usr \
            -DROCM_PATH=/opt/rocm \
            ..
    else
      cmake -DCMAKE_BUILD_TYPE=Release \
            -DCMAKE_INSTALL_PREFIX=/usr \
            ..
    fi
  fi
  
  make -j"$(nproc)"
}

package() {
  cd "$srcdir/darknet/build"
  make DESTDIR="$pkgdir" install
}