Unable to Rebuild Printer Driver from AUR

It really shouldn’t be this difficult!

As I mentioned in “Direct printing from Scribus to Canon MP640 discards all output”, a few years ago, I was able to successfully configure my Canon PIXMA MP640 printer, using the cnijfilter packages from AUR.

A few weeks ago, after pamac utterly destroyed my installation, by deleting the kernel images required to boot, among other things, and having given up on the interminable chases, down an ever-growing series of rabbit holes, in an attempt to resurrect it piecemeal, I eventually opted for a clean reinstallation.

I now have the system more-or-less working to my satisfaction, except that I have no working printer. I had expected this to entail simply rebuilding the two cnijfilter packages, cnijfilter-common and cnijfilter-mp640, from AUR, but no such luck – the cnijfilter-common package no longer builds!

Why this should be appears to be a consequence of GCC evolution – it has become less tolerant of potentially ambiguous coding practices. In this particular case, the first fatal error encountered is a gratuitous omission of a requisite header file, in one of what would appear to be one of Canon’s original C source files. I have sufficient C programming expertise to correct this, but if I then simply attempt the AUR build again, my correction is discarded. If instead, I amend one of the existing patch files, within the AUR build tree, to apply the correction during the build, the build then fails a validation check, and immediately aborts.

I do not have sufficient knowledge of the AUR build system, or how this is processed within pamac, to resolve this. Any advice would be greatly appreciated.

Looks like lgmon2/src/keytext.c is missing the <stdlib.h> include:

cnijfilter-common build log

make[3]: Entering directory '/build/cnijfilter-common/src/cnijfilter-source-4.10-1/lgmon2/src'
gcc -m32 -DHAVE_CONFIG_H -I. -I..     -O2 -Wall -I/usr/include/libusb-1.0 -I./common -I/usr/include/libxml2 -MT cnijcomif.o -MD -MP -MF .deps/cnijcomif.Tpo -c -o cnijcomif.o cnijcomif.c
gcc -m32 -DHAVE_CONFIG_H -I. -I..     -O2 -Wall -I/usr/include/libusb-1.0 -I./common -I/usr/include/libxml2 -MT cnijifusb.o -MD -MP -MF .deps/cnijifusb.Tpo -c -o cnijifusb.o cnijifusb.c
gcc -m32 -DHAVE_CONFIG_H -I. -I..     -O2 -Wall -I/usr/include/libusb-1.0 -I./common -I/usr/include/libxml2 -MT cnijlgmon2.o -MD -MP -MF .deps/cnijlgmon2.Tpo -c -o cnijlgmon2.o cnijlgmon2.c
gcc -m32 -DHAVE_CONFIG_H -I. -I..     -O2 -Wall -I/usr/include/libusb-1.0 -I./common -I/usr/include/libxml2 -MT cnijifnet.o -MD -MP -MF .deps/cnijifnet.Tpo -c -o cnijifnet.o cnijifnet.c
gcc -m32 -DHAVE_CONFIG_H -I. -I..     -O2 -Wall -I/usr/include/libusb-1.0 -I./common -I/usr/include/libxml2 -MT keytext.o -MD -MP -MF .deps/keytext.Tpo -c -o keytext.o keytext.c
keytext.c: In function ‘CheckFileExists’:
keytext.c:57:32: error: implicit declaration of function ‘malloc’ [-Wimplicit-function-declaration]
   57 |         full_filename = (char*)malloc( full_filename_len );
      |                                ^~~~~~
keytext.c:42:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
   41 | #include "keytext.h"
  +++ |+#include <stdlib.h>
   42 | 
keytext.c:57:32: warning: incompatible implicit declaration of built-in function ‘malloc’ [-Wbuiltin-declaration-mismatch]
   57 |         full_filename = (char*)malloc( full_filename_len );
      |                                ^~~~~~
keytext.c:57:32: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
keytext.c:70:9: error: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
   70 |         free(full_filename);
      |         ^~~~
keytext.c:70:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
keytext.c:70:9: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
keytext.c:70:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
keytext.c: In function ‘NewStringList’:
keytext.c:82:52: warning: incompatible implicit declaration of built-in function ‘malloc’ [-Wbuiltin-declaration-mismatch]
   82 |         if ( (lpStringListComp = (LPSTRINGLISTCOMP)malloc(sizeof(STRINGLISTCOMP))) == NULL ) goto Err1;
      |                                                    ^~~~~~
keytext.c:82:52: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
keytext.c:85:47: warning: incompatible implicit declaration of built-in function ‘malloc’ [-Wbuiltin-declaration-mismatch]
   85 |         if ( (lpStringListComp->key = (char *)malloc(len)) == NULL ) goto Err1;
      |                                               ^~~~~~
keytext.c:85:47: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
keytext.c:90:48: warning: incompatible implicit declaration of built-in function ‘malloc’ [-Wbuiltin-declaration-mismatch]
   90 |         if ( (lpStringListComp->text = (char *)malloc(len)) == NULL ) goto Err2;
      |                                                ^~~~~~
keytext.c:90:48: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
keytext.c:101:48: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
  101 |         if ( lpStringListComp->text != NULL )  free( lpStringListComp->text );
      |                                                ^~~~
keytext.c:101:48: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
keytext.c:103:47: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
  103 |         if ( lpStringListComp->key != NULL )  free( lpStringListComp->key );
      |                                               ^~~~
keytext.c:103:47: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
keytext.c: In function ‘FreeStringListComp’:
keytext.c:132:17: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
  132 |                 free( current->key );
      |                 ^~~~
keytext.c:132:17: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
keytext.c:136:17: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
  136 |                 free( current->text);
      |                 ^~~~
keytext.c:136:17: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
keytext.c: In function ‘LoadKeyTextList’:
keytext.c:288:36: warning: incompatible implicit declaration of built-in function ‘malloc’ [-Wbuiltin-declaration-mismatch]
  288 |         if ( (list = (KeyTextList*)malloc(sizeof(KeyTextList))) == NULL ) goto Err1;
      |                                    ^~~~~~
keytext.c:288:36: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
keytext.c:301:9: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
  301 |         free( list );
      |         ^~~~
keytext.c:301:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
keytext.c: In function ‘FreeKeyTextList’:
keytext.c:311:9: warning: incompatible implicit declaration of built-in function ‘free’ [-Wbuiltin-declaration-mismatch]
  311 |         free( g_key_keytext_list );
      |         ^~~~
keytext.c:311:9: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
make[3]: *** [Makefile:426: keytext.o] Error 1
make[3]: *** Waiting for unfinished jobs....
cnijlgmon2.c: In function ‘main’:
cnijlgmon2.c:346:47: warning: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Wsizeof-pointer-memaccess]
  346 |         strncpy(job_id, CN_START_JOBID, sizeof(CN_START_JOBID));
      |                                               ^
cnijcomif.c: In function ‘CNIF_GetSerialNum’:
cnijcomif.c:174:9: warning: ‘strncpy’ specified bound 256 equals destination size [-Wstringop-truncation]
  174 |         strncpy(dev_uri, (const char *)buffer, CN_DEVICE_URI_LEN);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mv -f .deps/cnijcomif.Tpo .deps/cnijcomif.Po
mv -f .deps/cnijifnet.Tpo .deps/cnijifnet.Po
cnijlgmon2.c:265:9: warning: ‘strncpy’ specified bound 256 equals destination size [-Wstringop-truncation]
  265 |         strncpy(dev_uri, argv[1], CN_DEVICE_URI_LEN);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cnijifusb.c: In function ‘CNIF_USB_IsIvec’:
cnijifusb.c:615:9: warning: ‘strncpy’ specified bound 4096 equals destination size [-Wstringop-truncation]
  615 |         strncpy(buffer, info, CN_READ_SIZE);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cnijifusb.c: In function ‘CNIF_USB_IsPrinter’:
cnijifusb.c:657:9: warning: ‘strncpy’ specified bound 4096 equals destination size [-Wstringop-truncation]
  657 |         strncpy(buffer, info, sizeof(buffer));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mv -f .deps/cnijlgmon2.Tpo .deps/cnijlgmon2.Po
mv -f .deps/cnijifusb.Tpo .deps/cnijifusb.Po
make[3]: Leaving directory '/build/cnijfilter-common/src/cnijfilter-source-4.10-1/lgmon2/src'
make[2]: *** [Makefile:422: all-recursive] Error 1
make[2]: Leaving directory '/build/cnijfilter-common/src/cnijfilter-source-4.10-1/lgmon2'
make[1]: *** [Makefile:354: all] Error 2
make[1]: Leaving directory '/build/cnijfilter-common/src/cnijfilter-source-4.10-1/lgmon2'
make: *** [Makefile:18: common] Error 1

It now builds:

