summaryrefslogtreecommitdiff
path: root/net-print/cnijfilter-drivers/cnijfilter-drivers-3.70.ebuild
blob: ced74ef1843a9f99af6275bd14a1c327010351bd (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=5

MY_PN="${PN/-drivers/}"

inherit eutils autotools flag-o-matic multilib

DESCRIPTION="Canon InkJet Printer Driver for Linux (Pixus/Pixma-Series)."
HOMEPAGE="http://support-sg.canon-asia.com/contents/SG/EN/0100411802.html"
SRC_URI="http://gdlp01.c-wss.com/gds/8/0100004118/01/${MY_PN}-source-${PV}-1.tar.gz"

LICENSE="GPL-2 cnijfilter"
SLOT="${PV}"
KEYWORDS="~amd64 ~x86"
PRINTER_USE=( ip100 mx710 mx890 mx370 mx430 mx510 e600 )
PRINTER_ID=( 303 394 395 396 397 398 399 )
IUSE="${PRINTER_USE[@]} +servicetools"

RDEPEND="
	net-print/cnijfilter[servicetools?]
	>=media-libs/libpng-1.5
	>=media-libs/tiff-3.4
	>=net-print/cups-1.4
	servicetools? (
		>=dev-libs/libxml2-2.7.3-r2
		>=x11-libs/gtk+-2.6:2
	)
"
DEPEND="${DEPEND}
	sys-devel/gettext
"

REQUIRED_USE="|| ( ${PRINTER_USE[@]} )"

S="${WORKDIR}/${MY_PN}-source-${PV}-1"

_dir_build() {
	local dirs=$1
	local command=$2
	local d

	[[ $# -ne 2 ]] && die "Call as: _dir_build DIRS COMMAND"

	for d in ${dirs}; do
		local suffix=""
		echo ">>> Working in: ${d}"
		pushd ${d} >/dev/null
		# progpath must be set otherwise we go for /usr/local/bin
		if [[ ${command} == econf* ]]; then
			${command} --enable-progpath="${EPREFIX}/usr/bin"
		else
			${command}
		fi
		popd > /dev/null
	done
}

_printer_dir_build() {
	local command=$1
	local d

	[[ $# -ne 1 ]] && die "Call as: _printer_dir_build COMMAND"

	for (( i=0; i<${#PRINTER_USE[@]}; i++ )); do
		local name="${PRINTER_USE[$i]}"
		if use ${name}; then
			for d in ${DIRS_PRINTER}; do
				echo ">>> Working in: ${name}/${d}"
				pushd ${name}/${d} > /dev/null
				if [[ ${command} == econf* ]]; then
					${command} \
						--enable-progpath="${EPREFIX}/usr/bin" \
						--program-suffix=${name}
				else
					${command}
				fi
				popd > /dev/null
			done
		fi
	done
}

pkg_setup() {
	[[ -z ${LINGUAS} ]] && LINGUAS="en"

	DIRS_PRINTER="cnijfilter"
	# lgmon must be first as it is required by cngpijmon
	use servicetools && DIRS_PRINTER+=" lgmon cngpijmon printui"
}

src_prepare() {
	local d i

	# missing macros directory make aclocal fail
	mkdir printui/m4 || die

	epatch \
		"${FILESDIR}/${MY_PN}"-3.70-png.patch \
		"${FILESDIR}/${MY_PN}"-3.70-ppd.patch \
		"${FILESDIR}/${MY_PN}"-3.70-ppd2.patch \
		"${FILESDIR}/${MY_PN}"-3.70-libexec-cups.patch \
		"${FILESDIR}/${MY_PN}"-3.70-libexec-backend.patch

	_dir_build "${DIRS_PRINTER}" "eautoreconf"

	for (( i=0; i<${#PRINTER_USE[@]}; i++ )); do
		local name="${PRINTER_USE[$i]}"
		local pid="${PRINTER_ID[$i]}"
		if use ${name}; then
			mkdir -p ${name} || die
			ln -s "${S}"/${pid} ${name}/ || die
			for d in ${DIRS_PRINTER}; do
				cp -a ${d} ${name} || die
			done
		fi
	done
}

src_configure() {
	local d i

	_printer_dir_build "econf"
}

src_compile() {
	_printer_dir_build "emake"
}

src_install() {
	local _libdir="${EPREFIX}/usr/$(get_libdir)"
	local _libdir_pkg=libs_bin$(use amd64 && echo 64 || echo 32)
	local _ppddir="${EPREFIX}/usr/share/cups/model"

	_printer_dir_build "emake DESTDIR=${D} install"

	for (( i=0; i<${#PRINTER_USE[@]}; i++ )); do
		local name="${PRINTER_USE[$i]}"
		local pid="${PRINTER_ID[$i]}"
		if use ${name}; then
			dodir ${_libdir}
			# no doexe due to symlinks
			cp -a "${pid}/${_libdir_pkg}"/* "${D}/${_libdir}" || die
			exeinto ${_libdir}/cnijlib
			doexe ${pid}/database/*
			# create symlink for the cnijlib to bjlib as some formats need it
			dosym ${_libdir}/cnijlib ${_libdir}/bjlib
			insinto ${_ppddir}
			doins ppd/canon${name}.ppd
		fi
	done
}

pkg_postinst() {
	einfo ""
	einfo "For installing a printer:"
	einfo " * Restart CUPS: /etc/init.d/cupsd restart"
	einfo " * Go to http://127.0.0.1:631/"
	einfo "   -> Printers -> Add Printer"
	einfo ""
	einfo "If you experience any problems, please visit:"
	einfo " http://forums.gentoo.org/viewtopic-p-3217721.html"
	einfo ""
}