[2022-02-05] cudatoolkit.SlackBuildを更新(メンテナーG.Peronさんがスクリプトを更新してくださった)

About cudatoolkit (NVIDIA developper pageより)
NVIDIA ® CUDA ® Toolkitは、高性能GPU高速化アプリケーションを作成するための開発環境を提供します。
CUDA Toolkitを使用すると、GPUアクセラレーション機能を持つ組み込みシステム、デスクトップワークステーション、
エンタープライズデータセンター、クラウドベースのプラットフォーム、およびHPCスーパーコンピュータ上でアプリケーションを開発、
最適化、および展開できます。このツールキットには、GPU高速化ライブラリ、デバッグおよび最適化ツール、C/C++コンパイラ、
x 86、Arm、POWERなどの主要アーキテクチャ上でアプリケーションを構築およびデプロイするためのランタイムライブラリが含まれている。

科学者や研究者は、マルチGPU構成全体に計算を分散させるための組み込み機能を使用して、単一のGPUワークステーションから
数千のGPUを備えたクラウドへのインストールに拡張するアプリケーションを開発できます。
=== ここまで ===

slackware用のパッケージはSBoに上がっているスクリプトから作成できるが、
元ソースファイル(cuda_10.2.89_440.33.01_linux.run)のサイズが巨大(3GB超)
ということもあり、パッケージ作成のための作業スペースに4GB以上の容量が必要で
完成するパッケージサイズも2GBを超える。
わたしの slackware64-current環境では長い間 version 10.2.89 をインストールしたまま
放置していたが、slackware64-15.0 リリースが間近に控えているのを機会に
最新version 11.6.0 へアップデートしてみた。

1. 作業経緯
    cuda_10.2.89_440.33.01_linux.run -> cuda_11.6.0_510.39.01_linux.run
    でソースのディレクトリ構造が大きく変わっているため、従来のSBoのスクリプトが
    そのままでは利用できなくなっていた。
    Web検索した結果、SBoの cudatooliktメンテナー Mr.Giorgio Peronの githubを
    見つけることができた。

元スクリプトからの修正箇所:
※1) $VERSION : 11.5.1 -> 11.6.0
※2) $DRIVER :   495.29.05 --> 510.39.01
※3) ライセンス関連ファイルのリンク修正
※4) /usr/share/cuda/bin/{gcc, g++} リンクを有効化

対処方法がわからないため以下は放置状態(後日対策必要)
・/usr/share/applications/nsight.desktop が機能していない


2. 謝辞
    11.x 向けにスクリプトを更新されたメンテナー Mr.Giorgio Peron に深く感謝します。
    slackware64-15.0が正式リリースされたらSBoの cudatoolkitも最新 11.xへ更新されること
    を期待します。


3. updated scripts

cudatoolkit.SlackBuild (Thanks . G.Peron) -- 更新 2022-02-05
[code]
#!/bin/bash

# Slackware build script for CUDA Toolkit

# Copyright 2022 Giorgio Peron <giorgio.peron@gmail.com>, Belluno, Italy
# 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.
#
# thanks to JW (ABE Shin-ichi ) <shin1.abe@nifty.com> for some fix

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

PRGNAM=cudatoolkit
FILENAME=cuda
VERSION=${VERSION:-11.6.0}
DRIVER=${DRIVER:-510.39.01}
BUILD=${BUILD:-2}
TAG=${TAG:-jw}
PKGTYPE=${PKGTYPE:-txz}


case "$( uname -m )" in
  i?86) ARCH=i386 ;;
  arm*) ARCH=arm ;;
     *) ARCH=$( uname -m ) ;;
esac

# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
# the name of the created package would be, and then exit. This information
# could be useful to other scripts.
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}

set -e

if [ "$ARCH" = "x86_64" ]; then
  LIBDIRSUFFIX="64"
else
  printf "\n\n$ARCH is not supported... \n"
  exit 1
fi

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
mkdir -p $PRGNAM-$VERSION

