9256ae
commit b32dcedd13b3fc2ea7a8099cc0f67eaa31b8c298
9256ae
Author: Chris Liddell <chris.liddell@artifex.com>
9256ae
Date:   Thu May 21 09:06:01 2015 +0100
9256ae
9256ae
    Simplify/Improve endian decisions in lcms2.h
9256ae
    
9256ae
    Firstly, protect the endian decisions in lcms2.h so that settings given on the
9256ae
    compiler command line are not silently overridden. Thus being set explicitly
9256ae
    gets the highest priority.
9256ae
    
9256ae
    Secondly, use the endianness detected by the configure script, and remove the
9256ae
    complex and error prone stuff for PPC platforms from lcms2.h. Thus the endianess
9256ae
    from configure gets second highest priority.
9256ae
    
9256ae
    Thirdly, if neither of the above are set, fall back to some simple (and long
9256ae
    standing) platform/compiler specific tests. These should rarely, if ever, come
9256ae
    into play in a "normal" build for a "normal" Unix-like system.
9256ae
9256ae
diff --git a/include/lcms2.h b/include/lcms2.h
9256ae
index a0421d8..f32beec 100644
9256ae
--- a/include/lcms2.h
9256ae
+++ b/include/lcms2.h
9256ae
@@ -173,46 +173,43 @@
9256ae
 #  define CMS_IS_WINDOWS_ 1
9256ae
 #endif
9256ae
 
9256ae
-// Try to detect big endian platforms. This list can be endless, so only some checks are performed over here.
9256ae
-// you can pass this toggle to the compiler by using -DCMS_USE_BIG_ENDIAN or something similar
9256ae
-
9256ae
-#if defined(__sgi__) || defined(__sgi) || defined(sparc)
9256ae
-#   define CMS_USE_BIG_ENDIAN      1
9256ae
-#endif
9256ae
+// Try to detect big endian platforms. This list can be endless, so primarily rely on the configure script
9256ae
+// on Unix-like systems, and allow it to be set on the compiler command line using
9256ae
+// -DCMS_USE_BIG_ENDIAN or something similar
9256ae
+#ifdef CMS_USE_BIG_ENDIAN // set at compiler command line takes overall precedence
9256ae
+#  if CMS_USE_BIG_ENDIAN == 0
9256ae
+#    undef CMS_USE_BIG_ENDIAN
9256ae
+#  endif
9256ae
+#else // CMS_USE_BIG_ENDIAN
9256ae
 
9256ae
-#if defined(__s390__) || defined(__s390x__)
9256ae
-#   define CMS_USE_BIG_ENDIAN   1
9256ae
-#endif
9256ae
+#  ifdef WORDS_BIGENDIAN // set by configure (or explicitly on compiler command line)
9256ae
+#    define CMS_USE_BIG_ENDIAN 1
9256ae
+#  else // WORDS_BIGENDIAN
9256ae
+// Fall back to platform/compiler specific tests
9256ae
+#    if defined(__sgi__) || defined(__sgi) || defined(sparc)
9256ae
+#      define CMS_USE_BIG_ENDIAN      1
9256ae
+#    endif
9256ae
 
9256ae
-#  ifdef TARGET_CPU_PPC
9256ae
-#    if TARGET_CPU_PPC
9256ae
+#    if defined(__s390__) || defined(__s390x__)
9256ae
 #      define CMS_USE_BIG_ENDIAN   1
9256ae
 #    endif
9256ae
-#  endif
9256ae
 
9256ae
-#if defined(__powerpc__) || defined(__ppc__) || defined(TARGET_CPU_PPC)
9256ae
-#   define CMS_USE_BIG_ENDIAN   1
9256ae
-#   if defined (__GNUC__) && defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN)
9256ae
-#       if __BYTE_ORDER  == __LITTLE_ENDIAN
9256ae
-//               // Don't use big endian for PowerPC little endian mode
9256ae
-#                undef CMS_USE_BIG_ENDIAN
9256ae
-#       endif
9256ae
-#   endif
9256ae
-#endif
9256ae
+#    ifdef macintosh
9256ae
+#      ifdef __BIG_ENDIAN__
9256ae
+#        define CMS_USE_BIG_ENDIAN      1
9256ae
+#      endif
9256ae
+#      ifdef __LITTLE_ENDIAN__
9256ae
+#        undef CMS_USE_BIG_ENDIAN
9256ae
+#      endif
9256ae
+#    endif
9256ae
+#  endif  // WORDS_BIGENDIAN
9256ae
 
9256ae
-// WORDS_BIGENDIAN takes precedence
9256ae
-#if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(WORDS_BIGENDIAN)
9256ae
-#   define CMS_USE_BIG_ENDIAN      1
9256ae
-#endif
9256ae
+#  if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__)
9256ae
+#    define CMS_USE_BIG_ENDIAN      1
9256ae
+#  endif
9256ae
+
9256ae
+#endif  // CMS_USE_BIG_ENDIAN
9256ae
 
9256ae
-#ifdef macintosh
9256ae
-# ifdef __BIG_ENDIAN__
9256ae
-#   define CMS_USE_BIG_ENDIAN      1
9256ae
-# endif
9256ae
-# ifdef __LITTLE_ENDIAN__
9256ae
-#   undef CMS_USE_BIG_ENDIAN
9256ae
-# endif
9256ae
-#endif
9256ae
 
9256ae
 // Calling convention -- this is hardly platform and compiler dependent
9256ae
 #ifdef CMS_IS_WINDOWS_