--- a/simgear/nasal/naref.h	2010-03-04 03:21:35.000000000 +0000
+++ b/simgear/nasal/naref.h	2010-03-04 04:22:46.000000000 +0000
@@ -1,6 +1,8 @@
 #ifndef _NAREF_H
 #define _NAREF_H
 
+#include <stdlib.h>
+
 /* Rather than play elaborate and complicated games with
  * platform-dependent endianness headers, just detect the platforms we
  * support.  This list is simpler and smaller, yet still quite
@@ -10,14 +12,13 @@
 /* Win64 and Irix should work with this too, but have not been
  * tested */
 # define NASAL_NAN64
-#elif defined(_M_IX86) || defined(i386) || defined(__x86_64) || \
-      defined(__ia64__) || defined(_M_IA64) || defined(__ARMEL__) || \
-      defined(__alpha__)
-# define NASAL_LE
-#elif defined(__sparc) || defined(__ppc__) || defined(__PPC) || \
-      defined(__mips) || defined(__ARMEB__) || \
-      defined(__hppa__) || defined(__s390__) || defined(__s390x__)
-# define NASAL_BE
+#elif defined(__GLIBC__)
+  #include <endian.h>
+  #if (__BYTE_ORDER == __LITTLE_ENDIAN)
+    #define NASAL_LE
+  #elif (__BYTE_ORDER == __BIG_ENDIAN)
+    #define NASAL_BE
+  #endif
 #else
 # error Unrecognized CPU architecture
 #endif
