From patchwork Sun Oct 29 11:32:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Li X-Patchwork-Id: 10031367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 24E7B602D6 for ; Sun, 29 Oct 2017 11:32:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15462287AC for ; Sun, 29 Oct 2017 11:32:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07FC2287AF; Sun, 29 Oct 2017 11:32:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6556E287AC for ; Sun, 29 Oct 2017 11:32:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751405AbdJ2Lcm (ORCPT ); Sun, 29 Oct 2017 07:32:42 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:43905 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751310AbdJ2Lcl (ORCPT ); Sun, 29 Oct 2017 07:32:41 -0400 Received: by mail-yw0-f193.google.com with SMTP id y75so9231767ywg.0 for ; Sun, 29 Oct 2017 04:32:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=DU2SMYehN0N4upg3glcsFPsUuZTO93upmk/r70NgAgc=; b=uiDTQM4Y5K/E/h7Cn/Y1tG4RyL6wq4pO2PomysK0VKf1EU4943/O2ob4cJGpylNbEa 9+cOlrxdOaq3AxIl79SO4DfqayeaCiQC6gcO/I2atHZkF1yTSODxksDGxzbr5U+sZ+d5 X3cBYy1zjsU8ak0WbUy51sZUuopydWZgxax2BFNksHgfLhHI5PI/g+HnErl+DJR6oPwm GGwvwaJqvCOlWOut9MA2QoK9fI/mU+aaKnldFHLqABBSPHWaEBzznVnpSCnTpc1PTgPA 5b2qd+V+Simlw4fXIhK9pCquIEGZG4kopCMm+QSOFMwTR/mJNACJhQQlfKF4GJWMPL+d eH0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=DU2SMYehN0N4upg3glcsFPsUuZTO93upmk/r70NgAgc=; b=oB6GTFUi0ONK9s1Rr7C2khPmzVPU9C/MGzoLXy7VsOGNYhC3aYLldzKD1EUY814kMj LNcXBeMvAdBVBQkqFsPP5Kz9Gv5kQbGp5kRlhnRxgo4CNv+I97t1sraCKUlQtXwf3vhJ 3JQ77LPPSlzQJcq7El+8JYlfjK82RSdmcIwk8XVcZekTvsfkxMbJ9nY3H3zNlg7VPa0Y k5BNA8kNX5lvXvxCR62C/Uk14dMMNYK76hWQCAd61pvpuyB7ReTakLz2XBBO6wa2z8W7 Dt0EGJ5gyhiiVBlXbvkLQixC3Zn0m7cfJd6u7inE1IRf8/K6QfvQlEKQP5xZxoJvZ9nM AYQQ== X-Gm-Message-State: AMCzsaXl9DfP4vtMrRUL5vbGKK2gIeDRtzTVHgghcSojtP+d0qiOS19u FGk2EuzR+M/dDAb8gLw91UCO6MBO72YItVZOgw== X-Google-Smtp-Source: ABhQp+Q4qtF2ewGVGxBDA+035cr0cF1rx3Y+rFzGraS9JgGpTKkgCdtoz0qlGN0S7EmpO2khYTl0TTCl7c4rlcmxwnI= X-Received: by 10.37.190.136 with SMTP id i8mr202745ybk.287.1509276760440; Sun, 29 Oct 2017 04:32:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.103.133 with HTTP; Sun, 29 Oct 2017 04:32:39 -0700 (PDT) In-Reply-To: <1509019885.29077.6.camel@kernel.org> References: <20171025100222.5983-1-jlayton@kernel.org> <20171025142009.foxh2rblmfpxvm7d@ltop.local> <1509019885.29077.6.camel@kernel.org> From: Christopher Li Date: Sun, 29 Oct 2017 19:32:39 +0800 X-Google-Sender-Auth: 7r3hMW16i4F4L9as9VKPkp5MByE Message-ID: Subject: Re: [PATCH] build: clean up $CFLAGS handling in the makefile To: Jeff Layton Cc: Luc Van Oostenryck , Linux-Sparse Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Oct 26, 2017 at 8:11 PM, Jeff Layton wrote: > > Perhaps instead of describing it, you could roll up an alternative patch > that shows what you would prefer to see here? Here it is the patch. I push it on https://git.kernel.org/pub/scm/devel/sparse/chrisl/sparse.git/log/?h=cflags Chris From 9fc170ec5e5814ae858922496dea668bb80dbf34 Mon Sep 17 00:00:00 2001 From: Christopher Li Date: Sun, 29 Oct 2017 19:16:44 +0800 Subject: [PATCH] Makefile: provide CFLAGS for command line override. Avoid assign to CFLAGS in Makefile. Rename BASIC_CFLAGS to COMMON_CFLAGS. Use PKG_CFLAGS to store external package related cflags. Signed-off-by: Christopher Li Acked-by: Jeff Layton --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) $(LLVM_VERSION) installed.) diff --git a/Makefile b/Makefile index 76902b7..ef47358 100644 --- a/Makefile +++ b/Makefile @@ -12,14 +12,14 @@ OS = linux CC = gcc -CFLAGS = -O2 -finline-functions -fno-strict-aliasing -g -CFLAGS += -Wall -Wwrite-strings +COMMON_CFLAGS = -O2 -finline-functions -fno-strict-aliasing -g +COMMON_CFLAGS += -Wall -Wwrite-strings LDFLAGS += -g LD = gcc AR = ar PKG_CONFIG = pkg-config -ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) +ALL_CFLAGS = $(CFLAGS) $(COMMON_CFLAGS) $(PKG_CFLAGS) # # For debugging, put this in local.mk: # @@ -35,13 +35,13 @@ LLVM_CONFIG:=llvm-config HAVE_LLVM:=$(shell $(LLVM_CONFIG) --version >/dev/null 2>&1 && echo 'yes') GCC_BASE = $(shell $(CC) --print-file-name=) -BASIC_CFLAGS = -DGCC_BASE=\"$(GCC_BASE)\" +COMMON_CFLAGS += -DGCC_BASE=\"$(GCC_BASE)\" MULTIARCH_TRIPLET = $(shell $(CC) -print-multiarch 2>/dev/null) -BASIC_CFLAGS += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\" +COMMON_CFLAGS += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\" ifeq ($(HAVE_GCC_DEP),yes) -BASIC_CFLAGS += -Wp,-MD,$(@D)/.$(@F).d +COMMON_CFLAGS += -Wp,-MD,$(@D)/.$(@F).d endif DESTDIR= @@ -72,7 +72,7 @@ GTK2_LIBS := $(shell $(PKG_CONFIG) --libs gtk+-2.0) PROGRAMS += test-inspect INST_PROGRAMS += test-inspect test-inspect_EXTRA_DEPS := ast-model.o ast-view.o ast-inspect.o -test-inspect.o $(test-inspect_EXTRA_DEPS): BASIC_CFLAGS += $(GTK2_CFLAGS) +test-inspect.o $(test-inspect_EXTRA_DEPS): PKG_CFLAGS += $(GTK2_CFLAGS) test-inspect_EXTRA_OBJS := $(GTK2_LIBS) else $(warning Your system does not have libgtk2, disabling test-inspect) @@ -89,7 +89,7 @@ LLVM_LIBS := $(shell $(LLVM_CONFIG) --libs) LLVM_LIBS += $(shell $(LLVM_CONFIG) --system-libs 2>/dev/null) PROGRAMS += $(LLVM_PROGS) INST_PROGRAMS += sparse-llvm sparsec -sparse-llvm.o: BASIC_CFLAGS += $(LLVM_CFLAGS) +sparse-llvm.o: PKG_CFLAGS += $(LLVM_CFLAGS) sparse-llvm_EXTRA_OBJS := $(LLVM_LIBS) $(LLVM_LDFLAGS) else $(warning LLVM 3.0 or later required. Your system has version