3 NR_CPU
=$
(cat /proc
/cpuinfo |
grep ^processor |
wc -l)
4 TARGET
="bzImage modules"
5 WLOG
="smatch_warns.txt"
6 LOG
="smatch_compile.warns"
9 echo "Usage: $0 [smatch options]"
10 echo "Compiles the kernel with -j${NR_CPU}"
11 echo " available options:"
12 echo " --endian : enable endianess check"
13 echo " --target {TARGET} : specify build target, default: $TARGET"
14 echo " --log {FILE} : Output compile log to file, default is: $LOG"
15 echo " --wlog {FILE} : Output warnigs to file, default is: $WLOG"
16 echo " --help : Show this usage"
22 if [[ "$1" == "--endian" ]] ; then
23 ENDIAN
="CF=-D__CHECK_ENDIAN__"
25 elif [[ "$1" == "--target" ]] ; then
29 elif [[ "$1" == "--log" ]] ; then
33 elif [[ "$1" == "--wlog" ]] ; then
37 elif [[ "$1" == "--help" ]] ; then
44 SCRIPT_DIR
=$
(dirname $0)
45 if [ -e $SCRIPT_DIR/..
/smatch
] ; then
46 cp $SCRIPT_DIR/..
/smatch
$SCRIPT_DIR/..
/bak.smatch
47 CMD
=$SCRIPT_DIR/..
/bak.smatch
48 elif which smatch |
grep smatch
> /dev
/null
; then
51 echo "Smatch binary not found."
56 find -name \
*.c.smatch
-exec rm \
{\
} \
;
57 make -j${NR_CPU} $ENDIAN -k CHECK
="$CMD -p=kernel --file-output $*" \
58 C
=1 $TARGET 2>&1 |
tee $LOG
59 find -name \
*.c.smatch
-exec cat \
{\
} \
; -exec rm \
{\
} \
; > $WLOG
61 echo "Done. The warnings are saved to $WLOG"