]> git.notmuchmail.org Git - notmuch/blobdiff - configure
util: detect byte order
[notmuch] / configure
index 1a8e939f8ad6d5e09651e9153579ef7d661a586e..13b60620fe3cebdd0cc00cee4a4bc088260ef720 100755 (executable)
--- a/configure
+++ b/configure
@@ -441,6 +441,19 @@ else
 EOF
 fi
 
+printf "Checking byte order... "
+cat> _byteorder.c <<EOF
+#include <stdio.h>
+#include <stdint.h>
+uint32_t test = 0x34333231;
+int main() { printf("%.4s\n", (const char*)&test); return 0; }
+EOF
+${CC} ${CFLAGS} _byteorder.c -o _byteorder > /dev/null 2>&1
+util_byte_order=$(./_byteorder)
+echo $util_byte_order
+
+rm -f _byteorder _byteorder.c
+
 if [ $errors -gt 0 ]; then
     cat <<EOF
 
@@ -702,6 +715,9 @@ prefix = ${PREFIX}
 # LIBDIR_IN_LDCONFIG value below is still set correctly.
 libdir = ${LIBDIR:=\$(prefix)/lib}
 
+# byte order within a 32 bit word. 1234 = little, 4321 = big, 0 = guess
+UTIL_BYTE_ORDER = ${util_byte_order}
+
 # Whether libdir is in a path configured into ldconfig
 LIBDIR_IN_LDCONFIG = ${libdir_in_ldconfig}
 
@@ -807,7 +823,9 @@ CONFIGURE_CFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)      \\
                   -DHAVE_STRSEP=\$(HAVE_STRSEP)                         \\
                   -DSTD_GETPWUID=\$(STD_GETPWUID)                       \\
                   -DSTD_ASCTIME=\$(STD_ASCTIME)                         \\
-                  -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)
+                  -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)         \\
+                  -DUTIL_BYTE_ORDER=\$(UTIL_BYTE_ORDER)
+
 CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\
                     \$(TALLOC_CFLAGS) -DHAVE_VALGRIND=\$(HAVE_VALGRIND) \\
                     \$(VALGRIND_CFLAGS) \$(XAPIAN_CXXFLAGS)             \\
@@ -815,6 +833,8 @@ CONFIGURE_CXXFLAGS = -DHAVE_GETLINE=\$(HAVE_GETLINE) \$(GMIME_CFLAGS)    \\
                     -DHAVE_STRSEP=\$(HAVE_STRSEP)                       \\
                     -DSTD_GETPWUID=\$(STD_GETPWUID)                     \\
                     -DSTD_ASCTIME=\$(STD_ASCTIME)                       \\
-                    -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)
+                    -DHAVE_XAPIAN_COMPACT=\$(HAVE_XAPIAN_COMPACT)       \\
+                    -DUTIL_BYTE_ORDER=\$(UTIL_BYTE_ORDER)
+
 CONFIGURE_LDFLAGS =  \$(GMIME_LDFLAGS) \$(TALLOC_LDFLAGS) \$(XAPIAN_LDFLAGS)
 EOF