o2em.SlackBuild 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/bin/bash
  2. # Slackware build script for o2em
  3. # Written by B. Watson (urchlay@slackware.uk)
  4. # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
  5. # 20211102 bkw: BUILD=2
  6. # - fix -current build.
  7. # - binaries in /usr/games.
  8. # - man page in section 6.
  9. # - /usr/share/o2em => /usr/share/games/o2em.
  10. # - convert docs to utf-8.
  11. cd $(dirname $0) ; CWD=$(pwd)
  12. PRGNAM=o2em
  13. VERSION=${VERSION:-1.18}
  14. BUILD=${BUILD:-2}
  15. TAG=${TAG:-_SBo}
  16. PKGTYPE=${PKGTYPE:-tgz}
  17. if [ -z "$ARCH" ]; then
  18. case "$( uname -m )" in
  19. i?86) ARCH=i586 ;;
  20. arm*) ARCH=arm ;;
  21. *) ARCH=$( uname -m ) ;;
  22. esac
  23. fi
  24. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  25. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  26. exit 0
  27. fi
  28. TMP=${TMP:-/tmp/SBo}
  29. PKG=$TMP/package-$PRGNAM
  30. OUTPUT=${OUTPUT:-/tmp}
  31. if [ "$ARCH" = "i586" ]; then
  32. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  33. elif [ "$ARCH" = "i686" ]; then
  34. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  35. elif [ "$ARCH" = "x86_64" ]; then
  36. SLKCFLAGS="-O2 -fPIC"
  37. else
  38. SLKCFLAGS="-O2"
  39. fi
  40. set -e
  41. SRC=${PRGNAM}${VERSION/./}src
  42. rm -rf $PKG
  43. mkdir -p $TMP $PKG $OUTPUT
  44. cd $TMP
  45. rm -rf $SRC
  46. unzip -L $CWD/$SRC.zip
  47. cd $SRC
  48. chown -R root:root .
  49. find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
  50. \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
  51. # Patch does this:
  52. # make makefile.linux use allegro-config to find cflags/libs for allegro
  53. # make various source files #include <errno.h>
  54. # add SLKCFLAGS support to makefile.linux
  55. patch -p1 < $CWD/compile_fix.diff
  56. # Patch fixes wordsize assumptions on x86_64 and makes no difference on x86
  57. patch -p1 < $CWD/wordsize.diff
  58. cd src
  59. make -f makefile.linux SLKCFLAGS="$SLKCFLAGS -fcommon"
  60. mkdir -p $PKG/usr/games $PKG/usr/libexec \
  61. $PKG/usr/share/pixmaps $PKG/usr/share/icons/hicolor/64x64/apps
  62. install -s -m0755 -oroot -groot dis48 $PKG/usr/games
  63. install -s -m0755 -oroot -groot $PRGNAM $PKG/usr/libexec/$PRGNAM.bin
  64. install -m0755 -oroot -groot $CWD/$PRGNAM.sh $PKG/usr/games/$PRGNAM
  65. install -m0644 -oroot -groot $PRGNAM.png $PKG/usr/share/icons/hicolor/64x64/apps
  66. ln -s ../icons/hicolor/64x64/apps/$PRGNAM.png $PKG/usr/share/pixmaps/$PRGNAM.png
  67. # There is no .desktop file because the emulator lacks a UI (if we
  68. # launch it from the K menu, it prints an error on stdout and exits),
  69. # and because ".bin" isn't much of a MIME type so we can't really
  70. # do association (there's no magic header for the ROMs either).
  71. mkdir -p $PKG/usr/man/man6
  72. gzip -9c < $CWD/$PRGNAM.6 > $PKG/usr/man/man6/$PRGNAM.6.gz
  73. mkdir -p $PKG/usr/share/games/$PRGNAM/{bios,voice}
  74. unzip -L $CWD/o2mainsamp.zip -d $PKG/usr/share/games/$PRGNAM/voice
  75. if [ -e $CWD/odyssey2.zip ]; then
  76. unzip $CWD/odyssey2.zip
  77. ROMFILE=o2bios.rom
  78. elif [ -e $CWD/o2bios.rom ]; then
  79. ROMFILE=$CWD/o2bios.rom
  80. elif [ -e $CWD/o2rom.bin ]; then
  81. ROMFILE=$CWD/o2rom.bin
  82. fi
  83. if [ -n "$ROMFILE" ]; then
  84. cat $ROMFILE > $PKG/usr/share/games/$PRGNAM/bios/o2rom.bin
  85. INCROM="includes"
  86. else
  87. INCROM="does NOT include"
  88. fi
  89. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  90. cd ../docs
  91. for file in *; do
  92. sed 's/\r//g' < $file \
  93. | iconv -f iso-8859-1 -t utf-8 \
  94. > $PKG/usr/doc/$PRGNAM-$VERSION/$file
  95. done
  96. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  97. mkdir -p $PKG/install
  98. sed -e "s,@INCROM@,$INCROM," \
  99. $CWD/slack-desc > $PKG/install/slack-desc
  100. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  101. cd $PKG
  102. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE