commit b32dcedd13b3fc2ea7a8099cc0f67eaa31b8c298
Author: Chris Liddell <chris.liddell@artifex.com>
Date:   Thu May 21 09:06:01 2015 +0100

    Simplify/Improve endian decisions in lcms2.h
    
    Firstly, protect the endian decisions in lcms2.h so that settings given on the
    compiler command line are not silently overridden. Thus being set explicitly
    gets the highest priority.
    
    Secondly, use the endianness detected by the configure script, and remove the
    complex and error prone stuff for PPC platforms from lcms2.h. Thus the endianess
    from configure gets second highest priority.
    
    Thirdly, if neither of the above are set, fall back to some simple (and long
    standing) platform/compiler specific tests. These should rarely, if ever, come
    into play in a "normal" build for a "normal" Unix-like system.

diff --git a/include/lcms2.h b/include/lcms2.h
index a0421d8..f32beec 100644
--- a/include/lcms2.h
+++ b/include/lcms2.h
@@ -173,46 +173,43 @@
 #  define CMS_IS_WINDOWS_ 1
 #endif
 
-// Try to detect big endian platforms. This list can be endless, so only some checks are performed over here.
-// you can pass this toggle to the compiler by using -DCMS_USE_BIG_ENDIAN or something similar
-
-#if defined(__sgi__) || defined(__sgi) || defined(sparc)
-#   define CMS_USE_BIG_ENDIAN      1
-#endif
+// Try to detect big endian platforms. This list can be endless, so primarily rely on the configure script
+// on Unix-like systems, and allow it to be set on the compiler command line using
+// -DCMS_USE_BIG_ENDIAN or something similar
+#ifdef CMS_USE_BIG_ENDIAN // set at compiler command line takes overall precedence
+#  if CMS_USE_BIG_ENDIAN == 0
+#    undef CMS_USE_BIG_ENDIAN
+#  endif
+#else // CMS_USE_BIG_ENDIAN
 
-#if defined(__s390__) || defined(__s390x__)
-#   define CMS_USE_BIG_ENDIAN   1
-#endif
+#  ifdef WORDS_BIGENDIAN // set by configure (or explicitly on compiler command line)
+#    define CMS_USE_BIG_ENDIAN 1
+#  else // WORDS_BIGENDIAN
+// Fall back to platform/compiler specific tests
+#    if defined(__sgi__) || defined(__sgi) || defined(sparc)
+#      define CMS_USE_BIG_ENDIAN      1
+#    endif
 
-#  ifdef TARGET_CPU_PPC
-#    if TARGET_CPU_PPC
+#    if defined(__s390__) || defined(__s390x__)
 #      define CMS_USE_BIG_ENDIAN   1
 #    endif
-#  endif
 
-#if defined(__powerpc__) || defined(__ppc__) || defined(TARGET_CPU_PPC)
-#   define CMS_USE_BIG_ENDIAN   1
-#   if defined (__GNUC__) && defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN)
-#       if __BYTE_ORDER  == __LITTLE_ENDIAN
-//               // Don't use big endian for PowerPC little endian mode
-#                undef CMS_USE_BIG_ENDIAN
-#       endif
-#   endif
-#endif
+#    ifdef macintosh
+#      ifdef __BIG_ENDIAN__
+#        define CMS_USE_BIG_ENDIAN      1
+#      endif
+#      ifdef __LITTLE_ENDIAN__
+#        undef CMS_USE_BIG_ENDIAN
+#      endif
+#    endif
+#  endif  // WORDS_BIGENDIAN
 
-// WORDS_BIGENDIAN takes precedence
-#if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(WORDS_BIGENDIAN)
-#   define CMS_USE_BIG_ENDIAN      1
-#endif
+#  if defined(_HOST_BIG_ENDIAN) || defined(__BIG_ENDIAN__)
+#    define CMS_USE_BIG_ENDIAN      1
+#  endif
+
+#endif  // CMS_USE_BIG_ENDIAN
 
-#ifdef macintosh
-# ifdef __BIG_ENDIAN__
-#   define CMS_USE_BIG_ENDIAN      1
-# endif
-# ifdef __LITTLE_ENDIAN__
-#   undef CMS_USE_BIG_ENDIAN
-# endif
-#endif
 
 // Calling convention -- this is hardly platform and compiler dependent
 #ifdef CMS_IS_WINDOWS_
