From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvirP-0004yY-PX for qemu-devel@nongnu.org; Fri, 22 May 2015 05:03:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YvirO-000526-Qd for qemu-devel@nongnu.org; Fri, 22 May 2015 05:03:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37300) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvirO-00051n-IM for qemu-devel@nongnu.org; Fri, 22 May 2015 05:03:18 -0400 From: Stefan Hajnoczi Date: Fri, 22 May 2015 10:02:01 +0100 Message-Id: <1432285330-13994-30-git-send-email-stefanha@redhat.com> In-Reply-To: <1432285330-13994-1-git-send-email-stefanha@redhat.com> References: <1432285330-13994-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 29/38] configure: factor out supported flag check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , John Snow , Stefan Hajnoczi From: John Snow 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 770f4c6..f744266 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 -- 2.1.0