mitsuba2.SlackBuild 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/bin/bash
  2. # Copyright 2014-22 Klaatu, Wellington NZ
  3. # GNU All-Permissive License
  4. # Copying and distribution of this file, with or without modification,
  5. # are permitted in any medium without royalty provided the copyright
  6. # notice and this notice are preserved. This file is offered as-is,
  7. # without any warranty.
  8. # 20220322 bkw: Modified by SlackBuilds.org: fix 32-bit build.
  9. cd $(dirname $0) ; CWD=$(pwd)
  10. PRGNAM=mitsuba2
  11. VERSION=${VERSION:-4e7628c}
  12. BUILD=${BUILD:-1}
  13. TAG=${TAG:-_SBo}
  14. PKGTYPE=${PKGTYPE:-tgz}
  15. if [ -z "$ARCH" ]; then
  16. case "$( uname -m )" in
  17. i?86) ARCH=i586 ;;
  18. arm*) ARCH=arm ;;
  19. *) ARCH=$( uname -m ) ;;
  20. esac
  21. fi
  22. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  23. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  24. exit 0
  25. fi
  26. TMP=${TMP:-/tmp/SBo}
  27. PKG=$TMP/package-$PRGNAM
  28. OUTPUT=${OUTPUT:-/tmp}
  29. if [ "$ARCH" = "i586" ]; then
  30. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  31. LIBDIRSUFFIX=""
  32. elif [ "$ARCH" = "i686" ]; then
  33. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  34. LIBDIRSUFFIX=""
  35. elif [ "$ARCH" = "x86_64" ]; then
  36. SLKCFLAGS="-O2 -fPIC"
  37. LIBDIRSUFFIX="64"
  38. else
  39. SLKCFLAGS="-O2"
  40. LIBDIRSUFFIX=""
  41. fi
  42. set -e
  43. rm -rf $PKG
  44. mkdir -p $TMP $PKG $OUTPUT
  45. cd $TMP
  46. rm -rf $PRGNAM-$VERSION
  47. tar xvf $CWD/$PRGNAM-$VERSION.tar.xz
  48. cd $PRGNAM-$VERSION
  49. chown -R root:root .
  50. find -L . \
  51. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  52. -o -perm 511 \) -exec chmod 755 {} \+ -o \
  53. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  54. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+
  55. case "$ARCH" in
  56. i?86) patch -p1 < $CWD/32bit.diff ;;
  57. esac
  58. mkdir -p build
  59. cd build
  60. cmake -GNinja \
  61. $extra \
  62. -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
  63. -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
  64. -DCMAKE_INSTALL_PREFIX=/usr \
  65. -DLIB_SUFFIX=${LIBDIRSUFFIX} \
  66. -DMAN_INSTALL_DIR=/usr/man \
  67. -DCMAKE_BUILD_TYPE=Release ..
  68. ninja
  69. # no install option provided, so copy compiled code to /opt
  70. mkdir -p $PKG/opt
  71. mv dist $PKG/opt/$PRGNAM-$VERSION
  72. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  73. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  74. mkdir -p $PKG/usr/bin
  75. ln -s $PKG/opt/$PRGNAM-$VERSION/mitsuba $PKG/usr/bin/mitsuba
  76. cd ..
  77. # sample scenes
  78. mkdir -p $PKG/usr/share/$PRGNAM-$VERSION
  79. cp -a resources $PKG/usr/share/$PRGNAM-$VERSION
  80. # docs
  81. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  82. cp -a setpath.sh $PKG/usr/doc/$PRGNAM-$VERSION
  83. cp LICENSE README.md $PKG/usr/doc/$PRGNAM-$VERSION
  84. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  85. # generated docs
  86. if [ "$DOCS" ]; then
  87. mkdir $PKG/usr/doc/$PRGNAM-$VERSION/html
  88. sphinx docs $PKG/usr/doc/$PRGNAM-$VERSION/html
  89. fi
  90. mkdir -p $PKG/install
  91. cat $CWD/slack-desc > $PKG/install/slack-desc
  92. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  93. cd $PKG
  94. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE