Fix build with JasPer 2.0.17+.
https://github.com/DentonW/DevIL/issues/90
https://github.com/DentonW/DevIL/issues/94
https://github.com/DentonW/DevIL/pull/91
https://sourceforge.net/p/openil/patches/54/

Fix build with JasPer 3+.
https://github.com/DentonW/DevIL/issues/99
https://github.com/DentonW/DevIL/issues/101
https://github.com/DentonW/DevIL/pull/102
--- src-IL/src/il_jp2.cpp.orig	2017-01-01 18:03:56.000000000 -0600
+++ src-IL/src/il_jp2.cpp	2024-05-05 20:50:24.000000000 -0500
@@ -314,13 +314,36 @@
 
 
 
+// Hack to compile against different versions of Jasper which expect
+// slightly different function types for their callbacks.  The defined()
+// checks are just looking for sybols that happen to have arrived around
+// the same time as the API change, so no reason they won't break in the
+// future :-(  Hopefully by the time it does nobody will care about pre-2.0.20
+// versions of jasper
+//
+// see: https://github.com/OSGeo/gdal/commit/9ef8e16e27c5fc4c491debe50bf2b7f3e94ed334
+//      https://github.com/DentonW/DevIL/issues/90
+#if JAS_VERSION_MAJOR >= 3
+static ssize_t iJp2_file_read(jas_stream_obj_t *obj, char *buf, size_t cnt)
+#elif defined(PRIjas_seqent)
+static int iJp2_file_read(jas_stream_obj_t *obj, char *buf, unsigned cnt)
+#else
 static int iJp2_file_read(jas_stream_obj_t *obj, char *buf, int cnt)
+#endif
 {
 	obj;
 	return iread(buf, 1, cnt);
 }
 
+#if JAS_VERSION_MAJOR >= 3
+static ssize_t iJp2_file_write(jas_stream_obj_t *obj, const char *buf, size_t cnt)
+#elif defined(JAS_INCLUDE_JP2_CODEC)
+static int iJp2_file_write(jas_stream_obj_t *obj, const char *buf, unsigned cnt)
+#elif defined(PRIjas_seqent)
+static int iJp2_file_write(jas_stream_obj_t *obj, char *buf, unsigned cnt)
+#else
 static int iJp2_file_write(jas_stream_obj_t *obj, char *buf, int cnt)
+#endif
 {
 	obj;
 	return iwrite(buf, 1, cnt);
