From 0aa640a303804c49a50309ae2fd77851e2030fb1 Mon Sep 17 00:00:00 2001 From: John Snow Date: Fri, 9 Mar 2018 11:49:31 -0500 Subject: [PATCH] configure: factor out supported flag check Factor out the function that checks if a compiler flag is supported or not. Backports commit 93b25869228a3c0c632a6aa66624cc4e549ba14a from qemu --- qemu/configure | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) 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