summaryrefslogtreecommitdiff
blob: ee631a1a5cd6cbf6faaaf30eaddb8bfdfd100a9b (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
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-gfx/iscan/iscan-1.17.0.ebuild,v 1.1 2005/11/24 23:50:53 sbriesen Exp $

inherit eutils multilib

DESCRIPTION="EPSON Image Scan! for Linux (including sane-epkowa backend)"
HOMEPAGE="http://www.avasys.jp/english/linux_e/dl_scan.html"
SRC_URI="http://lx1.avasys.jp/iscan/v${PV//./}/${P}-1.c2.tar.gz"
LICENSE="GPL-2 x86? ( EAPL EPSON )"
SLOT="0"

KEYWORDS="~x86 ~amd64"
IUSE="X gimp unicode"

# -> non-free modules are x86 only
# -> isane frontend needs non-free modules
# -> sane-epkowa should be usable on every arch

DEPEND=">=dev-libs/libusb-0.1.6
	media-gfx/sane-backends
	media-libs/libpng
	media-libs/jpeg
	x86? (
		X? (
			sys-devel/gettext
			>=x11-libs/gtk+-2.0
			gimp? ( media-gfx/gimp )
		)
	)"

pkg_setup() {
	if ! use x86 && use X; then
		ewarn "The iscan application needs CSS x86-only libs and"
		ewarn "thus can't be built currently. You can still use"
		ewarn "'xscanimage', 'xsane' or 'kooka' with sane-epkowa"
		ewarn "backend. But some low-end scanners are also not"
		ewarn "supported, because they need these x86 libs, too."
	fi
}

src_unpack() {
	unpack ${A}
	cd "${S}"

	if use unicode; then
		einfo "Converting docs to UTF-8"
		for i in {NEWS,README}.ja non-free/{EAPL,LICENSE.EPSON}.ja.txt; do
			iconv -f eucjp -t utf8 -o "${i}~" "${i}" && mv -f "${i}~" "${i}" || rm -f "${i}~"
		done
	fi

	if ! ( use x86 && use X ); then  # disable iscan frontend
		sed -i -e 's:^\([[:space:]]\)frontend[[:space:]]*\\:\1\\:g' \
			-e 's:^\([[:space:]]\)po[[:space:]]*\\:\1\\:g' Makefile.in
		sed -i -e 's:iscan.1::g' doc/Makefile.in
	fi

	if ! use x86; then  # disable non-free modules (x86-only)
		sed -i -e 's:^\([[:space:]]\)non-free[[:space:]]*\\:\1\\:g' Makefile.in
	fi
}

src_compile() {
	econf --enable-jpeg --enable-png --with-pic || die "econf failed"
	emake || die "emake failed"
}

src_install() {
	make DESTDIR="${D}" install || die "make install failed"

	# --disable-static doesn't work, so we just remove static lib
	rm -f "${D}/usr/$(get_libdir)/sane/libsane-epkowa.a"

	# install docs
	dodoc AUTHORS {NEWS,README}*

	# install hotplug stuff	
	insinto /etc/hotplug/usb
	exeinto /etc/hotplug/usb
	doins utils/hotplug/iscan.usermap
	doexe utils/hotplug/iscan-device

	# install sane config
	insinto /etc/sane.d
	doins backend/epkowa.conf

	# link iscan so it is seen as a plugin in gimp
	if use x86 && use X && use gimp; then
		local plugindir
		if [ -x /usr/bin/gimptool ]; then
			plugindir="$(gimptool --gimpplugindir)/plug-ins"
		elif [ -x /usr/bin/gimptool-2.0 ]; then
			plugindir="$(gimptool-2.0 --gimpplugindir)/plug-ins"
		else
			die "Can't find GIMP plugin directory."
		fi
		dodir "${plugindir}"
		dosym /usr/bin/iscan "${plugindir}"
	fi

	# install desktop entry
	if use x86 && use X; then
		make_desktop_entry iscan "Image Scan! for Linux ${PV}" scanner.png
	fi
}