summaryrefslogtreecommitdiff
blob: 1f1f40f5c124253a1d4784b79de8625c77046c9b (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-simulation/openttd/openttd-0.6.3.ebuild,v 1.6 2009/02/02 15:14:49 ranger Exp $

EAPI="2"

inherit eutils games

MY_P=${P/_rc/-RC}

DESCRIPTION="OpenTTD is a clone of Transport Tycoon Deluxe"
HOMEPAGE="http://www.openttd.org/"
SRC_URI="http://binaries.openttd.org/releases/${PV}/${MY_P}-source.tar.bz2"
SCENARIOS="0.4.8 0.5.0"
for scenario in ${SCENARIOS}; do
	SRC_URI="${SRC_URI} scenarios? (
	http://binaries.openttd.org/scenarios/${PN}-${scenario}-scenarios.tar.bz2 )"
done

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 ppc ppc64 x86"
IUSE="alsa debug dedicated iconv +png scenarios timidity +truetype +zlib"
RESTRICT="test"

DEPEND="!dedicated? (
			media-libs/libsdl[X]
			truetype? (
				media-libs/fontconfig
				media-libs/freetype:2
			)
		)
		iconv? ( virtual/libiconv )
		png? ( media-libs/libpng )
		zlib? ( sys-libs/zlib )"
RDEPEND="${DEPEND}
		!dedicated? (
			timidity? ( media-sound/timidity++ )
			!timidity? ( alsa? ( media-sound/alsa-utils ) )
		)"

S=${WORKDIR}/${MY_P}

src_unpack() {
	unpack ${MY_P}-source.tar.bz2

	if use scenarios ; then
		cd "${S}"/bin/scenario/
		for scenario in ${SCENARIOS}; do
			unpack ${PN}-${scenario}-scenarios.tar.bz2
		done
	fi

	cd "${S}"
	epatch "${FILESDIR}/libiconv.patch"
	epatch "${FILESDIR}/install.patch"
	epatch "${FILESDIR}/menu_name.patch"
}

src_configure() {
	local myopts=""
	use debug && myopts="${myopts} --enable-debug=3"
	if use dedicated; then
		myopts="${myopts} --enable-dedicated "
	else
		myopts="${myopts} --with-sdl $(use_with truetype freetype)
			$(use_with truetype fontconfig)"
		if ! use timidity; then
			use alsa && myopts="${myopts} --with-midi=/usr/bin/aplaymidi"
		fi
	fi
	# configure is a hand-written sh-script, so econf will not work
	./configure --disable-strip \
		--prefix-dir=/usr \
		--binary-dir=games/bin \
		--data-dir=share/games/${PN} \
		--install-dir="${D}" \
		--doc-dir=share/doc/${P} \
		--menu-group="Game;Simulation;" \
		$(use_with iconv) \
		$(use_with png) \
		$(use_with zlib) \
		${myopts} \
		|| die "configure failed"
}

src_compile() {
	emake || die "emake failed"
}

src_install() {
	emake DESTDIR="${D}" install || die "emake install failed"

	if use scenarios ; then
		insinto "${GAMES_DATADIR}"/${PN}/scenario
		doins bin/scenario/*.scn || die "doins failed (scenario)"
		doins bin/scenario/*/*.scn || die "doins failed (scenario)"
	fi

	prepgamesdirs
}

pkg_postinst() {
	games_pkg_postinst

	elog
	elog "In order to play, you must copy the following 6 files from "
	elog "a version of TTD to ${GAMES_DATADIR}/${PN}/data/."
	elog
	elog "From the WINDOWS version you need: "
	elog "  sample.cat trg1r.grf trgcr.grf trghr.grf trgir.grf trgtr.grf"
	elog "OR from the DOS version you need: "
	elog "  SAMPLE.CAT TRG1.GRF TRGC.GRF TRGH.GRF TRGI.GRF TRGT.GRF"
	elog
	elog "File names are case sensitive so make sure they are "
	elog "correct for whichever version you have."
	elog

	if use scenarios ; then
		elog "Scenarios are installed into:"
		elog "${GAMES_DATADIR}/${PN}/scenario,"
		elog "you will have to symlink them to ~/.openttd/scenario in order"
		elog "to use them."
		elog "Example:"
		elog " ln -s ${GAMES_DATADIR}/${PN}/scenario ~/.openttd/scenario"
		elog
	fi

	if use dedicated ; then
		ewarn "Warning: The init script will kill all running openttd"
		ewarn "processes when run, including any running client sessions!"
	else
		if use timidity || use alsa ; then
			elog "If you want music, you must copy the gm/ directory to"
			elog "${GAMES_DATADIR}/${PN}/"
			elog "You can enable MIDI by running:"
			elog "  openttd -m extmidi"
			elog
			if use timidity ; then
				elog "You also need soundfonts for timidity, if you don't"
				elog "know what that is, do:"
				elog
				elog "emerge media-sound/timidity-eawpatches"
			else
				elog "You have emerged with 'aplaymidi' for playing MIDI."
				elog "You have to set the environment variable ALSA_OUTPUT_PORTS."
				elog "Available ports can be listed by using 'aplaymidi -l'."
			fi
		else
			elog "timidity and/or alsa not in USE so music will not be played during the game."
		fi
		elog
	fi
}