From patchwork Tue Apr 26 21:06:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Schutt X-Patchwork-Id: 733561 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3QL7Kp0002105 for ; Tue, 26 Apr 2011 21:07:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758191Ab1DZVHb (ORCPT ); Tue, 26 Apr 2011 17:07:31 -0400 Received: from sentry-three.sandia.gov ([132.175.109.17]:57586 "EHLO sentry-three.sandia.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758181Ab1DZVHa (ORCPT ); Tue, 26 Apr 2011 17:07:30 -0400 X-WSS-ID: 0LKA2OF-0C-8X3-02 X-M-MSG: Received: from interceptor1.sandia.gov (interceptor1.sandia.gov [132.175.109.5]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by sentry-three.sandia.gov (Postfix) with ESMTP id 1025D4E8AA5 for ; Tue, 26 Apr 2011 15:07:17 -0600 (MDT) Received: from sentry.sandia.gov (mm04snlnto.sandia.gov [132.175.109.21]) by interceptor1.sandia.gov (RSA Interceptor) for ; Tue, 26 Apr 2011 15:02:40 -0600 Received: from [132.175.109.1] by sentry.sandia.gov with ESMTP (SMTP Relay 01 (Email Firewall v6.3.2)); Tue, 26 Apr 2011 15:06:38 -0600 X-Server-Uuid: 6BFC7783-7E22-49B4-B610-66D6BE496C0E Received: from localhost.localdomain (skynetcore1.sandia.gov [134.253.138.22]) by mailgate.sandia.gov (8.14.4/8.14.4) with ESMTP id p3QL6Gr2016412; Tue, 26 Apr 2011 15:06:22 -0600 From: "Jim Schutt" To: ceph-devel@vger.kernel.org cc: "Jim Schutt" Subject: [PATCH] configure.ac: Add a macro to check for supported compiler flags. Date: Tue, 26 Apr 2011 15:06:14 -0600 Message-ID: <1303851974-29838-2-git-send-email-jaschut@sandia.gov> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1303851974-29838-1-git-send-email-jaschut@sandia.gov> References: <1303851974-29838-1-git-send-email-jaschut@sandia.gov> X-PMX-Version: 5.6.0.2009776, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.4.26.205419 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1800_1899 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __LINES_OF_YELLING 0, __MIME_TEXT_ONLY 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_PATH 0, __URI_NO_WWW 0, __URI_NS ' X-TMWD-Spam-Summary: TS=20110426210657; ID=1; SEV=2.3.1; DFV=B2011042620; IFV=NA; AIF=B2011042620; RPD=5.03.0010; ENG=NA; RPDID=7374723D303030312E30413031303230372E34444237333345462E303030323A534346535441543838363133332C73733D312C6667733D30; CAT=NONE; CON=NONE; SIG=AAAAAAAAAAAAAAAAAAAAAAAAfQ== X-MMS-Spam-Filter-ID: B2011042620_5.03.0010 MIME-Version: 1.0 X-WSS-ID: 61A9EC542K42262789-01-01 X-RSA-Inspected: yes X-RSA-Classifications: public X-RSA-Action: allow Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 26 Apr 2011 21:07:31 +0000 (UTC) Ancient versions of gcc, such as the gcc 4.1.2 in RHEL 5.5, don't support some -W flags that newer versions do. Fix up configure.ac and Makefile.am to use them if you have them. Signed-off-by: Jim Schutt --- configure.ac | 21 +++++++++++++++++++++ src/Makefile.am | 2 +- 2 files changed, 22 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index 5642717..dc4d710 100644 --- a/configure.ac +++ b/configure.ac @@ -33,6 +33,27 @@ AC_PROG_CXX AC_PROG_MAKE_SET AC_PROG_LIBTOOL +# Checks for compiler warning types + +# AC_CHECK_CC_FLAG(FLAG_TO_TEST, VARIABLE_TO_SET_IF_SUPPORTED) +# --------- +AC_DEFUN([AC_CHECK_CC_FLAG], +[{ + AC_LANG_PUSH([C]) + my_cflags_save="$CFLAGS" + CFLAGS="$my_cflags_save $1" + AC_MSG_CHECKING([whether $CC accepts $1]) + AC_COMPILE_IFELSE(AC_LANG_PROGRAM(), + [AC_MSG_RESULT([yes]); AC_SUBST([$2], ["$1"])], + [AC_MSG_RESULT([no])] + ) + CFLAGS="$my_cflags_save" + AC_LANG_POP([C]) +}]) + +AC_CHECK_CC_FLAG([-Wtype-limits], [WARN_TYPE_LIMITS]) +AC_CHECK_CC_FLAG([-Wignored-qualifiers], [WARN_IGNORED_QUALIFIERS]) + # Checks for libraries. AC_CHECK_LIB([m], [pow], [true], AC_MSG_FAILURE([libm not found])) AC_CHECK_LIB([pthread], [pthread_create], [true], AC_MSG_FAILURE([libpthread not found])) diff --git a/src/Makefile.am b/src/Makefile.am index 3113111..071360e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -479,7 +479,7 @@ CLEANFILES += \ ## AM_COMMON_FLAGS = -Wall -D__CEPH__ -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE -rdynamic \ --Wtype-limits -Wignored-qualifiers -Winit-self -Wpointer-arith \ +${WARN_TYPE_LIMITS} ${WARN_IGNORED_QUALIFIERS} -Winit-self -Wpointer-arith \ -fno-strict-aliasing AM_CFLAGS = $(AM_COMMON_FLAGS)