summaryrefslogtreecommitdiff
blob: d9514e43db1a530204c4dc8c7767c6f02542a9af (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
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/games-fps/doomlegacy/doomlegacy-1.42.ebuild,v 1.4 2006/02/13 21:22:53 tupone Exp $

inherit eutils games

DESCRIPTION="Doom legacy, THE doom port"
HOMEPAGE="http://legacy.newdoom.com/"
SRC_URI="mirror://sourceforge/doomlegacy/legacy_${PV/.}_src.tar.gz
	mirror://gentoo/legacy-${PV}.dat.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="-ppc x86"
IUSE="X dga esd" #sdl - broken with recent sdl-mixer releases

RDEPEND="
	virtual/opengl
	virtual/glu
	|| ( x11-libs/libXxf86vm
		 virtual/x11 )
	esd? ( media-sound/esound )"
	# broken with recent sdl-mixer releases
	#sdl? (
		#media-libs/libsdl
		#media-libs/sdl-mixer
	#)"
DEPEND="${RDEPEND}
	x86? ( >=dev-lang/nasm-0.98 )
	|| (
		 (
		   x11-proto/xextproto
	       x11-proto/xf86vidmodeproto
		   dga? ( x11-proto/xf86dgaproto )
		 )
		 virtual/x11
	   )"

S=${WORKDIR}/doomlegacy_${PV/.}_src

src_unpack() {
	unpack ${A}
	mkdir bin
	cd "${S}"
	epatch "${FILESDIR}"/${PV}-errno.patch
	epatch "${FILESDIR}"/${PV}-makefile.patch
	epatch "${FILESDIR}"/${PV}-sdl-gentoo-paths.patch

	# disable logfile writing
	sed -i \
		-e 's:#define LOGMESSAGES::' doomdef.h \
		|| die 'sed failed'

	# make sure the games can find the wads/data files
	sed -i \
		-e "/#define DEFAULTWADLOCATION1/s:\".*\":\"${GAMES_DATADIR}/doom-data\":" \
		linux_x/i_system.c || die "sed linux_x/i_system.c failed"
	sed -i \
		-e "s:GENTOO_DATADIR:${GAMES_DATADIR}/doom-data:" \
		sdl/i_system.c || die "sed failed"

	# move opengl lib file because it's not useful to anyone else
	sed -i \
		-e "s:\"r_opengl:\"${GAMES_LIBDIR}/${PN}/r_opengl:" \
		linux_x/i_video_xshm.c \
		|| die "sed failed"

	cd linux_x/musserv
	make -f Makefile.linux clean
}

src_compile() {
	# this is ugly but it's late (here) and it works
	local makeopts i interfaces

	# broken with recent sdl-mixer releases
	#use sdl && interfaces="${interfaces} SDL"
	use X && interfaces="${interfaces} X"
	[ -z "${interfaces}" ] && interfaces="X"
	mkdir "${WORKDIR}"/my-bins
	for i in ${interfaces} ; do
		case ${i} in
			SDL)
				makeopts="LINUX=1 SDL=1 HAVE_MIXER=1" ;;
			X)
				makeopts="LINUX=1 X=1"
				use x86 && makeopts="${makeopts} USEASM=1"
				use dga && makeopts="${makeopts} WITH_DGA=1"
				use esd && makeopts="${makeopts} HAVE_ESD=1";;
		esac
		emake EXTRAOPTS="${CFLAGS}" ${makeopts} || die "build failed"
		mv \
			"${WORKDIR}"/bin/* \
			linux_x/musserv/linux/musserver \
			linux_x/sndserv/linux/llsndserv \
			"${WORKDIR}"/my-bins/
		rm "${WORKDIR}"/objs/*
	done
}

src_install() {
	dohtml _doc/*.html
	rm _doc/*.html
	dodoc _doc/*

	cd "${WORKDIR}"
	exeinto "${GAMES_LIBDIR}/${PN}"
	doexe my-bins/r_opengl.so || die "doexe failed"
	rm my-bins/r_opengl.so
	dogamesbin my-bins/* || die "dogamesbin failed"

	insinto "${GAMES_DATADIR}/doom-data"
	newins legacy-${PV}.dat legacy.dat || die "newins failed"

	prepgamesdirs
}