|
|
#!/bin/bash
# Slackware build script for openvino
# Copyright 2024 Johannes Schoepfer, Germany
# 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:-2024.0.0}
VERSION_FLATBUFFERS=24.3.25
VERSION_ONNX=1.16.0
VERSION_ONEDNN_GPU=3.4.1
COMMIT_ONEDNN=26633ae49edd4353a29b7170d9fcef6b2d79f4b3
COMMIT_MLAS=d1bc25ec4660cddd87804fcf03b2411b5dfb2e94
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 {} +
# Flatbuffers from SBo provide broken cmake files(static-lib removed but static-lib-cmake-files not removed)
(
cd thirdparty/flatbuffers/
rmdir flatbuffers
tar vxf $CWD/flatbuffers-$VERSION_FLATBUFFERS.tar.gz
ln -s flatbuffers-$VERSION_FLATBUFFERS flatbuffers
)
# onnx frontend
(
cd thirdparty/onnx/
rmdir onnx
tar vxf $CWD/onnx-$VERSION_ONNX.tar.gz
ln -s onnx-$VERSION_ONNX onnx
)
# mlas for cpu inference device
(
cd src/plugins/intel_cpu/thirdparty
rmdir mlas
tar vxf $CWD/mlas-$COMMIT_MLAS.tar.gz
ln -s mlas-$COMMIT_MLAS mlas
)
# oneDNN for cpu inference device, fork from openvinotoolkit needed
# oneDNN supports 64 bit platforms only
if [ "$LIBDIRSUFFIX" == 64 ]; then
CPU=ON
GPU=ON
(
cd src/plugins/intel_cpu/thirdparty
rmdir onednn
tar vxf $CWD/oneDNN-$COMMIT_ONEDNN.tar.gz
ln -s oneDNN-$COMMIT_ONEDNN onednn
)
# oneDNN for gpu inference device, original project
(
cd src/plugins/intel_gpu/thirdparty
rmdir onednn_gpu
tar vxf $CWD/oneDNN-$VERSION_ONEDNN_GPU.tar.gz
ln -s oneDNN-$VERSION_ONEDNN_GPU onednn_gpu
)
else
CPU=OFF
GPU=OFF
fi
#-DENABLE_TBBBIND_2_5=OFF prevents using static prebuild libtbbbind
# https://github.com/openvinotoolkit/openvino/blob/master/docs/dev/cmake_options_for_custom_compilation.md
mkdir -p build
cd build
unshare -n cmake \
-DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
-DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
-DCMAKE_CXX_STANDARD=17 \
-DLIB_SUFFIX=${LIBDIRSUFFIX} \
-DCMAKE_INSTALL_PREFIX=/usr/share/openvino \
-DENABLE_SYSTEM_PUGIXML=ON \
-DENABLE_SYSTEM_SNAPPY=ON \
-DENABLE_SYSTEM_OPENCL=ON \
-DENABLE_SYSTEM_TBB=ON \
-DENABLE_TBBBIND_2_5=OFF \
-DENABLE_SYSTEM_PROTOBUF=ON \
-DProtobuf_LIBRARY=/usr/lib$LIBDIRSUFFIX/libprotobuf.so \
-DENABLE_SYSTEM_OPENCL=ON \
-DOpenCV_DIR=/usr/lib64/cmake/opencv4 \
-DENABLE_JS=OFF \
-DENABLE_SAMPLES=OFF \
-DENABLE_INTEL_CPU=$CPU \
-DENABLE_INTEL_GPU=$GPU \
-DENABLE_OV_ONNX_FRONTEND=ON \
-Wno-dev \
-DCMAKE_BUILD_TYPE=Release ..
cmake --build .
make install/strip DESTDIR=$PKG
cd ..
rmdir $PKG/usr/share/openvino/samples/cpp/thirdparty/gflags/gflags
rmdir $PKG/usr/share/openvino/samples/cpp/thirdparty/nlohmann_json
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
|