From 93b25869228a3c0c632a6aa66624cc4e549ba14a Mon Sep 17 00:00:00 2001 From: John Snow Date: Wed, 25 Mar 2015 18:57:37 -0400 Subject: [PATCH] configure: factor out supported flag check Factor out the function that checks if a compiler flag is supported or not. Signed-off-by: John Snow Reviewed-by: Stefan Hajnoczi Message-id: 1427324259-1481-3-git-send-email-jsnow@redhat.com Signed-off-by: Stefan Hajnoczi --- configure | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/configure b/configure index 770f4c6526..f744266681 100755 --- a/configure +++ b/configure @@ -436,6 +436,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 @@ -1445,10 +1449,7 @@ if test -z "$werror" ; then fi # check that the C compiler works. -cat > $TMPC < $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