summaryrefslogtreecommitdiff
blob: 65cce61ea57341989cddabf8d7b3a30ca3d6ade2 (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
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-gfx/iscan/iscan-1.18.0.ebuild,v 1.1 2006/02/10 20:18:56 sbriesen Exp $

inherit eutils multilib toolchain-funcs

SRC_GCC33="${P}-1.tar.gz"
SRC_GCC34="${P}-1.c2.tar.gz"

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//./}/${SRC_GCC33}
	http://lx1.avasys.jp/iscan/v${PV//./}/${SRC_GCC34}"
LICENSE="GPL-2 x86? ( EAPL EPSON )"
SLOT="0"

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

# HINTS:
# -> non-free modules are x86 only
# -> isane frontend needs non-free modules
# -> sane-epkowa should be usable on every arch
# -> ${P}-1.tar.gz    (for gcc 3.2/3.3)
# -> ${P}-1.c2.tar.gz (for gcc 3.4 or later)

# FIXME:
# make jpeg/png optional. Problem is, that the
# configure script ignores --disable-*, if the
# corresponding lib is found on the system.

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

	# Select correct tarball for installed GCC. This is not a perfect
	# solution and should be expanded to other working GCC versions.
	einfo "GCC version: $(gcc-fullversion)"
	case "$(gcc-version)" in
		3.[23])
			MY_A="${SRC_GCC33}";;
		3.4)
			MY_A="${SRC_GCC34}";;
		*)
			if use x86; then
				die "Your GCC version is not supported. You need either 3.2, 3.3 or 3.4!"
			else
				MY_A="${SRC_GCC34}"  # fallback to GCC 3.4, should not harm.
			fi;;
	esac
}

src_unpack() {
	unpack "${MY_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
}

pkg_postinst() {
	einfo
	einfo "Hint: to enable the backend, add 'epkowa' in /etc/sane.d/dll.conf"
	einfo "Then edit /etc/sane.d/epkowa.conf to suit your needs."
	einfo
}