PKGBUILD diff
diff --git a/PKGBUILD b/PKGBUILD
index fe96d35..3d6009b 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -34,11 +34,13 @@ install=cnijfilter-common.install
 source=("cnijfilter-source-4.10-1.tar.gz::http://pdisp01.c-wss.com/gdl/WWUFORedirectTarget.do?id=MDEwMDAwNTg1ODAx&cmp=ACB&lang=EN"
        "cups.patch"
        "buildfiles.patch"
-   "mychanges.patch")
+ "mychanges.patch"
+ "keytext.patch")
 sha512sums=('58198e92e360c71c95423bfa8278f449eb645245af1b96770323cb6f4b2b7186e5ab326d58377c20627c750d3d8c253addf637f9d18e085b1c89a81d6239ab51'
             'ce3de5764d47809166c86cc52feeae354f459bdc1db757ee62e8c7793b4886f95d9a04caee5adefc73b3ae1752ce370668d23d9530ebf8be2b7b25066e064210'
             'fb73e2e0653f2654a9c5211b5dc3e06ce24cd2f5bf64a27009f5446e69c7f02d78bb201f15da0f68ad01b1cb4e699c808eccb9df690ffea07b6d5a59ab5629f3'
-            '1c70fbe7da493cd44e13149baeda1d90edbbe0d9e52ca9178e70b8dc0e494f544523eefad653e2f2a4c0283f601feb549767f2eb2941cd44dc97ebc8b2b0db9a')
+            '1c70fbe7da493cd44e13149baeda1d90edbbe0d9e52ca9178e70b8dc0e494f544523eefad653e2f2a4c0283f601feb549767f2eb2941cd44dc97ebc8b2b0db9a'
+            'b5485eced55767e4cb419ebd2c15f42f9f5d7b1302a7970c40bc4de175f1d2b48f93974c2df424af53dca0bd3a63235951fab9da1d6db09468f9f878e6d82358')
 
 prepare() {
   cd "${srcdir}/${_pkgname}-source-${pkgver}-${_pkgreview}/"
@@ -46,6 +48,7 @@ prepare() {
   patch -p1 -i ${srcdir}/cups.patch
   patch -p1 -i ${srcdir}/buildfiles.patch
   patch -p1 -i ${srcdir}/mychanges.patch
+  patch -p1 -i ${srcdir}/keytext.patch
 }
 
 build() {
keytext.patch
diff --unified --recursive --text a/lgmon2/src/keytext.c b/lgmon2/src/keytext.c
--- a/lgmon2/src/keytext.c	2013-12-23 21:09:15.000000000 -0700
+++ b/lgmon2/src/keytext.c	2024-11-03 10:54:25.716586047 -0700
@@ -37,6 +37,7 @@
 #include <unistd.h>
 #include <libxml/parser.h>	/* Ver.2.80 */
 #include <string.h>
+#include <stdlib.h>
 
 #include "keytext.h"

However, cnijfilter-mp640 fails and I’m not sure how to fix it:

cnijfilter-mp640 build log

make[3]: Entering directory '/build/cnijfilter-mp640/src/cnijfilter-source-3.20-1/cnijfilter/src'
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjferror.o -MD -MP -MF .deps/bjferror.Tpo -c -o bjferror.o bjferror.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjfilter.o -MD -MP -MF .deps/bjfilter.Tpo -c -o bjfilter.o bjfilter.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjfimage.o -MD -MP -MF .deps/bjfimage.Tpo -c -o bjfimage.o bjfimage.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjfoption.o -MD -MP -MF .deps/bjfoption.Tpo -c -o bjfoption.o bjfoption.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjfpos.o -MD -MP -MF .deps/bjfpos.Tpo -c -o bjfpos.o bjfpos.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjfrcaccess.o -MD -MP -MF .deps/bjfrcaccess.Tpo -c -o bjfrcaccess.o bjfrcaccess.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT getipc.o -MD -MP -MF .deps/getipc.Tpo -c -o getipc.o getipc.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjflist.o -MD -MP -MF .deps/bjflist.Tpo -c -o bjflist.o bjflist.c
bjfoption.c: In function ‘usage’:
bjfoption.c:106:36: error: implicit declaration of function ‘tolower’ [-Wimplicit-function-declaration]
  106 |                 small_tmpname[i] = tolower(modelname[i]);
      |                                    ^~~~~~~
bjfoption.c:46:1: note: include ‘<ctype.h>’ or provide a declaration of ‘tolower’
   45 | #include "bjfpath.h"
  +++ |+#include <ctype.h>
   46 | 
bjfoption.c: In function ‘SetCmdOption’:
bjfoption.c:542:47: error: passing argument 3 of ‘poptGetContext’ from incompatible pointer type [-Wincompatible-pointer-types]
  542 |         optcon = poptGetContext( NULL, cargc, cargv, optionsTable, 0 );
      |                                               ^~~~~
      |                                               |
      |                                               char **
In file included from bjfoption.c:29:
/usr/include/popt.h:217:41: note: expected ‘const char **’ but argument is of type ‘char **’
  217 |                 int argc, const char ** argv,
      |                           ~~~~~~~~~~~~~~^~~~
bjfoption.c: In function ‘MakeModelnameConfname’:
bjfoption.c:1505:32: error: implicit declaration of function ‘toupper’ [-Wimplicit-function-declaration]
 1505 |                 modelname[i] = toupper(small_modelname[i]);
      |                                ^~~~~~~
bjfoption.c:1505:32: note: include ‘<ctype.h>’ or provide a declaration of ‘toupper’
make[3]: *** [Makefile:393: bjfoption.o] Error 1
make[3]: *** Waiting for unfinished jobs....
mv -f .deps/bjferror.Tpo .deps/bjferror.Po
bjfilter.c: In function ‘main’:
bjfilter.c:163:78: error: implicit declaration of function ‘tolower’ [-Wimplicit-function-declaration]
  163 |         for( i=0; i<sizeof(small_modelname); i++ )      small_modelname[i] = tolower(tmp_modelname[i]);
      |                                                                              ^~~~~~~
bjfilter.c:55:1: note: include ‘<ctype.h>’ or provide a declaration of ‘tolower’
   54 | #include "bjfpath.h"
  +++ |+#include <ctype.h>
   55 | 
bjfimage.c: In function ‘tiff_image_init’:
bjfimage.c:421:9: warning: ‘uint32’ is deprecated [-Wdeprecated-declarations]
  421 |         uint32                          width = 0;
      |         ^~~~~~
bjfimage.c:422:9: warning: ‘uint32’ is deprecated [-Wdeprecated-declarations]
  422 |         uint32                          length = 0;
      |         ^~~~~~
bjfimage.c:428:9: warning: ‘uint16’ is deprecated [-Wdeprecated-declarations]
  428 |         uint16                          config;
      |         ^~~~~~
bjfimage.c:429:9: warning: ‘uint16’ is deprecated [-Wdeprecated-declarations]
  429 |         uint16                          compress;
      |         ^~~~~~
bjfilter.c: In function ‘MakeBJPrintData’:
bjfilter.c:386:25: error: implicit declaration of function ‘SetExtLevel’ [-Wimplicit-function-declaration]
  386 |                         SetExtLevel(&lpbjinfo->bjfmgninfo, lpbjinfo->bjfoption.extension);
      |                         ^~~~~~~~~~~
mv -f .deps/getipc.Tpo .deps/getipc.Po
bjfilter.c: In function ‘set_position_parameter’:
bjfilter.c:985:5: error: implicit declaration of function ‘bjf_margin_init’; did you mean ‘bjf_image_init’? [-Wimplicit-function-declaration]
  985 |     bjf_margin_init( &lpbjinfo->bjfmgninfo );
      |     ^~~~~~~~~~~~~~~
      |     bjf_image_init
mv -f .deps/bjflist.Tpo .deps/bjflist.Po
bjfimage.c: In function ‘ppm_write_tmpfile’:
bjfimage.c:1862:18: error: implicit declaration of function ‘write’; did you mean ‘fwrite’? [-Wimplicit-function-declaration]
 1862 |         w_size = write( fd , PPMRAWSTART , 2 );
      |                  ^~~~~
      |                  fwrite
bjfimage.c:1901:9: error: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration]
 1901 |         close( fd );
      |         ^~~~~
      |         pclose
bjfimage.c:1908:17: error: implicit declaration of function ‘unlink’ [-Wimplicit-function-declaration]
 1908 |                 unlink(outfile);
      |                 ^~~~~~
make[3]: *** [Makefile:393: bjfilter.o] Error 1
make[3]: *** [Makefile:393: bjfimage.o] Error 1
mv -f .deps/bjfrcaccess.Tpo .deps/bjfrcaccess.Po
mv -f .deps/bjfpos.Tpo .deps/bjfpos.Po
make[3]: Leaving directory '/build/cnijfilter-mp640/src/cnijfilter-source-3.20-1/cnijfilter/src'
make[2]: *** [Makefile:362: all-recursive] Error 1
make[2]: Leaving directory '/build/cnijfilter-mp640/src/cnijfilter-source-3.20-1/cnijfilter'
make[1]: *** [Makefile:303: all] Error 2
make[1]: Leaving directory '/build/cnijfilter-mp640/src/cnijfilter-source-3.20-1/cnijfilter'
make: *** [Makefile:18: mp640] Error 1

EDIT: I tried adding the missing <ctype.h> include in cnijfilter/src/bjfoption.c, but it still fails:

cnijfilter-mp640 build log

make[3]: Entering directory '/build/cnijfilter-mp640/src/cnijfilter-source-3.20-1/cnijfilter/src'
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjferror.o -MD -MP -MF .deps/bjferror.Tpo -c -o bjferror.o bjferror.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjfilter.o -MD -MP -MF .deps/bjfilter.Tpo -c -o bjfilter.o bjfilter.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjfimage.o -MD -MP -MF .deps/bjfimage.Tpo -c -o bjfimage.o bjfimage.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjfoption.o -MD -MP -MF .deps/bjfoption.Tpo -c -o bjfoption.o bjfoption.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjfpos.o -MD -MP -MF .deps/bjfpos.Tpo -c -o bjfpos.o bjfpos.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjfrcaccess.o -MD -MP -MF .deps/bjfrcaccess.Tpo -c -o bjfrcaccess.o bjfrcaccess.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT getipc.o -MD -MP -MF .deps/getipc.Tpo -c -o getipc.o getipc.c
gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../include/cncl -I../include/misc    -O2 -MT bjflist.o -MD -MP -MF .deps/bjflist.Tpo -c -o bjflist.o bjflist.c
bjfimage.c: In function ‘tiff_image_init’:
bjfimage.c:421:9: warning: ‘uint32’ is deprecated [-Wdeprecated-declarations]
  421 |         uint32                          width = 0;
      |         ^~~~~~
bjfimage.c:422:9: warning: ‘uint32’ is deprecated [-Wdeprecated-declarations]
  422 |         uint32                          length = 0;
      |         ^~~~~~
bjfimage.c:428:9: warning: ‘uint16’ is deprecated [-Wdeprecated-declarations]
  428 |         uint16                          config;
      |         ^~~~~~
bjfimage.c:429:9: warning: ‘uint16’ is deprecated [-Wdeprecated-declarations]
  429 |         uint16                          compress;
      |         ^~~~~~
mv -f .deps/bjferror.Tpo .deps/bjferror.Po
bjfoption.c: In function ‘SetCmdOption’:
bjfoption.c:543:47: error: passing argument 3 of ‘poptGetContext’ from incompatible pointer type [-Wincompatible-pointer-types]
  543 |         optcon = poptGetContext( NULL, cargc, cargv, optionsTable, 0 );
      |                                               ^~~~~
      |                                               |
      |                                               char **
In file included from bjfoption.c:29:
/usr/include/popt.h:217:41: note: expected ‘const char **’ but argument is of type ‘char **’
  217 |                 int argc, const char ** argv,
      |                           ~~~~~~~~~~~~~~^~~~
bjfimage.c: In function ‘ppm_write_tmpfile’:
bjfimage.c:1862:18: error: implicit declaration of function ‘write’; did you mean ‘fwrite’? [-Wimplicit-function-declaration]
 1862 |         w_size = write( fd , PPMRAWSTART , 2 );
      |                  ^~~~~
      |                  fwrite
bjfimage.c:1901:9: error: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration]
 1901 |         close( fd );
      |         ^~~~~
      |         pclose
