diff mbox

[01/25] sparse: add make variable C to run sparse when compiling skiboot

Message ID 1424776479-13958-2-git-send-email-clg@fr.ibm.com
State Accepted
Headers show

Commit Message

Cédric Le Goater Feb. 24, 2015, 11:14 a.m. UTC
As this is done on the Linux kernel, one can now run sparse using
C=1 on the command line. The variable CF can be used to tune the
sparse options.

Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
---
 Makefile.main  |    3 +++
 Makefile.rules |   11 +++++++++++
 2 files changed, 14 insertions(+)
diff mbox

Patch

diff --git a/Makefile.main b/Makefile.main
index b5376fc0eaa9..c99182585638 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -87,6 +87,9 @@  ifneq ($(KERNEL),)
 CPPFLAGS += -DBUILTIN_KERNEL="\"$(KERNEL)\""
 endif
 
+CHECK		= sparse
+CHECKFLAGS     := $(CF)
+
 .SECONDARY:
 
 vpath %.c $(SRC)
diff --git a/Makefile.rules b/Makefile.rules
index 3014c819f9b2..27da0dce9be8 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -27,6 +27,15 @@  define cook_cflags
        $(filter-out $(CFLAGS_SKIP_$(1)), $(CPPFLAGS) $(CFLAGS)) $(CFLAGS_$(1))
 endef
 
+ifeq ($(C),1)
+  ifeq ($(VERBOSE),1)
+	cmd_check = $(CHECK) $(CHECKFLAGS) $(call cook_cflags,$@) $<
+  else
+	cmd_check = @$(CHECK) $(CHECKFLAGS) $(call cook_cflags,$@) $<
+  endif
+endif
+
+
 %.o : %.S include/asm-offsets.h
 	$(call Q,AS, $(CC) $(call cook_aflags,$@) -c $< -o $@, $@)
 
@@ -34,10 +43,12 @@  endef
 	$(call Q,CC, $(CC) $(call cook_aflags,$@) -E -c $< -o $@, $@)
 
 %.o : %.c
+	$(call cmd_check)
 	$(call Q,CC, $(CC) $(call cook_cflags,$@) -c $< -o $@, $@)
 
 # Force the use of the C compiler, not C++ for the .C files in libpore
 %.o : %.C
+	$(call cmd_check)
 	$(call Q,CC, $(CC) $(call cook_cflags,$@) -x c -c $< -o $@, $@)
 
 %.s : %.c