Use https by default
[gentoo.git] / games-emulation / sdlmame / sdlmame-0.149.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 PYTHON_COMPAT=( python2_7 )
7 inherit eutils flag-o-matic python-any-r1 games
8
9 MY_PV=${PV/.}
10 MY_CONF_PN=${PN/sdl}
11 MY_P=sdlmame${MY_PV}
12 MY_P=${MY_P%%_p*}
13 MY_CONF_VER="0.139"
14
15 # patches
16 SRC_URI="$(for PATCH_VER in $(seq 1 ${PV##*_p}) ; do echo "https://dev.gentoo.org/~hasufell/distfiles/${MY_P}u${PATCH_VER}_diff.zip"; done)"
17
18 DESCRIPTION="Multiple Arcade Machine Emulator (SDL)"
19 HOMEPAGE="http://mamedev.org/"
20 # Upstream doesn't allow fetching with unknown User-Agent such as wget
21 SRC_URI="$SRC_URI https://dev.gentoo.org/~hasufell/distfiles/${MY_P/sdl}s.zip"
22 if [[ ${PN} == "sdlmame" ]] ; then
23         SRC_URI="$SRC_URI http://www.netswarm.net/misc/sdlmame-ui.bdf.gz"
24 fi
25
26 LICENSE="XMAME"
27 SLOT="0"
28 KEYWORDS="~amd64 ~ppc ~x86"
29 IUSE="X alsa debug opengl"
30 REQUIRED_USE="debug? ( X )"
31
32 RDEPEND=">=dev-lang/lua-5.2
33         dev-libs/expat
34         media-libs/fontconfig
35         media-libs/flac
36         >=media-libs/libsdl-1.2.10[sound,joystick,opengl?,video]
37         media-libs/sdl-ttf
38         sys-libs/zlib
39         virtual/jpeg
40         alsa? ( media-libs/alsa-lib )
41         debug? (
42                 x11-libs/gtk+:2
43                 gnome-base/gconf
44         )
45         X? (
46                 x11-libs/libX11
47                 x11-libs/libXinerama
48         )"
49 DEPEND="${RDEPEND}
50         ${PYTHON_DEPS}
51         app-arch/unzip
52         virtual/pkgconfig
53         X? ( x11-proto/xineramaproto )"
54
55 S=${WORKDIR}
56
57 # Function to disable a makefile option
58 disable_feature() {
59         sed -i \
60                 -e "/$1.*=/s:^:# :" \
61                 "${S}"/${2:-makefile} \
62                 || die "sed failed"
63 }
64
65 # Function to enable a makefile option
66 enable_feature() {
67         sed -i \
68                 -e "/^#.*$1.*=/s:^#::"  \
69                 "${S}"/${2:-makefile} \
70                 || die "sed failed"
71 }
72
73 pkg_setup() {
74         games_pkg_setup
75         python-any-r1_pkg_setup
76 }
77
78 src_unpack() {
79         default
80         unpack ./mame.zip
81         rm -f mame.zip
82 }
83
84 src_prepare() {
85         if [[ $PV == *_p* ]] ; then
86                 edos2unix $(find $(grep +++ *diff | awk '{ print $2 }' | sort -u) 2>/dev/null) *diff
87                 einfo "Patching release with source updates"
88                 epatch ${MY_PV%%_p*}*.diff
89         fi
90         edos2unix makefile src/osd/sdl/{osdsdl.h,sdl.mak}
91
92         epatch \
93                 "${FILESDIR}"/${P}-QA.patch \
94                 "${FILESDIR}"/${P}-system-lua.patch \
95                 "${FILESDIR}"/${P}-no-opengl.patch \
96                 "${FILESDIR}"/${P}-debugger-linking.patch
97
98         # Don't compile zlib and expat
99         einfo "Disabling embedded libraries: expat, flac, jpeg, zlib, lua"
100         disable_feature BUILD_EXPAT
101         disable_feature BUILD_FLAC
102         disable_feature BUILD_JPEG
103         disable_feature BUILD_ZLIB
104         disable_feature BUILD_LUA
105
106         if use amd64; then
107                 einfo "Enabling 64-bit support"
108                 enable_feature PTR64
109         fi
110
111         if use ppc; then
112                 einfo "Enabling PPC support"
113                 enable_feature BIGENDIAN
114         fi
115
116         if use debug; then
117                 einfo "Enabling debug support"
118                 enable_feature DEBUG
119                 enable_feature DEBUG src/osd/sdl/sdl.mak
120         fi
121
122         enable_feature NO_USE_QTDEBUG src/osd/sdl/sdl.mak
123
124         if ! use opengl ; then
125                 einfo "Disabling opengl support"
126                 enable_feature NO_OPENGL src/osd/sdl/sdl.mak
127         fi
128
129         if ! use alsa ; then
130                 einfo "Disabling alsa midi support"
131                 enable_feature NO_USE_MIDI src/osd/sdl/sdl.mak
132         fi
133
134         if ! use X ; then
135                 einfo "Disabling X support"
136                 enable_feature NO_X11 src/osd/sdl/sdl.mak
137         fi
138 }
139
140 src_compile() {
141         emake \
142                 TARGET="${PN#sdl}" \
143                 NAME="${PN}" \
144                 OPT_FLAGS='-DINI_PATH=\"\$$HOME/.'${PN}'\;'"${GAMES_SYSCONFDIR}/${PN}"'\"' \
145                 NO_DEBUGGER=$(usex debug "0" "1") default
146 }
147
148 src_install() {
149         newgamesbin ${PN}$(use amd64 && echo 64)$(use debug && echo d) ${PN}
150
151         newman src/osd/sdl/man/${PN#sdl}.6 ${PN}.6
152
153         insinto "${GAMES_DATADIR}/${PN}"
154         doins -r src/osd/sdl/keymaps
155         [[ ${PN} == "sdlmame" ]] && newins sdlmame-ui.bdf ui.bdf
156
157         insinto "${GAMES_SYSCONFDIR}/${PN}"
158         doins "${FILESDIR}"/vector.ini
159
160         sed \
161                 -e "s:@GAMES_SYSCONFDIR@:${GAMES_SYSCONFDIR}:" \
162                 -e "s:@GAMES_DATADIR@:${GAMES_DATADIR}:" \
163                 "${FILESDIR}/${MY_CONF_PN}-${MY_CONF_VER}".ini.in > "${D}/${GAMES_SYSCONFDIR}/${PN}/${MY_CONF_PN}".ini \
164                 || die "sed failed"
165
166         dodoc docs/{config,mame,newvideo}.txt
167         if [[ ${PN} == "sdlmame" ]] ; then
168                 dodoc whatsnew*.txt
169         else
170                 dodoc messnew*.txt
171         fi
172
173         keepdir \
174                 "${GAMES_DATADIR}/${PN}"/{ctrlr,cheats,roms,samples,artwork,crosshair} \
175                 "${GAMES_SYSCONFDIR}/${PN}"/{ctrlr,cheats}
176
177         prepgamesdirs
178 }
179
180 pkg_postinst() {
181         games_pkg_postinst
182
183         elog "optional dependencies:"
184         elog "  games-emulation/sdlmametools (development tools)"
185         echo
186         elog "It's strongly recommended that you change either the system-wide"
187         elog "${MY_CONF_PN}.ini at \"${GAMES_SYSCONFDIR}/${PN}\" or use a per-user setup at \$HOME/.${PN}"
188
189         if use opengl; then
190                 echo
191                 elog "You built ${PN} with opengl support and should set"
192                 elog "\"video\" to \"opengl\" in ${MY_CONF_PN}.ini to take advantage of that"
193         fi
194 }