--- setup.py
+++ setup.py
@@ -42,7 +42,6 @@
 from distutils.command.build import build
 from distutils.command.build_ext import build_ext
 import os, sys, re
-import struct
 
 if sys.version[0:1] == '1':
     raise RuntimeError ("The Python Cryptography Toolkit requires "
@@ -100,10 +99,10 @@
         w(kwd.get("end", "\n"))
 
 def endianness_macro():
-    s = struct.pack("@I", 0x33221100)
-    if s == "\x00\x11\x22\x33".encode():     # little endian
+    s = os.getenv('TARGET_ARCH_BE', '')
+    if s == "":   # little endian
         return ('PCT_LITTLE_ENDIAN', 1)
-    elif s == "\x33\x22\x11\x00".encode():   # big endian
+    elif s == "y":   # big endian
         return ('PCT_BIG_ENDIAN', 1)
     raise AssertionError("Machine is neither little-endian nor big-endian")
 
