a7de4d056476a57a076566c7130995d7b237abc4
[gentoo.git] / media-gfx / sane-backends / sane-backends-1.0.25-r1.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 inherit eutils flag-o-matic multilib multilib-minimal udev user toolchain-funcs
8
9 # gphoto and v4l are handled by their usual USE flags.
10 # The pint backend was disabled because I could not get it to compile.
11 IUSE_SANE_BACKENDS="
12         abaton
13         agfafocus
14         apple
15         artec
16         artec_eplus48u
17         as6e
18         avision
19         bh
20         canon
21         canon630u
22         canon_dr
23         canon_pp
24         cardscan
25         coolscan
26         coolscan2
27         coolscan3
28         dc210
29         dc240
30         dc25
31         dell1600n_net
32         dmc
33         epjitsu
34         epson
35         epson2
36         fujitsu
37         genesys
38         gt68xx
39         hp
40         hp3500
41         hp3900
42         hp4200
43         hp5400
44         hp5590
45         hpljm1005
46         hpsj5s
47         hs2p
48         ibm
49         kodak
50         kodakaio
51         kvs1025
52         kvs20xx
53         kvs40xx
54         leo
55         lexmark
56         ma1509
57         magicolor
58         matsushita
59         microtek
60         microtek2
61         mustek
62         mustek_pp
63         mustek_usb
64         mustek_usb2
65         nec
66         net
67         niash
68         p5
69         pie
70         pixma
71         plustek
72         plustek_pp
73         pnm
74         qcam
75         ricoh
76         rts8891
77         s9036
78         sceptre
79         sharp
80         sm3600
81         sm3840
82         snapscan
83         sp15c
84         st400
85         stv680
86         tamarack
87         teco1
88         teco2
89         teco3
90         test
91         u12
92         umax
93         umax1220u
94         umax_pp
95         xerox_mfp"
96
97 IUSE="doc gphoto2 ipv6 nls snmp systemd threads usb v4l xinetd zeroconf"
98
99 for backend in ${IUSE_SANE_BACKENDS}; do
100         case ${backend} in
101         # Disable backends that require parallel ports as no one has those anymore.
102         canon_pp|hpsj5s|mustek_pp|\
103         pnm)
104                 IUSE+=" -sane_backends_${backend}"
105                 ;;
106         mustek_usb2|kvs40xx)
107                 IUSE+=" sane_backends_${backend}"
108                 ;;
109         *)
110                 IUSE+=" +sane_backends_${backend}"
111         esac
112 done
113
114 REQUIRED_USE="
115         sane_backends_mustek_usb2? ( threads )
116         sane_backends_kvs40xx? ( threads )
117 "
118
119 DESCRIPTION="Scanner Access Now Easy - Backends"
120 HOMEPAGE="http://www.sane-project.org/"
121 case ${PV} in
122 9999)
123         EGIT_REPO_URI="git://anonscm.debian.org/sane/sane-backends.git"
124         inherit git-r3 autotools
125         ;;
126 *_pre*)
127         MY_P="${PN}-git${PV#*_pre}"
128         SRC_URI="http://www.sane-project.org/snapshots/${MY_P}.tar.gz
129                 mirror://gentoo/${MY_P}.tar.gz"
130         S=${WORKDIR}/${MY_P}
131         ;;
132 *)
133         MY_P=${P}
134         FRS_ID="4146"
135         SRC_URI="https://alioth.debian.org/frs/download.php/file/${FRS_ID}/${P}.tar.gz"
136         ;;
137 esac
138
139 LICENSE="GPL-2 public-domain"
140 SLOT="0"
141 if [[ ${PV} != "9999" ]] ; then
142         KEYWORDS="alpha amd64 arm ~arm64 ~hppa ~ia64 ~m68k ~mips ppc ~ppc64 ~s390 ~sh ~sparc x86 ~x86-fbsd ~amd64-linux ~x86-linux"
143 fi
144
145 RDEPEND="
146         sane_backends_dc210? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
147         sane_backends_dc240? ( >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}] )
148         sane_backends_dell1600n_net? (
149                 >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}]
150                 >=media-libs/tiff-3.9.7-r1:0=[${MULTILIB_USEDEP}]
151         )
152         sane_backends_canon_pp? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )
153         sane_backends_hpsj5s? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )
154         sane_backends_mustek_pp? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )
155         usb? ( >=virtual/libusb-1-r1:1=[${MULTILIB_USEDEP}] )
156         gphoto2? (
157                 >=media-libs/libgphoto2-2.5.3.1:=[${MULTILIB_USEDEP}]
158                 >=virtual/jpeg-0-r2:0=[${MULTILIB_USEDEP}]
159         )
160         v4l? ( >=media-libs/libv4l-0.9.5[${MULTILIB_USEDEP}] )
161         xinetd? ( sys-apps/xinetd )
162         snmp? ( net-analyzer/net-snmp )
163         systemd? ( sys-apps/systemd:0= )
164         zeroconf? ( >=net-dns/avahi-0.6.31-r2[${MULTILIB_USEDEP}] )
165 "
166
167 DEPEND="${RDEPEND}
168         v4l? ( sys-kernel/linux-headers )
169         doc? (
170                 virtual/latex-base
171                 dev-texlive/texlive-latexextra
172         )
173         >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}]"
174
175 # We now use new syntax construct (SUBSYSTEMS!="usb|usb_device)
176 RDEPEND="${RDEPEND}
177         !<sys-fs/udev-114"
178
179 MULTILIB_CHOST_TOOLS=(
180         /usr/bin/sane-config
181 )
182
183 pkg_setup() {
184         enewgroup scanner
185         enewuser saned -1 -1 -1 scanner
186 }
187
188 src_prepare() {
189         cat >> backend/dll.conf.in <<-EOF
190         # Add support for the HP-specific backend.  Needs net-print/hplip installed.
191         hpaio
192         # Add support for the Epson-specific backend.  Needs media-gfx/iscan installed.
193         epkowa
194         EOF
195         epatch "${FILESDIR}"/${PN}-1.0.24-saned_pidfile_location.patch
196         epatch "${FILESDIR}"/${PN}-1.0.25-disable-usb-tests.patch
197         if [[ ${PV} == "9999" ]] ; then
198                 mv configure.{in,ac} || die
199                 AT_NOELIBTOOLIZE=yes eautoreconf
200         fi
201
202         # Fix for "make check".  Upstream sometimes forgets to update this.
203         local ver=$(./configure --version | awk '{print $NF; exit 0}')
204         sed -i \
205                 -e "/by sane-desc 3.5 from sane-backends/s:sane-backends .*:sane-backends ${ver}:" \
206                 testsuite/tools/data/html* || die
207 }
208
209 src_configure() {
210         append-flags -fno-strict-aliasing
211
212         # if LINGUAS is set, just use the listed and supported localizations.
213         if [[ ${LINGUAS+set} == "set" ]]; then
214                 mkdir -p po || die
215                 strip-linguas -u po
216                 printf '%s\n' ${LINGUAS} > po/LINGUAS
217         fi
218
219         multilib-minimal_src_configure
220 }
221
222 multilib_src_configure() {
223         # the blank is intended - an empty string would result in building ALL backends.
224         local BACKENDS=" "
225
226         use gphoto2 && BACKENDS="gphoto2"
227         use v4l && BACKENDS="${BACKENDS} v4l"
228         for backend in ${IUSE_SANE_BACKENDS}; do
229                 if use "sane_backends_${backend}" && [ ${backend} != pnm ]; then
230                         BACKENDS="${BACKENDS} ${backend}"
231                 fi
232         done
233
234         local myconf=(
235                 $(use_enable usb libusb_1_0)
236                 $(multilib_native_use_with snmp)
237         )
238
239         # you can only enable this backend, not disable it...
240         if use sane_backends_pnm; then
241                 myconf+=( --enable-pnm-backend )
242         fi
243         if ! use doc; then
244                 myconf+=( --disable-latex )
245         fi
246         if use sane_backends_mustek_pp; then
247                 myconf+=( --enable-parport-directio )
248         fi
249         if ! { use sane_backends_canon_pp || use sane_backends_hpsj5s || use sane_backends_mustek_pp; }; then
250                 myconf+=( sane_cv_use_libieee1284=no )
251         fi
252
253         # relative path must be used for tests to work properly
254         ECONF_SOURCE=${S} \
255         SANEI_JPEG="sanei_jpeg.o" SANEI_JPEG_LO="sanei_jpeg.lo" \
256         BACKENDS="${BACKENDS}" \
257         econf \
258                 $(use_with gphoto2) \
259                 $(multilib_native_use_with systemd) \
260                 $(use_with v4l) \
261                 $(use_enable ipv6) \
262                 $(use_enable nls translations) \
263                 $(use_enable threads pthread) \
264                 $(use_enable zeroconf avahi) \
265                 "${myconf[@]}"
266 }
267
268 multilib_src_compile() {
269         emake VARTEXFONTS="${T}/fonts"
270
271         if tc-is-cross-compiler; then
272                 pushd "${BUILD_DIR}"/tools >/dev/null || die
273
274                 # The build system sucks and doesn't handle this properly.
275                 # https://alioth.debian.org/tracker/index.php?func=detail&aid=314236&group_id=30186&atid=410366
276                 tc-export_build_env BUILD_CC
277                 ${BUILD_CC} ${BUILD_CPPFLAGS} ${BUILD_CFLAGS} ${BUILD_LDFLAGS} \
278                         -I. -I../include -I"${S}"/include \
279                         "${S}"/sanei/sanei_config.c "${S}"/sanei/sanei_constrain_value.c \
280                         "${S}"/sanei/sanei_init_debug.c "${S}"/tools/sane-desc.c -o sane-desc || die
281                 local dirs=( hal hotplug hotplug-ng udev )
282                 local targets=(
283                         hal/libsane.fdi
284                         hotplug/libsane.usermap
285                         hotplug-ng/libsane.db
286                         udev/libsane.rules
287                 )
288                 mkdir -p "${dirs[@]}" || die
289                 emake "${targets[@]}"
290
291                 popd >/dev/null
292         fi
293
294         if use usb; then
295                 sed -i -e '/^$/d' \
296                         tools/hotplug/libsane.usermap || die
297         fi
298 }
299
300 multilib_src_install() {
301         emake INSTALL_LOCKPATH="" DESTDIR="${D}" install \
302                 docdir="${EPREFIX}"/usr/share/doc/${PF}
303
304         if multilib_is_native_abi; then
305                 if use usb; then
306                         insinto /etc/hotplug/usb
307                         doins tools/hotplug/libsane.usermap
308                 fi
309
310                 udev_newrules tools/udev/libsane.rules 41-libsane.rules
311                 insinto "/usr/share/pkgconfig"
312                 doins tools/sane-backends.pc
313         fi
314 }
315
316 multilib_src_install_all() {
317         keepdir /var/lib/lock/sane
318         fowners root:scanner /var/lib/lock/sane
319         fperms g+w /var/lib/lock/sane
320         dodir /etc/env.d
321
322         if use usb; then
323                 exeinto /etc/hotplug/usb
324                 doexe tools/hotplug/libusbscanner
325                 newdoc tools/hotplug/README README.hotplug
326         fi
327
328         dodoc NEWS AUTHORS ChangeLog* PROBLEMS README README.linux
329         prune_libtool_files --all
330         if use xinetd; then
331                 insinto /etc/xinetd.d
332                 doins "${FILESDIR}"/saned
333         fi
334
335         newinitd "${FILESDIR}"/saned.initd saned
336         newconfd "${FILESDIR}"/saned.confd saned
337 }
338
339 pkg_postinst() {
340         if use xinetd; then
341                 elog "If you want remote clients to connect, edit"
342                 elog "/etc/sane.d/saned.conf and /etc/hosts.allow"
343         fi
344
345         elog "If you are using a USB scanner, add all users who want"
346         elog "to access your scanner to the \"scanner\" group."
347 }