diff --git a/m4/sah_select_bitness.m4 b/m4/sah_select_bitness.m4 index 57be329ce5..3f80dfacde 100644 --- a/m4/sah_select_bitness.m4 +++ b/m4/sah_select_bitness.m4 @@ -7,15 +7,17 @@ AC_DEFUN([SAH_DEFAULT_BITNESS],[ ${CC} ${CFLAGS} ${CPPFLAGS} -fno-lto -c conftest.$ac_ext 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD COMPILER_MODEL_BITS=32 if test -f conftest.${OBJEXT}; then - if test -n "$(${OBJDUMP} --file-headers conftest.${OBJEXT} | grep 'file format' | grep 64)" -o -n "$(file conftest.${OBJEXT} | grep -i 64-bit)"; then + OBJDUMP_TEST="$(${OBJDUMP} --file-headers conftest.${OBJEXT} | grep 'file format')" + FILE_TEST="$(file conftest.${OBJEXT})" + if test -n "$(echo $OBJDUMP_TEST | grep 64)" -o -n "$(echo $FILE_TEST | grep -i 64-bit)"; then COMPILER_MODEL_BITS=64 #else - #if test -n "$(${OBJDUMP} --file-headers conftest.${OBJEXT} | grep 'file format' | grep 16)"; then + #if test -n "$(echo $OBJDUMP_TEST | grep 16)"; then #COMPILER_MODEL_BITS=16 #fi fi fi - /bin/rm conftest.$ac_ext conftest.${OBJEXT} + /bin/rm -f conftest.$ac_ext conftest.${OBJEXT} AC_MSG_RESULT([$COMPILER_MODEL_BITS]) AC_LANG_POP([C]) @@ -25,13 +27,20 @@ AC_DEFUN([SAH_DEFAULT_BITNESS],[ AC_REQUIRE_CPP ${CXX} ${CXXFLAGS} ${CPPFLAGS} -fno-lto -c conftest.$ac_ext 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD if test -f conftest.${OBJEXT}; then - if test -n "$(${OBJDUMP} --file-headers conftest.${OBJEXT} | grep 'file format' | grep 64)" -o -n "$(file conftest.${OBJEXT} | grep -i 64-bit)"; then + OBJDUMP_TEST="$(${OBJDUMP} --file-headers conftest.${OBJEXT} | grep 'file format')" + FILE_TEST="$(file conftest.${OBJEXT})" + if test -n "$(echo $OBJDUMP_TEST | grep 32)" -o -n "$(echo $FILE_TEST | grep -i 32-bit)"; then + if test "${COMPILER_MODEL_BITS}" != "32"; then + AC_MSG_ERROR([32 but not same as bitness in C]) + fi + fi + if test -n "$(echo $OBJDUMP_TEST | grep 64)" -o -n "$(echo $FILE_TEST | grep -i 64-bit)"; then if test "${COMPILER_MODEL_BITS}" != "64"; then AC_MSG_ERROR([64 but not same as bitness in C]) fi fi fi - /bin/rm conftest.$ac_ext conftest.${OBJEXT} + /bin/rm -f conftest.$ac_ext conftest.${OBJEXT} AC_MSG_RESULT([$COMPILER_MODEL_BITS]) AC_LANG_POP([C++]) fi @@ -47,14 +56,15 @@ AC_DEFUN([SAH_SELECT_BITNESS],[ AC_REQUIRE_CPP ${CC} ${CFLAGS} ${CPPFLAGS} -m$1 -fno-lto -c conftest.$ac_ext 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD if test -f conftest.${OBJEXT}; then - if test -n "$(file conftest.${OBJEXT} | grep -i $1-bit)"; then + FILE_TEST="$(file conftest.${OBJEXT})" + if test -n "$(echo $FILE_TEST | grep -i $1-bit)"; then CFLAGS="${CFLAGS} -m$1" AC_MSG_RESULT([ok use $1]) else AC_MSG_ERROR([failed still $COMPILER_MODEL_BITS]) fi fi - /bin/rm conftest.$ac_ext conftest.${OBJEXT} + /bin/rm -f conftest.$ac_ext conftest.${OBJEXT} else AC_MSG_RESULT([ok use $1]) fi @@ -67,14 +77,15 @@ AC_DEFUN([SAH_SELECT_BITNESS],[ AC_REQUIRE_CPP ${CXX} ${CXXFLAGS} ${CPPFLAGS} -m$1 -fno-lto -c conftest.$ac_ext 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD if test -f conftest.${OBJEXT}; then - if test -n "$(file conftest.${OBJEXT} | grep -i $1-bit)"; then + FILE_TEST="$(file conftest.${OBJEXT})" + if test -n "$(echo $FILE_TEST | grep -i $1-bit)"; then CXXFLAGS="${CXXFLAGS} -m$1" AC_MSG_RESULT([ok use $1]) else AC_MSG_ERROR([failed still $COMPILER_MODEL_BITS]) fi fi - /bin/rm conftest.$ac_ext conftest.${OBJEXT} + /bin/rm -f conftest.$ac_ext conftest.${OBJEXT} else AC_MSG_RESULT([ok use $1]) fi