#!/bin/sh # many parts of this blatantly ripped from GNU Autoconf macros # Use this for cross-compiling, as we can't run cross-compiled binaries # on our host. if test -z "$O" || ! cd "$O"; then echo '$O= not defined or not a directory' >&2 exit 1 fi echo '/* architecture-specific settings (auto-detected): */' # check sizes of various types we care for # this is slightly slower but much easier to read and follow than the # bisecting autoconf version for t in short int long 'long long'; do > out for s in 2 4 6 8 12 1 16 24 32 0; do cat > t.c <> out $CC -o t.o $CFLAGS $CPPFLAGS t.c \ >> out 2>&1 && break done if test $s -eq 0; then echo "Unable to calculate sizeof($t) for cross-compiling" >&2 cat out >&2 exit 1 fi t=`echo $t | tr a-z A-Z | tr ' ' _` echo "#define SIZEOF_$t $s" echo "SIZEOF_$t := $s" >> config_detected.mk done # check endian-ness cat > t.c < out $CC -o t.o $CFLAGS $CPPFLAGS t.c >> out 2>&1 if grep BIGenDianSyS t.o >/dev/null 2>&1; then echo "#define WORDS_BIGENDIAN 1" echo "WORDS_BIGENDIAN := 1" >> config_detected.mk elif grep LiTTleEnDian t.o >/dev/null 2>&1; then echo "/* #undef WORDS_BIGENDIAN */" echo "# WORDS_BIGENDIAN :=" >> config_detected.mk else echo "Unable to determine endian-ness for cross compiling" >&2 cat out >&2 exit 1 fi echo '' exec rm -f t.o out t.c