diff --git a/eclass/autotools.eclass b/eclass/autotools.eclass index 9143aa454d0d..1f3289fc9120 100644 --- a/eclass/autotools.eclass +++ b/eclass/autotools.eclass @@ -518,6 +518,36 @@ autotools_run_tool() { set -- "${1}" $(autotools_m4dir_include) "${@:2}" $(autotools_m4sysdir_include) fi + # re-order arguments, bug #680210 + local _old_args=( ${@} ) + local _at_command= + local _at_file= + local -a _at_args=() + local _argument= + + for _argument in ${_old_args[*]}; do + if [[ -z "${_at_command}" ]]; then + _at_command=${_argument} + continue + fi + + if [[ -z "${_at_file}" && "${_argument}" =~ \.(in|ac)$ ]]; then + _at_file=${_argument} + continue + fi + + _at_args+=( ${_argument} ) + done + + # make sure file is last argument + if [[ -n "${_at_file}" ]]; then + _at_args+=( ${_at_file} ) + fi + + debug-print "\$@ before reordering of arguments: ${@}" + set -- "${_at_command}" "${_at_args[@]}" + debug-print "\$@ after reordering of arguments: ${@}" + # If the caller wants to probe something, then let them do it directly. if ${return_output} ; then "$@" @@ -527,8 +557,19 @@ autotools_run_tool() { printf "***** $1 *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}" ebegin "Running $@" - "$@" >> "${STDERR_TARGET}" 2>&1 - if ! eend $? && ${autofail} ; then + + local _retVal=1 + if [[ ${WANT_AUTOCONF} = 2.1 && -n "${_at_file}" ]] ; then + local _output_file=${_at_file%.*} + debug-print "Creating ${PWD}/${_output_file} ..." + "$@" > "${_output_file}" 2> "${STDERR_TARGET}" + _retVal=$? + else + "$@" >> "${STDERR_TARGET}" 2>&1 + _retVal=$? + fi + + if ! eend ${_retVal} && ${autofail} ; then echo eerror "Failed Running $1 !" eerror