Make smatch installable.
[smatch.git] / smatch_scripts / kchecker
blob4a908b3eacf1699a18ee2ab569ff32f9effe1d62
1 #!/bin/bash
3 function useage {
4 echo "Usage: $0 [--sparse][--valgrind][--debug] path/to/file.c"
5 exit 1
8 CMD=smatch
10 while true ; do
11 if [[ "$1" == "--sparse" ]] ; then
12 CMD="sparse"
13 shift
14 elif [[ "$1" == "--valgrind" ]] ; then
15 PRE="valgrind"
16 shift
17 elif [[ "$1" == "" ]] ; then
18 break
19 else
20 if [[ "$1" == "--help" ]] ; then
21 $CMD --help
22 exit 1
24 if echo $1 | grep -q ^- ; then
25 POST="$POST $1"
26 else
27 break
29 shift
31 done
33 cname=$1
34 cname=$(echo ${cname/.o/.c})
35 if [[ "$cname" == "" ]] ; then
36 useage
38 if ! test -e $cname ; then
39 useage
42 oname=$(echo ${cname/.c/.o})
43 if ! echo $oname | grep .o$ > /dev/null ; then
44 useage
46 rm -f $oname
47 make C=y CHECK="$PRE $CMD $POST" $oname