Release coccinelle-0.2.2-rc1
[bpt/coccinelle.git] / scripts / coccicheck / configure
CommitLineData
951c7801
C
1#!/bin/bash
2
3MODE=$1
4PROJECT=$2
5
6if [ "$MODE" == "" -o "$PROJECT" == "" ]; then
7 echo -e "\n\tUsage: $0 mode path\n"
8 echo -e "\tmode\torg or diff according to your needs"
9 echo -e "\tpath\tyour project path\n"
10 exit 1
11fi
12
7f004419
C
13SPATCHVER=`spatch -version 2>&1 | sed "s|spatch version \([^ ]*\) .*|\1|"`
14WITHPYTHON=`spatch -version 2>&1 | sed "s|spatch version \([^ ]*\) with Python support|yes|"`
15WITHPYTHON=`echo $WITHPYTHON | sed "s|spatch version \([^ ]*\) without Python support||"`
16
17echo "Using spatch version $SPATCHVER"
18#TODO: Add version check
19
20if [ "$WITHPYTHON" ] ; then
21 echo "Your version has been build with Python support"
22else
23 echo "Your version has no Python support"
24 if [ "org" == "$MODE" ] ; then
25 echo "org mode requires Python support."
26 exit 1
27 fi
28fi
29echo
30
951c7801
C
31echo "Using PREFIX="${PREFIX:=`pwd`}
32echo "Using PROJECT="${PROJECT:=$PREFIX/project}
33echo "Using COCCI="${COCCI:=$PREFIX/cocci}
34echo "Using RESULTS="${RESULTS:=$PREFIX/results}
7f004419
C
35
36if [ "`which glimpse`" ]; then
37 FLAGS=${SPFLAGS:="-timeout 60 -use_glimpse"}
38else
39 FLAGS=${SPFLAGS:="-timeout 60"}
40fi
41SPFLAGS="$FLAGS -D $MODE"
42echo "Using SPFLAGS="$SPFLAGS
951c7801
C
43
44echo -e "\nFor efficiency, run \`<coccinelle dir>/scripts/glimpseindex_cocci.sh\`"
7f004419
C
45echo -e "in $PROJECT"
46echo -e "NB: glimpse is available at http://webglimpse.net/ but it is not under the GPL.\n"
951c7801 47
c3e37e97
C
48cat > Makefile <<EOF
49PREFIX?=${PREFIX}
50PROJECT?=${PROJECT}
51SPFLAGS?="${SPFLAGS}"
951c7801 52
c3e37e97
C
53COCCI?=${COCCI}
54RESULTS?=${RESULTS}
55
56.PHONY:: update viewlog viewfilteredlog viewres checkcocci
57.PHONY:: all clean distclean depend
58
59all:
60 \$(MAKE) -C \$(RESULTS)
61
62update:
63 ./bin/update_result_tree \$(PREFIX) \$(PROJECT) \$(COCCI) \$(RESULTS) \$(SPFLAGS)
64
65viewlog:
66 find \$(RESULTS) -name "*.log" | xargs cat | pager
67
68viewfilteredlog:
69 find \$(RESULTS) -name "*.log" | xargs cat | \\
70 grep -ve "^\$\$" | \\
71 grep -v "HANDLING" | \\
72 grep -v "NOTE" | \\
73 grep -v "Unsupported form of #define" | \\
74 grep -v "no glimpse keyword inferred from snippet" | \\
75 grep -v "EXN:Common.Timeout" | \\
76 grep -v "FLOW: can't find exit or error exit:" | \\
77 grep -v "FLOW: deadcode detected:" | \\
78 grep -v "LEXER: identifier with dollar:" | \\
79 grep -v "LEXER: unrecognised symbol in char:" | \\
80 grep -v "LEXER: ZARB" | \\
81 grep -v "CFG: orphelin nodes, maybe something weird happened" | \\
82 grep -v "not worth trying" | \\
83 grep -v "MultiFound field:" | \\
84 grep -ve "(ONCE) warning: I consider .* as a constant" | \\
85 grep -ve "TYPE: header .* not found"
86
87viewres:
88 find \$(RESULTS) -name "*.out" | xargs pager
89
90checkcocci:
91 for c in \`find \$(COCCI) -name "*.cocci"\`; do spatch -parse_cocci \$\$c > /dev/null ; done
92
93clean:
94 find \$(RESULTS) -name "*.out" -delete
95 find \$(RESULTS) -name "*.log" -delete
96
97distclean:
98 rm -rf \$(RESULTS)
99
100depend: update
101EOF