2021-07-04 01:48:15 +08:00
|
|
|
#!/bin/bash
|
2011-09-10 04:19:06 +08:00
|
|
|
|
2014-12-21 12:15:59 +08:00
|
|
|
# Slackware build script for CUDA Toolkit
|
|
|
|
|
2020-06-19 16:18:14 +08:00
|
|
|
# Copyright 2020 Giorgio Peron <giorgio.peron@gmail.com>, Belluno, Italy
|
2011-09-10 04:19:06 +08:00
|
|
|
# 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.
|
|
|
|
|
2021-07-04 17:41:06 +08:00
|
|
|
cd $(dirname $0) ; CWD=$(pwd)
|
|
|
|
|
2011-09-10 04:19:06 +08:00
|
|
|
PRGNAM=cudatoolkit
|
2014-12-21 12:15:59 +08:00
|
|
|
FILENAME=cuda
|
2020-06-19 16:18:14 +08:00
|
|
|
VERSION=${VERSION:-10.2.89}
|
|
|
|
DRIVER=${DRIVER:-440.33.01}
|
2011-09-10 04:19:06 +08:00
|
|
|
BUILD=${BUILD:-1}
|
|
|
|
TAG=${TAG:-_SBo}
|
2021-07-04 18:23:38 +08:00
|
|
|
PKGTYPE=${PKGTYPE:-tgz}
|
2011-09-10 04:19:06 +08:00
|
|
|
|
|
|
|
|
|
|
|
case "$( uname -m )" in
|
|
|
|
i?86) ARCH=i386 ;;
|
|
|
|
arm*) ARCH=arm ;;
|
|
|
|
*) ARCH=$( uname -m ) ;;
|
|
|
|
esac
|
|
|
|
|
2021-07-04 18:23:38 +08:00
|
|
|
# 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
|
|
|
|
|
2011-09-10 04:19:06 +08:00
|
|
|
TMP=${TMP:-/tmp/SBo}
|
|
|
|
PKG=$TMP/package-$PRGNAM
|
|
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ "$ARCH" = "x86_64" ]; then
|
2012-02-22 07:50:39 +08:00
|
|
|
LIBDIRSUFFIX="64"
|
2011-09-10 04:19:06 +08:00
|
|
|
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
|
2012-02-22 07:50:39 +08:00
|
|
|
|
2022-01-28 04:30:34 +08:00
|
|
|
# 20220127 bkw: it wasn't necessary to chmod +x the .run file. Plus,
|
|
|
|
# SlackBuilds should *never* write to $CWD.
|
2020-06-19 16:18:14 +08:00
|
|
|
sh $CWD/$FILENAME\_$VERSION\_$DRIVER\_linux.run --target $PRGNAM-$VERSION --noexec
|
2012-02-22 07:50:39 +08:00
|
|
|
|
2020-06-19 16:18:14 +08:00
|
|
|
mkdir -p $PKG/usr/share
|
|
|
|
cd $PRGNAM-$VERSION/builds
|
|
|
|
cp -r cuda-toolkit "$PKG/usr/share/cuda"
|
|
|
|
cp -r cublas/include/* "$PKG/usr/share/cuda/include/"
|
|
|
|
mkdir -p $PKG/usr/lib64
|
|
|
|
cp -r cublas/lib64/* "$PKG/usr/lib$LIBDIRSUFFIX/"
|
|
|
|
cp -r cuda-samples "$PKG/usr/share/cuda/samples"
|
2011-09-10 04:19:06 +08:00
|
|
|
|
2020-06-19 16:18:14 +08:00
|
|
|
# Define compilers for CUDA to use.
|
|
|
|
# This allows us to use older versions of GCC if we have to.
|
|
|
|
# ln -s /usr/bin/gcc-8 "${PKG}/usr/share/cuda/bin/gcc"
|
|
|
|
# ln -s /usr/bin/g++-8 "${PKG}/usr/share/cuda/bin/g++"
|
2011-09-10 04:19:06 +08:00
|
|
|
|
2020-06-19 16:18:14 +08:00
|
|
|
# Put man in the standard place
|
|
|
|
mv $PKG/usr/share/cuda/doc/man $PKG/usr/
|
2014-12-21 12:15:59 +08:00
|
|
|
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
|
|
|
|
|
2020-06-19 16:18:14 +08:00
|
|
|
# Put doc in the standard place
|
|
|
|
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
|
|
|
|
mv $PKG/usr/share/cuda/doc/* $PKG/usr/doc/$PRGNAM-$VERSION/
|
|
|
|
rm -rf $PKG/usr/share/cuda/doc
|
|
|
|
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
|
|
|
|
|
|
|
|
# Create soname links.
|
|
|
|
find cuda-toolkit/targets -type f -name '*.so*' ! -path '*stubs/*' -print0 | while read -rd $'\0' _lib; do
|
|
|
|
_base=${_lib%.so.*}
|
|
|
|
_current_soname=$(basename ${_lib%.*})
|
|
|
|
while [[ $_current_soname != $(basename $_base) ]]; do
|
|
|
|
ln -sf ${_lib##*/} ${PKG}/usr/share/cuda/lib$LIBDIRSUFFIX/$_current_soname
|
|
|
|
_current_soname=${_current_soname%.*}
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
# 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 pkgconfig files
|
|
|
|
mkdir -p "$PKG"/usr/lib${LIBDIRSUFFIX}/pkgconfig
|
|
|
|
cp "${CWD}"/files/*.pc "${PKG}"/usr/lib${LIBDIRSUFFIX}/pkgconfig
|
|
|
|
|
|
|
|
# Remove included copy of java and link to system java 8
|
|
|
|
rm -fr "${PKG}/usr/share/cuda/jre"
|
|
|
|
sed 's|../jre/bin/java|/usr/bin/java|g' \
|
|
|
|
-i "${PKG}/usr/share/cuda/libnsight/nsight.ini" \
|
|
|
|
-i "${PKG}/usr/share/cuda/libnvvp/nvvp.ini"
|
|
|
|
|
|
|
|
# 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
|
2011-09-10 04:19:06 +08:00
|
|
|
|
2012-02-22 07:50:39 +08:00
|
|
|
# Put libraries in the standard place
|
|
|
|
mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}
|
2020-06-19 16:18:14 +08:00
|
|
|
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
|
2014-12-21 12:15:59 +08:00
|
|
|
cd $PKG/usr/share/cuda
|
|
|
|
ln -sf ../../lib${LIBDIRSUFFIX} lib${LIBDIRSUFFIX}
|
2011-09-10 04:19:06 +08:00
|
|
|
|
2020-06-19 16:18:14 +08:00
|
|
|
# Register application NVVP and NSIGHT
|
2014-12-21 12:15:59 +08:00
|
|
|
mkdir -p $PKG/usr/share/applications
|
|
|
|
cp $CWD/files/*.desktop $PKG/usr/share/applications
|
2011-09-10 04:19:06 +08:00
|
|
|
|
|
|
|
# Put include in the standard place
|
2020-06-19 16:18:14 +08:00
|
|
|
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
|
2014-12-21 12:15:59 +08:00
|
|
|
cd $PKG/usr/share/cuda/
|
2020-06-19 16:18:14 +08:00
|
|
|
ln -sf ../../include include
|
|
|
|
|
|
|
|
rm -rf $PKG/usr/share/cuda/targets
|
2011-09-10 04:19:06 +08:00
|
|
|
|
2017-03-07 01:28:41 +08:00
|
|
|
# These are already in the nvidia-driver package
|
|
|
|
rm -f $PKG/usr/lib${LIBDIRSUFFIX}/libOpenCL.s*
|
|
|
|
|
2011-09-10 04:19:06 +08:00
|
|
|
mkdir -p $PKG/install
|
|
|
|
cat $CWD/slack-desc > $PKG/install/slack-desc
|
2020-10-12 05:09:13 +08:00
|
|
|
cat $CWD/doinst.sh > $PKG/install/doinst.sh
|
2011-09-10 04:19:06 +08:00
|
|
|
|
|
|
|
cd $PKG
|
2021-07-04 18:23:38 +08:00
|
|
|
/sbin/makepkg -c n -l y $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
|