rubberband.SlackBuild 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #!/bin/bash
  2. # Slackware build script for rubberband
  3. # Written by Luis Henrique <email removed>
  4. # Modified by B. Watson <yalhcru@gmail.com>. Original had no license.
  5. # Modified version licensed under the WTFPL. See
  6. # http://www.wtfpl.net/txt/copying/ for details.
  7. # 20211125 bkw: update for v2.0.0
  8. # 20201103 bkw: update for v1.9.0
  9. # 20180702 bkw:
  10. # - update for v1.8.2
  11. # - add optional Java support.
  12. # - add license to script.
  13. # 20140915 bkw:
  14. # - took over maintenance
  15. # - get rid of static lib
  16. # - use sed instead of a diff for $LIBDIRSUFFIX
  17. # - fix libdir in .pc files also
  18. # - add man page
  19. cd $(dirname $0) ; CWD=$(pwd)
  20. PRGNAM=rubberband
  21. VERSION=${VERSION:-2.0.0}
  22. BUILD=${BUILD:-1}
  23. TAG=${TAG:-_SBo}
  24. PKGTYPE=${PKGTYPE:-tgz}
  25. if [ -z "$ARCH" ]; then
  26. case "$( uname -m )" in
  27. i?86) ARCH=i586 ;;
  28. arm*) ARCH=arm ;;
  29. *) ARCH=$( uname -m ) ;;
  30. esac
  31. fi
  32. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  33. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  34. exit 0
  35. fi
  36. TMP=${TMP:-/tmp/SBo}
  37. PKG=$TMP/package-$PRGNAM
  38. OUTPUT=${OUTPUT:-/tmp}
  39. if [ "$ARCH" = "i586" ]; then
  40. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  41. LIBDIRSUFFIX=""
  42. elif [ "$ARCH" = "i686" ]; then
  43. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  44. LIBDIRSUFFIX=""
  45. elif [ "$ARCH" = "x86_64" ]; then
  46. SLKCFLAGS="-O2 -fPIC"
  47. LIBDIRSUFFIX="64"
  48. else
  49. SLKCFLAGS="-O2"
  50. LIBDIRSUFFIX=""
  51. fi
  52. set -e
  53. rm -rf $PKG
  54. mkdir -p $TMP $PKG $OUTPUT
  55. cd $TMP
  56. rm -rf $PRGNAM-$VERSION
  57. tar xvf $CWD/$PRGNAM-$VERSION.tar.bz2
  58. cd $PRGNAM-$VERSION
  59. chown -R root:root .
  60. find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
  61. \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
  62. JAVA="${JAVA:-no}"
  63. if [ "$JAVA" = "yes" ]; then
  64. if [ -z "$JAVA_HOME" ]; then
  65. # if JAVA_HOME isn't set, try to set it by sourcing the profile script
  66. for i in /etc/profile.d/*jdk*.sh; do
  67. if [ -x $i ]; then
  68. source $i
  69. break
  70. fi
  71. done
  72. fi
  73. if [ -z "$JAVA_HOME" ]; then
  74. cat <<EOF
  75. !!! Java support requested, but JAVA_HOME is unset and I can't find
  76. !!! a /etc/profile.d script that sets it. Are you sure you have a JDK
  77. !!! package installed?
  78. EOF
  79. exit 1
  80. fi
  81. echo "=== JAVA_HOME='$JAVA_HOME'"
  82. if [ -z "$JAVA_HOME" -o ! -e $JAVA_HOME/include/jni.h ]; then
  83. cat <<EOF
  84. !!! Java support requested, but JAVA_HOME doesn't have the jni.h header.
  85. EOF
  86. exit 1
  87. fi
  88. EXTRA="-Dextra_include_dirs=$JAVA_HOME/include,$JAVA_HOME/include/linux"
  89. echo "=== EXTRA='$EXTRA'"
  90. fi
  91. mkdir build
  92. cd build
  93. CFLAGS="$SLKCFLAGS" \
  94. CXXFLAGS="$SLKCFLAGS" \
  95. meson .. \
  96. --buildtype=release \
  97. --infodir=/usr/info \
  98. --libdir=/usr/lib${LIBDIRSUFFIX} \
  99. --localstatedir=/var \
  100. --mandir=/usr/man \
  101. --prefix=/usr \
  102. --sysconfdir=/etc \
  103. $EXTRA \
  104. -Dstrip=true
  105. "${NINJA:=ninja}"
  106. DESTDIR=$PKG $NINJA install
  107. cd ..
  108. # I don't see a way to disable the static lib at build time, so:
  109. rm -f $PKG/usr/lib*/lib$PRGNAM.a
  110. JNILIB=$PKG/usr/lib$LIBDIRSUFFIX/lib$PRGNAM-jni.so
  111. if [ "$JAVA" = "yes" -a ! -e $JNILIB ]; then
  112. cat <<EOF
  113. !!! Java support requested, but failed to build. Check the above output
  114. !!! from Meson and Ninja, and adjust JAVA_HOME if needed.
  115. EOF
  116. exit 1
  117. fi
  118. WITHJAVA=WITHOUT
  119. [ -e $JNILIB ] && WITHJAVA=WITH
  120. # man page borrowed from Debian
  121. mkdir -p $PKG/usr/man/man1
  122. gzip -9c < $CWD/$PRGNAM.1 > $PKG/usr/man/man1/$PRGNAM.1.gz
  123. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  124. cp -a CHANGELOG COPYING README* $PKG/usr/doc/$PRGNAM-$VERSION
  125. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  126. mkdir -p $PKG/install
  127. sed "s,@WITHJAVA@,$WITHJAVA," $CWD/slack-desc > $PKG/install/slack-desc
  128. cd $PKG
  129. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE