2023-05-08  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* include/lcms2.h [DJGPP]: For DJGPP define CMS_IS_DJGPP_.
	[CMS_IS_DJGPP_] : For DJGPP use 260 instead of 256 as default for
	cmsMAX_PATH.
	[DJGPP]: For DJGPP define CMS_NO_PTHREADS.

	* src/cmscgats.c [CMS_IS_DJGPP_]: For DJGPP define DIR_CHAR_ALT as
	backslash for alternate directory separator character.
	(isabsolutepath) [CMS_IS_DJGPP_]: For DJGPP check for absolute path
	allowing both slash and backslash characters.
	(BuildAbsolutePath) [CMS_IS_DJGPP_]: For DJGPP check for absolute path
	allowing both slash and backslash charcters.

	* src/cmspcs.c (_cmsLCMScolorSpace):  Use int instead as cmsColorSpaceSignature
	as return type.

	* utils/transicc/transicc.c [DJGPP]: For DJGPP include unistd.h for
	isatty prototype.






diff -aprNU5 lcms2-2.15.orig/include/lcms2.h lcms2-2.15/include/lcms2.h
--- lcms2-2.15.orig/include/lcms2.h	2023-02-28 18:53:10 +0000
+++ lcms2-2.15/include/lcms2.h	2023-05-08 23:07:26 +0000
@@ -28,12 +28,14 @@
 
 #ifndef _lcms2_H
 
 // ********** Configuration toggles ****************************************
 
-// Uncomment this one if you are using big endian machines
-// #define CMS_USE_BIG_ENDIAN   1
+#include <machine/endian.h>
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define USE_BIG_ENDIAN   1
+#endif
 
 // Uncomment this one if your compiler/machine does NOT support the
 // "long long" type.
 // #define CMS_DONT_USE_INT64        1
 
@@ -54,11 +56,13 @@
 
 // Uncomment to get rid of the tables for "half" float support
 // #define CMS_NO_HALF_SUPPORT 1
 
 // Uncomment to get rid of pthreads/windows dependency
-// #define CMS_NO_PTHREADS  1
+#if defined(__DJGPP__)
+#define CMS_NO_PTHREADS  1
+#endif
 
 // Uncomment this for special windows mutex initialization (see lcms2_internal.h)
 // #define CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
 
 // Uncomment this to remove the "register" storage class
@@ -171,10 +175,15 @@ typedef cmsInt32Number       cmsS15Fixed
 typedef cmsUInt32Number      cmsU16Fixed16Number;
 
 // Boolean type, which will be using the native integer
 typedef int                  cmsBool;
 
+// Try to detect DJGPP
+#if defined (DJGPP) || defined(__DJGPP__)
+#  define CMS_IS_DJGPP_ 1
+#endif
+
 // Try to detect windows
 #if defined (_WIN32) || defined(_WIN64) || defined(WIN32) || defined(_WIN32_)
 #  define CMS_IS_WINDOWS_ 1
 #endif
 
@@ -261,11 +270,15 @@ typedef int                  cmsBool;
 #    define CMS_NO_PTHREADS 1
 # endif
 #endif
 
 // Some common definitions
-#define cmsMAX_PATH     256
+#ifdef CMS_IS_DJGPP_
+# define cmsMAX_PATH     260  /*  Max value from pathconf.  */
+#else
+# define cmsMAX_PATH     256
+#endif
 
 #ifndef FALSE
 #       define FALSE 0
 #endif
 #ifndef TRUE
diff -aprNU5 lcms2-2.15.orig/src/cmscgats.c lcms2-2.15/src/cmscgats.c
--- lcms2-2.15.orig/src/cmscgats.c	2023-02-28 18:53:12 +0000
+++ lcms2-2.15/src/cmscgats.c	2023-05-08 23:11:44 +0000
@@ -39,11 +39,14 @@
 
 #ifdef CMS_IS_WINDOWS_
 #    include <io.h>
 #    define DIR_CHAR    '\\'
 #else
-#    define DIR_CHAR    '/'
+#    define DIR_CHAR            '/'
+#    ifdef CMS_IS_DJGPP_
+#        define DIR_CHAR_ALT    '\\'
+#    endif
 #endif
 
 
 // Symbols
 typedef enum {
@@ -462,14 +465,18 @@ cmsBool isabsolutepath(const char *path)
         return FALSE;
 
     strncpy(ThreeChars, path, 3);
     ThreeChars[3] = 0;
 
-    if(ThreeChars[0] == DIR_CHAR)
+#ifdef CMS_IS_DJGPP_
+    if(ThreeChars[0] == DIR_CHAR || ThreeChars[0] == DIR_CHAR_ALT)
+#else
+     if(ThreeChars[0] == DIR_CHAR)
+#endif
         return TRUE;
 
-#ifdef  CMS_IS_WINDOWS_
+#if defined( CMS_IS_DJGPP_) || defined( CMS_IS_WINDOWS_)
     if (isalpha((int) ThreeChars[0]) && ThreeChars[1] == ':')
         return TRUE;
 #endif
     return FALSE;
 }
@@ -493,11 +500,18 @@ cmsBool BuildAbsolutePath(const char *re
 
     // No, search for last
     strncpy(buffer, basePath, MaxLen);
     buffer[MaxLen-1] = 0;
 
+#ifdef CMS_IS_DJGPP_
+    for (len = MaxLen; len;)
+      if (len--, buffer[len] == DIR_CHAR || buffer[len] == DIR_CHAR_ALT)
+        break;
+    tail = len ? buffer + len : NULL;
+#else
     tail = strrchr(buffer, DIR_CHAR);
+#endif
     if (tail == NULL) return FALSE;    // Is not absolute and has no separators??
 
     len = (cmsUInt32Number) (tail - buffer);
     if (len >= MaxLen) return FALSE;
 
diff -aprNU5 lcms2-2.15.orig/src/cmspcs.c lcms2-2.15/src/cmspcs.c
--- lcms2-2.15.orig/src/cmspcs.c	2023-02-28 18:53:12 +0000
+++ lcms2-2.15/src/cmspcs.c	2023-05-08 23:13:00 +0000
@@ -867,11 +867,11 @@ int CMSEXPORT _cmsLCMScolorSpace(cmsColo
     case cmsSig14colorData:return PT_MCH14;
 
     case cmsSigMCHFData:
     case cmsSig15colorData:return PT_MCH15;
 
-    default:  return (cmsColorSpaceSignature) 0;
+    default:  return (int)(cmsColorSpaceSignature) 0;
     }
 }
 
 
 cmsInt32Number CMSEXPORT cmsChannelsOfColorSpace(cmsColorSpaceSignature ColorSpace)
@@ -945,6 +945,6 @@ cmsInt32Number CMSEXPORT cmsChannelsOfCo
 cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace)
 {
     int n = cmsChannelsOfColorSpace(ColorSpace);
     if (n < 0) return 3;
     return (cmsUInt32Number)n;
-}
\ No newline at end of file
+}
diff -aprNU5 lcms2-2.15.orig/utils/transicc/transicc.c lcms2-2.15/utils/transicc/transicc.c
--- lcms2-2.15.orig/utils/transicc/transicc.c	2023-02-28 18:53:12 +0000
+++ lcms2-2.15/utils/transicc/transicc.c	2023-05-08 23:14:10 +0000
@@ -28,10 +28,14 @@
 
 #ifndef _MSC_VER 
 #    include <unistd.h> 
 #endif 
 
+#ifdef CMS_IS_DJGPP_
+#    include <unistd.h>
+#endif
+
 #ifdef CMS_IS_WINDOWS_
 #    include <io.h>
 #endif
 
 #define MAX_INPUT_BUFFER 4096