bjfimage.c:1908:17: error: implicit declaration of function ‘unlink’ [-Wimplicit-function-declaration]
 1908 |                 unlink(outfile);
      |                 ^~~~~~
bjfilter.c: In function ‘main’:
bjfilter.c:163:78: error: implicit declaration of function ‘tolower’ [-Wimplicit-function-declaration]
  163 |         for( i=0; i<sizeof(small_modelname); i++ )      small_modelname[i] = tolower(tmp_modelname[i]);
      |                                                                              ^~~~~~~
bjfilter.c:55:1: note: include ‘<ctype.h>’ or provide a declaration of ‘tolower’
   54 | #include "bjfpath.h"
  +++ |+#include <ctype.h>
   55 | 
bjfilter.c: In function ‘MakeBJPrintData’:
bjfilter.c:386:25: error: implicit declaration of function ‘SetExtLevel’ [-Wimplicit-function-declaration]
  386 |                         SetExtLevel(&lpbjinfo->bjfmgninfo, lpbjinfo->bjfoption.extension);
      |                         ^~~~~~~~~~~
make[3]: *** [Makefile:393: bjfimage.o] Error 1
make[3]: *** Waiting for unfinished jobs....
bjfilter.c: In function ‘set_position_parameter’:
bjfilter.c:985:5: error: implicit declaration of function ‘bjf_margin_init’; did you mean ‘bjf_image_init’? [-Wimplicit-function-declaration]
  985 |     bjf_margin_init( &lpbjinfo->bjfmgninfo );
      |     ^~~~~~~~~~~~~~~
      |     bjf_image_init
