From: Aaron Carroll Date: Thu, 14 Mar 2013 05:57:40 +0000 (+1100) Subject: configure: endianness check for cross compile X-Git-Tag: fio-2.0.15~27 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=1a17cfdb5e261459920212531d8f5e0eedfb267b;ds=inline configure: endianness check for cross compile - Add a cross compile check: assume yes if we can't run a test binary - If cross compiling, revert to a compile-time endianess check. This tries a few possible ways to detect big endian, but otherwise assumes little. We rely on the run-time check to save us if the build-time check is wrong. Signed-off-by: Aaron Carroll Signed-off-by: Jens Axboe --- diff --git a/configure b/configure index 84c6af28..965623d7 100755 --- a/configure +++ b/configure @@ -322,10 +322,27 @@ fi cc="${CC-${cross_prefix}gcc}" +########################################## +# check cross compile + +cross_compile="no" +cat > $TMPC </dev/null || cross_compile="yes" +else + fatal "compile test failed" +fi + ########################################## # check endianness bigendian="no" -cat > $TMPC < $TMPC < int main(void) { @@ -333,8 +350,24 @@ int main(void) return (*((uint8_t*)(&i))) == 0x67; } EOF -if compile_prog "" "" "endian"; then - $TMPE && bigendian="yes" + if compile_prog "" "" "endian"; then + $TMPE && bigendian="yes" + fi +else + # If we're cross compiling, try our best to work it out and rely on the + # run-time check to fail if we get it wrong. + cat > $TMPC < +int main(void) +{ +#if __BYTE_ORDER != __BIG_ENDIAN +# error "Unknown endianness" +#endif +} +EOF + compile_prog "" "" "endian" && bigendian="yes" + check_define "__ARMEB__" && bigendian="yes" + check_define "__MIPSEB__" && bigendian="yes" fi @@ -342,6 +375,7 @@ echo "Operating system $targetos" echo "CPU $cpu" echo "Big endian $bigendian" echo "Compiler $cc" +echo "Cross compile $cross_compile" echo ##########################################