From 8a4dff14ad7560aae83e9155d0c62ba7f8c101fd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 1 Jun 2008 22:24:55 +0000 Subject: Add the bs build system from mpd-ke Dealing with autotools is too painful when having to deal with multiple build environments and configurations. git-svn-id: https://svn.musicpd.org/mpd/trunk@7368 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- bs/cross-arch.sh | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 bs/cross-arch.sh (limited to 'bs/cross-arch.sh') diff --git a/bs/cross-arch.sh b/bs/cross-arch.sh new file mode 100755 index 000000000..c520433a5 --- /dev/null +++ b/bs/cross-arch.sh @@ -0,0 +1,82 @@ +#!/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 -- cgit v1.2.3