aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Makefile
diff options
authorChristopher Li <sparse@chrisli.org>2017-10-29 19:16:44 +0800
committerChristopher Li <sparse@chrisli.org>2017-11-11 08:56:52 +0800
commit9d58bbdf7865d0be560b77a4879ca2ad7b5479be (patch)
treed512aee52584ed0f00319f65b4ca9fd30cd3166c /Makefile
parent7316dd328344aa8a1350254cf24c0bf35d5e6599 (diff)
downloadsparse-dev-9d58bbdf7865d0be560b77a4879ca2ad7b5479be.tar.gz
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. V4: As point out by Luc, sparse-llvm.sc is missing the $(LLVM_CFLAGS). Signed-off-by: Christopher Li <sparse@chrisli.org> Acked-by: Jeff Layton <jlayton@kernel.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile18
1 files changed, 9 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index d1a303e1..815d2bf6 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
+COMMON_CFLAGS = -O2 -finline-functions -fno-strict-aliasing -g
+COMMON_CFLAGS += -Wall -Wwrite-strings
LDFLAGS += -g
LD = gcc
AR = ar
@@ -21,7 +21,7 @@ PKG_CONFIG = pkg-config
CHECKER = CHECK=./sparse ./cgcc -no-compile
CHECKER_FLAGS =
-ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS)
+ALL_CFLAGS = $(COMMON_CFLAGS) $(PKG_CFLAGS) $(CFLAGS)
#
# For debugging, put this in local.mk:
#
@@ -44,13 +44,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=
@@ -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): PKG_CFLAGS += $(GTK_CFLAGS)
test-inspect_EXTRA_OBJS := $(GTK_LIBS)
else
$(warning Your system does not have gtk3/gtk2, disabling test-inspect)
@@ -101,7 +101,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 sparse-llvm.sc: PKG_CFLAGS += $(LLVM_CFLAGS)
sparse-llvm_EXTRA_OBJS := $(LLVM_LIBS) $(LLVM_LDFLAGS)
else
$(warning LLVM 3.0 or later required. Your system has version $(LLVM_VERSION) installed.)
@@ -208,7 +208,7 @@ ifneq ($(DEP_FILES),)
include $(DEP_FILES)
endif
-c2xml.o c2xml.sc: CFLAGS += $(LIBXML_CFLAGS)
+c2xml.o c2xml.sc: PKG_CFLAGS += $(LIBXML_CFLAGS)
pre-process.sc: CHECKER_FLAGS += -Wno-vla