Blender.SlackBuild 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #!/bin/bash
  2. # Slackware build script for Blender
  3. # Copyright 2015-2022 Christoph Willing, Brisbane Australia
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  15. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. # 20220322 bkw: Modified by SlackBuilds.org, BUILD=2:
  23. # - make embree optional (makes it possible to build Blender on 32-bit,
  24. # since embree is 64-bit-only).
  25. # - add patch to fix 32-bit compilation.
  26. cd $(dirname $0) ; CWD=$(pwd)
  27. PRGNAM=Blender
  28. VERSION=${VERSION:-3.0.1}
  29. BUILD=${BUILD:-2}
  30. TAG=${TAG:-_SBo}
  31. PKGTYPE=${PKGTYPE:-tgz}
  32. SRCNAM=blender
  33. BASE_VERSION=${BASE_VERSION:-$( echo $VERSION | sed -e 's/[^0-9.]*//g')}
  34. PYTHON_VERSION=$(python3 -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))')
  35. if [ -z "$ARCH" ]; then
  36. case "$( uname -m )" in
  37. i?86) ARCH=i586 ;;
  38. arm*) ARCH=arm ;;
  39. *) ARCH=$( uname -m ) ;;
  40. esac
  41. fi
  42. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  43. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  44. exit 0
  45. fi
  46. TMP=${TMP:-/tmp/SBo}
  47. PKG=$TMP/package-$SRCNAM
  48. OUTPUT=${OUTPUT:-/tmp}
  49. if [ "$ARCH" = "i586" ]; then
  50. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  51. LIBDIRSUFFIX=""
  52. elif [ "$ARCH" = "i686" ]; then
  53. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  54. LIBDIRSUFFIX=""
  55. elif [ "$ARCH" = "x86_64" ]; then
  56. SLKCFLAGS="-O2 -fPIC"
  57. LIBDIRSUFFIX="64"
  58. else
  59. SLKCFLAGS="-O2"
  60. LIBDIRSUFFIX=""
  61. fi
  62. cuda=""
  63. if [ -d /usr/include/cuda ]; then
  64. # If cudatoolkit is installed, assume we want to use it
  65. cuda="-DWITH_CYCLES_CUDA_BINARIES=ON"
  66. # However disable cuda if requested by e.g. CUDA=no
  67. if [ ${CUDA:-yes} != "yes" ]; then
  68. cuda="-DWITH_CYCLES_CUDA_BINARIES=OFF"
  69. fi
  70. fi
  71. embree="-DWITH_CYCLES_EMBREE=OFF"
  72. # If embree is installed, use it unless user says EMBREE=no.
  73. if [ -d /usr/include/embree3 -a "${EMBREE:-yes}" = "yes" ]; then
  74. embree="-DWITH_CYCLES_EMBREE=ON"
  75. fi
  76. set -e
  77. rm -rf $PKG
  78. mkdir -p $TMP $PKG $OUTPUT
  79. cd $TMP
  80. rm -rf $SRCNAM-$VERSION
  81. tar xvf $CWD/$SRCNAM-$VERSION.tar.xz
  82. cd $SRCNAM-$VERSION
  83. chown -R root:root .
  84. find -L . \
  85. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  86. -o -perm 511 \) -exec chmod 755 {} \+ -o \
  87. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  88. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+
  89. # 20220322 bkw: 32-bit needs this
  90. [ -z "$LIBDIRSUFFIX" ] && patch -p1 < $CWD/overloaded_min.diff
  91. mkdir -p build
  92. cd build
  93. cmake ../ \
  94. -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
  95. -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
  96. -DCMAKE_INSTALL_PREFIX=/usr \
  97. -DWITH_INSTALL_PORTABLE:BOOL=OFF \
  98. -DWITH_BUILDINFO:BOOL=ON \
  99. -DWITH_OPENCOLLADA:BOOL=ON \
  100. -DWITH_OPENCOLORIO:BOOL=ON \
  101. -DPYTHON_VERSION=$PYTHON_VERSION \
  102. -DWITH_PYTHON_INSTALL:BOOL=OFF \
  103. -DWITH_PYTHON_INSTALL_NUMPY:BOOL=ON \
  104. -DWITH_CODEC_FFMPEG:BOOL=ON \
  105. -DWITH_OPENAL:BOOL=ON \
  106. -DWITH_JACK:BOOL=ON \
  107. -DWITH_JACK_DYNLOAD:BOOL=ON \
  108. -DPYTHON_LIBPATH:PATH=/usr/lib${LIBDIRSUFFIX} \
  109. -DWITH_CODEC_SNDFILE:BOOL=ON \
  110. -DWITH_FFTW3:BOOL=ON \
  111. -DWITH_IMAGE_OPENJPEG:BOOL=ON \
  112. -DWITH_SYSTEM_EIGEN3:BOOL=OFF \
  113. -DWITH_SYSTEM_GLEW:BOOL=OFF \
  114. -DWITH_SYSTEM_LZO:BOOL=ON \
  115. -DWITH_MEM_JEMALLOC:BOOL=ON \
  116. -DWITH_MEM_VALGRIND:BOOL=ON \
  117. -DWITH_MOD_OCEANSIM:BOOL=ON \
  118. -DWITH_SDL:BOOL=ON \
  119. -DWITH_SDL_DYNLOAD:BOOL=ON \
  120. -DCMAKE_BUILD_TYPE=Release \
  121. $cuda \
  122. $embree \
  123. -DCMAKE_EXE_LINKER_FLAGS:STRING="-lboost_locale"
  124. make
  125. make install DESTDIR=$PKG
  126. cd ..
  127. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  128. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  129. BLENDERBINS="blender"
  130. for bin in $BLENDERBINS ; do
  131. mv $PKG/usr/bin/$bin $PKG/usr/bin/$bin.bin
  132. cat <<EOF >$PKG/usr/bin/$bin
  133. #!/bin/sh
  134. export LD_LIBRARY_PATH=/usr/lib$LIBDIRSUFFIX/opencollada
  135. exec $bin.bin "\$@"
  136. EOF
  137. chmod 0755 $PKG/usr/bin/$bin
  138. done
  139. mkdir -p $PKG/usr/man/man1
  140. ./doc/manpage/blender.1.py --blender build/bin/blender --output $PKG/usr/man/man1/blender.1
  141. find $PKG/usr/man -type f -exec gzip -9 {} \;
  142. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  143. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  144. mv $PKG/usr/share/doc/$SRCNAM/* $PKG/usr/doc/$PRGNAM-$VERSION/
  145. rm -rf $PKG/usr/share/doc
  146. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  147. mkdir -p $PKG/install
  148. cat $CWD/slack-desc > $PKG/install/slack-desc
  149. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  150. cd $PKG
  151. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE