From patchwork Tue Mar 24 18:19:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 453976 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 8E9CE14007F for ; Wed, 25 Mar 2015 05:21:02 +1100 (AEDT) Received: from localhost ([::1]:33844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YaTRk-0004MO-Bg for incoming@patchwork.ozlabs.org; Tue, 24 Mar 2015 14:21:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YaTQm-0002ui-H0 for qemu-devel@nongnu.org; Tue, 24 Mar 2015 14:20:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YaTQg-0003Zk-61 for qemu-devel@nongnu.org; Tue, 24 Mar 2015 14:20:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39160) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YaTQf-0003X2-Lv for qemu-devel@nongnu.org; Tue, 24 Mar 2015 14:19:53 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2OIJons005376 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 24 Mar 2015 14:19:50 -0400 Received: from scv.usersys.redhat.com (dhcp-17-29.bos.redhat.com [10.18.17.29]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2OIJlYm010340; Tue, 24 Mar 2015 14:19:49 -0400 From: John Snow To: qemu-devel@nongnu.org Date: Tue, 24 Mar 2015 14:19:44 -0400 Message-Id: <1427221186-28404-3-git-send-email-jsnow@redhat.com> In-Reply-To: <1427221186-28404-1-git-send-email-jsnow@redhat.com> References: <1427221186-28404-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, John Snow , stefanha@redhat.com Subject: [Qemu-devel] [PATCH v4 2/4] configure: factor out supported flag check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Factor out the function that checks if a compiler flag is supported or not. Signed-off-by: John Snow --- configure | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/configure b/configure index 7a8637e..6f4bf4f 100755 --- a/configure +++ b/configure @@ -435,6 +435,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 @@ -1438,10 +1442,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 --keep-tmpc; then + QEMU_CFLAGS="$QEMU_CFLAGS $flag" fi done