3 echo "Using PREFIX="${PREFIX:=$1}
4 echo "Using PROJECT="${PROJECT:=$2}
5 echo "Using COCCI="${COCCI:=$3}
6 echo "Using RESULTS="${RESULTS:=$4}
7 echo "Using SPFLAGS="${SPFLAGS:=$5}
9 if [ "`which spatch.opt`" ] ; then
16 #echo "Using PREFIX="${PREFIX:=`pwd`}
17 #echo "Using COCCI="${COCCI:=$PREFIX/cocci}
18 #echo "Using PROJECT="${PROJECT:=$PREFIX/project}
19 #echo "Using RESULTS="${RESULTS:=$PREFIX/results}
21 SMPL
=`find $COCCI -mindepth 1 -type f -name "*.cocci"| sed "s|$COCCI/||g"`
23 PRJNAME
=`basename $PROJECT`
25 echo "Processing project \"$PRJNAME\""
31 f
=`basename $s .cocci`
33 # Produce bug report for a particular version and a particular bug pattern
34 echo "#!/bin/bash" > $RESULTS/$f.sh
35 echo "" >> $RESULTS/$f.sh
36 echo "FLAGS=\"`grep -E \"// +Options *:\" $COCCI/$s | cut -f2 -d\":\"`\"" >> $RESULTS/$f.sh
37 echo "INC?=$PROJECT/include" >> $RESULTS/$f.sh
38 echo "echo \"Applying $COCCI/$s with: '\$FLAGS'\"" >> $RESULTS/$f.sh
39 echo "nice -19 $SPATCH $SPFLAGS \$FLAGS -I \$INC -cocci_file $COCCI/$s -dir $PROJECT/ $FLAGS \\" >> $RESULTS/$f.sh
40 echo "> $f.out \\" >> $RESULTS/$f.sh
41 echo "2> $f.log" >> $RESULTS/$f.sh
42 echo "echo \"$f.out completed\"" >> $RESULTS/$f.sh
43 chmod u
+x
$RESULTS/$f.sh
48 #############################################
50 #############################################
51 # Generation of a Makefile per project
52 echo -e ".SUFFIXES: .out .sh\n" > $RESULTS/Makefile
53 echo -e "all: out\n" >> $RESULTS/Makefile
54 echo -e ".sh.out:" >> $RESULTS/Makefile
55 echo -e "\t-@./\$<\n" >> $RESULTS/Makefile
57 ALL_SMPL
=`echo -n "out:"`
60 f
=`basename $s .cocci`
62 # echo "$f.out:" >> $RESULTS/Makefile
63 # echo " -./$f.sh" >> $RESULTS/Makefile
64 ALL_SMPL
="$ALL_SMPL $f.out"
68 echo "$ALL_SMPL" >> $RESULTS/Makefile
70 #############################################
73 find -L $RESULTS -type l
-delete
75 find results
/ -depth -type d
-empty -delete