From patchwork Thu Feb 26 08:30:06 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 23756 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B4987DDDB6 for ; Thu, 26 Feb 2009 19:44:18 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1LcbpQ-0000Lf-0X; Thu, 26 Feb 2009 08:42:48 +0000 Received: from smtp.gentoo.org ([140.211.166.183]) by bombadil.infradead.org with esmtps (Exim 4.69 #1 (Red Hat Linux)) id 1LcbdA-0007Fq-8A for linux-mtd@lists.infradead.org; Thu, 26 Feb 2009 08:30:10 +0000 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id E0C7F64F71 for ; Thu, 26 Feb 2009 08:30:06 +0000 (UTC) From: Mike Frysinger To: linux-mtd@lists.infradead.org Subject: [PATCH v2] make sure compiler supports warning flags Date: Thu, 26 Feb 2009 03:30:06 -0500 Message-Id: <1235637006-28538-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 1.6.1.3 In-Reply-To: <8bd0f97a0902260028q1df6c376ta6537f83f2407f02@mail.gmail.com> References: <8bd0f97a0902260028q1df6c376ta6537f83f2407f02@mail.gmail.com> X-Bad-Reply: References and In-Reply-To but no 'Re:' in Subject. X-Spam-Score: 0.0 (/) X-Mailman-Approved-At: Thu, 26 Feb 2009 03:42:46 -0500 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Some compilers (like gcc-3.3) don't support all the newer -W flags that we are using. So import the compiler check found in the kernel and test each flag we add. The := is important so we only do the compiler tests once per `make` rather than every time we compile a file. Signed-off-by: Mike Frysinger --- v2 - remove debug code in try-run common.mk | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/common.mk b/common.mk index 0e8c62b..5e92b07 100644 --- a/common.mk +++ b/common.mk @@ -1,8 +1,18 @@ CC := $(CROSS)gcc AR := $(CROSS)ar RANLIB := $(CROSS)ranlib + +# Stolen from Linux build system +try-run = $(shell set -e; ($(1)) >/dev/null 2>&1 && echo "$(2)" || echo "$(3)") +cc-option = $(call try-run, $(CC) $(1) -c -xc /dev/null -o /dev/null,$(1),$(2)) + CFLAGS ?= -O2 -g -CFLAGS += -Wall -Wextra -Wwrite-strings -Wno-sign-compare -D_FILE_OFFSET_BITS=64 +WFLAGS := -Wall \ + $(call cc-option,-Wextra) \ + $(call cc-option,-Wwrite-strings) \ + $(call cc-option,-Wno-sign-compare) +CFLAGS += $(WFLAGS) +CPPFLAGS += -D_FILE_OFFSET_BITS=64 DESTDIR ?= /usr/local PREFIX=/usr