diff options
author | Nishanth Menon | 2015-09-03 05:43:52 -0500 |
---|---|---|
committer | Nishanth Menon | 2015-10-01 22:55:51 -0500 |
commit | 309ddafe963807193e221a7b09504ea0e810750b (patch) | |
tree | dd4717666eafcf1106db66c81b524034caeed042 | |
parent | 04469f058a4f9fb5d21a8b30358d1cb5be0fabc8 (diff) | |
download | ks2-boot-monitor-309ddafe963807193e221a7b09504ea0e810750b.tar.gz ks2-boot-monitor-309ddafe963807193e221a7b09504ea0e810750b.tar.xz ks2-boot-monitor-309ddafe963807193e221a7b09504ea0e810750b.zip |
Makefile: Add support for sparse check
Build with make C=1 to check with sparse. by overriding the SPARSE
variable with other static analysers, Further additional checks may be
performed.
Signed-off-by: Nishanth Menon <nm@ti.com>
-rw-r--r-- | make.rules | 3 | ||||
-rw-r--r-- | makedefs | 18 |
2 files changed, 21 insertions, 0 deletions
diff --git a/make.rules b/make.rules index 10b6de1f9cbc..99883a5e63f5 100644 --- a/make.rules +++ b/make.rules | |||
@@ -61,6 +61,9 @@ build_dir: | |||
61 | fi | 61 | fi |
62 | 62 | ||
63 | $(OBJDIR)/%.o: %.c | 63 | $(OBJDIR)/%.o: %.c |
64 | ifneq ($(CHECK),0) | ||
65 | $(Q_SPARSE) $(CFLAGS) $(CPPFLAGS) $(SPARSE_FLAGS) $(TARGET_ARCH) -c -o $@ $< | ||
66 | endif | ||
64 | $(Q_CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@ $< | 67 | $(Q_CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@ $< |
65 | 68 | ||
66 | $(OBJDIR)/%.o: %.S | 69 | $(OBJDIR)/%.o: %.S |
@@ -39,11 +39,16 @@ BIN=$(CROSS_COMPILE)objcopy | |||
39 | OBJCOPY=$(CROSS_COMPILE)objcopy | 39 | OBJCOPY=$(CROSS_COMPILE)objcopy |
40 | CSCOPE ?= cscope | 40 | CSCOPE ?= cscope |
41 | TAGS ?= ctags | 41 | TAGS ?= ctags |
42 | SPARSE ?= sparse | ||
42 | 43 | ||
43 | ifeq ("$(origin V)", "command line") | 44 | ifeq ("$(origin V)", "command line") |
44 | export VERBOSE=$(V) | 45 | export VERBOSE=$(V) |
45 | endif | 46 | endif |
46 | 47 | ||
48 | ifeq ("$(origin C)", "command line") | ||
49 | export CHECK=$(C) | ||
50 | endif | ||
51 | |||
47 | ifndef VERBOSE | 52 | ifndef VERBOSE |
48 | export VERBOSE=0 | 53 | export VERBOSE=0 |
49 | endif | 54 | endif |
@@ -54,10 +59,16 @@ else | |||
54 | Q=@ | 59 | Q=@ |
55 | .SILENT: | 60 | .SILENT: |
56 | endif | 61 | endif |
62 | |||
63 | ifndef CHECK | ||
64 | export CHECK=0 | ||
65 | endif | ||
66 | |||
57 | Q_CC=$(Q:@=@echo ' CC '$@;)$(CC) | 67 | Q_CC=$(Q:@=@echo ' CC '$@;)$(CC) |
58 | Q_LD=$(Q:@=@echo ' LINK '$@;)$(LD) | 68 | Q_LD=$(Q:@=@echo ' LINK '$@;)$(LD) |
59 | Q_BIN=$(Q:@=@echo ' BIN '$@;)$(BIN) | 69 | Q_BIN=$(Q:@=@echo ' BIN '$@;)$(BIN) |
60 | Q_OBJCOPY=$(Q:@=@echo ' OBJCOPY '$@;)$(OBJCOPY) | 70 | Q_OBJCOPY=$(Q:@=@echo ' OBJCOPY '$@;)$(OBJCOPY) |
71 | Q_SPARSE=$(Q:@=@echo ' CHECK '$@;)$(SPARSE) | ||
61 | 72 | ||
62 | #RBL monitor stack size per core | 73 | #RBL monitor stack size per core |
63 | RBL_MON_STACK_SIZE=0x800 | 74 | RBL_MON_STACK_SIZE=0x800 |
@@ -84,3 +95,10 @@ GCCOPT = -marm -mcpu=cortex-a15 -Wa,-march=armv7-a+sec -g $(IPATH) | |||
84 | CFLAGS = $(GCCOPT) -I$(ROOT)/soc/$(SOC)/ -c | 95 | CFLAGS = $(GCCOPT) -I$(ROOT)/soc/$(SOC)/ -c |
85 | ASFLAGS=$(GCCOPT) -I$(ROOT)/soc/$(SOC)/ -c | 96 | ASFLAGS=$(GCCOPT) -I$(ROOT)/soc/$(SOC)/ -c |
86 | LDFLAGS=$(GCCOPT) --static -Wl,-T,$(ROOT)/soc/$(SOC)/$(EXE).lds -Wl,-Map,$(ROOT)/soc/$(SOC)/$(EXE).map -nostdlib $(LPATH) | 97 | LDFLAGS=$(GCCOPT) --static -Wl,-T,$(ROOT)/soc/$(SOC)/$(EXE).lds -Wl,-Map,$(ROOT)/soc/$(SOC)/$(EXE).map -nostdlib $(LPATH) |
98 | |||
99 | ifneq ($(CHECK),0) | ||
100 | INCPATH=$(shell $(CC) --print-file-name=include| sed -e 's/^/@/g'|\ | ||
101 | sed -e 's/\s\s*/@/g') | ||
102 | SPARSE_FLAGS += $(subst @,-I,$(INCPATH)) | ||
103 | SPARSE_FLAGS += -isystem | ||
104 | endif | ||