# 20220127 bkw: it wasn't necessary to chmod +x the .run file. Plus,
# SlackBuilds should *never* write to $CWD.
sh $CWD/$FILENAME\_$VERSION\_$DRIVER\_linux.run --target $PRGNAM-$VERSION --noexec


cd $PRGNAM-$VERSION/builds
rm -r NVIDIA*.run bin
mkdir -p ${PKG}/usr/share/cuda/extras
mv cuda_samples $PKG/usr/share/cuda/samples
cat EULA.txt > $PKG/usr/share/cuda/EULA.txt
rm EULA.txt
mv integration nsight_compute nsight_systems $PKG/usr/share/cuda
mv cuda_sanitizer_api/compute-sanitizer $PKG/usr/share/cuda/extras/compute-sanitizer
rmdir cuda_sanitizer_api
for lib in *; do
  if [[ "$lib" =~ .*"version.json".* ]]; then
    continue
  fi
  cp -r $lib/* "${PKG}/usr/share/cuda/"
done

# Define compilers for CUDA to use.
# This allows us to use older versions of GCC if we have to.
ln -s /usr/bin/gcc "${PKG}/usr/share/cuda/bin/gcc"
ln -s /usr/bin/g++ "${PKG}/usr/share/cuda/bin/g++"

mkdir -p "${PKG}/usr/share/licenses/$PRGNAM"
ln -s /usr/share/cuda/EULA.txt "${PKG}/usr/share/licenses/$PRGNAM/EULA.txt"
ln -s /usr/share/cuda/README "${PKG}/usr/share/licenses/$PRGNAM/README"

# Put man in the standard place
# mv $PKG/usr/share/cuda/doc/man $PKG/usr/
# find $PKG/usr/man -type f -exec gzip -9 {} \;
# for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done

# Put doc in the standard place
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp $PKG/usr/share/cuda/EULA.txt $PKG/usr/doc/$PRGNAM-$VERSION/
cp $PKG/usr/share/cuda/README $PKG/usr/doc/$PRGNAM-$VERSION/
mv $PKG/usr/share/cuda/cublas_version.txt \
  $PKG/usr/share/cuda/CUDA*.txt \
  $PKG/usr/share/cuda/DOCS \
  $PKG/usr/doc/$PRGNAM-$VERSION/
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

# Install profile and ld.so.config files
install -Dm755 "${CWD}/files/cuda.sh" "${PKG}/etc/profile.d/cuda.sh"
install -Dm755 "${CWD}/files/cuda.csh" "${PKG}/etc/profile.d/cuda.csh"
install -Dm644 "${CWD}/files/cuda.conf" "${PKG}/etc/ld.so.conf.d/cuda.conf"

# Install pkgconfig files
mkdir -p "$PKG"/usr/lib${LIBDIRSUFFIX}/pkgconfig
cp "${CWD}"/files/*.pc "${PKG}"/usr/lib${LIBDIRSUFFIX}/pkgconfig

# Allow newer compilers to work.
# See https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements
# for official requirements
sed -i "/.*unsupported GNU version.*/d" "${PKG}"/usr/share/cuda/targets/x86_64-linux/include/crt/host_config.h
sed -i "/.*unsupported clang version.*/d" "${PKG}"/usr/share/cuda/targets/x86_64-linux/include/crt/host_config.h

# Fix Makefile paths to CUDA
for f in $(find "$PKG"/usr/share/cuda -name Makefile); do
  sed -i "s|/usr/local/cuda|/usr/share/cuda|g" "$f"
done

# Put libraries in the standard place
mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}
mv -fn $PKG/usr/share/cuda/targets/x86_64-linux/lib/* $PKG/usr/lib${LIBDIRSUFFIX}/
rm -rf $PKG/usr/share/cuda/targets/x86_64-linux/lib
cd $PKG/usr/share/cuda
ln -sf ../../lib${LIBDIRSUFFIX} lib${LIBDIRSUFFIX}

# Register application NVVP and NSIGHT
mkdir -p $PKG/usr/share/applications
cp $CWD/files/*.desktop $PKG/usr/share/applications

# Put include in the standard place
mkdir -p $PKG/usr/include
mv -fn $PKG/usr/share/cuda/targets/x86_64-linux/include/* $PKG/usr/include/
rm -rf $PKG/usr/share/cuda/targets/x86_64-linux/include
cd $PKG/usr/share/cuda/
ln -sf ../../include include

# Finally remove targets folder
rm -rf $PKG/usr/share/cuda/targets

# These are already in the nvidia-driver package
rm -f $PKG/usr/lib${LIBDIRSUFFIX}/libOpenCL.s*

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

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


cudatoolkit.info
[code]
PRGNAM="cudatoolkit"
VERSION="11.6.0"
HOMEPAGE="https://developer.nvidia.com/cuda-toolkit"
DOWNLOAD="UNSUPPORTED"
MD5SUM=""
DOWNLOAD_x86_64="https://developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda_11.6.0_510.39.01_linux.run"
MD5SUM_x86_64="685ef40564b829eb8e6892563e9d8b80"
REQUIRES="nvidia-driver jdk"
MAINTAINER="Giorgio Peron"
#EMAIL="giorgio.peron@gmail.com" ; original creator
EMAIL="shin1.abe@nifty.com" ; edited based on original script

slac-desc
[code]
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':' except on otherwise blank lines.

           |-----handy-ruler------------------------------------------------------|
cudatoolkit: cudatoolkit (NVIDIA's parallel computing architecture)
cudatoolkit:
cudatoolkit: CUDA is NVIDIA's parallel computing architecture. It enables dramatic
cudatoolkit: increases in computing performance by harnessing the power of
cudatoolkit: the GPU.
cudatoolkit:
cudatoolkit: Homepage https://developer.nvidia.com/cuda-toolkit
cudatoolkit:
cudatoolkit:
cudatoolkit:
cudatoolkit


4. 念の為、nv-codec-haders (ffnvcodec) も更新
*******************
FFmpeg version of headers required to interface with Nvidias codec APIs.

Corresponds to Video Codec SDK version 11.1.5.

Minimum required driver versions:
Linux: 470.57.02 or newer
*******************

nv-codec-headers.SlackBuild
[code]
#!/bin/bash

# Slackware build script for nv-codec-headers

# Copyright 2018-2021, Andrew Strong, Blue Mountains, Australia.
# 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=nv-codec-headers
# Note that the version number is contained
# within the file ffnvcodec.pc.in:
VERSION=${VERSION:-11.1.5.1}
BUILD=${BUILD:-1}
TAG=${TAG:-jw}
PKGTYPE=${PKGTYPE:-txz}

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

# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
# the name of the created package would be, and then exit. This information
# could be useful to other scripts.
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
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  LIBDIRSUFFIX="64"
else
  LIBDIRSUFFIX=""
fi

set -e

rm -rf $PKG
mkdir -p $PKG
cd $TMP
rm -rf $PRGNAM

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

cd $PRGNAM-$VERSION
chown -R root:root .

make PREFIX=/usr LIBDIR=lib${LIBDIRSUFFIX} install DESTDIR=$PKG

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a README $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


5. === ffmpeg-4.4.1 再構築 ===
ffmpeg.SlackBuild
[code]
#!/bin/sh

# Heavily based on the Slackware 14.1 SlackBuild

# Written by Loris Vincenzi (info@slacky.it)
# Last build from 6c33c ( seic33c [at] gmail [dot] com )

# Slackware build script for ffmpeg
# Official Site: http://www.ffmpeg.org
# Patches from ...

# 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.
#
# Required: celt, enca, faac, frei0r, lame, libaacplus, libass, libbluray, libdc1394
# Required: libgsm, libmodplug,  libnut (Static), libva, libdvpau, libvpx, libxavs (Static)
# Required: openal-soft, opencore-amr, openjpeg, opus, orc, rtmpdump
# Required: schroedinger, speex, twolame, utvideo (Static), vo-aacenc, vo-amrwbenc,
# Required: x264, xvidcore
#
## Chanhes
# 2020-06-13 : version 4.2.3-2jw  Rebuild to fix miising vdpau support
# 2021-04-13 : version bump to 4.4 with nvenc support
# 2021-10-02 : -2jw ; with "--enable-encoder=aac"
# 2022-01-21 : -4jw : add options "--enable-nvenc, --enable-cuda" just incase
# 2022-01-25 : -6jw ; add option "--enable-cuda-nvcc --extra-ldflags="-L/usr/share/cuda/lib64" --extra-cflags="-I/usr/share/cuda/include"
#                --nvccflags="-gencode arch=compute_75,code=sm_75 -O2" --enable-cuda-nvcc --nvcc=nvcc"

set -e

# Basic information.

PKGNAME=ffmpeg
VERSION=${VERSION:-4.4.1}
#VERSION=$(date +%Y%m%d)         #In case of git/svn/cvs
ARCH=${ARCH:-$(uname -m)}
BUILD=${BUILD:-6}             # against nv-codec-headers-11.1.5.1, cudatoolkit-11.6.0 and against libvpx-1.11.0 .so and libx264.so.160 version bump.
TAG=${TAG:-jw}
SOURCE="http://www.ffmpeg.org/releases/$PKGNAME-$VERSION.tar.xz"
TAR=      # empty = auto
DIR=      # empty = auto
#TAR=$PKGNAME-$VERSION.tar.bz2        #In case of git/svn/cvs
#DIR=$PKGNAME                        #In case of git/svn/cvs
DOCS="C* INSTALL LICENSE README RELEASE VERSION doc/*.html doc/*.txt"
SLKFILES=""

# Automatically determine the architecture we're building on:
case "$ARCH" in
      i?86) export ARCH=i486; SLKCFLAGS="-O2 -march=i486 -mtune=i686"; CHOST="i486-slackware-linux" ;;
    x86_64) SLKCFLAGS="-O2 -fPIC"; SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64"; CHOST="x86_64-slackware-linux" ;;
      arm*) export ARCH=arm; SLKCFLAGS="-O2 -march=armv5te"; CHOST="arm-slackware-linux-gnueabi" ;;
# Unless $ARCH is already set, use uname -m for all other archs:
         *) export ARCH=$( uname -m ) ;;
esac

# If EULA
if [ -e EULA.TXT ];then
    more EULA.TXT
    echo "Do you accept terms? (yes/[no])"
    read ACCEPT
    if [ "$ACCEPT" != "yes" ];then
        echo; echo "SlackBuild Aborted!!"
        exit 1
    fi
fi

# Do not touch following if not needed
JOBS=${JOBS:--j2}
CWD=$(pwd)
TMP=${TMP:-/tmp/buildpkgs/$PKGNAME}
PKG=$TMP/package-$PKGNAME
OUTPUT=${OUTPUT:-$CWD}
TAR=${TAR:-$(basename $SOURCE)}
DIR=${DIR:-$(echo "$TAR"|sed -r 's/(\.tar|)(.gz|.bz2|.xz|.tgz|)$//')}

if [ ! -e $CWD/$TAR ];then

# Download sources from git/mercurial/svn/etcetera into a directory named $DIR

#    git clone $SOURCE $DIR
#    tar czf $TAR $DIR
#    rm -rf $DIR

    wget $SOURCE -O "$CWD/$TAR"
fi

### Preparing Source
rm -rf $TMP
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
tar xvf $CWD/$TAR
cd $DIR

# Add local patch here
# zcat $CWD/0001-ffmpeg-2.8.2_fix-libvpxenc.patch.gz |patch -p1 --verbose || exit 1
# zcat $CWD/ffmpeg.openjpeg2.3.diff.gz | patch -p1 --verbose || exit 1
patch -p1 < $CWD/vmaf-model-path.patch

chown -R root:root .
chmod -R u+w,go+r-w,a-s .

# Customize as you need
CPPFLAGS="-I/usr/include/vpx" \
LDFLAGS="$SLKLDFLAGS" \
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure --prefix=/usr \
--shlibdir=/usr/lib${LIBDIRSUFFIX} \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--mandir=/usr/man \
--disable-static \
--disable-doc \
--enable-shared \
--enable-gnutls \
--enable-hwaccels \
--enable-vaapi \
--enable-vdpau \
--enable-ffnvcodec \
--extra-ldflags="-L/usr/share/cuda/lib64" \
--extra-cflags="-I/usr/share/cuda/include" \
--nvccflags="-gencode arch=compute_75,code=sm_75 -O2" \
--enable-cuda-nvcc \
--nvcc=nvcc \
--enable-nvdec \
--enable-nvenc \
--enable-cuda \

--enable-nonfree \
--enable-gpl \
--enable-version3 \
--enable-postproc \
--enable-swscale \
--enable-avfilter \
--enable-pthreads \
--enable-bzlib \
--enable-libcelt \
--enable-libcdio  \
--enable-frei0r \
--enable-libass \
--enable-libbluray \
--enable-libcaca \
--enable-libopencore-amrnb \
--enable-libopencore-amrwb \
--enable-libopus \
--enable-libdc1394 \
--enable-libfontconfig \
--enable-libfreetype \
--enable-libfribidi \
--enable-gnutls \
--enable-libgsm \
--enable-libmodplug \
--enable-libmp3lame \
--enable-librtmp \
--enable-libspeex \
--enable-libvpx \
--enable-libwebp \
--enable-libopenjpeg \
--enable-libpulse \
--disable-libsmbclient \
--enable-libspeex \
--enable-libtheora \
--enable-libtwolame \
--enable-libv4l2 \
--enable-libvo-amrwbenc \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
--enable-libxavs \
--enable-libxvid \
--enable-openal \
--disable-openssl \
--enable-zlib \
--disable-debug \
--enable-encoder=aac \
--arch=${ARCH}
echo -e "\E[0;32mPress any key to build the package!\E[0;0m"
read
make $JOBS
make tools/qt-faststart
make install DESTDIR=$PKG

# Don't ship .la files:
rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la

## Do special operations

install -D -m 0755 tools/qt-faststart $PKG/usr/bin/qt-faststart

# install -m 644 -p -D doc/ffserver.conf  $PKG/etc/ffserver.conf.new

# Documentation
mkdir -p $PKG/usr/doc/$PKGNAME-$VERSION

for DC in $DOCS;do
    [ -e $DC ] && cp -r $DC $PKG/usr/doc/$PKGNAME-$VERSION/ || true
done

mkdir -p $PKG/usr/doc/$PKGNAME-$VERSION/SlackBuild

cd $CWD
for SB in $PKGNAME.SlackBuild slack-desc doinst.sh doinst.sh.gz EULA.TXT $SLKFILES;do
    [ -e "$SB" ] && cp -r $SB $PKG/usr/doc/$PKGNAME-$VERSION/SlackBuild/$SB || true
done

for i in man info
do
    if [ -d $PKG/usr/$i ]; then
           cd $PKG/usr/$i
        find . -type f -exec gzip -9 {} \;
        for file in $( find . -type l ) ; do ln -s $( readlink $file ).gz $file.gz ; rm $file ; done
        [ "$i" == "info" ] && rm -f dir
    fi
done

cd $PKG
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true
find . | xargs file | grep "current ar archive" | cut -f 1 -d : | xargs -r strip --strip-unneeded 2> /dev/null || true

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
[ -e $CWD/doinst.sh ] && cat $CWD/doinst.sh > $PKG/install/doinst.sh
[ -e $CWD/doinst.sh.gz ] && zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh

cd $PKG
chown -R root:root $PKG

if [ -x "$(which requiredbuilder 2>/dev/null)" ];then
        ADD=$(ls /var/log/packages/ | sed -ne 's/\(frei0r\)-\([^-]\+-[^-]\+-[^-]\+\)/\1 >= \2/p') \
    requiredbuilder -y -v -s $CWD $PKG # add "-c -b" if you have binary files in /usr/share
    [ -e install/slack-required ] && cat install/slack-required > $PKG/usr/doc/$PKGNAME-$VERSION/SlackBuild/slack-required
fi

/sbin/makepkg -l y -c n $OUTPUT/$PKGNAME-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-txz}

if [ "$1" = "--cleanup" ]; then
    rm -rf $TMP
fi



=== インストール後の cudatoolkit バージョン確認と ffmpeg-4.4.1 サポートLOG ===
[code]
nvidia 関連ツールによるバージョン確認
$ nvcc -V
     nvcc: NVIDIA (R) Cuda compiler driver
     Copyright (c) 2005-2021 NVIDIA Corporation
     Built on Fri_Dec_17_18:16:03_PST_2021
     Cuda compilation tools, release 11.6, V11.6.55
     Build cuda_11.6.r11.6/compiler.30794723_0

$ nvidia-smi      
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.39.01    Driver Version: 510.39.01    CUDA Version: 11.6     | <-- here
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0  On |                  N/A |
|  0%   56C    P0    29W / 200W |    417MiB /  6144MiB |      1%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      2761      G   /usr/libexec/Xorg                 302MiB |
|    0   N/A  N/A      2829      G   xfwm4                               2MiB |
|    0   N/A  N/A      3575      G   /usr/lib64/firefox/firefox        105MiB |
|    0   N/A  N/A      3696      G   ...lib64/firefox/firefox-bin        1MiB |
|    0   N/A  N/A      3744      G   ...lib64/firefox/firefox-bin        1MiB |
+-----------------------------------------------------------------------------+

ffmpeg-4.4.1 compiled with --enable-nvenc is working
$ ffmpeg -encoders |grep nvenc
 V....D h264_nvenc           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc                NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_h264           NVIDIA NVENC H.264 encoder (codec h264)
 V..... nvenc_hevc           NVIDIA NVENC hevc encoder (codec hevc)
 V....D hevc_nvenc           NVIDIA NVENC hevc encoder (codec hevc)

$ ffmpeg -decoders |grep cuvid
 V..... av1_cuvid            Nvidia CUVID AV1 decoder (codec av1)
 V..... h264_cuvid           Nvidia CUVID H264 decoder (codec h264)
 V..... hevc_cuvid           Nvidia CUVID HEVC decoder (codec hevc)
 V..... mjpeg_cuvid          Nvidia CUVID MJPEG decoder (codec mjpeg)
 V..... mpeg1_cuvid          Nvidia CUVID MPEG1VIDEO decoder (codec mpeg1video)
 V..... mpeg2_cuvid          Nvidia CUVID MPEG2VIDEO decoder (codec mpeg2video)
 V..... mpeg4_cuvid          Nvidia CUVID MPEG4 decoder (codec mpeg4)
 V..... vc1_cuvid            Nvidia CUVID VC1 decoder (codec vc1)
 V..... vp8_cuvid            Nvidia CUVID VP8 decoder (codec vp8)
 V..... vp9_cuvid            Nvidia CUVID VP9 decoder (codec vp9)

$ ffmpeg -filters |grep cuvid
 ... hwupload_cuda     V->V       Upload a system memory frame to a CUDA device.
 ... overlay_cuda      VV->V      Overlay one video on top of another using CUDA
 ... scale_cuda        V->V       GPU accelerated video resizer
 ... thumbnail_cuda    V->V       Select the most representative frame in a given sequence of consecutive frames.
 T.. yadif_cuda        V->V       Deinterlace CUDA frames

$ ffmpeg -hwaccels
Hardware acceleration methods:
vdpau
cuda
vaapi


6. 実際にエンコードしてみる
[code]
$ ffmpeg -hwaccel cuda -hwaccel_output_format cuda -c:v mpeg2_cuvid -i INPUT_TEST.vob -c:v h264_nvenc -c:a copy -f mp4 OUTPUT.mp4

---
結果)
・INPUT_TEST.vob  -- size 1.1GB
・変換に要した時間 --- 20 sec.



編集中