summaryrefslogtreecommitdiff
blob: 1fd3bb244404a9bd9d7a83b60c07a24815e59cd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils games flag-o-matic

MY_PV=${PV/./}
# Minor releases
MY_PV=${MY_PV/_p/u}
MY_P=${PN}${MY_PV}
MY_V=${PV%%_p*}

DESCRIPTION="Multiple Arcade Machine Emulator (SDL)"
HOMEPAGE="http://rbelmont.mameworld.info/?page_id=163"
# Hope it goes to gentoo mirrors...
#SRC_URI="mirror://gentoo/${MY_P}.zip"
SRC_URI="http://rbelmont.mameworld.info/${MY_P}.zip"

# Same as xmame. Should it be renamed to MAME?
LICENSE="XMAME"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~x86"
IUSE="minimal debug"

DEPEND=">=media-libs/libsdl-1.2.10
		sys-libs/zlib
		dev-libs/expat
		debug? (
			>gnome-base/gconf-2
			>=x11-libs/gtk+-2 )"

RDEPEND="${DEPEND}"

S="${WORKDIR}/${MY_P}"
RESTRICT="fetch strip"

pkg_nofetch() {
	einfo "Please download sdlmame from"
	einfo "${SRC_URI}"
	einfo "and put the file in ${DISTDIR}"
	einfo
}

# Function to disable a makefile option
disable_feature() {
	sed -i \
		-e "/$1.*=/s:^:# :" \
		"${S}"/makefile || die "disable $1 pacth failed"
}

# Function to enable a makefile option
enable_feature() {
	sed -i \
		-e "/^#.*$1.*=/s:^# ::"  \
		"${S}"/makefile || die "enable $1 patch failed"
}

src_unpack() {
	unpack ${A}
	# Don't compile zlib and expat
	einfo "Disabling embedded libraries: zlib and expat"
	$(disable_feature BUILD_ZLIB)
	$(disable_feature BUILD_EXPAT)

	case ${ARCH} in
		amd64)	einfo "Enabling 64-bit support"
				$(enable_feature PTR64)
				$(enable_feature AMD64)
				;;

		x86)	einfo "Optimizing build for $(get-flag march)"
				case $(get-flag march) in
					pentium3)	$(enable_feature PM);;
					pentium-m)	$(enable_feature PM);;
					pentium4)   $(enable_feature P4);;
					athlon)		$(enable_feature ATHLON);;
					k7)			$(enable_feature ATHLON);;
					i686)		$(enable_feature I686);;
					pentiumpro)	$(enable_feature I686);;
				esac
				;;

		ppc)	einfo "Enabling PPC support"
				$(enable_feature G4)
				;;
	esac

	if use debug ; then
		$(enable_feature DEBUG)
		$(enable_feature SYMBOLS)
		$(enable_feature PROFILE)
	fi

	einfo "Applying WolfMAME patches"
	cd "${S}"
	epatch "${FILESDIR}"/${MY_V}/dipports.patch
	epatch "${FILESDIR}"/${MY_V}/inpview.patch
	epatch "${FILESDIR}"/${MY_V}/wolf.patch
}

src_compile() {
	# Minimal driver support. Good for ebuild testing...
	if use minimal ; then
		make_opts="SUBTARGET=tiny"
	fi

	emake \
		NAME=${PN} \
		SUFFIX="" \
		${make_opts} \
		|| die "emake failed"
}

src_install() {
	dogamesbin ${PN} || die "dogamesbin ${PN} failed"

	# Follows xmame ebuild, avoiding collision on /usr/games/bin/jedutil
	exeinto $(games_get_libdir)/${PN}
	local f
	for f in chdman jedutil romcmp ; do
		doexe "${f}" || die "doexe ${f} failed"
	done

	dodoc docs/* *.txt

	prepgamesdirs
}