apulse.SlackBuild 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #!/bin/bash
  2. # Slackware build script for apulse
  3. # Originally written by: Ryan P.C. McQuen | Everett, WA | <email removed>
  4. # Heavily modified and now maintained by B. Watson <urchlay@slackware.uk>
  5. # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
  6. # 20210301 bkw:
  7. # - Take over maintenance.
  8. # - Replace Capi X's version (submitted in 2019) with Ryan's (removed
  9. # in 2016), since it supports multilib and by default doesn't stomp
  10. # on the system pulseaudio libs. Add the ability to install the
  11. # headers and .pc files, like Capi's build did, but disable it by
  12. # default (SYSTEM variable).
  13. # - Relicense as WTFPL, with permission from original author (Ryan).
  14. # - i486 => i586.
  15. # - Rewrite README to document the new stuffs.
  16. # - Simplify the script a bit.
  17. # - Actually use SLKCFLAGS.
  18. # - Upstream ships a man page now, install it to /usr/man.
  19. cd $(dirname $0) ; CWD=$(pwd)
  20. PRGNAM=apulse
  21. VERSION=${VERSION:-0.1.13}
  22. BUILD=${BUILD:-1}
  23. TAG=${TAG:-_SBo}
  24. PKGTYPE=${PKGTYPE:-tgz}
  25. SYSTEM=${SYSTEM:-no}
  26. [ "$SYSTEM" = "devel" ] && HEADERS=yes
  27. case "$SYSTEM" in
  28. yes|devel) AP_SUBDIR=${AP_SUBDIR:-/}
  29. COEXIST="CONFLICTS" ;;
  30. no) AP_SUBDIR=${AP_SUBDIR:-/apulse}
  31. COEXIST="can safely coexist" ;;
  32. *) echo "*** Invalid SYSTEM setting '$SYSTEM', use one of: no yes devel" 1>&2
  33. exit 1 ;;
  34. esac
  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-$PRGNAM
  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. # automatically detect multilib, can override with COMPAT32=no
  59. [ -e /lib/libc.so.6 ] && COMPAT32="${COMPAT32:-yes}"
  60. else
  61. SLKCFLAGS="-O2"
  62. LIBDIRSUFFIX=""
  63. fi
  64. set -e
  65. buildit() {
  66. rm -rf build
  67. mkdir -p build
  68. cd build
  69. cmake \
  70. -DAPULSEPATH=/usr/lib$2${AP_SUBDIR} \
  71. -DAPULSE_SEARCH_PATHS=/usr/lib${AP_SUBDIR}:/usr/lib${LIBDIRSUFFIX}${AP_SUBDIR} \
  72. -DCMAKE_INSTALL_PREFIX=/usr \
  73. -DCMAKE_BUILD_TYPE=Release \
  74. -DCMAKE_CXX_FLAGS_RELEASE="$SLKCFLAGS $1 -DNDEBUG" \
  75. -DCMAKE_C_FLAGS_RELEASE="$SLKCFLAGS $1 -DNDEBUG" \
  76. ..
  77. make VERBOSE=1
  78. make install/strip DESTDIR=$PKG
  79. cd -
  80. }
  81. install_pc() {
  82. mkdir -p $PKG/usr/lib$1/pkgconfig
  83. for i in $CWD/pc/*.pc; do
  84. sed "s,@64@,$1,g" $i > $PKG/usr/lib$1/pkgconfig/$( basename $i )
  85. done
  86. }
  87. rm -rf $PKG
  88. mkdir -p $TMP $PKG $OUTPUT
  89. cd $TMP
  90. rm -rf $PRGNAM-$VERSION
  91. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  92. cd $PRGNAM-$VERSION
  93. chown -R root:root .
  94. find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
  95. \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
  96. # hardcoded, can't override on cmake command line.
  97. sed -i 's,share/man/,man/,' CMakeLists.txt
  98. # for compat32, we assume x86_64 CPUs handle i686 instructions. also,
  99. # unlike normal 32-bit packages, this one gets -fPIC (which won't hurt).
  100. [ "$COMPAT32" = "yes" ] && buildit "-m32 -march=i686 -mtune=i686" ""
  101. # either way, build the normal libraries with normal cflags.
  102. buildit "" "$LIBDIRSUFFIX"
  103. gzip -9 $PKG/usr/man/*/*
  104. if [ "$HEADERS" = "yes" ]; then
  105. mkdir -p $PKG/usr/include
  106. cp -a 3rdparty/pulseaudio-headers/pulse $PKG/usr/include
  107. install_pc "$LIBDIRSUFFIX"
  108. [ "$COMPAT32" = "yes" ] && install_pc ""
  109. fi
  110. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/
  111. cp -a LICENSE.MIT README.md $PKG/usr/doc/$PRGNAM-$VERSION
  112. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  113. mkdir -p $PKG/install
  114. sed "s,@COEXIST@,$COEXIST," $CWD/slack-desc > $PKG/install/slack-desc
  115. cd $PKG
  116. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE