You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.6 KiB

  1. #!/bin/bash
  2. # Slackware build script for pocketsphinx
  3. # Copyright 2022-2025 Vijay Marcel
  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. # Changelog for pocketsphinx SlackBuild Script
  23. # --------------------------------------------------------------------
  24. # 03/09/2022: Added to SBo
  25. # 14/07/2023: Updated to github commit id 8221706.This version joins Opencv4 and lensfun
  26. # in not compiling with FFmpeg. FFmpeg will detect pocketsphinx but it will eventually
  27. # run into error during compilation.This seems to be FFmpeg upstream problem so
  28. # don't enable pocketsphinx in FFmpeg when you try to recompile it.
  29. # 19/02/2024: Updated to version 5.0.3. Removed python plugin.
  30. # one of the reasons why pocketsphinx fails to build with FFmpeg is due to
  31. # intentional API break in pocketsphinx. This is an upstream FFmpeg
  32. # problem see https://trac.ffmpeg.org/ticket/10520
  33. # 18/02/2025: Updated to version 5.0.4
  34. # ----------------------------------------------------------------------------------------
  35. cd $(dirname $0) ; CWD=$(pwd)
  36. PRGNAM=pocketsphinx
  37. VERSION=${VERSION:-5.0.4}
  38. BUILD=${BUILD:-1}
  39. TAG=${TAG:-_SBo}
  40. PKGTYPE=${PKGTYPE:-tgz}
  41. if [ -z "$ARCH" ]; then
  42. case "$( uname -m )" in
  43. i?86) ARCH=i586 ;;
  44. arm*) ARCH=arm ;;
  45. *) ARCH=$( uname -m ) ;;
  46. esac
  47. fi
  48. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  49. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  50. exit 0
  51. fi
  52. TMP=${TMP:-/tmp/SBo}
  53. PKG=$TMP/package-$PRGNAM
  54. OUTPUT=${OUTPUT:-/tmp}
  55. if [ "$ARCH" = "i586" ]; then
  56. SLKCFLAGS="-march=i586 -mtune=i686 -pipe -O2 -fPIC"
  57. LIBDIRSUFFIX=""
  58. elif [ "$ARCH" = "i686" ]; then
  59. SLKCFLAGS="-march=i686 -mtune=i686 -pipe -O2 -fPIC"
  60. LIBDIRSUFFIX=""
  61. elif [ "$ARCH" = "x86_64" ]; then
  62. SLKCFLAGS="-march=x86-64 -mtune=generic -pipe -O2 -fPIC"
  63. LIBDIRSUFFIX="64"
  64. else
  65. SLKCFLAGS="-O2"
  66. LIBDIRSUFFIX=""
  67. fi
  68. set -e
  69. trap 'echo "$0 FAILED at line $LINENO!" | tee -a $OUTPUT/error-${PRGNAM}.log' ERR
  70. rm -rf $PKG
  71. mkdir -p $TMP $PKG $OUTPUT
  72. cd $TMP
  73. rm -rf $PRGNAM-$VERSION
  74. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  75. cd $PRGNAM-$VERSION
  76. chown -R root:root .
  77. find -L . \
  78. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  79. -o -perm 511 \) -exec chmod 755 {} \; -o \
  80. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  81. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  82. cmake -B build -S $TMP/$PRGNAM-$VERSION \
  83. -DCMAKE_C_FLAGS="$SLKCFLAGS" \
  84. -DCMAKE_CXX_FLAGS="$SLKCFLAGS" \
  85. -DCMAKE_INSTALL_PREFIX=/usr \
  86. -DCMAKE_INSTALL_BINDIR=/usr/bin \
  87. -DCMAKE_INSTALL_DOCDIR=/usr/doc \
  88. -DCMAKE_INSTALL_INCLUDEDIR=/usr/include \
  89. -DCMAKE_INSTALL_LIBDIR=/usr/lib${LIBDIRSUFFIX} \
  90. -DCMAKE_BUILD_TYPE=Release \
  91. -DBUILD_SHARED_LIBS:BOOL=ON \
  92. -DCMAKE_INSTALL_MANDIR=/usr/man \
  93. -DFIXED_POINT:BOOL=ON \
  94. -DBUILD_GSTREAMER:BOOL=ON
  95. cmake --build build
  96. DESTDIR=$PKG cmake --install build
  97. cp $PKG/usr/include/pocketsphinx.h $PKG/usr/include/pocketsphinx
  98. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  99. | cut -f 1 -d : | xargs strip --strip-unneeded --remove-section=.comment --remove-section=.note 2> /dev/null || true
  100. find $PKG/usr/man -type f -exec gzip -9 {} \;
  101. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  102. # Don't ship .la files:
  103. rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.la
  104. mkdir -pv $PKG/usr/doc/$PRGNAM-$VERSION
  105. cp -a AUTHORS NEWS LICENSE README.md $PKG/usr/doc/$PRGNAM-$VERSION
  106. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  107. find $PKG/usr/doc/$PRGNAM-$VERSION -type f -exec chmod 0644 {} \+
  108. mkdir -p $PKG/install
  109. cat $CWD/slack-desc > $PKG/install/slack-desc
  110. cd $PKG
  111. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE