bsnes.SlackBuild 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/sh
  2. # Slackware build script for bsnes
  3. # Copyright 2019-2020 Hunter Sezen California, USA
  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. PRGNAM=bsnes
  23. LIBNAM=${PRGNAM}_libretro
  24. VERSION=${VERSION:-114}
  25. BUILD=${BUILD:-1}
  26. TAG=${TAG:-_SBo}
  27. if [ -z "$ARCH" ]; then
  28. case "$( uname -m )" in
  29. i?86) ARCH=i586 ;;
  30. arm*) ARCH=arm ;;
  31. *) ARCH=$( uname -m ) ;;
  32. esac
  33. fi
  34. CWD=$(pwd)
  35. TMP=${TMP:-/tmp/SBo}
  36. PKG=$TMP/package-$PRGNAM
  37. OUTPUT=${OUTPUT:-/tmp}
  38. LIBDIRSUFFIX=
  39. [ "$ARCH" = x86_64 ] && LIBDIRSUFFIX=64
  40. set -eu
  41. if pkg-config --exists sdl2 && pkg-config --exists gtksourceview-2.0; then
  42. STANDALONE="${STANDALONE:-yes}"
  43. else
  44. STANDALONE=no
  45. fi
  46. if [ "${LIBRETRO:=yes}" != yes ] && [ "$STANDALONE" != yes ]; then
  47. printf %s\\n \
  48. 'ERROR: Both the standalone and Libretro builds are disabled.' >&2
  49. exit 1
  50. fi
  51. rm -rf $PKG
  52. mkdir -p $TMP $PKG $OUTPUT
  53. cd $TMP
  54. rm -rf ${PRGNAM}_v$VERSION-source
  55. unzip $CWD/${PRGNAM}_v$VERSION-source.zip
  56. cd ${PRGNAM}_v$VERSION-source
  57. chown -R root:root .
  58. find -L . \
  59. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  60. -o -perm 511 \) -exec chmod 755 {} \; -o \
  61. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  62. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  63. if ! pkg-config --exists libpulse || [ "${PULSE:-yes}" != yes ]; then
  64. sed -i 's/ audio.pulseaudio audio.pulseaudiosimple//' ruby/GNUmakefile
  65. fi
  66. if ! pkg-config --exists openal || [ "${OPENAL:-yes}" != yes ]; then
  67. sed -i 's/ audio.openal//' ruby/GNUmakefile
  68. fi
  69. (
  70. cd $PRGNAM
  71. if [ "$STANDALONE" = yes ]; then
  72. make \
  73. target=$PRGNAM \
  74. compiler=clang++
  75. # The install target in bsnes/target-bsnes/GNUmakefile intentionally
  76. # does not support installing as root or DESTDIR. It is easier to
  77. # handle the install here instead.
  78. mkdir -p "$PKG/usr/games" \
  79. "$PKG/usr/share/applications" \
  80. "$PKG/usr/share/icons" \
  81. "$PKG/usr/share/$PRGNAM/Database" \
  82. "$PKG/usr/share/$PRGNAM/Locale"
  83. cp out/$PRGNAM "$PKG/usr/games"
  84. cp target-$PRGNAM/resource/$PRGNAM.desktop "$PKG/usr/share/applications"
  85. cp target-$PRGNAM/resource/$PRGNAM.png "$PKG/usr/share/icons"
  86. cp Database/* "$PKG/usr/share/$PRGNAM/Database"
  87. cp Locale/* "$PKG/usr/share/$PRGNAM/Locale"
  88. fi
  89. if [ "$LIBRETRO" = yes ]; then
  90. make clean
  91. make \
  92. target=libretro \
  93. compiler=clang++
  94. install -Dm0644 out/$LIBNAM.so \
  95. $PKG/usr/lib${LIBDIRSUFFIX}/libretro/$LIBNAM.so
  96. # bsnes_libretro.info from:
  97. # https://github.com/libretro/libretro-super/blob/5d35cf946b352fe03cff293612a17d5d6efa8410/dist/info/bsnes_libretro.info
  98. install -Dm0644 $CWD/$LIBNAM-info \
  99. $PKG/usr/lib${LIBDIRSUFFIX}/libretro/info/$LIBNAM.info
  100. fi
  101. )
  102. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" |
  103. grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  104. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  105. cp GPLv3.txt LICENSE.txt README.md $PKG/usr/doc/$PRGNAM-$VERSION
  106. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  107. mkdir -p $PKG/install
  108. cat $CWD/slack-desc > $PKG/install/slack-desc
  109. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  110. cd $PKG
  111. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}