[Sheepdog] [PATCH] add semantic check by using sparse

OZAWA Tsuyoshi ozawa.tsuyoshi at lab.ntt.co.jp
Thu Apr 22 19:38:38 CEST 2010


Sparse is a semantic parser used in Linux kernel.
This patch provide sheepdog with semantic check.
To run sparse,
 $ make check

If script/checkarch.sh failed at running "make check", run
 $ make check32
or
 $ make check64
instead.

Signed-off-by: OZAWA Tsuyoshi <ozawa.tsuyoshi at lab.ntt.co.jp>
---
 Makefile            |   19 +++++++++++++++++++
 script/checkarch.sh |   26 ++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 0 deletions(-)
 create mode 100644 script/checkarch.sh

diff --git a/Makefile b/Makefile
index adce925..b537145 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,9 @@ VERSION ?= $(shell git log -1 --pretty=format:%h-%p || echo "unknown-version")
 
 PREFIX ?= /usr
 
+CHECK_CC = cgcc
+CHECK_CC_FLAGS = '$(CHECK_CC) -Wbitwise -Wno-return-void -no-compile $(ARCH)'
+
 export VERSION PREFIX
 
 .PHONY:all
@@ -19,3 +22,19 @@ clean:
 install:
 	$(MAKE) -C shepherd install
 	$(MAKE) -C collie install
+
+.PHONY:check
+check: ARCH=$(shell sh script/checkarch.sh)
+check:
+	CC=$(CHECK_CC_FLAGS) $(MAKE) all
+
+.PHONY:check32
+check32: override ARCH=-m32
+check32:
+	CC=$(CHECK_CC_FLAGS) $(MAKE) all
+
+.PHONY:check64
+check64: override ARCH=-m64
+check64:
+	CC=$(CHECK_CC_FLAGS) $(MAKE) all
+
diff --git a/script/checkarch.sh b/script/checkarch.sh
new file mode 100644
index 0000000..bd4c21b
--- /dev/null
+++ b/script/checkarch.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+arch=`gcc -dumpmachine`
+
+case $arch in
+`echo $arch | grep x86_64`)
+	echo -m64
+	;;
+`echo $arch | grep "i[3-6]86"`)
+	echo -m32
+	;;
+*)
+	echo '
+	Failed to parse your architecture.
+	Please run
+
+	$ make check32
+
+	or
+
+	$ make check64
+
+	manually.
+	'
+	exit 1
+;;
+esac
-- 
1.7.0




More information about the sheepdog mailing list