make[3]: *** [Makefile:393: bjfoption.o] Error 1
mv -f .deps/getipc.Tpo .deps/getipc.Po
mv -f .deps/bjflist.Tpo .deps/bjflist.Po
make[3]: *** [Makefile:393: bjfilter.o] Error 1
mv -f .deps/bjfrcaccess.Tpo .deps/bjfrcaccess.Po
mv -f .deps/bjfpos.Tpo .deps/bjfpos.Po
make[3]: Leaving directory '/build/cnijfilter-mp640/src/cnijfilter-source-3.20-1/cnijfilter/src'
make[2]: *** [Makefile:362: all-recursive] Error 1
make[2]: Leaving directory '/build/cnijfilter-mp640/src/cnijfilter-source-3.20-1/cnijfilter'
make[1]: *** [Makefile:303: all] Error 2
make[1]: Leaving directory '/build/cnijfilter-mp640/src/cnijfilter-source-3.20-1/cnijfilter'
make: *** [Makefile:18: mp640] Error 1

I would let the AUR maintainer know.

Thanks Yochanan,

Indeed, I had already identified the missing header problem, but didn’t know how to deal with the checksum validation failure. Seems like it’s sufficient to run sha512sum on any modified build files, and paste the resultant checksum(s) into the PKGBUILD file. Sure enough, that gets it to build for me too.

