Release coccinelle-0.2.0rc1
[bpt/coccinelle.git] / scripts / coccicheck / configure
1 #!/bin/bash
2
3 MODE=$1
4 PROJECT=$2
5
6 if [ "$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
11 fi
12
13 SPATCHVER=`spatch -version 2>&1 | sed "s|spatch version \([^ ]*\) .*|\1|"`
14 WITHPYTHON=`spatch -version 2>&1 | sed "s|spatch version \([^ ]*\) with Python support|yes|"`
15 WITHPYTHON=`echo $WITHPYTHON | sed "s|spatch version \([^ ]*\) without Python support||"`
16
17 echo "Using spatch version $SPATCHVER"
18 #TODO: Add version check
19
20 if [ "$WITHPYTHON" ] ; then
21 echo "Your version has been build with Python support"
22 else
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
28 fi
29 echo
30
31 echo "Using PREFIX="${PREFIX:=`pwd`}
32 echo "Using PROJECT="${PROJECT:=$PREFIX/project}
33 echo "Using COCCI="${COCCI:=$PREFIX/cocci}
34 echo "Using RESULTS="${RESULTS:=$PREFIX/results}
35
36 if [ "`which glimpse`" ]; then
37 FLAGS=${SPFLAGS:="-timeout 60 -use_glimpse"}
38 else
39 FLAGS=${SPFLAGS:="-timeout 60"}
40 fi
41 SPFLAGS="$FLAGS -D $MODE"
42 echo "Using SPFLAGS="$SPFLAGS
43
44 echo -e "\nFor efficiency, run \`<coccinelle dir>/scripts/glimpseindex_cocci.sh\`"
45 echo -e "in $PROJECT"
46 echo -e "NB: glimpse is available at http://webglimpse.net/ but it is not under the GPL.\n"
47
48 sed -i "s|^PREFIX?=.*$|PREFIX?=${PREFIX}|" Makefile
49 sed -i "s|^PROJECT?=.*$|PROJECT?=${PROJECT}|" Makefile
50 sed -i "s|^COCCI?=.*$|COCCI?=${COCCI}|" Makefile
51 sed -i "s|^RESULTS?=.*$|RESULTS?=${RESULTS}|" Makefile
52 sed -i "s|^SPFLAGS?=.*$|SPFLAGS?=\"${SPFLAGS}\"|" Makefile
53