summaryrefslogtreecommitdiff
blob: df34b4f3d2b9de90976de42cb01daeb4022c5bae (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
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-java/qtjambi/qtjambi-4.5.2_p1.ebuild,v 1.3 2010/05/19 14:27:29 caster Exp $

EAPI="2"

JAVA_PKG_IUSE="doc source"
WANT_ANT_TASKS="ant-trax"

inherit multilib qt4-r2 java-pkg-2 java-ant-2

QTVER="${PV%.*}*"
MY_PV="${PV/p/0}"
MY_P="${PN}-src-lgpl-${MY_PV}"

DESCRIPTION="QtJambi is a set of Java bindings and utilities for the Qt C++ toolkit."
HOMEPAGE="http://qt.nokia.com/"
SRC_URI="http://get.qt.nokia.com/${PN}/source/${MY_P}.tar.gz"

LICENSE="|| ( LGPL-2.1 GPL-3 )"
SLOT="4"
KEYWORDS="~amd64 ~x86"
IUSE="debug examples opengl phonon webkit xmlpatterns"

COMMON_DEPS="=x11-libs/qt-gui-${QTVER}:${SLOT}
	=x11-libs/qt-sql-${QTVER}:${SLOT}
	=x11-libs/qt-svg-${QTVER}:${SLOT}
	opengl? ( =x11-libs/qt-opengl-${QTVER}:${SLOT} )
	phonon? ( =x11-libs/qt-phonon-${QTVER}:${SLOT} )
	webkit? (
		=x11-libs/qt-phonon-${QTVER}:${SLOT}
		=x11-libs/qt-webkit-${QTVER}:${SLOT}
	)
	xmlpatterns? ( =x11-libs/qt-xmlpatterns-${QTVER}:${SLOT} )"
DEPEND="${COMMON_DEPS}
	>=virtual/jdk-1.6"
RDEPEND="${COMMON_DEPS}
	>=virtual/jre-1.6"

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

src_prepare() {
	epatch \
		"${FILESDIR}"/generator-4.5.0_p1.patch \
		"${FILESDIR}"/configuration-4.5.0_p1.patch \
		"${FILESDIR}"/gcc4.4-4.5.0_p1.patch \
		"${FILESDIR}"/ant180-4.5.2.patch

	# Respect MAKEOPTS
	sed -i -e "/String arguments =/s|=.*|=\" ${MAKEOPTS}\";|" \
		com/trolltech/tools/ant/MakeTask.java || die

	java-ant_rewrite-classpath
}

qtjambi_use() {
	if [[ $1 == "phonon" ]] && use webkit; then
		# USE=webkit requires phonon support
		echo "-Dgentoo.phonon=true"
	else
		echo "-Dgentoo.$1=$(use $1 && echo true || echo false)"
	fi
}

qt_config_use() {
	if [[ $1 == "phonon" ]] && use webkit; then
		# USE=webkit requires phonon support
		echo "QT_CONFIG+=phonon"
	else
		echo "QT_CONFIG$(use $1 && echo '+' || echo '-')=$1"
	fi
}

src_compile() {
	local myconf="-Dqtjambi.config=$(use debug && echo debug || echo release)
			-Dlibrary.designer=true
			$(qtjambi_use opengl)
			$(qtjambi_use phonon)
			$(qtjambi_use webkit)
			$(qtjambi_use xmlpatterns)"
	export QTDIR="/usr/$(get_libdir)/qt4"

	einfo "Initializing Qt Jambi build environment"
	eant -Dgentoo.classpath="$(java-pkg_getjar --build-only ant-core ant.jar)" \
		${myconf} init

	einfo "Merging XML files used by the Qt Jambi generator"
	eant ${myconf} generator.xmlmerge

	# Use eqmake4 instead of generator.qmake ant target
	eqmake4 generator/generator.pro -o generator/Makefile

	einfo "Building and running the generator"
	eant ${myconf} generator.run   # implies generator.compile

	# Use eqmake4 instead of library.native.qmake ant target
	eqmake4 java.pro -recursive \
		$(qt_config_use opengl) \
		$(qt_config_use phonon) \
		$(qt_config_use webkit) \
		$(qt_config_use xmlpatterns)

	einfo "Building the native library"
	eant ${myconf} library.native.compile

	einfo "Building the Java library"
	eant ${myconf} library.java

	einfo "Building the Designer library"
	eant ${myconf} library.designer

	if use examples; then
		einfo "Building examples"
		eant ${myconf} examples
	fi

	# Build API documentation
	if use doc; then
		einfo "Generating Javadoc"
		javadoc -J-Xmx256m -d javadoc -subpackages com || die
	fi

	# Generate start script for jambi-designer
	cat > bin/jambi-designer <<-EOF
		#!/bin/sh
		export LD_LIBRARY_PATH="/usr/$(get_libdir)/qt4:/usr/$(get_libdir)/${PN}-${SLOT}:\${LD_LIBRARY_PATH}"
		export CLASSPATH="/usr/share/${PN}-${SLOT}/lib/${PN}.jar:/usr/share/${PN}-${SLOT}/lib/${PN}-designer.jar:\${CLASSPATH}"
		export QT_PLUGIN_PATH="/usr/$(get_libdir)/qt4/plugins"
		exec /usr/bin/designer "\$@"
	EOF
}

src_install() {
	dobin "${S}"/bin/* || die
	newbin "${S}"/generator/generator jambi-generator || die

	einfo "Installing jars"
	java-pkg_newjar qtjambi-${MY_PV}.jar
	java-pkg_newjar qtjambi-designer-${MY_PV}.jar ${PN}-designer.jar
	java-pkg_dojar ant-qtjambi.jar

	einfo "Installing native libraries"
	java-pkg_doso "${S}"/lib/*

	einfo "Installing designer plugins"
	exeinto /usr/$(get_libdir)/qt4/plugins/${PN}
	doexe plugins/designer/*.so || die
	# Designer needs these libraries in both directories
	dosym /usr/$(get_libdir)/qt4/plugins/${PN}/libJambiCustomWidget.so \
		/usr/$(get_libdir)/qt4/plugins/designer/libJambiCustomWidget.so
	dosym /usr/$(get_libdir)/qt4/plugins/${PN}/libJambiLanguage.so \
		/usr/$(get_libdir)/qt4/plugins/designer/libJambiLanguage.so

	if use doc; then
		einfo "Installing documentation"
		dohtml "${S}"/readme.html
		java-pkg_dojavadoc "${S}"/javadoc
	fi

	if use examples; then
		einfo "Installing examples"

		# Get rid of class files before installing
		find "${S}"/com/trolltech/examples -name '*.class' -delete || die

		java-pkg_newjar qtjambi-examples-${MY_PV}.jar ${PN}-examples.jar
		java-pkg_doexamples "${S}"/com/trolltech/examples
		java-pkg_dolauncher jambi-examples --main com.trolltech.launcher.Launcher \
			--java_args "-Djava.library.path=/usr/$(get_libdir)/qt4:/usr/$(get_libdir)/${PN}-${SLOT}"
	fi

	use source && java-pkg_dosrc "${S}"/com
}