summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ada3005d3969735988fbca0163ee330d6be15ccd (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
# Maintainer : Daniel Bermond <dbermond@archlinux.org>
# Contributor: Fabio 'Lolix' Loli <fabio.loli@disroot.org>

pkgname=intel-npu-driver-git
pkgver=1.10.1.r0.g93fb54b
pkgrel=3
pkgdesc='Intel Neural Processing Unit (NPU) driver (git version)'
arch=('x86_64')
url='https://github.com/intel/linux-npu-driver/'
license=('MIT' 'BSD-3-Clause')
depends=(
    'gtest'
    'openssl'
    'level-zero-loader'
    'opencv'
    'systemd-libs'
    'yaml-cpp')
optdepends=('intel-npu-compiler: for compiling OpenVINO IR models')
makedepends=(
    'cmake'
    'git'
    'level-zero-headers'
    'libdrm')
provides=('intel-npu-driver')
conflicts=('intel-npu-driver')
install=intel-npu-driver.install
source=('git+https://github.com/intel/linux-npu-driver.git'
        'git+https://github.com/intel/level-zero-vpu-extensions.git'
        'git+https://github.com/openvinotoolkit/vpux_plugin_elf.git'
        'git+https://github.com/xanderlent/intel-npu-driver-rpm.git'
        '10-intel-npu.rules'
        '010-intel-npu-driver-fix-libdrm-header.patch'
        '020-intel-npu-driver-rename-installed-binaries.patch')
sha256sums=('SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            '592a2f5575ecce93a03c66987573fe675d41a63b49cee11d2553645d9e5624fe'
            '4dad75ab65bd244d1be9a3bc62ff81da357c3a181693761081acaa82be3fe6b3'
            'db6dd634ca144607a5961950298a8fbc162f90d3f55f69eca0e585f1657aeeda')

prepare() {
    git -C linux-npu-driver submodule init
    git -C linux-npu-driver config --local submodule.third_party/level-zero.update none
    git -C linux-npu-driver config --local submodule.third_party/level-zero-npu-extensions.url "${srcdir}/level-zero-vpu-extensions"
    git -C linux-npu-driver config --local submodule.third_party/vpux_elf.url "${srcdir}/vpux_plugin_elf"
    git -C linux-npu-driver config --local submodule.third_party/googletest.update none
    git -C linux-npu-driver config --local submodule.third_party/yaml-cpp.update none
    git -C linux-npu-driver -c protocol.file.allow='always' submodule update
    
    # fix build with level-zero 1.18
    # https://github.com/intel/level-zero-npu-extensions/commit/110f48ee8eda22d8b40daeeecdbbed0fc3b08f8b
    git -C linux-npu-driver/third_party/level-zero-npu-extensions config --local advice.detachedHead false
    git -C linux-npu-driver/third_party/level-zero-npu-extensions checkout 110f48ee8eda22d8b40daeeecdbbed0fc3b08f8b
    
    patch -d linux-npu-driver -Np1 -i "${srcdir}/010-intel-npu-driver-fix-libdrm-header.patch"
    patch -d linux-npu-driver -Np1 -i "${srcdir}/020-intel-npu-driver-rename-installed-binaries.patch"
    
    patch -d linux-npu-driver -Np1 -i "${srcdir}/intel-npu-driver-rpm/0001-Disable-third-party-googletest-and-yaml-cpp.patch"
    patch -d linux-npu-driver -Np1 -i "${srcdir}/intel-npu-driver-rpm/0002-Make-firmware-install-respect-CMAKE_INSTALL_PATH.patch"
    patch -d linux-npu-driver -Np1 -i "${srcdir}/intel-npu-driver-rpm/0004-Fix-usage-of-upstreamed-extension.patch"
}

pkgver() {
    git -C linux-npu-driver describe --long --tags --abbrev='7' | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
    # fix error: "_FORTIFY_SOURCE" redefined
    # note: upstream forces _FORTIFY_SOURCE=2
    export CFLAGS="${CFLAGS/-Wp,-D_FORTIFY_SOURCE=?/}"
    export CXXFLAGS="${CXXFLAGS/-Wp,-D_FORTIFY_SOURCE=?/}"
    
    cmake -B build -S linux-npu-driver \
        -G 'Unix Makefiles' \
        -DCMAKE_BUILD_TYPE:STRING='None' \
        -DCMAKE_INSTALL_PREFIX:PATH='/usr' \
        -DENABLE_NPU_COMPILER_BUILD:BOOL='OFF' \
        -DLevelZero_INCLUDE_DIR:PATH='/usr/include' \
        -Wno-dev
    cmake --build build
}

package() {
    DESTDIR="$pkgdir" cmake --install build
    chmod 644 "${pkgdir}/usr/lib/firmware/updates/intel/vpu"/vpu_*.bin
    install -D -m644 10-intel-npu.rules -t "${pkgdir}/usr/lib/udev/rules.d"
    install -D linux-npu-driver/LICENSE.md -t "${pkgdir}/usr/share/licenses/${pkgname}"
    install -D linux-npu-driver/firmware/bin/COPYRIGHT "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-firmware"
}