# Copyright 1999-2002 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 # Based on the 0.59.1 ebuild by Ben Lutgens # $Header: /home/cvsroot/gentoo-x86/app-emulation/xmame/xmame-0.62.2-r1.ebuild,v 1.2 2003/01/13 22:18:15 rphillips Exp $ IUSE="sdl dga xv alsa esd opengl X 3dfx svga ggi arts" # TARGET may be one of mame/mess/neomame/cpmame/mmsnd/tiny TARGET="mame" P="xmame-${PV}" S=${WORKDIR}/${P} DESCRIPTION="Multiple Arcade Machine Emulator for X11" SRC_URI="http://x.mame.net/download/${P}.tar.bz2" HOMEPAGE="http://x.mame.net" SLOT="0" LICENSE="xmame" DEPEND="sdl? ( >=media-libs/libsdl-1.2.0 ) sys-libs/zlib alsa? ( media-libs/alsa-lib ) xv? ( >=x11-base/xfree-4.1.0 ) dga? ( >=x11-base/xfree-4.1.0 ) esd? ( >=media-sound/esound-0.2.29 ) svga? ( media-libs/svgalib ) ggi? ( media-libs/libggi ) x86? ( dev-lang/nasm ) arts? ( kde-base/arts ) sys-apps/usbutils" RDEPEND=${DEPEND} # Please note modifications for ppc in this ebuild. If you update the ebuild, # please either test on ppc, or send it to a ppc developer for testing before # you commit the ebuild. Thanks :-) KEYWORDS="~x86 ~ppc ~alpha ~sparc ~mips" # current versions of xmame trigger a bug in icc # that cause iccbin to segfault if [ ${CC} = "icc" ]; then CC="gcc"; fi src_unpack() { unpack ${P}.tar.bz2 cd ${S} sed -e "s:^CFLAGS.*:\#CFLAGS:g" -e \ "s:^TARGET = mame:TARGET = ${TARGET}:g" -e \ "s:PREFIX = /usr/local:PREFIX = /usr:g" -e \ "s:MANDIR = \$\(PREFIX\)/man/man6:MANDIR = \$\(PREFIX\)/share/man/man6:g" \ makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix if [ ${ARCH} = "x86" ]; then # Enable joystick support sed -e "s/\# JOY_I386/JOY_I386/g" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix # Enable M68K asm core if [ ${CC} != "icc" ]; then einfo "Ah, an x86 machine using gcc. We'll use asm M68K cores then." sed -e "s/\# X86_ASM_68000 = 1/X86_ASM_68000 = 1/g" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix einfo "Ah, an x86 machine using gcc. We'll use the DRC MIPS3 engine then." sed -e "s/\# X86_MIPS3_DRC = 1/X86_MIPS3_DRC = 1/g" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix fi if [ ${CC} = "icc" ]; then einfo "You are using the Intel C++ Compiler" einfo "Expect a LONG link time" einfo "Using i386_noasm instructions" # icc doesn't know about __inline__ and likes different LD flags and doesn't like ranlib AND doesn't like inline assembly sed -e "s/^CC.*/CC = icc/g" -e \ "s/^IL.*/IL = '-DINLINE=static'/g" -e \ "s/^RANLIB.*/RANLIB = true/g" -e \ "s/^MY_CPU = i386/MY_CPU = i386_noasm/g" -e \ "s/^LD.*/LD = icc -Wl,-s -ipo -ipo_obj/g" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix fi fi if [ ${ARCH} = "ppc" ]; then einfo "PPC. Using risc instructions." sed -e "s:MY_CPU = i386:\#MY_CPU = i386:g" -e \ "s:\# MY_CPU = risc$:MY_CPU = risc:" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix fi if [ ${ARCH} = "alpha" ]; then einfo "ALPHA. Using alpha instructions." sed -e "s:MY_CPU = i386:\#MY_CPU = i386:g" -e \ "s:\# MY_CPU = risc$:MY_CPU = alpha:" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix fi if [ ${ARCH} = "sparc" ]; then einfo "SPARC. Using risc instructions." sed -e "s:MY_CPU = i386:\#MY_CPU = i386:g" -e \ "s:\# MY_CPU = risc$:MY_CPU = risc:" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix fi if [ ${ARCH} = "mips" ]; then einfo "MIPS. Using risc instructions." sed -e "s:MY_CPU = i386:\#MY_CPU = i386:g" -e \ "s:\# MY_CPU = risc$:MY_CPU = risc:" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix fi if [ "`use esd`" ]; then einfo "Adding Esound support" sed -e "s/\# SOUND_ESOUND/SOUND_ESOUND/g" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix fi if [ "`use alsa`" ]; then einfo "Adding Alsa support" sed -e "s/\# SOUND_ALSA/SOUND_ALSA/g" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix fi if [ "`use sdl`" ]; then einfo "Adding SDL sound support" sed -e "s/\# SOUND_SDL/SOUND_SDL/g" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix fi if [ "`use arts`" ]; then einfo "Adding arts support" sed -e "s/\# SOUND_ARTS/SOUND_ARTS/g" makefile.unix > makefile.unix.tmp mv makefile.unix.tmp makefile.unix fi if [ "`use X`" ] || [ "`use dga`" ] || [ "`use xv`" ]; then einfo "We'll be doing an X11 build" cp makefile.unix makefile.x11; fi if [ "`use svga`" ]; then einfo "We'll be doing an svga build" cp makefile.unix makefile.svga sed -e "s/DISPLAY_METHOD = x11/DISPLAY_METHOD = svgalib/g" \ makefile.svga > makefile.svga.tmp mv makefile.svga.tmp makefile.svga fi if [ "`use sdl`" ]; then einfo "We'll be doing an SDL build" cp makefile.unix makefile.SDL sed -e "s/DISPLAY_METHOD = x11/DISPLAY_METHOD = SDL/g" \ makefile.SDL > makefile.SDL.tmp mv makefile.SDL.tmp makefile.SDL fi if [ "`use ggi`" ]; then einfo "We'll be doing a GGI build" cp makefile.unix makefile.ggi sed -e "s/DISPLAY_METHOD = x11/DISPLAY_METHOD = ggi/g" \ makefile.ggi > makefile.ggi.tmp mv makefile.ggi.tmp makefile.ggi fi if [ "`use opengl`" ]; then einfo "We'll be doing an xgl build" cp makefile.unix makefile.xgl sed -e "s/DISPLAY_METHOD = x11/DISPLAY_METHOD = xgl/g" \ makefile.xgl > makefile.xgl.tmp mv makefile.xgl.tmp makefile.xgl sed -e "s//\"\/usr\/lib\/opengl\/xfree\/include\/glx.h\"/g" \ src/unix/video-drivers/gltool.h > src/unix/video-drivers/gltool.h.tmp mv src/unix/video-drivers/gltool.h.tmp src/unix/video-drivers/gltool.h fi if [ "`use dga`" ]; then einfo "DGA. This requires an suid x${TARGET}.x11 binary." sed -e "s/\# X11_DGA = 1/X11_DGA = 1/g" \ makefile.x11 > makefile.x11.tmp mv makefile.x11.tmp makefile.x11 if [ "`use 3dfx`" ]; then einfo "Adding 3dfx dga bug workarounds" sed -e "s/\# TDFX_DGA_WORKAROUND/TDFX_DGA_WORKAROUND/g" \ makefile.x11 > makefile.x11.tmp mv makefile.x11.tmp makefile.x11 fi fi if [ "`use xv`" ]; then einfo "Adding Xv support to the the x11 build" sed -e "s/\# X11_XV = 1/X11_XV = 1/g" makefile.x11 > makefile.x11.tmp mv makefile.x11.tmp makefile.x11 fi } src_compile() { local MYFLAGS local GCCMAJ MYFLAGS="" # 08 Oct 2002 Caleb Shay # Parallel makes breaks the build MAKEOPTS="" # This is SUCH a nasty hack. Is there a better way to find the gcc version? GCCMAJ=`gcc -v 2>&1 | grep version | tail -1 | awk '{print $3}' | cut -f1 -d\.` if [ ${ARCH} = "ppc" ]; then # add Makefile suggested flags for ppc MYFLAGS=" -O2 -Wall -Wno-unused -funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math -fsigned-char" fi if [ ${ARCH} = "x86" ] ; then if [ ${CC} = "icc" ]; then # Makefile recommended ICC flags einfo "Setting icc-x86 recommended CFLAGS" MYFLAGS="-O3 -rcd -Xa -ipo -ipo_obj" else # add Makefile suggested flags for x86 einfo "Setting gcc-x86 recommended CFLAGS" MYFLAGS="${CFLAGS} -O3 -Wall -Wno-unused -funroll-loops -fstrength-reduce -fomit-frame-pointer -ffast-math -fsigned-char" if [ ${GCCMAJ} -eq 2 ]; then einfo "gcc2 found. Setting appropriate CFLAGS" MYFLAGS="${MYFLAGS} -malign-functions=2 -malign-jumps=2 -malign-loops=2 -fstrict-aliasing" else einfo "gcc3 found. Setting appropriate CFLAGS" MYFLAGS="${MYFLAGS} -falign-functions=2 -falign-jumps=2 -falign-loops=2" fi fi fi if [ "`use X`" ] || [ "`use dga`" ] || [ "`use xv`" ]; then einfo "Building x${TARGET}.x11" cp makefile.x11 Makefile emake CFLAGS="${MYFLAGS}" || die fi if [ "`use sdl`" ]; then einfo "Building x${TARGET}.SDL" cp makefile.SDL Makefile emake CFLAGS="${MYFLAGS}" || die fi if [ "`use svga`" ]; then einfo "Building x${TARGET}.svgalib" cp makefile.svga Makefile emake CFLAGS="${MYFLAGS}" || die fi if [ "`use ggi`" ]; then einfo "Building x${TARGET}.ggi" cp makefile.ggi Makefile emake CFLAGS="${MYFLAGS}" || die fi if [ "`use opengl`" ]; then einfo "Buildng x${TARGET}.xgl" cp makefile.xgl Makefile emake CFLAGS="${MYFLAGS}" || die fi } src_install () { if [ "`use X`" ] || [ "`use dga`" ] || [ "`use xv`" ]; then einfo "Installing x${TARGET}.x11" cp makefile.x11 Makefile make \ PREFIX=${D}/usr \ BINDIR=${D}/usr/bin \ MANDIR=${D}/usr/share/man/man6 \ install fi if [ "`use sdl`" ]; then einfo "Installing x${TARGET}.SDL" cp makefile.SDL Makefile make \ PREFIX=${D}/usr \ BINDIR=${D}/usr/bin \ MANDIR=${D}/usr/share/man/man6 \ install fi if [ "`use svga`" ]; then einfo "Installing x${TARGET}.svgalib" cp makefile.svga Makefile make \ PREFIX=${D}/usr \ BINDIR=${D}/usr/bin \ MANDIR=${D}/usr/share/man/man6 \ install fi if [ "`use ggi`" ]; then einfo "Installing x${TARGET}.ggi" cp makefile.ggi Makefile make \ PREFIX=${D}/usr \ BINDIR=${D}/usr/bin \ MANDIR=${D}/usr/share/man/man6 \ install fi if [ "`use opengl`" ]; then einfo "Installing x${TARGET}.xgl" cp makefile.xgl Makefile make \ PREFIX=${D}/usr \ BINDIR=${D}/usr/bin \ MANDIR=${D}/usr/share/man/man6 \ install fi dodoc doc/{changes.*,gamelist.${TARGET},readme.${TARGET},x${TARGET}rc.dist,*.txt} dohtml -r doc if [ "`use X`" ] || [ "`use dga`" ] || [ "`use xv`" ]; then einfo "Creating x${TARGET} symlink" dosym x${TARGET}.x11 /usr/bin/x${TARGET} fi } pkg_postinst() { einfo "Your available ${TARGET} binaries are:" if [ "`use X`" ] || [ "`use dga`" ] || [ "`use xv`" ]; then einfo " x${TARGET}.x11"; fi if [ "`use sdl`" ]; then einfo " x${TARGET}.SDL" fi if [ "`use svga`" ]; then einfo " x${TARGET}.svgalib" fi if [ "`use ggi`" ]; then einfo " x${TARGET}.ggi" fi if [ "`use opengl`" ]; then einfo " x${TARGET}.xgl" fi if [ "`use X`" ] || [ "`use dga`" ] || [ "`use xv`" ]; then einfo "x${TARGET} is a symbolic link to x${TARGET}.x11" fi if [ "`use dga`" ]; then einfo "DGA support requires root priveleges, but x${TARGET}.x11 is NOT installed SUID root by default." fi }