diff --git a/qemu/configure b/qemu/configure index 298480b8..b8f2537f 100755 --- a/qemu/configure +++ b/qemu/configure @@ -268,6 +268,12 @@ EOF compile_object } +write_c_skeleton() { + cat > $TMPC < $TMPC << EOF -int main(void) { return 0; } -EOF + write_c_skeleton; if compile_prog "" "-liberty" ; then LIBS="-liberty $LIBS" fi @@ -705,16 +709,19 @@ gcc_flags="-Wno-string-plus-int $gcc_flags" # enable it for all configure tests. If a configure test failed due # to -Werror this would just silently disable some features, # so it's too error prone. -cat > $TMPC << EOF -int main(void) { return 0; } -EOF -for flag in $gcc_flags; do +cc_has_warning_flag() { + write_c_skeleton; + # Use the positive sense of the flag when testing for -Wno-wombat # support (gcc will happily accept the -Wno- form of unknown # warning options). - optflag="$(echo $flag | sed -e 's/^-Wno-/-W/')" - if compile_prog "-Werror $optflag" "" ; then - QEMU_CFLAGS="$QEMU_CFLAGS $flag" + optflag="$(echo $1 | sed -e 's/^-Wno-/-W/')" + compile_prog "-Werror $optflag" "" +} + +for flag in $gcc_flags; do + if cc_has_warning_flag $flag ; then + QEMU_CFLAGS="$QEMU_CFLAGS $flag" fi done