summaryrefslogtreecommitdiff
blob: 43b35a12fa229c3e5394fe547fa229dc0fa47d03 (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-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI="5"
JAVA_PKG_IUSE="source"

inherit eutils java-pkg-2 java-ant-2 toolchain-funcs flag-o-matic fdo-mime gnome2-utils

MY_P="${PN}-src-${PV}"
DESCRIPTION="TuxGuitar is a multitrack guitar tablature editor and player written in Java-SWT"
HOMEPAGE="http://www.tuxguitar.com.ar/"
SRC_URI="mirror://sourceforge/${PN}/${MY_P}.tar.gz"
LICENSE="LGPL-2.1"
SLOT="0"
IUSE="alsa fluidsynth oss pdf timidity"

KEYWORDS="~amd64 ~x86"
CDEPEND="dev-java/swt:3.5[cairo]
	alsa? ( media-libs/alsa-lib )
	fluidsynth? ( media-sound/fluidsynth )
	pdf? ( dev-java/itext:0 )"
RDEPEND=">=virtual/jre-1.5
	timidity? (
		alsa? ( media-sound/timidity++[alsa] )
		oss? ( media-sound/timidity++[oss] )
		media-sound/timidity++
	)
	${CDEPEND}"

DEPEND=">=virtual/jdk-1.5
	${CDEPEND}"

S="${WORKDIR}/${MY_P}"

src_prepare() {
	java-pkg_jar-from --into TuxGuitar/lib swt-3.5
	java-pkg-2_src_prepare
}

src_compile() {
	if use pdf; then
		echo "" >> TuxGuitar-pdf/build.properties || die
		echo "path.itext=$(java-pkg_getjar itext iText.jar)" >> TuxGuitar-pdf/build.properties || die "Error adding itext path"
		echo "path.swt=$(java-pkg_getjar swt-3.5 swt.jar)" >> TuxGuitar-pdf/build.properties || die "Error adding swt path"
	fi
	cd TuxGuitar || die "cd failed"
	eant all
	for plugin in $(list_plugins); do
		plugin_compile $plugin
	done
}

src_install() {
	cd TuxGuitar || die "cd failed"
	java-pkg_dojar tuxguitar.jar
	use source && java-pkg_dosrc src/org
	# TODO: Decide if plugin sources should be installed
	java-pkg_dolauncher ${PN} \
		--main org.herac.tuxguitar.gui.TGMain \
		--java_args "-Xms128m -Xmx128m  -Dtuxguitar.share.path=/usr/share/${PN}/lib/share"
	# Images and Files
	insinto /usr/share/${PN}/lib
	doins -r share
	java-pkg_sointo /usr/share/${PN}/lib/lib
	for plugin in $(list_plugins); do
		plugin_install $plugin
	done
	doman "${S}/misc/${PN}.1"
	insinto /usr/share/mime/packages
	doins "${S}/misc/${PN}.xml"
	doicon "${S}/misc/${PN}.xpm"
	domenu "${S}/misc/${PN}.desktop"
}

plugin_compile() {
	cd "${S}"/TuxGuitar-${1} || die
	eant all
	if [[ -d jni ]]; then
		append-flags $(java-pkg_get-jni-cflags)
		cd jni || die "\"cd jni\" failed"
		CC=$(tc-getCC) emake
	fi
}

plugin_install() {
	cd "${S}"/TuxGuitar-${1} || die
	local TUXGUITAR_INST_PATH=/usr/share/${PN}/lib
	local BINARY_NAME=tuxguitar-${1}
	insinto ${TUXGUITAR_INST_PATH}/share/plugins
	doins ${BINARY_NAME}.jar
	#TuxGuitar has its own classloader. No need to register the plugins.
	if [[ -d jni ]]; then
		java-pkg_doso jni/lib${BINARY_NAME}-jni.so
	fi
}

#Return list of plugins to compile/install
list_plugins() {
	echo \
		$(usev alsa) ascii browser-ftp compat converter $(usev fluidsynth) gtp \
		jsa lilypond midi musicxml $(usev oss) $(usev pdf) ptb tef tray tuner
}

pkg_postinst() {
	fdo-mime_desktop_database_update
	gnome2_icon_cache_update
	if use fluidsynth; then
		ewarn "Fluidsynth plugin blocks behavior of JSA plugin."
		ewarn "Enable only one of them in \"Tools > Plugins\""
	fi
}

pkg_postrm() {
	fdo-mime_desktop_database_update
	gnome2_icon_cache_update
}