Skip to content

Instantly share code, notes, and snippets.

@jayme-github
Last active July 2, 2017 14:19
Show Gist options
  • Select an option

  • Save jayme-github/aea8b34c4a5b5c94dcbd833daf0073b8 to your computer and use it in GitHub Desktop.

Select an option

Save jayme-github/aea8b34c4a5b5c94dcbd833daf0073b8 to your computer and use it in GitHub Desktop.
Fix Build of Canon IJ Printer Driver Ver. 3.80 for Linux on Debian 9 ("Stretch")

http://www.canon.de/support/consumer_products/products/printers/inkjet/pixma_ip_series/pixma_ip7250.aspx?type=drivers&language=&os=Linux%20(64-bit)

Build process is pretty broken. After applying the patch below you may need to run first build with dpkg-buildpackage -rfakeroot --no-pre-clean as package tries to make clean without running autogen first.

If build fails because linker errors like

make[2]: Entering directory '/tmp/cnijfilter-source-3.80-1/cngpijmon/cnijnpr/cnijnpr'
gcc  -O2 -L../../../com/libs_bin64 -L../../../lgmon/src  -o cnijnpr cnijnpr.o -lcnnet -lbscc2sts -ldl 
/usr/bin/ld: cannot find -lbscc2sts
collect2: error: ld returned 1 exit status
Makefile:336: recipe for target 'cnijnpr' failed

Try to build lgmon manually and re-run buildpackage with --no-pre-clean:

