summary refs log tree commit diff
path: root/pkgs/misc/cups/drivers/cnijfilter2/default.nix
blob: 323163bed3317d7fd2f5c57340fcd4ee5de292c1 (plain) (blame)
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
{ stdenv, lib, fetchzip, autoconf, automake, cups, glib, libxml2, libusb, libtool
, withDebug ? false }:

stdenv.mkDerivation {
  pname = "cnijfilter2";

  version = "5.70";

  src = fetchzip {
    url = "http://gdlp01.c-wss.com/gds/0/0100009930/01/cnijfilter2-source-5.70-1.tar.gz";
    sha256 = "045zjsmaidn1m44ki6m1018gjzbj77gm234n5i2lshxpbzpyh0is";
  };

  buildInputs = [
    cups automake autoconf glib libxml2 libusb libtool
  ];

  # lgmon3's --enable-libdir flag is used soley for specifying in which
  # directory the cnnnet.ini cache file should reside.
  # NixOS uses /var/cache/cups, and given the name, it seems like a reasonable
  # place to put the cnnet.ini file, and thus we do so.
  #
  # Note that the drivers attempt to dlopen
  # $out/lib/cups/filter/libcnbpcnclapicom2.so
  buildPhase = ''
    mkdir -p $out/lib
    cp com/libs_bin64/* $out/lib
    mkdir -p $out/lib/cups/filter
    ln -s $out/lib/libcnbpcnclapicom2.so $out/lib/cups/filter

    export NIX_LDFLAGS="$NIX_LDFLAGS -L$out/lib"
  '' + lib.optionalString withDebug ''
    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -D__DEBUG__ -DDEBUG_LOG"
  '' + ''

    (
      cd lgmon3
      substituteInPlace src/Makefile.am \
        --replace /usr/include/libusb-1.0 \
                  ${libusb.dev}/include/libusb-1.0
      ./autogen.sh --prefix=$out --enable-progpath=$out/bin \
                   --datadir=$out/share \
                   --enable-libdir=/var/cache/cups
      make
    )

    (
      cd cmdtocanonij2
      ./autogen.sh --prefix=$out
      make
    )

    (
      cd cnijbe2
      substituteInPlace src/Makefile.am \
        --replace "/usr/lib/cups/backend" \
                  "$out/lib/cups/backend"
      ./autogen.sh --prefix=$out --enable-progpath=$out/bin
      make
    )

    (
      cd rastertocanonij
      ./autogen.sh --prefix=$out --enable-progpath=$out/bin
      make
    )

    (
      cd tocanonij
      ./autogen.sh --prefix=$out --enable-progpath=$out/bin
      make
    )

    (
      cd tocnpwg
      ./autogen.sh --prefix=$out --enable-progpath=$out/bin
      make
    )
  '';

  installPhase = ''
    (
      cd lgmon3
      make install
    )

    (
      cd cmdtocanonij2
      make install
    )

    (
      cd cnijbe2
      make install
    )

    (
      cd rastertocanonij
      make install
    )

    (
      cd tocanonij
      make install
    )

    (
      cd tocnpwg
      make install
    )

    mkdir -p $out/share/cups/model
    cp ppd/*.ppd $out/share/cups/model
  '';

  meta = with lib; {
    description = "Canon InkJet printer drivers for the MG7500, MG6700, MG6600, MG5600, MG2900, MB2000, MB2300, iB4000, MB5000, MB5300, iP110, E450, MX490, E480, MG7700, MG6900, MG6800, MG5700, MG3600, and G3000 series.";
    homepage = "http://support-th.canon-asia.com/contents/TH/EN/0100712901.html";
    license = licenses.unfree;
    platforms = platforms.linux;
    maintainers = with maintainers; [ cstrahan ];
  };
}