uncrustify.SlackBuild 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. # Slackware build script for uncrustify
  3. # Copyright 2015-2022, Zhu Qun-Ying
  4. #
  5. # Written by Aleksandar Samardzic <asamardzic@gmail.com>
  6. cd $(dirname $0) ; CWD=$(pwd)
  7. PRGNAM=uncrustify
  8. VERSION=${VERSION:-0.76.0}
  9. BUILD=${BUILD:-1}
  10. TAG=${TAG:-_SBo}
  11. PKGTYPE=${PKGTYPE:-tgz}
  12. if [ -z "$ARCH" ]; then
  13. case "$( uname -m )" in
  14. i?86) ARCH=i586 ;;
  15. arm*) ARCH=arm ;;
  16. *) ARCH=$( uname -m ) ;;
  17. esac
  18. fi
  19. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  20. # the name of the created package would be, and then exit. This information
  21. # could be useful to other scripts.
  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. elif [ "$ARCH" = "i686" ]; then
  32. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  33. elif [ "$ARCH" = "x86_64" ]; then
  34. SLKCFLAGS="-O2 -fPIC"
  35. else
  36. SLKCFLAGS="-O2"
  37. fi
  38. set -e
  39. rm -rf $PKG
  40. mkdir -p $TMP $PKG $OUTPUT
  41. cd $TMP
  42. rm -rf $PRGNAM-$PRGNAM-$VERSION
  43. tar xvf $CWD/$PRGNAM-$PRGNAM-$VERSION.tar.gz
  44. cd $PRGNAM-$PRGNAM-$VERSION
  45. chown -R root:root .
  46. find -L . \
  47. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  48. -o -perm 511 \) -exec chmod 755 {} \; -o \
  49. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  50. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  51. mkdir -p build
  52. cd build
  53. cmake \
  54. -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
  55. -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
  56. -DCMAKE_INSTALL_PREFIX=/usr \
  57. -DCMAKE_BUILD_TYPE=Release ..
  58. make
  59. make install DESTDIR=$PKG
  60. cd ..
  61. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  62. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  63. mv $PKG/usr/share/man $PKG/usr
  64. gzip -9 $PKG/usr/man/man1/*
  65. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  66. cp -a documentation $PKG/usr/doc/$PRGNAM-$VERSION
  67. mv $PKG/usr/share/doc/uncrustify/* $PKG/usr/doc/$PRGNAM-$VERSION
  68. rm -rf $PKG/usr/share
  69. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  70. mkdir -p $PKG/install
  71. cat $CWD/slack-desc > $PKG/install/slack-desc
  72. cd $PKG
  73. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE