summaryrefslogtreecommitdiff
blob: 94d841c27532c7d5c54bdcf9e42a69684736a1c0 (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# Copyright 1999-2018 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=4

inherit eutils multilib toolchain-funcs

RADIANT_MAJOR_VERSION="5"
RADIANT_MINOR_VERSION="0"
DESCRIPTION="NetRadiant is a fork of map editor for Q3 based games, GtkRadiant 1.5"
HOMEPAGE="http://dev.alientrap.org/projects/netradiant"
BASE_ZIP_URI="http://ingar.satgnu.net/files/gtkradiant/gamepacks/"
SRC_URI="http://rion-overlay.googlecode.com/files/${P}.tar.xz
	osirion? ( ${BASE_ZIP_URI}/OsirionPack.zip )
	quake1? ( ${BASE_ZIP_URI}/Quake1Pack.zip )
	warsow? ( ${BASE_ZIP_URI}/WarsowPack.zip )
	!bindist? (
		openarena? ( ${BASE_ZIP_URI}/OpenArenaPack.zip )
		quake2? ( ${BASE_ZIP_URI}/Quake2Pack.zip )
		tremulous? ( ${BASE_ZIP_URI}/TremulousPack.zip )
	)
"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
RADIANT_GPL_PACKS="darkplaces nexuiz osirion quake2world warsow +xonotic"
RADIANT_NONGPL_PACKS="openarena quake1 quake2 tremulous"
RADIANT_TOOLS="h2data q2map q3data q3map2 qdata3"
RADIANT_PACKS="${RADIANT_GPL_PACKS} ${RADIANT_NONGPL_PACKS}"
RADIANT_BINS=" ${RADIANT_TOOLS} gtk"
IUSE="${RADIANT_PACKS} ${RADIANT_BINS// / +} bindist"

RDEPEND="
	dev-libs/glib:2
	dev-libs/libxml2
	>=media-libs/libpng-1.2
	>=sys-libs/zlib-1.2
	gtk? (
		>=x11-libs/gtk+-2.4:2
		>=x11-libs/gtkglext-1
		x11-libs/pango
	)
	!dev-games/gtkradiant
"
DEPEND="${RDEPEND}
	app-arch/xz-utils
	dev-vcs/subversion
	virtual/pkgconfig
	osirion? ( app-arch/unzip )
	quake1? ( app-arch/unzip )
	warsow? ( app-arch/unzip )
	!bindist? (
		openarena? ( app-arch/unzip )
		quake2? ( app-arch/unzip )
		tremulous? ( app-arch/unzip )
	)
"

radiant_zip_unpack() {
		if use ${1,,}; then
			cd "${WORKDIR}/packs/" || die
			unpack "${1}Pack.zip"
			mv ${1}Pack ${1,,} || die
		fi
}

pkg_setup() {
	targets=""
	for i in ${RADIANT_BINS};do
		if use $i; then
			targets+=" ${i/gtk/radiant}"
		fi
	done
	if [ "x$targets" = "x" ]; then
		targets=" q3map2"
		ewarn "You disabled all binaries: defaulting to USE=\"q3map2\""
	fi
}

src_unpack() {
	unpack ${P}.tar.xz

	if use gtk; then
		radiant_zip_unpack Osirion
		radiant_zip_unpack Quake1
		radiant_zip_unpack Warsow

		if use !bindist; then
			MY_RADIANT_PACKS="${RADIANT_GPL_PACKS//+/} ${RADIANT_NONGPL_PACKS}"
			radiant_zip_unpack OpenArena
			radiant_zip_unpack Quake2
			radiant_zip_unpack Tremulous
		else
			MY_RADIANT_PACKS="${RADIANT_GPL_PACKS//+/}"
			for i in ${RADIANT_NONGPL_PACKS}; do
				if use ${i}; then
					ewarn "USE bindist disables ${i} non GPL pack"
				fi
			done
		fi
	fi
}

src_prepare() {
	sed -e '/$(INSTALLDIR)/s,heretic2/h2data,/h2data,' \
		-i Makefile || die
}

src_configure() {
	tc-export CC CXX AR RANLIB

	export TEE_STDERR=""

	# dependencies-check wants gtk
	if use gtk; then
		emake dependencies-check
	fi
}

src_compile() {
	emake ${targets// / binaries-}
}

src_install() {
	insinto /usr/$(get_libdir)/${PN}
	doins \
		setup/data/tools/q3data.qdt

	dodoc ChangeLog ChangeLog.idsoftware CONTRIBUTORS tools/quake3/q3map2/changelog.q3map{1,2.txt}

	pushd install || die
	exeinto /usr/$(get_libdir)/${PN}
	for i in ${targets}; do
		doexe ${i}.x86
		dosym /usr/$(get_libdir)/${PN}/${i}.x86 /usr/bin/${i}
	done

	# radiant
	if use gtk; then
		dosym /usr/$(get_libdir)/${PN}/radiant.x86 /usr/bin/${PN}

		newicon "${S}"/icons/radiant-src.png ${PN}.png
		make_desktop_entry ${PN} NetRadiant ${PN} "Development;GTK;"

		# modules
		insinto /usr/$(get_libdir)/${PN}/modules
		doins modules/*.so

		# plugins
		insinto /usr/$(get_libdir)/${PN}/plugins
		doins plugins/*.so

		# data
		popd || die
		echo "$RADIANT_MINOR_VERSION" > RADIANT_MINOR || die
		echo "$RADIANT_MAJOR_VERSION" > RADIANT_MAJOR || die
		insinto /usr/$(get_libdir)/${PN}
		doins -r \
			RADIANT_MAJOR \
			RADIANT_MINOR \
			setup/data/tools/bitmaps \
			setup/data/tools/gl \
			setup/data/tools/global.xlink \
			setup/data/tools/plugins \
			docs

		# packs
		for x in ${MY_RADIANT_PACKS//+/}; do
			if use $x; then
				cd "${WORKDIR}"/packs/${x} || die
				# USE and dir names differ
				n="$(echo $x | sed \
					-e 's/^quake/q/' \
					-e 's/2world$/2w/' \
					-e 's/^openarena/oa/' \
					-e 's/^tremulous/trem/' \
				)"
				insinto /usr/$(get_libdir)/${PN}
				doins -r ${n}.game

				insinto /usr/$(get_libdir)/${PN}/games
				doins games/${n}.game
			fi
		done
	fi
}