cd lgmon
make
cd ..
dpkg-buildpackage -rfakeroot --no-pre-clean
diff -ur cnijfilter-source-3.80-1.orig/backend/src/cnij_backend_common.c cnijfilter-source-3.80-1/backend/src/cnij_backend_common.c
--- cnijfilter-source-3.80-1.orig/backend/src/cnij_backend_common.c 2012-03-29 06:50:27.000000000 +0200
+++ cnijfilter-source-3.80-1/backend/src/cnij_backend_common.c 2017-07-02 15:44:36.118823615 +0200
@@ -38,6 +38,7 @@
// CUPS Header
#include <cups/cups.h>
#include <cups/ipp.h>
+#include <cups/ppd.h>
// Header file for CANON
#include "cnij_backend_common.h"
diff -ur cnijfilter-source-3.80-1.orig/cngpij/cngpij/bjcups.c cnijfilter-source-3.80-1/cngpij/cngpij/bjcups.c
--- cnijfilter-source-3.80-1.orig/cngpij/cngpij/bjcups.c 2012-04-17 05:39:20.000000000 +0200
+++ cnijfilter-source-3.80-1/cngpij/cngpij/bjcups.c 2017-07-01 23:32:02.268152248 +0200
@@ -66,6 +66,27 @@
char* g_printer_name = NULL;
+#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
+#define HAVE_CUPS_1_6 1
+#endif
+
+#ifndef HAVE_CUPS_1_6
+
+#define ippSetOperation(ipp_request, ipp_op_id) ipp_request->request.op.operation_id = ipp_op_id
+#define ippSetRequestId(ipp_request, ipp_rq_id) ipp_request->request.op.request_id = ipp_rq_id
+#define ippGetStatusCode(ipp_request) ipp_request->request.status.status_code
+#define ippFirstAttribute(ipp) ipp->attrs /* simplistic */
+#define bjcups_ippNextAttribute(resp, attr) attr->next
+#define ippGetGroupTag(attr) attr->group_tag
+#define ippGetName(attr) attr->name
+#define ippGetString(attr, ind, lang) attr->values[ind].string.text
+#define ippGetValueTag(attr) attr->value_tag
+
+#else
+
+#define bjcups_ippNextAttribute(resp, attr) ippNextAttribute(resp)
+
+#endif
extern int GetIPCData(LPIPCU pipc, char *sname);
static short getDeviceURI( const char *pDestName, char *pDeviceURI, short bufSize);
@@ -698,8 +719,8 @@
else {
pRequest = ippNew();
- pRequest->request.op.operation_id = CUPS_GET_PRINTERS;
- pRequest->request.op.request_id = 1;
+ ippSetOperation(pRequest, CUPS_GET_PRINTERS);
+ ippSetRequestId(pRequest, 1);
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19
@@ -708,29 +729,29 @@
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, NULL);
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) {
- if (pResponse->request.status.status_code > IPP_OK_CONFLICT) {
+ if (ippGetStatusCode(pResponse) > IPP_OK_CONFLICT) {
fputs("ERROR: IPP ERROR\n", stderr);
goto onErr;
}
else {
- pAttribute = pResponse->attrs;
+ pAttribute = ippFirstAttribute(pResponse);
while (pAttribute != NULL) {
- while (pAttribute != NULL && pAttribute->group_tag != IPP_TAG_PRINTER) {
- pAttribute = pAttribute->next;
+ while (pAttribute != NULL && ippGetGroupTag(pAttribute) != IPP_TAG_PRINTER) {
+ pAttribute = bjcups_ippNextAttribute(pResponse, pAttribute);
}
if (pAttribute == NULL) {
break;
}
- while (pAttribute != NULL && pAttribute->group_tag == IPP_TAG_PRINTER) {
- if (strcmp(pAttribute->name, "printer-name") == 0 && pAttribute->value_tag == IPP_TAG_NAME) {
- pPrinter = pAttribute->values[0].string.text;
+ while (pAttribute != NULL && ippGetGroupTag(pAttribute) == IPP_TAG_PRINTER) {
+ if (strcmp(ippGetName(pAttribute), "printer-name") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_NAME) {
+ pPrinter = ippGetString(pAttribute, 0, NULL);
}
- if (strcmp(pAttribute->name, "device-uri") == 0 && pAttribute->value_tag == IPP_TAG_URI) {
- pDUri = pAttribute->values[0].string.text;
+ if (strcmp(ippGetName(pAttribute), "device-uri") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_URI) {
+ pDUri = ippGetString(pAttribute, 0, NULL);
}
- pAttribute = pAttribute->next;
+ pAttribute = bjcups_ippNextAttribute(pResponse, pAttribute);
}
if (strcasecmp(pDestName, pPrinter) == 0) {
@@ -739,7 +760,7 @@
}
if (pAttribute != NULL)
- pAttribute = pAttribute->next;
+ pAttribute = bjcups_ippNextAttribute(pResponse, pAttribute);
}
}
diff -ur cnijfilter-source-3.80-1.orig/cngpijmnt/src/main.c cnijfilter-source-3.80-1/cngpijmnt/src/main.c
--- cnijfilter-source-3.80-1.orig/cngpijmnt/src/main.c 2012-04-26 11:49:34.000000000 +0200
+++ cnijfilter-source-3.80-1/cngpijmnt/src/main.c 2017-07-01 23:40:10.948023152 +0200
@@ -59,6 +59,27 @@
char* g_printer_name = NULL;
+#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
+#define HAVE_CUPS_1_6 1
+#endif
+
+#ifndef HAVE_CUPS_1_6
+
+#define ippSetOperation(ipp_request, ipp_op_id) ipp_request->request.op.operation_id = ipp_op_id
+#define ippSetRequestId(ipp_request, ipp_rq_id) ipp_request->request.op.request_id = ipp_rq_id
+#define ippGetStatusCode(ipp_request) ipp_request->request.status.status_code
+#define ippFirstAttribute(ipp) ipp->attrs /* simplistic */
+#define bjcups_ippNextAttribute(resp, attr) attr->next
+#define ippGetGroupTag(attr) attr->group_tag
+#define ippGetName(attr) attr->name
+#define ippGetString(attr, ind, lang) attr->values[ind].string.text
+#define ippGetValueTag(attr) attr->value_tag
+
+#else
+
+#define bjcups_ippNextAttribute(resp, attr) ippNextAttribute(resp)
+
+#endif
extern int GetIPCData(LPIPCU pipc, char *sname);
static short getDeviceURI( const char *pDestName, char *pDeviceURI, short bufSize);
@@ -321,8 +342,8 @@
else {
pRequest = ippNew();
- pRequest->request.op.operation_id = CUPS_GET_PRINTERS;
- pRequest->request.op.request_id = 1;
+ ippSetOperation(pRequest, CUPS_GET_PRINTERS);
+ ippSetRequestId(pRequest, 1);
pLanguage = bjcupsLangDefault(); // cupsLangDefault() -> bjcupsLangDefault() for cups-1.1.19
@@ -331,29 +352,29 @@
ippAddString(pRequest, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, NULL);
if ((pResponse = cupsDoRequest(pHTTP, pRequest, "/")) != NULL) {
- if (pResponse->request.status.status_code > IPP_OK_CONFLICT) {
+ if (ippGetStatusCode(pResponse) > IPP_OK_CONFLICT) {
fputs("ERROR: IPP ERROR\n", stderr);
goto onErr;
}
else {
- pAttribute = pResponse->attrs;
+ pAttribute = ippFirstAttribute(pResponse);
while (pAttribute != NULL) {
- while (pAttribute != NULL && pAttribute->group_tag != IPP_TAG_PRINTER) {
- pAttribute = pAttribute->next;
+ while (pAttribute != NULL && ippGetGroupTag(pAttribute) != IPP_TAG_PRINTER) {
+ pAttribute = bjcups_ippNextAttribute(pResponse, pAttribute);
}
if (pAttribute == NULL) {
break;
}
- while (pAttribute != NULL && pAttribute->group_tag == IPP_TAG_PRINTER) {
- if (strcmp(pAttribute->name, "printer-name") == 0 && pAttribute->value_tag == IPP_TAG_NAME) {
- pPrinter = pAttribute->values[0].string.text;
+ while (pAttribute != NULL && ippGetGroupTag(pAttribute) == IPP_TAG_PRINTER) {
+ if (strcmp(ippGetName(pAttribute), "printer-name") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_NAME) {
+ pPrinter = ippGetString(pAttribute, 0, NULL);
}
- if (strcmp(pAttribute->name, "device-uri") == 0 && pAttribute->value_tag == IPP_TAG_URI) {
- pDUri = pAttribute->values[0].string.text;
+ if (strcmp(ippGetName(pAttribute), "device-uri") == 0 && ippGetValueTag(pAttribute) == IPP_TAG_URI) {
+ pDUri = ippGetString(pAttribute, 0, NULL);
}
- pAttribute = pAttribute->next;
+ pAttribute = bjcups_ippNextAttribute(pResponse, pAttribute);
}
if (strcasecmp(pDestName, pPrinter) == 0) {
@@ -362,7 +383,7 @@
}
if (pAttribute != NULL)
- pAttribute = pAttribute->next;
+ pAttribute = bjcups_ippNextAttribute(pResponse, pAttribute);
}
}
diff -ur cnijfilter-source-3.80-1.orig/cngpijmon/src/bjcupsmon_cups.c cnijfilter-source-3.80-1/cngpijmon/src/bjcupsmon_cups.c
--- cnijfilter-source-3.80-1.orig/cngpijmon/src/bjcupsmon_cups.c 2012-05-22 11:49:27.000000000 +0200
+++ cnijfilter-source-3.80-1/cngpijmon/src/bjcupsmon_cups.c 2017-07-02 15:44:29.850809874 +0200
@@ -21,6 +21,7 @@
#include <cups/cups.h>
#include <cups/ppd.h>
#include <cups/language.h>
+#include <cups/ppd.h>
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>
diff -ur cnijfilter-source-3.80-1.orig/cnijfilter/src/bjfimage.c cnijfilter-source-3.80-1/cnijfilter/src/bjfimage.c
--- cnijfilter-source-3.80-1.orig/cnijfilter/src/bjfimage.c 2012-03-22 02:50:19.000000000 +0100
+++ cnijfilter-source-3.80-1/cnijfilter/src/bjfimage.c 2017-07-02 15:43:56.118736443 +0200
@@ -1520,8 +1520,8 @@
short tmpformat;
short retbyte = 0;
short bpp = 3;
- long width = 0;
- long length = 0;
+ png_uint_32 width = 0;
+ png_uint_32 length = 0;
long rstep = 0;
long RasterLength = 0;
long i;
@@ -1574,7 +1574,7 @@
goto onErr;
}
- if (setjmp (png_p->jmpbuf))
+ if (setjmp (png_jmpbuf(png_p)))
{
png_destroy_read_struct(&png_p, &info_p, (png_infopp)NULL);
goto onErr;
diff -ur cnijfilter-source-3.80-1.orig/debian/compat cnijfilter-source-3.80-1/debian/compat
--- cnijfilter-source-3.80-1.orig/debian/compat 2012-03-29 06:50:27.000000000 +0200
+++ cnijfilter-source-3.80-1/debian/compat 2017-07-01 22:57:17.492884574 +0200
@@ -1 +1 @@
-4
+5
diff -ur cnijfilter-source-3.80-1.orig/debian/control cnijfilter-source-3.80-1/debian/control
--- cnijfilter-source-3.80-1.orig/debian/control 2012-03-29 06:50:27.000000000 +0200
+++ cnijfilter-source-3.80-1/debian/control 2017-07-02 16:08:31.240724142 +0200
@@ -2,7 +2,7 @@
Section: graphics
Priority: optional
Maintainer: Canon Inc. <sup-debian@list.canon.co.jp>
-Build-Depends: debhelper (>= 4.0.0), libcupsys2-dev, libxml2-dev, libtiff4-dev
+Build-Depends: debhelper (>= 5.0.0), libcups2-dev, libxml2-dev, libtiff5-dev, libpopt-dev, libtool-bin
Standards-Version: 3.7.2
Package: cnijfilter-common
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment