diff options
Diffstat (limited to 'games/mame/mame.SlackBuild')
-rw-r--r-- | games/mame/mame.SlackBuild | 354 |
1 files changed, 203 insertions, 151 deletions
diff --git a/games/mame/mame.SlackBuild b/games/mame/mame.SlackBuild index 38ffff4b93..3526c37b91 100644 --- a/games/mame/mame.SlackBuild +++ b/games/mame/mame.SlackBuild @@ -1,101 +1,57 @@ -#!/bin/sh +#!/bin/bash # Slackware build script for mame -# Written by B. Watson (yalhcru@gmail.com) +# Written by B. Watson (urchlay@slackware.uk) # Adapted from Erik W. Hanson's mame.SlackBuild for older mame versions, # which was originally adapted from sdlmame.SlackBuild by B. Watson. # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details. +# 20240330 bkw: Updated for v0.264. +# 20231031 bkw: Updated for v0.260, add WAYLAND option. +# 20230710 bkw: Updated for v0.256. +# 20230428 bkw: Updated for v0.254. +# 20230103 bkw: Updated for v0.251. +# 20220205 bkw: Updated for v0.240. + +# 20211115 bkw: +# - updated for v0.237 on -current aka 15.0rc1. +# - new-style icons. +# - update mame.ini (lots of new options, some old ones went away). +# - include the new support stuff (hash, language, etc) +# - rename mame's 'split' to 'mame-split' to avoid potential conflict +# with coreutils (if someone has /usr/games before /usr/bin in $PATH). +# - include ini/{examples,presets} in the package (in the doc dir). +# - make ccache work! finally! see README_ccache.txt if you care. +# - make GroovyMAME support work again (upstream switched to github). +# - remove gcc9 stuff. it was specific to Slackware 14.2. + +# 20191208 bkw: Updated for v0.214, after long hiatus. This isn't +# actually the latest version, but it's the latest version that will +# compile with any of the compilers available in Slackware 14.2: +# gcc-5.5.0, llvm-3.8.0, llvm-8.0.1 (from /extra). It may still be +# possible to patch 0.216 to build, or possibly 0.217 will have a fix for +# llvm-8.0.1 (mame docs claim to support "clang version 5 and later"). +# Meanwhile this update is better than nothing. Special thanks for ponce +# and chriswilling for doing test builds on much faster machines than +# I currently have access to. Also, moved old comment log entries to +# ChangeLog.old as it was getting ridiculously long. + # 20181227 bkw: Updated for v0.205. # 20181130 bkw: Updated for v0.204, including compile fix for xavix.cpp. # 20181031 bkw: Updated for v0.203. # 20180928 bkw: Updated for v0.202. # 20180830 bkw: Updated for v0.201. -# 20180731 bkw: Updated for v0.200. -# 20180628 bkw: Updated for v0.199. -# 20180612 bkw: Updated for v0.198 (missed a few releases...) -# 20180130 bkw: Updated for v0.194. -# 20180101 bkw: Updated for v0.193. -# 20171210 bkw: Updated for v0.192. -# 20170927 bkw: Updated for v0.190. - -# 20170902 bkw: Updated for v0.189. -# - Fix complay.py build error. Turns out that the build would fail -# only on systems where PyXML is installed, so add -S to python -# command line so 'import xml.sax' imports the xml stuff that ships -# with core python, instead of the (outdated, deprecated) 3rd-party -# stuff from PyXML. -# - Stop installing useless junk in /usr/doc. -# - Install swlist docs. -# - Compacted log entries. - -# 20170726 bkw: Updated for v0.188. -# 20170702 bkw: Updated for v0.187. - -# 20170607 bkw: Updated for v0.186. -# - Link with ld.gold instead of the default ld, which saves *2 hours* of -# build time on my test box (build is 3x as fast as it was). - -# 20170428 bkw: Updated for v0.185. - -# 20170404 bkw: -# - mame.ini: get rid of $HOME in bgfx_path. Thanks to Doogster for -# reporting this. - -# 20170330 bkw: Updated for v0.184. - -# 20170301 bkw: -# - Use long-form github URL. -# - Fix changelog so newer entries are at the top. - -# 20170223 bkw: Updated for v0.183. -# 20170214 bkw: Add support for GroovyMAME patch. -# 20170128 bkw: Updated for v0.182. -# 20170111 bkw: Updated for v0.181. Missed a month again. -# 20161101 bkw: Updated for v0.179. - -# 20160928 bkw: -# - Updated for v0.178. Sorry, missed a month. -# - Install artwork/ and bgfx/ so the new bgfx shader stuff will work. -# - Set bgfx_path in mame.ini. The default is still 'video opengl' but -# now it's easy to enable bgfx, just by changing to 'video bgfx'. -# Thanks to Doogster for pointing this out. - -# 20160728 bkw: -# - Updated for v0.176. Upstream does a release on the last Wednesday -# of every month. I doubt I'm going to find time to update this -# script 12 times a year, but maybe... - -# 20160721 bkw: -# - Updated for v0.175 (again, after missing several releases) -# - Update ARCH stuff, i486 => i586 -# - Add missing mame.6 and mess.6 man pages (whoops!) -# - man pages now in docs/man/ instead of src/osd/sdl/ -# - Don't modify the *.1 man pages to put them in section 6 any more -# - Symlink mame -> mess in /usr/games (to keep old frontends working) -# - Disable QT debugger by default, as it now requires qt5 and I don't -# want qt5 as a hard dep for this... how many people who install mame -# are *really* going to debug the game ROM code? -# - Add QTDEBUG=yes option for people who really want the debugger, -# make slack-desc say whether or not it's enabled. -# - Upstream removed 'testkeys', stop trying to install it. - -# 20151112 bkw: -# - Updated for v0.167, after missing several releases (sorry!) -# - Get rid of MESS and UME options, mame has basically turned -# into UME at this point (includes old mame + mess in one binary) -# - Use shipped man pages from the source, instead of our own -# - Add new tools: castool floptool imgtool nlwav -# - Use icon extracted from mame.ico in the source -# - Update .ini file slightly (sound=sdl, not sound=1) + +cd $(dirname $0) ; CWD=$(pwd) PRGNAM=mame -VERSION=${VERSION:-0.205} +VERSION=${VERSION:-0.264} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} if [ -z "$ARCH" ]; then case "$( uname -m )" in @@ -105,25 +61,25 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then + echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" + exit 0 +fi + TMP=${TMP:-/tmp/SBo} -PKG=$TMP/package-${PRGNAM} +PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} # NB nonstandard flags here. Upstream defaults to -O3, so we'll leave # that as-is. Only the arch-specific stuff goes here. if [ "$ARCH" = "i586" ]; then SLKCFLAGS="-march=i586 -mtune=i686" - LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-march=i686 -mtune=i686" - LIBDIRSUFFIX="" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-fPIC" - LIBDIRSUFFIX="64" else SLKCFLAGS="" - LIBDIRSUFFIX="" fi # Source extracts to e.g. mame-mame0175/ @@ -132,6 +88,29 @@ DIRNAME=$PRGNAM-$SHORTNAME set -e +# 20200108 bkw: before doing ANYTHING else, check to make sure +# our required deps are installed. This is helpful because if +# they are missing, the mame compile will still start and run +# for an hour or more before it errors out, wasting a lot of +# time (some of which was mine). +MISSING="" +for i in sdl2 SDL2_ttf; do + pkg-config --exists $i || MISSING="$MISSING $i" +done +if [ -n "$MISSING" ]; then + echo "*** Missing required dependencies:$MISSING" 1>&2 + exit 1 +fi + +# 20211112 bkw: GroovyMAME support has changed, see README_groovy.txt. +# This part of it has to run in $CWD. +GROOVY="${GROOVY:-no}" + +if [ "$GROOVY" = "update" ]; then + sh mkgroovy.sh $VERSION + GROOVY=yes +fi + rm -rf $PKG mkdir -p $TMP $PKG $OUTPUT cd $TMP @@ -144,18 +123,19 @@ chown -R root:root . find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \ \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+ -# 20181130 bkw: the new xavix code in 0.204 is missing this include. -# Add future versions to the first case, as needed. -case "$VERSION" in - 0.204) sed -i '1i#include <cmath>' src/mame/video/xavix.cpp ;; - *) ;; -esac - # OK, building modern mame is a bit of a PITA. It uses genie (written # in lua, a fork of premake), but you don't get to run genie directly, -# you got a main makefile that builds lua, then builds genie, then runs -# genie with arguments based on the options in the main makefile. Also, -# it uses python to convert XML layout files to C++ code. +# you got a main makefile that builds lua, then builds genie, +# then runs genie with arguments based on the options in the main +# makefile... and genie generates a bunch of makefiles, then runs make +# on those. Also, it uses python3 to convert XML layout files to +# C++ code. + +# During the Slackware 14.2 cycle, I used to do this: +# LDOPTS="-fuse-ld=gold -static-libstdc++ -static-libgcc" \ +# This allowed installing Pat's unsupported gcc9 package, +# building mame with it, then restoring the original gcc +# version and mame would still run. # Where possible, use system libraries instead of building the ones # bundled with the mame source. However, SBo's lua is (still!) too old @@ -171,15 +151,6 @@ esac # JDK! In case you're wondering, only the C code in the bundled portmidi # is built (no Java needed). -# The OVERRIDE_CC and OVERRIDE_CXX are there because mame's build -# ignores $PATH when searching for gcc/g++, and won't find my ccache -# symlinks in /usr/local/bin. On a normal (non-ccache-using) system, -# these options do nothing (they use the compilers in /usr/bin, which -# is the default anyway) and you can forget about them... or, if you use -# distcc, this will allow it to actually work. (Mini-rant: PATH has been -# a standard mechanism on both Unix and DOS/Windows systems for what, -# 30 or 40 years now? Come on people...) - # Version-specific patches & sed fixes. We do it this way to keep this # script compatible with older versions. PATCHES="" @@ -188,7 +159,10 @@ case "$VERSION" in sed -i '1i#include <cmath>' \ src/devices/cpu/mips/ps2vif1.cpp \ src/devices/cpu/mips/mips3.cpp - ;; + ;; + 0.204) + sed -i '1i#include <cmath>' src/mame/video/xavix.cpp + ;; *) ;; esac @@ -210,53 +184,102 @@ sed -i 's,\.;ini,/etc,' src/osd/sdl/sdlmain.cpp # stuff above. #SDL_INI_PATH='$$HOME/.mame;/etc' \ -# Previous versions of mame used qt4 for the debugger GUI. Now it's -# qt5, so I've made it optional (Slackware 14.2 still only has qt4). -if [ "${QTDEBUG:-no}" = "yes" ]; then +# 20211110 bkw: undocumented option. keep this Just In Case. +if [ "${QTDEBUG:-yes}" = "yes" ]; then QTOPT=1 - WITHQT="with" else QTOPT=0 - WITHQT="without" fi -# Now, let's check for GroovyMAME. All the user has to do is place -# the .diff in the SlackBuild's directory. The filename always starts -# with the MAME version number, minus its dots. If we find multiple -# files matching this, sort them lexically and use the last (hopefully -# this is the one with the highest version number). -GROOVYDIFF="$( ls $CWD/${VERSION/./}_groovymame_*.diff 2>/dev/null | tail -1 )" -if [ -e "$GROOVYDIFF" ]; then - GROOVYVER="$( basename $GROOVYDIFF .diff | cut -d_ -f3- | sed 's,-,_,g' )" +# 20211112 bkw: the rest of the GroovyMAME stuff. +# The diffs look to be close to half a meg, so they're compressed. +if [ "$GROOVY" = "yes" ]; then + GROOVYDIFF="$( /bin/ls $CWD/gm${VERSION/./}*.diff.xz 2>/dev/null | tail -1 )" + if [ -e "$GROOVYDIFF" ]; then + GROOVYVER="$( basename $GROOVYDIFF .diff.xz )" + echo "=== GROOVYDIFF $GROOVYDIFF" + echo "=== GROOVYVER $GROOVYVER" + + # The "-f -Z" is necessary to make sure the patched files end up + # with the same timestamp every time the script is run. ccache + # needs this because the include_file_mtime doesn't seem to + # play nice with precompiled headers, even though it's supposed to. + # When the patch is generated, we have to add timestamps to make + # this work (see mkgroovy.sh for details). + + xzcat "$GROOVYDIFF" | patch -p1 -f -Z + else + cat <<EOF +*** +GroovyMAME support was requested, but I don't have a GroovyMAME patch +for MAME $VERSION. Try running this script with GROOVY=update in the +environment, or wait a few days for the GroovyMAME author to release +an update. See README_groovy.txt for more information. +*** +EOF + exit 1 + fi +fi + +# Build option notes: + +# Having ARCH set in the env will break the build, hence ARCH="". + +# Using ld.gold is *much* faster, and I see no disadvantage to it. + +# The point of the OVERRIDE_CC and friends is to make the build use $PATH +# to find gcc (so ccache will be found if it's using the symlink method). - # .diffs are shipped with CRLF endings, fix: - sed 's,\r,,g' "$GROOVYDIFF" > groovy.diff +# 20211109 bkw: N.B. upstream requires python 3, but they default to +# /usr/bin/python as the executable, so I still have to override it. +# The -S means the same thing in python3 as it did it 2: disable use +# of site packages. We needed it with py2 because otherwise the build +# would fail if PyXML happened to be installed. Probably don't need it +# with py3, but it won't hurt anything either. - patch -p0 < groovy.diff +# 20211111 bkw: make ccache handle precompiled headers +export CCACHE_SLOPPINESS=pch_defines,time_macros,include_file_mtime,include_file_ctime - echo "GROOVYDIFF $GROOVYDIFF" - echo "GROOVYVER $GROOVYVER" +# 20211111 bkw: undocumented option, build a mame that only supports +# pac-man and its clones. used for testing only. +if [ "${PACONLY:-no}" = "yes" ]; then + PACOPT="SOURCES=src/mame/drivers/pacman.cpp" fi +# 20231031 bkw: build option for wayland, see README +if [ "${WAYLAND:-no}" = "yes" ]; then + WAYLOPT="USE_WAYLAND=1" +fi -# Having ARCH set in the env will break the build, hence ARCH="". -# Using ld.gold is *much* faster, and I see no disadvantage to it. +# 20211111 bkw: build with ccache by default, now that it works. +if [ "${USE_CCACHE:-yes}" = "yes" ]; then + CC="/usr/bin/ccache /usr/bin/clang" + CXX="/usr/bin/ccache /usr/bin/clang++" +else + CC="${CC:-$( which gcc )}" + CXX="${CXX:-$( which g++ )}" +fi make USE_QTDEBUG=$QTOPT \ USE_SYSTEM_LIB_EXPAT=1 \ USE_SYSTEM_LIB_ZLIB=1 \ USE_SYSTEM_LIB_JPEG=1 \ USE_SYSTEM_LIB_FLAC=1 \ - PYTHON_EXECUTABLE="/usr/bin/python -S" \ + PYTHON_EXECUTABLE="/usr/bin/python3 -S" \ OPT_FLAGS="$SLKCFLAGS" \ - LDOPTS="-fuse-ld=gold" \ - OVERRIDE_CC="$( which gcc )" \ - OVERRIDE_CXX="$( which g++ )" \ + LDOPTS="-fuse-ld=gold" \ + OVERRIDE_CC="$CC" \ + OVERRIDE_CXX="$CXX" \ + CC="$CC" \ + CXX="$CXX" \ ARCH="" \ + PRECOMPILE=1 \ VERBOSE=1 \ NOWERROR=1 \ TOOLS=1 \ TARGET=$PRGNAM \ + $PACOPT \ + $WAYLOPT \ SUBTARGET=$PRGNAM # No 'make install' target, do it manually. @@ -264,21 +287,42 @@ mkdir -p $PKG/usr/games $PKG/etc $PKG/usr/man/man6 $PKG/usr/man/man1 \ $PKG/usr/share/applications $PKG/usr/share/pixmaps # Deal with upstream's executable-naming silliness. -[ -e ${PRGNAM}64 ] && mv ${PRGNAM}64 $PRGNAM -[ -e ${PRGNAM}32 ] && mv ${PRGNAM}32 $PRGNAM +for i in tiny 32 64; do + [ -e ${PRGNAM}$i ] && mv ${PRGNAM}$i $PRGNAM +done # .desktop borrowed from Ludovic Lechapt's Debian package. -# Icon extracted from src/mame/osd/windows/mame/mame.ico with icotool. cat $CWD/desktop/$PRGNAM.desktop > $PKG/usr/share/applications/$PRGNAM.desktop -cat $CWD/desktop/$PRGNAM.png > $PKG/usr/share/pixmaps/$PRGNAM.png + +# Icon extracted from src/mame/osd/windows/mame/mame.ico with icotool. +for px in 16 32 48 64 128; do + size=${px}x${px} + dir=$PKG/usr/share/icons/hicolor/$size/apps + mkdir -p $dir + convert -resize $size $CWD/desktop/$PRGNAM.png $dir/$PRGNAM.png +done + +ln -s ../icons/hicolor/48x48/apps/$PRGNAM.png $PKG/usr/share/pixmaps/$PRGNAM.png + cat $CWD/$PRGNAM.ini > $PKG/etc/$PRGNAM.ini.new -# Install the binaries: -install -s -m0755 -oroot -groot \ - $PRGNAM castool chdman floptool imgtool jedutil \ - ldresample ldverify nltool nlwav pngcmp regrep \ - romcmp split src2html srcclean unidasm \ - $PKG/usr/games/ +# This one *must* exist. +install -s -m0755 -oroot -groot $PRGNAM $PKG/usr/games/ + +# 20211110 bkw: removed src2html (no longer exists) and renamed split +# to mame-split since we have a split command in coreutils already. +# Also, in case upstream drops another of these utilities, check for +# existence before trying to install (because it takes hours to +# compile). +# Install the tools: +for i in castool chdman floptool imgtool jedutil \ + ldresample ldverify nltool nlwav pngcmp \ + regrep romcmp srcclean unidasm +do + [ -e $i ] && install -s -m0755 -oroot -groot $i $PKG/usr/games/ +done + +[ -e split ] && install -s -m0755 -oroot -groot $i $PKG/usr/games/$PRGNAM-split ln -s $PRGNAM $PKG/usr/games/mess @@ -289,24 +333,32 @@ install -m0644 -oroot -groot docs/man/*.6 $PKG/usr/man/man6 gzip -9 $PKG/usr/man/man?/*.? # Create empty dirs for the user to populate with ROMs and such. -for i in roms samples ctrlr font cheat; do - mkdir -p $PKG/usr/share/games/$PRGNAM/$i -done +SHAREDIR=$PKG/usr/share/games/$PRGNAM +mkdir -p $SHAREDIR/{roms,font,cheat} -# Install the artwork and bgfx stuff (needed for 'video bgfx' in mame.ini). -cp -a artwork bgfx $PKG/usr/share/games/$PRGNAM +# Install the support stuff. +cp -a artwork bgfx plugins samples hash ctrlr $SHAREDIR + +# 20211110 bkw: also the translations (but not the .po files, those are +# the sources for the .mo files, which are what mame actually needs). +cp -p --parents language/*/*.mo $SHAREDIR # CONTRIBUTING.md is a 1-byte placeholder, and we don't need a shell script. rm -f docs/CONTRIBUTING.md docs/update.sh -mkdir -p $PKG/usr/doc/${PRGNAM}-$VERSION +PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION +mkdir -p $PKGDOC # can't just "cp docs/* ..." because man/ is a dir, set -e kills the script -cp docs/L* docs/*.* $PKG/usr/doc/${PRGNAM}-$VERSION -cp -a docs/swlist $PKG/usr/doc/${PRGNAM}-$VERSION -cat $CWD/${PRGNAM}.SlackBuild > $PKG/usr/doc/${PRGNAM}-$VERSION/${PRGNAM}.SlackBuild +# 20240330 bkw: docs/swlist is gone in 0.264. +cp docs/L* docs/*.* $PKGDOC +cp -a docs/legal $PKGDOC +cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild + +# in case someone finds these useful... +cp -a ini/examples ini/presets $PKGDOC mkdir -p $PKG/install -sed "s,@WITHQT@,$WITHQT," $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/slack-desc > $PKG/install/slack-desc [ -n "$GROOVYVER" ] && \ sed -i "19s,\$, This package was patched with GroovyMAME $GROOVYVER.," \ @@ -315,4 +367,4 @@ sed "s,@WITHQT@,$WITHQT," $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/doinst.sh > $PKG/install/doinst.sh cd $PKG -/sbin/makepkg -l y -c n $OUTPUT/${PRGNAM}-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE |