34d65bbe5436127f846ad2f9667fbc36dc0e769a
[gentoo.git] / app-accessibility / brltty / brltty-6.0-r1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python{2_7,3_{5,6,7}} )
7 FINDLIB_USE="ocaml"
8 JAVA_PKG_WANT_SOURCE="1.8"
9 JAVA_PKG_WANT_TARGET="1.8"
10
11 inherit findlib eutils multilib toolchain-funcs java-pkg-opt-2 flag-o-matic usr-ldscript \
12         autotools udev systemd python-r1
13
14 DESCRIPTION="Daemon that provides access to the Linux/Unix console for a blind person"
15 HOMEPAGE="https://brltty.app/"
16 SRC_URI="https://brltty.app/archive/${P}.tar.xz"
17
18 LICENSE="GPL-2 LGPL-2.1"
19 SLOT="0"
20 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~x86"
21 IUSE="+api +beeper bluetooth +contracted-braille doc +fm gpm iconv icu
22                 java louis +midi ncurses nls ocaml +pcm policykit python
23                 usb systemd +speech tcl xml X"
24 REQUIRED_USE="doc? ( api )
25         java? ( api )
26         ocaml? ( api )
27         python? ( api ${PYTHON_REQUIRED_USE} )
28         tcl? ( api )"
29
30 COMMON_DEP="
31         app-accessibility/at-spi2-core:2
32         dev-libs/libpcre2[pcre32]
33         sys-apps/dbus
34         bluetooth? ( net-wireless/bluez )
35         gpm? ( >=sys-libs/gpm-1.20 )
36         iconv? ( virtual/libiconv )
37         icu? ( dev-libs/icu:= )
38         louis? ( dev-libs/liblouis )
39         midi? ( media-libs/alsa-lib )
40         ncurses? ( sys-libs/ncurses:0= )
41         pcm? ( media-libs/alsa-lib )
42         policykit? ( sys-auth/polkit )
43         python? ( ${PYTHON_DEPS} )
44         speech? (
45                 app-accessibility/espeak
46                 app-accessibility/flite
47                 app-accessibility/speech-dispatcher
48         )
49         systemd? ( sys-apps/systemd )
50         tcl? ( >=dev-lang/tcl-8.4.15:0= )
51         usb? ( virtual/libusb:0 )
52         xml? ( dev-libs/expat )
53         X? (
54                 x11-libs/libX11
55                 x11-libs/libXaw
56                 x11-libs/libXt
57                 x11-libs/libXtst
58         )"
59 DEPEND="${COMMON_DEP}"
60 BDEPEND="
61         virtual/pkgconfig
62         java? ( >=virtual/jdk-1.4 )
63         nls? ( virtual/libintl )
64         python? ( >=dev-python/cython-0.16[${PYTHON_USEDEP}] )
65 "
66 RDEPEND="java? ( >=virtual/jre-1.4 )
67         ${COMMON_DEP}"
68
69 HTML_DOCS=( "${S}"/Documents/Manual-BrlAPI/. )
70
71 PATCHES=(
72         "${FILESDIR}"/${PN}-6.0-udev.patch
73         "${FILESDIR}"/${PN}-5.2-respect-AR.patch
74 )
75
76 src_prepare() {
77         default
78
79         java-pkg-opt-2_src_prepare
80
81         # We run eautoconf instead of using eautoreconf because brltty uses
82         # a custom build system that uses autoconf without the rest of the
83         # autotools.
84         eautoconf
85         use python && python_copy_sources
86 }
87
88 src_configure() {
89         tc-export AR LD PKG_CONFIG
90
91         export JAVAC=""
92         export JAVA_JNI_FLAGS=""
93         if use java; then
94                 export JAVA_HOME="$(java-config -g JAVA_HOME)"
95                 export JAVAC_HOME="${JAVA_HOME}/bin"
96                 export JAVA_JNI_FLAGS="$(java-pkg_get-jni-cflags)"
97                 export JAVAC="$(java-pkg_get-javac) -encoding UTF-8 $(java-pkg_javac-args)"
98         fi
99
100         # override prefix in order to install into /
101         # braille terminal needs to be available as soon in the boot process as
102         # possible
103         # Also override localstatedir so that the lib/brltty directory is installed
104         # correctly.
105         # Disable stripping since we do that ourselves.
106         local myconf=(
107                 --prefix="${EPREFIX}"/
108                 --localedir="${EPREFIX}"/usr/share/locale
109                 --includedir="${EPREFIX}"/usr/include
110                 --localstatedir="${EPREFIX}"/var
111                 --disable-stripping
112                 --with-install-root="${D}"
113                 --with-writable-directory="${EPREFIX}"/run/brltty
114                 $(use_enable api)
115                 $(use_with beeper beep-package)
116                 $(use_enable contracted-braille)
117                 $(use_with fm fm-package)
118                 $(use_enable gpm)
119                 $(use_enable iconv)
120                 $(use_enable icu)
121                 $(use_enable java java-bindings)
122                 $(use_enable louis liblouis)
123                 $(use_with midi midi-package)
124                 $(use_enable nls i18n)
125                 $(use_enable ocaml ocaml-bindings)
126                 $(use_with pcm pcm-package)
127                 $(use_enable policykit polkit)
128                 $(use_enable python python-bindings)
129                 $(use_enable speech speech-support)
130                 $(use_with systemd service-package)
131                 $(use_enable tcl tcl-bindings)
132                 $(use_enable xml expat)
133                 $(use_enable X x)
134                 $(use_with bluetooth bluetooth-package)
135                 $(use_with ncurses curses)
136                 $(use_with usb usb-package) )
137
138         econf "${myconf[@]}"
139
140         if use python; then
141                 python_configure() {
142                         econf "${myconf[@]}"
143                 }
144                 python_foreach_impl run_in_build_dir python_configure
145         fi
146 }
147
148 src_compile() {
149         emake JAVA_JNI_FLAGS="${JAVA_JNI_FLAGS}" JAVAC="${JAVAC}"
150
151         if use python; then
152                 python_build() {
153                         cd "Bindings/Python" || die
154                         emake
155                 }
156                 python_foreach_impl run_in_build_dir python_build
157         fi
158 }
159
160 src_install() {
161         if use ocaml; then
162                 findlib_src_preinst
163         fi
164
165         emake OCAML_LDCONF= install
166
167         if use python; then
168                 python_install() {
169                         cd "Bindings/Python" || die
170                         emake install
171                 }
172                 python_foreach_impl run_in_build_dir python_install
173         fi
174
175         if use java; then
176                 java-pkg_doso Bindings/Java/libbrlapi_java.so
177                 java-pkg_dojar Bindings/Java/brlapi.jar
178         fi
179
180         insinto /etc
181         doins Documents/brltty.conf
182         udev_newrules Autostart/Udev/rules 70-brltty.rules
183         newinitd "${FILESDIR}"/brltty.rc brltty
184         systemd_dounit Autostart/Systemd/brltty@.service
185         systemd_dotmpfilesd "${FILESDIR}/${PN}.tmpfiles.conf"
186
187         if use api ; then
188                 local libdir="$(get_libdir)"
189                 mkdir -p "${ED}"/usr/${libdir}/ || die
190                 mv "${ED}"/${libdir}/*.a "${ED}"/usr/${libdir}/ || die
191                 gen_usr_ldscript libbrlapi.so
192         fi
193
194         cd Documents || die
195         mv Manual-BRLTTY/English/BRLTTY.txt BRLTTY-en.txt || die
196         mv Manual-BRLTTY/French/BRLTTY.txt BRLTTY-fr.txt || die
197         mv Manual-BrlAPI/English/BrlAPI.txt BrlAPI-en.txt || die
198         dodoc CONTRIBUTORS ChangeLog HISTORY README* TODO BRLTTY-*.txt
199         if use doc; then
200                 dodoc BrlAPI-*.txt
201                 HTML_DOCS="Manual-BRLTTY" einstalldocs
202         fi
203
204         keepdir /var/lib/BrlAPI
205         rmdir "${ED}/run/brltty" || die
206         rmdir "${ED}/run" || die
207 }
208
209 pkg_postinst() {
210         elog
211         elog "please be sure ${ROOT}/etc/brltty.conf is correct for your system."
212         elog
213         elog "To make brltty start on boot, type this command as root:"
214         elog
215         elog "rc-update add brltty boot"
216 }