linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] build: clean up $CFLAGS handling in the makefile
@ 2017-10-25 10:02 Jeff Layton
  2017-10-25 14:20 ` Luc Van Oostenryck
  0 siblings, 1 reply; 21+ messages in thread
From: Jeff Layton @ 2017-10-25 10:02 UTC (permalink / raw)
  To: sparse; +Cc: linux-sparse, luc.vanoostenryck

From: Jeff Layton <jlayton@redhat.com>

The fedora packaging tools want to provide a base set of $CFLAGS when
building packages, but that fails when building sparse.

There are a couple of build targets in the makefile that add options to
$CFLAGS.  When we do a build though, we pass $ALL_CFLAGS to the
compiler, and that ends up without those extra options, if CFLAGS= was
passed to the make command.

This patch changes the code to append the options to $ALL_CFLAGS instead
of $CFLAGS. At the same time, passing a CFLAGS argument to make ends up
with the initial CFLAGS assignment being clobbered such that we lose the
options that are assigned to it internally. Fold the internal usage of
CFLAGS into BASIC_CFLAGS. They both just end up as part of ALL_CFLAGS
anyway, so this should be functionally equivalent.

Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 Makefile | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

I sent this last week in a reply to a different thread. Re-posting it
here since it got no replies.

diff --git a/Makefile b/Makefile
index d0341764158e..335dcfff54ce 100644
--- a/Makefile
+++ b/Makefile
@@ -12,8 +12,8 @@ OS = linux
 
 
 CC = gcc
-CFLAGS = -O2 -finline-functions -fno-strict-aliasing -g
-CFLAGS += -Wall -Wwrite-strings
+BASIC_CFLAGS = -O2 -finline-functions -fno-strict-aliasing -g
+BASIC_CFLAGS += -Wall -Wwrite-strings
 LDFLAGS += -g
 LD = gcc
 AR = ar
@@ -21,7 +21,7 @@ PKG_CONFIG = pkg-config
 CHECKER = ./cgcc -no-compile
 CHECKER_FLAGS =
 
-ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS)
+ALL_CFLAGS = $(BASIC_CFLAGS) $(CFLAGS)
 #
 # For debugging, put this in local.mk:
 #
@@ -44,7 +44,7 @@ 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)\"
+BASIC_CFLAGS += -DGCC_BASE=\"$(GCC_BASE)\"
 
 MULTIARCH_TRIPLET := $(shell $(CC) -print-multiarch 2>/dev/null)
 BASIC_CFLAGS += -DMULTIARCH_TRIPLET=\"$(MULTIARCH_TRIPLET)\"
@@ -83,7 +83,7 @@ PROGRAMS += test-inspect
 INST_PROGRAMS += test-inspect
 test-inspect_EXTRA_DEPS := ast-model.o ast-view.o ast-inspect.o
 test-inspect_OBJS := test-inspect.o $(test-inspect_EXTRA_DEPS)
-$(test-inspect_OBJS) $(test-inspect_OBJS:.o=.sc): CFLAGS += $(GTK_CFLAGS)
+$(test-inspect_OBJS) $(test-inspect_OBJS:.o=.sc): ALL_CFLAGS += $(GTK_CFLAGS)
 test-inspect_EXTRA_OBJS := $(GTK_LIBS)
 else
 $(warning Your system does not have gtk3/gtk2, disabling test-inspect)
@@ -208,7 +208,7 @@ ifneq ($(DEP_FILES),)
 include $(DEP_FILES)
 endif
 
-c2xml.o c2xml.sc: CFLAGS += $(LIBXML_CFLAGS)
+c2xml.o c2xml.sc: ALL_CFLAGS += $(LIBXML_CFLAGS)
 
 pre-process.sc: CHECKER_FLAGS += -Wno-vla
 
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2017-11-09 22:55 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-25 10:02 [PATCH] build: clean up $CFLAGS handling in the makefile Jeff Layton
2017-10-25 14:20 ` Luc Van Oostenryck
2017-10-26 10:08   ` Christopher Li
2017-10-26 12:11     ` Jeff Layton
2017-10-26 17:11       ` Christopher Li
2017-10-29 11:32       ` Christopher Li
2017-10-29 17:28         ` Luc Van Oostenryck
2017-10-29 21:53           ` Christopher Li
2017-10-29 22:11             ` Josh Triplett
2017-10-29 22:48               ` Christopher Li
2017-10-30  5:40             ` Luc Van Oostenryck
2017-10-30  6:34               ` Christopher Li
2017-10-31 18:57         ` Jeff Layton
2017-11-01  0:56           ` Christopher Li
2017-11-01 14:17             ` Luc Van Oostenryck
2017-11-05  0:45               ` Christopher Li
2017-11-05 16:57                 ` Luc Van Oostenryck
2017-11-09 21:10                   ` Christopher Li
2017-11-09 21:26                     ` Luc Van Oostenryck
2017-11-09 22:18                       ` Christopher Li
2017-11-09 22:55                         ` Luc Van Oostenryck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).