Next, I need to build cnijfilter-mp640; that looks like it will need more comprehensive corrections, but I guess it should (eventually) yield to a similar patch-and-rebuild procedure.

I just edited my reply. Unfortunately, I’m not sure how to get cnijfilter-mp640 to build.

A possible alternative in AUR:

1 Like

That’s not really surprising … there’s a great deal more wrong than just that missing include.

I have managed to get it to build, and even to print a test page … in greyscale, when I expected colour :disappointed:

PKGBUILD.patch
diff --git a/PKGBUILD b/PKGBUILD
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -27,25 +27,28 @@ install=cnijfilter-mp640.install
 # File size: 6552576 bytes
 source=("http://gdlp01.c-wss.com/gds/7/0100002367/01/cnijfilter-source-3.20-1.tar.gz"
 	"id.patch"
 	"cups.patch"
 	"libpng15.patch"
-	"mychanges.patch")
+	"mychanges.patch"
+	"myextra.patch")
 sha512sums=('3e6e5f3ed43e4054938387298a6d116828a0928568b3a165622c5a61abe9e39a30bc6d99a336317be228a794f0a2645b8f5453939695879f209b1a061b7d9164'
             'b75cdbdadac5fb396458dc9f14529c5e39a4fa47f97cd6a21a69b0dbac73f1b8dd90780068f6a348fcfb15939d0866dde1a1cf1ff7faaf0c443d2205a242ccd5'
-            '747b17205a95197e8235959c691ee26b0c375ec8dae516416d16a9805c5b354c7019319d8be10c0c0230cfd8301ec5ddcd292bad245216d0a860cc2e6583c1fa'
+            'fd56d4e86de5a7d01dfe863cceb4bc9329ae45a372312348cdb51a01d839d8545964b675270cad72014c7aa895ca50439e22406c270d62f90114b57b8055a478'
             '0d8310867f45721150a870170172d3a0688bfba0267f627a630c105ff965d31f25dbcc31d3795874325bcb8eaeee395bf32b0648a743ff663dea6f977ab9070e'
-            'd4f98b8bb2413ebf07a325b48318a60be4e01794dbebf29788eabc6c68e98086826d3bc4651bba334cfd5af04966d01985801f7beed35ac65893d52eb8a7b246')
+            'd4f98b8bb2413ebf07a325b48318a60be4e01794dbebf29788eabc6c68e98086826d3bc4651bba334cfd5af04966d01985801f7beed35ac65893d52eb8a7b246'
+            'eda2068abdede5b698d4d7733d0b32324e7cad898777cb2dc0c8847e9c3e6d045e8cad0c5878bcb1185d15b97c17472010ca7de9e5264de46e84d0cbc9845825')
 
 prepare() {
   cd ${srcdir}/${_pkgname}-source-${pkgver}-${_pkgreview}
 
   patch -p1 -i ${srcdir}/id.patch
   patch -p1 -i ${srcdir}/cups.patch
   patch -p1 -i ${srcdir}/libpng15.patch
 
   patch -p1 -i ${srcdir}/mychanges.patch
+  patch -p1 -i ${srcdir}/myextra.patch
 }
 
 build() {
   cd ${srcdir}/${_pkgname}-source-${pkgver}-${_pkgreview}
 
myextra.patch
diff --git a/cngpijmon/src/bjcupsmon_ui.c b/cngpijmon/src/bjcupsmon_ui.c
--- a/cngpijmon/src/bjcupsmon_ui.c
+++ b/cngpijmon/src/bjcupsmon_ui.c
@@ -828,11 +828,11 @@ PUBLIC void updateUISettings(ST_PrinterS
 		if (pPrinterStatus != NULL) {
 			memset(tempBuf, 0, sizeof(tempBuf));
 			
 			if( pPrinterStatus->leverPosition != ID_LEVER_POSITION_INVALID 
 			  && pPrinterStatus->leverPosition != ID_LEVER_POSITION_NONE ) 
-				strncpy(tempBuf, dgettext(PACKAGE, ID_STS_MESSAGE_PAPERTHICKNESS_LEVERPOSITION), MAX_BUF_SIZE-1);
+				strncpy(tempBuf, dgettext(PACKAGE, gSTSMessageTable[ID_STS_MESSAGE_PAPERTHICKNESS_LEVERPOSITION]), MAX_BUF_SIZE-1);
 				//strncpy(tempBuf, dgettext(PACKAGE, N_("Paper Thickness Lever Position: ")), MAX_BUF_SIZE-1);
 			else
 				strncpy(tempBuf, "                                                ", MAX_BUF_SIZE-1);
 				//strncpy(tempBuf, dgettext(PACKAGE, "                                                "), MAX_BUF_SIZE-1);
 			switch (pPrinterStatus->leverPosition) {
@@ -845,16 +845,16 @@ PUBLIC void updateUISettings(ST_PrinterS
 					strcat(tempBuf, "Down");
 					//strcat(tempBuf, dgettext(PACKAGE, N_("Down")));
 					break;
 				
 				case ID_LEVER_POSITION_LEFT:	// Left.
-					strcat(tempBuf, dgettext(PACKAGE,ID_STS_MESSAGE_LEFT));
+					strcat(tempBuf, dgettext(PACKAGE, gSTSMessageTable[ID_STS_MESSAGE_LEFT]));
 					//strcat(tempBuf, dgettext(PACKAGE, N_("Left")));
 					break;
 				
 				case ID_LEVER_POSITION_RIGHT:	// Right.
-					strcat(tempBuf, dgettext(PACKAGE, ID_STS_MESSAGE_RIGHT));
+					strcat(tempBuf, dgettext(PACKAGE, gSTSMessageTable[ID_STS_MESSAGE_RIGHT]));
 					//strcat(tempBuf, dgettext(PACKAGE, N_("Right")));
 					break;
 				
 				default:
 					break;
diff --git a/cnijfilter/src/bjfilter.c b/cnijfilter/src/bjfilter.c
--- a/cnijfilter/src/bjfilter.c
+++ b/cnijfilter/src/bjfilter.c
@@ -21,10 +21,11 @@
  *    libraries released as the binary modules.
  *  - If you write modifications of your own for these programs, it is your
  *    choice whether to permit this exception to apply to your modifications.
  *    If you do not wish that, delete this exception.
 */
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <popt.h>
 #include <time.h>
@@ -55,10 +56,13 @@
 
 /* function prototypes */
 extern short GetIPCData(LPIPCU pipc, char *sname);
 extern short PsudoGetIPCData(LPIPCU pipc);
 
+extern void bjf_margin_init(LPBJF_MARGIN_INFO);
+extern short SetExtLevel(LPBJF_MARGIN_INFO, short);
+
 extern int ppm_write_tmpfile( LPBJF_IMAGEINFO lpbjfimage, char *filename , char *outfile);
 
 /* local function prototypes */
 static short h_extend( CPKByte CPKPTR, CPKByte CPKPTR, int, int, int );
 static void outCmd(CPKByte CPKPTR, CPKUInt32, int);
diff --git a/cnijfilter/src/bjfimage.c b/cnijfilter/src/bjfimage.c
--- a/cnijfilter/src/bjfimage.c
+++ b/cnijfilter/src/bjfimage.c
@@ -37,12 +37,13 @@
 ** Copyright (c) 1998-2001 Glenn Randers-Pehrson
 */
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 #include <png.h>
-#include <string.h>
 
 #include "cpktypes.h"
 #include "cncl.h"
 #include "cncldef.h"
 #include "bjfimage.h"
@@ -416,21 +417,21 @@ onErr:
 }
 
 static short tiff_image_init( LPBJF_IMAGEINFO lpbjfimage )
 {
 	TIFF				*tif = NULL;
-	uint32				width = 0;
-	uint32				length = 0;
-	unsigned short		bpp = 1;
-	unsigned short		photometric = PHOTOMETRIC_RGB;
+	uint32_t			width = 0;
+	uint32_t			length = 0;
+	unsigned short			bpp = 1;
+	unsigned short			photometric = PHOTOMETRIC_RGB;
 	float				x_resolution = 0;
 	float				y_resolution = 0;
 	short				outputtype;
-	uint16				config;
-	uint16				compress;
+	uint16_t			config;
+	uint16_t			compress;
 	short				result = -1;
-	static short		flg = 0;
+	static short			flg = 0;
 	short				resolution_unit = RESUNIT_INCH;
 
 	/*---
 		Tiff format do not support plural document.
 		At first this api call, return 1, after second call return 0.
diff --git a/cnijfilter/src/bjfoption.c b/cnijfilter/src/bjfoption.c
--- a/cnijfilter/src/bjfoption.c
+++ b/cnijfilter/src/bjfoption.c
@@ -24,12 +24,13 @@
  *    If you do not wish that, delete this exception.
 */
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
 #include <popt.h>
-#include <string.h>
 
 #include "cncl.h"
 #include "cncldef.h"
 #include "cncl2def.h"
 #include "cnclucom.h"
@@ -537,11 +538,11 @@ short SetCmdOption(
 
 
 	/*--- Analyze command line ---*/
 	init_optioninfo( lpbjfoption );
 	
-	optcon = poptGetContext( NULL, cargc, cargv, optionsTable, 0 );
+	optcon = poptGetContext( NULL, cargc, (const char **)(cargv), optionsTable, 0 );
 	
 	memset(confname , 0x00 , sizeof(confname));
 	MakeModelnameConfname( cargv[0], modelname, confname, BJFILTERXXXXRCPATH, BJFILTERDOTCONF );
 	first_modelstrnum = strlen(modelname);
 
diff --git a/printui/src/colordlg2.c b/printui/src/colordlg2.c
--- a/printui/src/colordlg2.c
+++ b/printui/src/colordlg2.c
@@ -148,11 +148,11 @@ static short SetGammaCombo(UIColorDialog
 
 	return gamma;
 }
 
 /* Ver.2.90 */
-static short CofirmSpinValue( spinbutton )
+static short CofirmSpinValue( GtkSpinButton *spinbutton )
 {
 	short	result = 0;
 
 	if( !strncmp( gtk_entry_get_text( GTK_ENTRY( spinbutton ) ), "-0" , 2 ) )
 	{
diff --git a/printui/src/uimain.c b/printui/src/uimain.c
--- a/printui/src/uimain.c
+++ b/printui/src/uimain.c
@@ -228,11 +228,11 @@ void ShowUtilButtons(UIMainDialog* main_
 		ShowUtilButton(main_window, "util_paper_source_setting_button");
 	}
 }
 
 static
-void ShowPaperGapCombo(main_window)
+void ShowPaperGapCombo(UIMainDialog* main_window)
 {
 	int show_lever_box = FALSE;
 
 	/* Ver.2.80: Set "lever_label" string according to model_name. */
 	GtkWidget* label = LookupWidget( UI_DIALOG(main_window)->window, "lever_label");

In addition to the new patches, which I’ve added in “myextra.patch”, I also corrected an error which appeared to have been introduced by the existing “cups.patch”:

cups.patch.correction
diff --git a/cups.patch b/cups.patch
--- a/cups.patch
+++ b/cups.patch
@@ -208,11 +208,11 @@ diff -aur cnijfilter-source-3.20-1/cngpi
 +        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)) {
++                                      while (pAttribute != NULL && ippGetGroupTag(pAttribute) != IPP_TAG_PRINTER) {
 +            pAttribute = ippNextAttribute(pResponse);
                                        }
                                        if (pAttribute == NULL) {
                                                break;
                                        }

I will be doing so. As noted above, I’m not convinced that I’ve identified a final solution, because before my installation failed, the printer was working in colour, (including the printing of the test page), whereas the test page now prints only in greyscale. I did have a similar issue previously, following a pamac update in which a printer option had been changed from colour to greyscale; I was able to change that through the old XFCE printer management applet, but the clean reinstallation now directs printer management to the CUPS interface, and I can’t see a similar option setting there.

Thanks. I may try that, if I cannot resolve the colour printing issue, with the cnijfilter-mp640 implementation.