db/fixup_kernel.sh: ignore do_loop_readv_writev()
[smatch.git] / smatch_scripts / wine_checker.sh
blob79b4faa51a07c7e3c0049a43b16227b5e22320e3
1 #!/bin/bash
3 function usage {
4 echo "Usage: $0 [--sparse][--valgrind][--debug] path/to/file.c"
5 exit 1
8 SCRIPT_DIR=$(dirname $0)
9 if [ -e $SCRIPT_DIR/../smatch ] ; then
10 CMD=$SCRIPT_DIR/../smatch
11 elif which smatch | grep smatch > /dev/null ; then
12 CMD=smatch
13 else
14 echo "Smatch binary not found."
15 exit 1
18 POST=""
19 WINE_ARGS="-p=wine --full-path -D__i386__"
21 while true ; do
22 if [[ "$1" == "--sparse" ]] ; then
23 CMD="sparse"
24 shift
25 elif [[ "$1" == "--valgrind" ]] ; then
26 PRE="valgrind"
27 shift
28 elif [[ "$1" == "" ]] ; then
29 break
30 else
31 if [[ "$1" == "--help" ]] ; then
32 $CMD --help
33 exit 1
35 if echo $1 | grep -q ^- ; then
36 POST="$POST $1"
37 else
38 break
40 shift
42 done
44 cname=$1
45 cname=$(echo ${cname/.o/.c})
46 if [[ "$cname" == "" ]] ; then
47 usege
49 if ! test -e $cname ; then
50 usege
53 oname=$(echo ${cname/.c/.o})
54 if ! echo $oname | grep .o$ > /dev/null ; then
55 usege
57 rm -f $oname
59 cur=$(pwd)
60 file_dir=$(dirname $oname)
61 o_short_name=$(basename $oname)
62 cd $file_dir
63 make CC="$PRE $CMD $POST $WINE_ARGS" $o_short_name
64 make $o_short_name
65 cd $cur