summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: cfb726dc831dff3f7f7d2acd1239025471b9750d (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
# Maintainer: Karol 'Kenji Takahashi' Wo┼║niak @ kenji.sx
# Based on a scangearmp-mg3200 package by morris555
#
# [Printer Model Name] [Printer Model ID]
# ------------------------------------------------------------------
#  mp230     401
#  mg2200    402
#  e510      403
#  mg3200    404
#  mg4200    405
#  ip7200    406
#  mg5400    407
#  mg6300    408

_name=mg4200
_id=405

pkgname=scangearmp-${_name}
pkgver=2.00
pkgrel=2
_pkgver=2.00-1
pkgdesc="Canon Scanner Driver (for ${_name} series)"
url="http://support-my.canon-asia.com/contents/MY/EN/0100470802.html"
arch=('i686' 'x86_64')
license=('custom')
depends=('gtk2' 'sane' 'libusb-compat' 'gimp')
install=scangearmp-mg4200.install
source=(
    http://gdlp01.c-wss.com/gds/8/0100004708/01/scangearmp-source-${_pkgver}.tar.gz
    'libpng15.patch'
    'fix_configure.patch'
)
md5sums=(
    'ccd538e1333bf34aa83900f093ecd9eb'
    '5fd4f2f00aad11ff108a2c642cf1a7c1'
    '6ff76bfcfa4b4021e47677882772c895'
)

if [ "$CARCH" == "x86_64" ]; then
    _libdir=libs_bin64
else
    _libdir=libs_bin32
fi

build() {
    cd "${srcdir}/scangearmp-source-${_pkgver}"

    # Patch for libpng>=1.5
    patch -p1 -i ../libpng15.patch
    patch -p1 -i ../fix_configure.patch

    cd scangearmp

    ./autogen.sh --prefix=/usr --enable-libpath=/usr/lib LDFLAGS="-lm -L`pwd`/../com/${_libdir}"
    # Force the use of system's libtool
    rm -f libtool
    ln -s `which libtool` .
    # Build package
    make clean || return 1
    make || return 1
}

package() {
    cd "${srcdir}/scangearmp-source-${_pkgver}/scangearmp"

    # Install package
    install -d -m 0755 $pkgdir/usr/lib/bjlib
    make DESTDIR=${pkgdir} install || return 1

    # Install SANE configuration file
    install -d -m 0755 $pkgdir/etc/sane.d/
    install -m 0644 ${srcdir}/scangearmp-source-${_pkgver}/scangearmp/backend/canon_mfp.conf $pkgdir/etc/sane.d/canon_mfp.conf

    # Install common libraries
    install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/com/${_libdir}/libcncpcmcm.so.8.0.1 ${pkgdir}/usr/lib/
    install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/com/${_libdir}/libcncpmsimg.so.1.0.2 ${pkgdir}/usr/lib/
    install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/com/${_libdir}/libcncpmslld.so.1.0.1 ${pkgdir}/usr/lib/
    install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/com/${_libdir}/libcncpmsui.so.2.0.0 ${pkgdir}/usr/lib/
    install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/com/${_libdir}/libcncpnet.so.1.2.2 ${pkgdir}/usr/lib/

    # Install specific libraries
    install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/${_id}/${_libdir}/libcncpmsimg${_id}.so.2.0.0 ${pkgdir}/usr/lib/
    install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/${_id}/${_libdir}/libcncpmslld${_id}c.so.1.04.1 ${pkgdir}/usr/lib/
    install -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/${_id}/${_libdir}/libcncpmslld${_id}.so.2.0.0 ${pkgdir}/usr/lib/
    # Create symbolic links
    cd ${pkgdir}/usr/lib/
    ln -s libcncpcmcm.so.8.0.1 libcncpcmcm.so
    ln -s libcncpmsimg.so.1.0.2 libcncpmsimg.so
    ln -s libcncpmslld.so.1.0.1 libcncpmslld.so
    ln -s libcncpmsui.so.2.0.0 libcncpmsui.so
    ln -s libcncpnet.so.1.2.2 libcncpnet.so

    ln -s libcncpmsimg${_id}.so.2.0.0 libcncpmsimg${_id}.so
    ln -s libcncpmslld${_id}c.so.1.04.1 libcncpmslld${_id}c.so
    ln -s libcncpmslld${_id}.so.2.0.0 libcncpmslld${_id}.so

    # Make scangearmp usable from gimp
    install -d -m 0755 ${pkgdir}/usr/lib/gimp/2.0/plug-ins/
    ln -s /usr/bin/scangearmp ${pkgdir}/usr/lib/gimp/2.0/plug-ins/

    # Install .tbl and .dat files
    install -D -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/${_id}/cnc*.tbl ${pkgdir}/usr/lib/bjlib/
    install -D -m 0755 ${srcdir}/scangearmp-source-${_pkgver}/${_id}/CNC_*.DAT ${pkgdir}/usr/lib/bjlib/

    # Install udev rules
    install -D -m 0644 ${srcdir}/scangearmp-source-${_pkgver}/scangearmp/etc/80-canon_mfp.rules ${pkgdir}/etc/udev/rules.d/80-canon_mfp.rules

    # Install .ini file
    install -D -m 0666 ${srcdir}/scangearmp-source-${_pkgver}/com/ini/canon_mfp_net.ini ${pkgdir}/usr/lib/bjlib/

    # Install license file
    cd ${srcdir}/scangearmp-source-${_pkgver}
    install -D LICENSE-scangearmp-${pkgver}EN.txt ${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-scangearmp-${pkgver}EN.txt

    # Remove unneeded files
    rm ${pkgdir}/usr/lib/libsane-canon_mfp.a
    rm ${pkgdir}/usr/lib/libsane-canon_mfp.la
}

# vim:set ts=4 sw=4 et: