Use https by default
[gentoo.git] / media-video / projectx / projectx-0.91.0.10.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 JAVA_PKG_IUSE="doc source"
8
9 inherit eutils toolchain-funcs java-pkg-2 java-ant-2
10
11 XDG_P="xdg-20100731"
12
13 DESCRIPTION="Converts, splits and demuxes DVB and other MPEG recordings"
14 HOMEPAGE="http://project-x.sourceforge.net/"
15 SRC_URI="https://dev.gentoo.org/~billie/distfiles/${P}.tar.xz
16         http://sbriesen.de/gentoo/distfiles/${PN}-idctfast.tar.xz
17         http://sbriesen.de/gentoo/distfiles/${XDG_P}.java.xz
18         http://sbriesen.de/gentoo/distfiles/${PN}-icon.png"
19
20 LICENSE="GPL-2"
21 SLOT="0"
22 KEYWORDS="amd64 ppc ppc64 x86"
23 IUSE="X cpu_flags_x86_mmx cpu_flags_x86_sse"
24
25 COMMON_DEP="dev-java/commons-net
26         X? ( =dev-java/browserlauncher2-1* )"
27
28 RDEPEND=">=virtual/jre-1.5
29         ${COMMON_DEP}"
30
31 DEPEND=">=virtual/jdk-1.5
32         app-arch/xz-utils
33         virtual/libiconv
34         ${COMMON_DEP}"
35
36 S="${WORKDIR}/Project-X"
37
38 mainclass() {
39         # read Main-Class from MANIFEST.MF
40         sed -n "s/^Main-Class: \([^ ]\+\).*/\1/p" "${S}/MANIFEST.MF" || die
41 }
42
43 java_prepare() {
44         local X
45
46         # apply stdout corruption patch (zzam@gentoo.org)
47         epatch "${FILESDIR}/${PN}-0.90.4.00_p33-stdout-corrupt.patch"
48
49         # apply BrowserLauncher2 patch
50         use X && epatch "${FILESDIR}/${PN}-0.90.4.00_p33-bl2.patch"
51         rm -rf src/edu || die
52
53         # apply IDCTFast patch
54         epatch "${FILESDIR}/${PN}-0.90.4.00_p33-idctfast.patch"
55
56         # apply XDG patch
57         cp -f "${WORKDIR}/${XDG_P}.java" "${S}/src/xdg.java" || die
58         epatch "${FILESDIR}/${PN}-0.90.4.00_p33-xdg.patch"
59
60         # copy build.xml
61         cp -f "${FILESDIR}/build-0.90.4.00_p33.xml" build.xml || die
62
63         # patch executable and icon
64         sed -i -e "s:^\(Exec=\).*:\1${PN}_gui:g" \
65                 -e "s:^\(Icon=\).*:\1${PN}:g" *.desktop || die
66
67         # convert CRLF to LF
68         edos2unix *.txt MANIFEST.MF
69
70         # convert docs to utf-8
71         if [ -x "$(type -p iconv)" ]; then
72                 for X in zutun.txt; do
73                         iconv -f LATIN1 -t UTF8 -o "${X}~" "${X}" && mv -f "${X}~" "${X}" || die
74                 done
75         fi
76
77         # merge/remove resources depending on USE="X"
78         if use X; then
79                 mv -f htmls resources/ || die
80         else
81                 rm -rf src/net/sourceforge/dvb/projectx/gui || die
82                 rm resources/*.gif || die
83         fi
84
85         # update library packages
86         cd lib || die
87         rm -f {commons-net,jakarta-oro}*.jar || die
88         java-pkg_jar-from commons-net
89         use X && java-pkg_jar-from browserlauncher2-1.0
90         java-pkg_ensure-no-bundled-jars
91 }
92
93 src_compile() {
94         local IDCT="idct-mjpeg"  # default IDCT implementation
95         if use x86 || use amd64; then
96                 use cpu_flags_x86_mmx && IDCT="idct-mjpeg-mmx"
97                 use cpu_flags_x86_sse && IDCT="idct-mjpeg-sse"
98         fi
99
100         eant build $(use_doc) -Dmanifest.mainclass=$(mainclass)
101
102         cd lib/PORTABLE || die
103         emake CC=$(tc-getCC) IDCT="${IDCT}" LDFLAGS="${LDFLAGS}" \
104                 CPLAT="${CFLAGS} -O3 -ffast-math -fPIC"
105 }
106
107 src_install() {
108         java-pkg_dojar dist/${PN}.jar
109         java-pkg_doso lib/PORTABLE/libidctfast.so
110
111         java-pkg_dolauncher ${PN}_cli --main $(mainclass) \
112                 --java_args "-Djava.awt.headless=true -Xmx256m"
113
114         if use X; then
115                 java-pkg_dolauncher ${PN}_gui --main $(mainclass) \
116                         --java_args "-Xmx256m"
117                 dosym ${PN}_gui /usr/bin/${PN}
118                 newicon "${DISTDIR}/${PN}-icon.png" "${PN}.png"
119                 domenu *.desktop
120         else
121                 dosym ${PN}_cli /usr/bin/${PN}
122         fi
123
124         dodoc *.txt
125         use doc && java-pkg_dojavadoc apidocs
126         use source && java-pkg_dosrc src
127 }