aboutsummaryrefslogtreecommitdiffstats
path: root/openvino/openvino.SlackBuild
blob: 738ee0fe70d1ee77fe94ef891bb68f7cd5758062 (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/bash

# Slackware build script for openvino

# Copyright 2024  Johannes Schoepfer, Germany
# Copyright 2026  Danilo M. <danix@danix.xyz>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=openvino
VERSION=${VERSION:-2026.4.0}
# All bundled deps are pinned to the exact commit openvino references at this
# tag (its git submodule gitlinks), downloaded as archive/<sha> tarballs.
COMMIT_MLAS=d1bc25ec4660cddd87804fcf03b2411b5dfb2e94
COMMIT_ONEDNN=1289c3b65dd6a119a5ed12a816517d9c3a21d81b
COMMIT_ONEDNN_GPU=a3d459721b72c3a9d2685b46c03dafee7af0f25c
COMMIT_FLATBUFFERS=595bf0007ab1929570c7671f091313c8fc20644e
COMMIT_ONNX=2bb50465112feca9003e1ed654d77f01ff1415ca
COMMIT_ITTAPI=ca45fef1a12cef3316e6ff362a4d36571270e392
COMMIT_PROTOBUF=d6511091a0cab1ad13f676a02676ad2a0e5eb9ae
# protobuf 5.26.0 needs utf8_range, which needs abseil as its own nested
# submodule; pinned to the commit that protobuf commit references.
COMMIT_ABSEIL=4a2c63365eff8823a5221db86ef490e828306f9d
COMMIT_XBYAK=431abd865e70a46d56f5aa0e1f87572decb60169
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  exit 0
fi

TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "aarch64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
elif [ "$ARCH" = "arm" ]; then
  SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
  LIBDIRSUFFIX=""
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xvf $CWD/$PRGNAM-$VERSION.tar.?z
cd $PRGNAM-$VERSION

chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} + -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} +

patch -p1 < $CWD/010-openvino-disable-werror.patch
patch -p1 < $CWD/020-openvino-use-protobuf-shared-libs.patch

# Each bundled dep ships as a git submodule; upstream leaves an empty
# placeholder dir where it expects the source. We drop in the pinned tarball
# and symlink the placeholder to whatever top-level dir it unpacks, so the
# extracted dir name (a commit hash) never has to be spelled out here. Bumping
# a dep is then just a new SHA/URL/md5 in the vars and .info, no edits below.
# args: <parent-dir> <placeholder-name> <tarball>
bundle_dep() {
  ( cd "$1"
    rmdir "$2"
    top=$(tar tf "$CWD/$3" | head -1 | cut -d/ -f1)
    tar xf "$CWD/$3"
    ln -s "$top" "$2"
  )
}

# Flatbuffers from SBo provide broken cmake files (static-lib removed but
# static-lib-cmake-files not removed), so bundle upstream's copy.
bundle_dep thirdparty/flatbuffers flatbuffers "flatbuffers-$COMMIT_FLATBUFFERS.tar.gz"
bundle_dep thirdparty/onnx onnx "onnx-$COMMIT_ONNX.tar.gz"
bundle_dep thirdparty/ittapi ittapi "ittapi-$COMMIT_ITTAPI.tar.gz"
bundle_dep thirdparty/protobuf protobuf "protobuf-$COMMIT_PROTOBUF.tar.gz"
bundle_dep thirdparty/protobuf/protobuf/third_party abseil-cpp "abseil-cpp-$COMMIT_ABSEIL.tar.gz"
# Bundle xbyak rather than use the system package: its cmake config exports a
# bare -isystem /usr/include, which breaks GCC 15's #include_next <stdlib.h>.
# Its submodule sits directly at thirdparty/xbyak (no nested wrapper dir).
bundle_dep thirdparty xbyak "xbyak-$COMMIT_XBYAK.tar.gz"
bundle_dep src/plugins/intel_cpu/thirdparty mlas "mlas-$COMMIT_MLAS.tar.gz"
bundle_dep src/plugins/intel_cpu/thirdparty onednn "oneDNN-$COMMIT_ONEDNN.tar.gz"
bundle_dep src/plugins/intel_gpu/thirdparty onednn_gpu "oneDNN-$COMMIT_ONEDNN_GPU.tar.gz"

# npu plugin needs avx and does not build with the default x86_64 arch
mkdir -p build
cd build
  # Configure with no network: openvino's cmake otherwise fetches prebuilt
  # deps (e.g. TBB) from storage.openvinotoolkit.org via aria2c, which would
  # silently pull in unvetted binaries. Skipped where unshare is not permitted
  # (containers without CAP_SYS_ADMIN); the pinned bundled deps still apply.
  unshare -n true 2>/dev/null && NETNS="unshare -n" || NETNS=""
  $NETNS cmake \
    -G Ninja \
    -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
    -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
    -DCMAKE_CXX_STANDARD=17 \
    -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
    -DCMAKE_INSTALL_PREFIX=/usr/share/openvino \
    -DLIB_SUFFIX=${LIBDIRSUFFIX} \
    -DENABLE_AVX2=OFF \
    -DENABLE_AVX512F=OFF \
    -DENABLE_CPPLINT=OFF \
    -DENABLE_SYSTEM_FLATBUFFERS=OFF \
    -DENABLE_SYSTEM_PUGIXML=ON \
    -DENABLE_SYSTEM_SNAPPY=ON \
    -DENABLE_SYSTEM_TBB=ON \
    -DENABLE_PROFILING_ITT=ON \
    -DENABLE_TBBBIND_2_5=OFF \
    -DENABLE_JS=OFF \
    -DENABLE_SAMPLES=OFF \
    -DENABLE_INTEL_CPU=ON \
    -DENABLE_INTEL_GPU=ON \
    -DENABLE_INTEL_NPU=OFF \
    -DCMAKE_BUILD_TYPE=Release ..
  "${NINJA:=ninja}"
  DESTDIR=$PKG $NINJA install/strip
cd ..

# We don't build samples, so we remove samples stub files
rm -rf $PKG/usr/share/openvino/samples

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a LICENSE README.md $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE